From patchwork Thu Sep 19 23:29:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 174108 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp1589195oce; Thu, 19 Sep 2019 16:30:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZzY3kZFqOKGBIlcu1B1d2B6KuL3bRyZ1JMT+EI0l5RAPTQOXNJ4GQGwRRjLZiFZ/dyYGP X-Received: by 2002:a05:6402:1426:: with SMTP id c6mr19303761edx.53.1568935835528; Thu, 19 Sep 2019 16:30:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568935835; cv=none; d=google.com; s=arc-20160816; b=hHupTBeojLF7iZtmjI94mFz1dULDuo4j44sgDVh+u7U7wCvF2zKX2LZYLg5THLVL8o Lv1Bgi7iVvBws6NinuC/fCyN7K44fd6SiDfMH9xRk9dUSfhjOAsocDkj5LTglVUaYAPg Kdkrv8OicmtMfK1X31dFhdOxa6/SterQZuLizwm6glZX0vqzOfKA4Kzo0BL85TkQWxaM G+z8EDHE9IhWOD6QtOoZyH0U1h48hXGgIze3d0F68vCARvSvJFPAvwXn+VsyNUojUn9R xPExlLWm2n4Rlb0w64kwHciX/WJmNA6OXQs1nNzwWoVC7a4p37bok2QI/pNa4SA4zGli XbBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=QPmhTNNeHsMpQB5FpTHLnap4hQHr8B38z692x1bPeOE=; b=WGmJg6evPsGbYp+6t3+i99ruq3rhogB89hcxrWlLrKtBiRtjdYRvOLbL6kj8+HnnGZ Hdj0iIJo5tiGfRqtsZz92dB2Wjamo7o0W+//opU1QY7aUlqXaLUvilg2jryuMtuICPxM r/3MC8xmEw4hFi/4jwLnLOOre1v/jUzRWqHrLk3cK90wC5SdBHkJlQv0/0+/3yw/UWBw 1l1uMVJoMmrqJZ9frgKcsU6fVjRpFLRJ23r0jUib9HuaSofjYLA3BRB1B22wU3TcluV/ scZqBbeCMDAXo7+SeH5UrN1oxVFoB9c/DiLezYxPaEW7ZU5/yIb92A93tvmUpy89MQr7 gHEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Bbc92H/H"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z12si57479eju.15.2019.09.19.16.30.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Sep 2019 16:30:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Bbc92H/H"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5sg-0006IN-3N for patch@linaro.org; Thu, 19 Sep 2019 19:30:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39225) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5s6-0006EQ-Ak for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:29:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iB5s5-0000ir-8Z for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:29:58 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:40601) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iB5s5-0000iV-1n for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:29:57 -0400 Received: by mail-pl1-x643.google.com with SMTP id d22so2303275pll.7 for ; Thu, 19 Sep 2019 16:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QPmhTNNeHsMpQB5FpTHLnap4hQHr8B38z692x1bPeOE=; b=Bbc92H/HCxfeTY5layjFht+Avl8YAvGQ7oS3mzcEiF60ozopazSrVflFe8u6KoOvNi saTo3BDtVhs1ubLHUgsnh2teyu7ZcylkZSTtmG+En9FwNxtaarczEGeEcWb/vJiR46eA QWQsOo2ies0BKNQ2cjxWfLBGaVNz1862ryTY1eHfAO6N72gyP4/fGQapyJ17yitRNI6o 40cc6BJSo6Ltfa0QOMhELyUicTeDNLH6joqyiEBc7Iu3IA3dnMdL2BK9RiC2+eqLUYRQ 1Bvu/cR6P1i5+OxeeriyJIzIJgJJX0Sp+njn3DwhEgNa3bMMMyjOf7gHkpES2EnWUE7V qSvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QPmhTNNeHsMpQB5FpTHLnap4hQHr8B38z692x1bPeOE=; b=F1TIWB/UHZoBykvwbCCMixseIEiydZ+91zOv66QAvqKUQ0gjxpRXWCtKJbQ3hNNevq y3S5ecYu9qZHAdIm7sl7iwaIxMNh2LweUsgyB6dhhbDKzQ+tJH/OvgbvdTbGHzQnN4uz K8x0FB3l0wErdqHebl6SygV5sch5+d4TnAHKw5hLkGbkZkRTAZO5peC+iIRrdnHdiWph xEYmnX+tv5XVnHdbxeCJmMuG8l4WYJpA/8vz7+qvhSQGvsutCugPq7pGA4LuShnTJq3o 3WGCODgE+x8j3wHsm3DMGBepjHOIMGR9P/9iszRP2gia/YxcGDahw02k/C9jynKWWViW fWiQ== X-Gm-Message-State: APjAAAUgSAKG0ho6eGuxU99nn49W4Cbn85jbdLWn2fdhiKY8J/uldDDd kil1tzwEDiqG6Haur/y63qdbUi4BA10= X-Received: by 2002:a17:902:59da:: with SMTP id d26mr12809340plj.193.1568935795675; Thu, 19 Sep 2019 16:29:55 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id h8sm103340pfo.64.2019.09.19.16.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 16:29:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 1/7] exec: Use TARGET_PAGE_BITS_MIN for TLB flags Date: Thu, 19 Sep 2019 16:29:46 -0700 Message-Id: <20190919232952.6382-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190919232952.6382-1-richard.henderson@linaro.org> References: <20190919232952.6382-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" These bits do not need to vary with the actual page size used by the guest. Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index d2d443c4f9..e0c8dc540c 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -317,20 +317,24 @@ CPUArchState *cpu_copy(CPUArchState *env); #if !defined(CONFIG_USER_ONLY) -/* Flags stored in the low bits of the TLB virtual address. These are - * defined so that fast path ram access is all zeros. +/* + * Flags stored in the low bits of the TLB virtual address. + * These are defined so that fast path ram access is all zeros. * The flags all must be between TARGET_PAGE_BITS and * maximum address alignment bit. + * + * Use TARGET_PAGE_BITS_MIN so that these bits are constant + * when TARGET_PAGE_BITS_VARY is in effect. */ /* Zero if TLB entry is valid. */ -#define TLB_INVALID_MASK (1 << (TARGET_PAGE_BITS - 1)) +#define TLB_INVALID_MASK (1 << (TARGET_PAGE_BITS_MIN - 1)) /* Set if TLB entry references a clean RAM page. The iotlb entry will contain the page physical address. */ -#define TLB_NOTDIRTY (1 << (TARGET_PAGE_BITS - 2)) +#define TLB_NOTDIRTY (1 << (TARGET_PAGE_BITS_MIN - 2)) /* Set if TLB entry is an IO callback. */ -#define TLB_MMIO (1 << (TARGET_PAGE_BITS - 3)) +#define TLB_MMIO (1 << (TARGET_PAGE_BITS_MIN - 3)) /* Set if TLB entry contains a watchpoint. */ -#define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS - 4)) +#define TLB_WATCHPOINT (1 << (TARGET_PAGE_BITS_MIN - 4)) /* Use this mask to check interception with an alignment mask * in a TCG backend. From patchwork Thu Sep 19 23:29:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 174110 Delivered-To: patch@linaro.org Received: by 2002:ac9:19ad:0:0:0:0:0 with SMTP id d45csp1589326oce; Thu, 19 Sep 2019 16:30:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8WLl2jWrKxRXLRiA0mXccHGPba3NU92VBDN9UPUMG8zllLHWx31/qu4B1uRxr8oK1se5C X-Received: by 2002:a17:906:6805:: with SMTP id k5mr16407952ejr.50.1568935843327; Thu, 19 Sep 2019 16:30:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568935843; cv=none; d=google.com; s=arc-20160816; b=0saYe1xPv9PlIMYO3n+IkMIzpKpUAt9dIZ2bdBbCtuVU1itXz5DDGD0WFk6iwfFOMu MwAYOH2KZJCehYY5XBp4MVUltq6iTi0glpJYhgesMPE4+UAH4NyKsrn0qhGswYLSCQQW loxVnuu1s9RdSl6Bwl4QjnD0Wphe2qvz3Cu6UobAwZtNYISEfN0vyQubLAzfzMHP6P2V D9G82SYGdrBtD4bEHldsuGVQVWqg/1U8PZymCQhIbNEZ8HpxpR6H3wVq2bqcHz53TF5w R/IX0jbERPDsehEbLpBe+y0l3E3qw1ZL43fiBM8hi0fgbWelPQBcXLDQ/oM/qkQfkcmT UYSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=q7PGmLFt8k2gMw2v7XrzLTew2NhAfZzpYEa2cTqkTY8=; b=NhevQNBtwyLW2Usrawgzoni9atQTzU4GCSLt3Hb03os27sh6sJfwy5/NpSmHLZYkJb 6J6yq5TzI38rkgh5cS9I5wdNSSJvH9sE9Dq0YNea/GVzK6mhJ8J3UUQDS8W3oMS+YX1l du9VNLiHU6V05MwyEgwsiE3bckQ9qFPH4szPomN2B7WY0w28GfKJsCm3sOoLytZwSGeX sdEN6M/RJh5FIaZYwZcjZg7Lpet/15yjfUV3z9juTq6F9ytrBgCqg7PJ9aIfFO1WxFLh N1JcinaUA/rgDbYqNlHPcRpT1z9krJFM8sgrBsrIlQ6EA+9sI3WzQIp3DMC1DlU/5ecz IGEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vJzAZ60U; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i56si198981eda.19.2019.09.19.16.30.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Sep 2019 16:30:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vJzAZ60U; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5sm-0006M9-Ur for patch@linaro.org; Thu, 19 Sep 2019 19:30:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39261) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5s8-0006IK-Dz for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iB5s6-0000jr-Ph for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:00 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:40490) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iB5s6-0000jB-EI for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:29:58 -0400 Received: by mail-pg1-x544.google.com with SMTP id w10so2729064pgj.7 for ; Thu, 19 Sep 2019 16:29:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q7PGmLFt8k2gMw2v7XrzLTew2NhAfZzpYEa2cTqkTY8=; b=vJzAZ60Uz+FyOHGBPbW7vw1/Rm7vhO0zQKoqyGu7Z3I+lnrrpkVi/ntQiMICrWDv2t wfmyDDIRnw2JpwO/w+m+++dIufEhQ72lLz/XRPcbCRh0v2OvU6SgoXOUj/+3IeLz3639 FE2eZux4+VAQ8gIEbUyKuncJMmfrkAzWU8pzBicCTUTOsrEqgNMXdO0aNx4DaCkQhAMQ 2kRt+bhd4Opu3k23Mb+TtkxT53kDq6WqP7a/CnkxfEotOArNf8LXGOmOrZCGHfqIQNm/ 9jHUYk4IxwQdfppme3UETl17SEoFhOIpT3yzM4c7Y+jTxBNMxjTGwCWPkYxDDfsErqJ6 XGkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=q7PGmLFt8k2gMw2v7XrzLTew2NhAfZzpYEa2cTqkTY8=; b=pobzVgUTzXm0bybhnBlHKSOPm9wWzcM3KJP1l0xPPwjP+ddUvcUP2SG9TSE18nE5J7 VRmS6XDYHq1YRia4dkkIL/PvB+DePvkETUqFCP1VA5H+i0Sc67LT5/U+gn00I54ni6uq wnu09jOCqKkwKR1cD7/v8ktFUuPtktbdj7iAVT3011zz8B74g8El8eIaNBZ+DtmMEZnw tx/o9lCABioNzgj9/b3TOmcMqouFvmFBOGPDD5wIHOnYA52uHMcaJBtNUCBB7m7StJE0 Ze7qFVaZT7s9Stb/Ey1mxVqCHbAet56HaN24mhyWhf75gxyOm2xy25jjuQKHQpWE4nvN 35oA== X-Gm-Message-State: APjAAAXL9c/SKo+yE1jBRtdVRMJL9DMnbl/iV+5dW5cIW4rYRG9Xhxi5 I3Hwk4trcBUaSYdiO6UpmGgcApxFna0= X-Received: by 2002:a63:c050:: with SMTP id z16mr10063295pgi.250.1568935796893; Thu, 19 Sep 2019 16:29:56 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id h8sm103340pfo.64.2019.09.19.16.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 16:29:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/7] exec: Split out variable page size support to exec-vary.c Date: Thu, 19 Sep 2019 16:29:47 -0700 Message-Id: <20190919232952.6382-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190919232952.6382-1-richard.henderson@linaro.org> References: <20190919232952.6382-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The next patch will play a trick with "const" that will confuse the compiler about the uses of target_page_bits within exec.c. Moving everything to a new file prevents this confusion. No functional change so far. Signed-off-by: Richard Henderson --- Makefile.target | 2 +- include/qemu-common.h | 6 +++++ exec-vary.c | 57 +++++++++++++++++++++++++++++++++++++++++++ exec.c | 34 -------------------------- 4 files changed, 64 insertions(+), 35 deletions(-) create mode 100644 exec-vary.c -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/Makefile.target b/Makefile.target index 5e916230c4..ca3d14efe1 100644 --- a/Makefile.target +++ b/Makefile.target @@ -107,7 +107,7 @@ obj-y += trace/ ######################################################### # cpu emulator library -obj-y += exec.o +obj-y += exec.o exec-vary.o obj-y += accel/ obj-$(CONFIG_TCG) += tcg/tcg.o tcg/tcg-op.o tcg/tcg-op-vec.o tcg/tcg-op-gvec.o obj-$(CONFIG_TCG) += tcg/tcg-common.o tcg/optimize.o diff --git a/include/qemu-common.h b/include/qemu-common.h index 0235cd3b91..3e800c2224 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -74,6 +74,12 @@ void cpu_exec_step_atomic(CPUState *cpu); */ bool set_preferred_target_page_bits(int bits); +/** + * finalize_target_page_bits: + * Commit the final value set by set_preferred_target_page_bits. + */ +void finalize_target_page_bits(void); + /** * Sends a (part of) iovec down a socket, yielding when the socket is full, or * Receives data into a (part of) iovec from a socket, diff --git a/exec-vary.c b/exec-vary.c new file mode 100644 index 0000000000..48c0ab306c --- /dev/null +++ b/exec-vary.c @@ -0,0 +1,57 @@ +/* + * Variable page size handling + * + * Copyright (c) 2003 Fabrice Bellard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "exec/exec-all.h" + +#ifdef TARGET_PAGE_BITS_VARY +int target_page_bits; +bool target_page_bits_decided; +#endif + +bool set_preferred_target_page_bits(int bits) +{ + /* + * The target page size is the lowest common denominator for all + * the CPUs in the system, so we can only make it smaller, never + * larger. And we can't make it smaller once we've committed to + * a particular size. + */ +#ifdef TARGET_PAGE_BITS_VARY + assert(bits >= TARGET_PAGE_BITS_MIN); + if (target_page_bits == 0 || target_page_bits > bits) { + if (target_page_bits_decided) { + return false; + } + target_page_bits = bits; + } +#endif + return true; +} + +void finalize_target_page_bits(void) +{ +#ifdef TARGET_PAGE_BITS_VARY + if (target_page_bits == 0) { + target_page_bits = TARGET_PAGE_BITS_MIN; + } + target_page_bits_decided = true; +#endif +} diff --git a/exec.c b/exec.c index 8b998974f8..33bd0e36c1 100644 --- a/exec.c +++ b/exec.c @@ -92,11 +92,6 @@ MemoryRegion io_mem_rom, io_mem_notdirty; static MemoryRegion io_mem_unassigned; #endif -#ifdef TARGET_PAGE_BITS_VARY -int target_page_bits; -bool target_page_bits_decided; -#endif - CPUTailQ cpus = QTAILQ_HEAD_INITIALIZER(cpus); /* current CPU in the current thread. It is only valid inside @@ -110,37 +105,8 @@ int use_icount; uintptr_t qemu_host_page_size; intptr_t qemu_host_page_mask; -bool set_preferred_target_page_bits(int bits) -{ - /* The target page size is the lowest common denominator for all - * the CPUs in the system, so we can only make it smaller, never - * larger. And we can't make it smaller once we've committed to - * a particular size. - */ -#ifdef TARGET_PAGE_BITS_VARY - assert(bits >= TARGET_PAGE_BITS_MIN); - if (target_page_bits == 0 || target_page_bits > bits) { - if (target_page_bits_decided) { - return false; - } - target_page_bits = bits; - } -#endif - return true; -} - #if !defined(CONFIG_USER_ONLY) -static void finalize_target_page_bits(void) -{ -#ifdef TARGET_PAGE_BITS_VARY - if (target_page_bits == 0) { - target_page_bits = TARGET_PAGE_BITS_MIN; - } - target_page_bits_decided = true; -#endif -} - typedef struct PhysPageEntry PhysPageEntry; struct PhysPageEntry { From patchwork Thu Sep 19 23:29:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 174113 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1673789ill; Thu, 19 Sep 2019 16:34:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrwcdoIR4rSJtmJB6j07F2r6BlIlaNjxJiGD9zvTJ/9OkmOMGkSRYwtkdRT7mbRd1fpCfk X-Received: by 2002:a37:84d:: with SMTP id 74mr451359qki.26.1568936095350; Thu, 19 Sep 2019 16:34:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568936095; cv=none; d=google.com; s=arc-20160816; b=X+j31enqFFfnK/9rsZlQRJbRE7ez3+Z5s0zte8py6WRkTh5NAI4/LFzOe+xhImoWY8 YPpwV9k8r90DFwBlXCInp5dlXb8id6BAYnyO93wDesDz2bY0uMSSi+4nZC4Ao1wB15Is LPhAkoLjKfILqZU6sBxn7t/Mu5eiUekOJKV0qKtkX30PQObk92c+IzGoLtpsrKdU8YF1 IGVoI0Z7gI0IxwIkaPED2L+YV3clec1xJJ8GnQyCYEyJ1TOO/0Sk9FBbgGGXbFTcLwYt WssPWEN8m/5fe1RoIRGvBM/BmTW4R26ZucFlejJcuFQuO3SBv/4el1sG1/y/Hpu2Ji0L yrFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=XQ1156VivyWb3zatoNFGmDs6MfFq3iJU57HLLRy6mmI=; b=O4p0JDAA7y/LI7xootLFsppUmn5cWknnwdrGLKUNFdDq0uYTkMSC6CLjlwMt7rz8Bj PvPBwgg3Si96PEwrxdtKq87UpCGqw75b447+Eeh805YxVObL0ROE740GxmvrUQ0XpaEJ CiOxAW+sX2vej3OXJdwdtyp3hgpAJ6b+z9j7oK4G5+opYHzhF/nn4NNwVCPdayvtanLF h3r/1opxpbxEUniYdr+0v20kGd0qHTgTLRxhcd3CGVJNiouzcy2H7b08Id2k7j7vpSjb W/meZbQQEfgCWnm7ChEv2A5A6MulNFqZPDf7iGnv3PBjMmXjAShHgTs6VZjuRFjVJgW/ Yd7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XMvS4pRh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s125si356173qkc.94.2019.09.19.16.34.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Sep 2019 16:34:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XMvS4pRh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5ws-0002yj-JQ for patch@linaro.org; Thu, 19 Sep 2019 19:34:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39272) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5s9-0006J1-4K for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iB5s7-0000kJ-NG for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:00 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:44456) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iB5s7-0000k1-He for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:29:59 -0400 Received: by mail-pg1-x544.google.com with SMTP id g3so1153945pgs.11 for ; Thu, 19 Sep 2019 16:29:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XQ1156VivyWb3zatoNFGmDs6MfFq3iJU57HLLRy6mmI=; b=XMvS4pRhRkue0uZW/ETU4StFmtshij19PuHQKMaK87fD7r2pUwNzldXtxeV/GVLprc zSUCDd8XorUxBWNtaJ38oePPKMY9MrEOJAaF2LPGIsoRtq2b7S0yD1dKqgMxKseV8ymH eOdZPMAQYol3hRMIgTbta1i6K4ijODABNr6aD14wGxDemyLQLEO3R2LHJBLjCoZOnCq1 Xkp3G4fqkHc/TuwhGIHPd2VSM+UMF6DRjCRjJKhLZBe9d7RvhGseK3l0t3nw757cbvuU bpfvsjWkj2sj9wPzp/8CKVY2USMg1AkPoeb35r1p5j6z1q4thU8MM9bo3lnVHOQoPYp5 QCBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XQ1156VivyWb3zatoNFGmDs6MfFq3iJU57HLLRy6mmI=; b=PuBkJWXMGeXct6Mob0dBanL5OSpEvoPt0IqkTco/p1ZJ81c0EmFskB2S4ynzaYLT3O 5FGycEZ+3CYD/D07gfMgASs+Uq8fco6+hudLJIiaVMLVgCF+clPiXzcJ8nSATD/BRhzI Avaauc9HTFeMt9LK1/MSdIgnVOIIbEJWEzFtdlOnlI9ec1318lsIuwavKwuEhne2Ee3X Vqrb5z0k7FlGX9+vnjjRLlJQp7YmEXDEIYRshRwYnj/xKiHjSatfoXp/lPfzeNWHh1ps crXeFWqCqnaMZScMmn3r8/w/IsyotLPHxdFkBu7hSn1l62QFb59igDh8p8Dpxv4+TG8R lVhw== X-Gm-Message-State: APjAAAU9t2L6xFH/6ccDuaZmZuPEpszprqPpbU1fMnIhupTA859MlFUt opgrrAQkRH3oAtH8LUN5Acsnm3NRfkI= X-Received: by 2002:a63:1950:: with SMTP id 16mr9701321pgz.213.1568935798155; Thu, 19 Sep 2019 16:29:58 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id h8sm103340pfo.64.2019.09.19.16.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 16:29:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 3/7] exec: Use const alias for TARGET_PAGE_BITS_VARY Date: Thu, 19 Sep 2019 16:29:48 -0700 Message-Id: <20190919232952.6382-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190919232952.6382-1-richard.henderson@linaro.org> References: <20190919232952.6382-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Using a variable that is declared "const" for this tells the compiler that it may read the value once and assume that it does not change across function calls. For target_page_size, this means we have only one assert per function, and one read of the variable. This reduces the size of qemu-system-aarch64 by 8k. Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 10 +++++---- exec-vary.c | 46 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index e0c8dc540c..a53b761b48 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -210,10 +210,12 @@ static inline void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val /* page related stuff */ #ifdef TARGET_PAGE_BITS_VARY -extern bool target_page_bits_decided; -extern int target_page_bits; -#define TARGET_PAGE_BITS ({ assert(target_page_bits_decided); \ - target_page_bits; }) +typedef struct { + bool decided; + int bits; +} TargetPageBits; +extern const TargetPageBits target_page; +#define TARGET_PAGE_BITS (assert(target_page.decided), target_page.bits) #else #define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS #endif diff --git a/exec-vary.c b/exec-vary.c index 48c0ab306c..67cdf57a9c 100644 --- a/exec-vary.c +++ b/exec-vary.c @@ -22,8 +22,38 @@ #include "exec/exec-all.h" #ifdef TARGET_PAGE_BITS_VARY -int target_page_bits; -bool target_page_bits_decided; +/* + * We want to declare the "target_page" variable as const, which tells + * the compiler that it can cache any value that it reads across calls. + * This avoids multiple assertions and multiple reads within any one user. + * + * This works because we initialize the target_page data very early, in a + * location far removed from the functions that require the final results. + * + * This also requires that we have a non-constant symbol by which we can + * perform the actual initialization, and which forces the data to be + * allocated within writable memory. Thus "init_target_page", and we use + * that symbol exclusively in the two functions that initialize this value. + * + * The "target_page" symbol is created as an alias of "init_target_page". + */ +static TargetPageBits init_target_page; + +/* + * Note that this is *not* a redundant decl, this is the definition of + * the "target_page" symbol. The syntax for this definition requires + * the use of the extern keyword. This seems to be a GCC bug in + * either the syntax for the alias attribute or in -Wredundant-decls. + * + * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91765 + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wredundant-decls" + +extern const TargetPageBits target_page + __attribute__((alias("init_target_page"))); + +#pragma GCC diagnostic pop #endif bool set_preferred_target_page_bits(int bits) @@ -36,11 +66,11 @@ bool set_preferred_target_page_bits(int bits) */ #ifdef TARGET_PAGE_BITS_VARY assert(bits >= TARGET_PAGE_BITS_MIN); - if (target_page_bits == 0 || target_page_bits > bits) { - if (target_page_bits_decided) { + if (init_target_page.bits == 0 || init_target_page.bits > bits) { + if (init_target_page.decided) { return false; } - target_page_bits = bits; + init_target_page.bits = bits; } #endif return true; @@ -49,9 +79,9 @@ bool set_preferred_target_page_bits(int bits) void finalize_target_page_bits(void) { #ifdef TARGET_PAGE_BITS_VARY - if (target_page_bits == 0) { - target_page_bits = TARGET_PAGE_BITS_MIN; + if (init_target_page.bits == 0) { + init_target_page.bits = TARGET_PAGE_BITS_MIN; } - target_page_bits_decided = true; + init_target_page.decided = true; #endif } From patchwork Thu Sep 19 23:29:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 174115 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1675914ill; Thu, 19 Sep 2019 16:37:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGmeqyVHa0SFafSAmfp7fgRmp4Gupn0d/ValYhOcXRF7wFIB6QctGXTHa/30a6VX7eDjx+ X-Received: by 2002:a05:6214:12ad:: with SMTP id w13mr10180215qvu.124.1568936253993; Thu, 19 Sep 2019 16:37:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568936253; cv=none; d=google.com; s=arc-20160816; b=bMWRGgByN3tkqEJKIWICR1E/tzUrqJfL+aRNdZDTN09zfcNLOZOK7GMO/yz1mB9awL 62I6qu2sSBw62Hym45CBpKSa72PrkF76VnpzEDmfTWrGP2xT8/zqYUvRSdjojRRcoKAk hQ7hJotepakqZsxOYPt6AONFy4ZHDjSdzlyRUNQNtWF4e6Rg0bslx19LDJ86Lg2d+n0P 3YqxYo7ONDSQaNss8WLrvXSDfQ3ccC5lu2zJh7e/QQEVGzr6eIngi/CUuEf6sl7k6fxK V5eIHIuafB6XkomVcKLRy9RiDHMYz8cUNEmYWhJg4oHwLQTtJ7FA6mXjv6fEr50nl14P v4mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=rPvPWOfw9gxBJUIgR2g0hYWJxDjG7PfgkcfZjjTlu/I=; b=Yubd9Zq64I0N6VfktJ6DiqrZFHguDI8VoCsJIVaMrMEvoCeBrfWlljAGjjtQuaLvof wecGUD4avtk7k5+/+hLZW/oIs+jU8okPKczsvoTTWTHEgOgUern4XxVwP9GISF/750OY LYmMzCoawvOvm8LgkizkpnSDkSpgxPQKptpjsCvX6u0YrpBmC48vrCaVP8lhKN2zg3+H p15CjYyDVtEU9MJdXRffVJYVIKfroN+jzkCuqhOKfQoajZ64ie9ZnYKy4qD/MWOrAz3F FA6of4TwttrsQSypL29LsQLWImD/XHn3fIY2p2ZkLB8BX5la3M2JTr9keKOhn/B5yKyA oF3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dNgytJWu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u31si226461qvh.96.2019.09.19.16.37.33 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Sep 2019 16:37:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dNgytJWu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5zR-0006Eu-HE for patch@linaro.org; Thu, 19 Sep 2019 19:37:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39283) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5s9-0006Jv-Vl for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iB5s8-0000l9-QQ for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:01 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:39637) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iB5s8-0000kg-Kg for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:00 -0400 Received: by mail-pg1-x544.google.com with SMTP id u17so2734856pgi.6 for ; Thu, 19 Sep 2019 16:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rPvPWOfw9gxBJUIgR2g0hYWJxDjG7PfgkcfZjjTlu/I=; b=dNgytJWu3DysilndtjVQ/G7mr/w5sHBC6L9k/4mLvM9lNAp0Q87LNCJbKLDdu9YMlZ ECO8Ed6likncOc70MbwGpKuPiO4ZovS09XzfiWiKLanRkpmeGqijIVBZn9/7eLPbdTjI iDR6TdNJlS+1DEUfkYsU4ZEVYvWZYi95RI0lGs0Trrl8mDYwaoxt30NJIy/ukVmkTKi1 m1Vqh4y1cNPVH8m3+v4K4BqiKYbAG4UfqNEhndHqCppX6vvRTpAr4yhnKAcOHL7U8/al 6b+4y/8a39dHndeTfago1M+PKL/XzK1qkQ3oNsLDF+aQzdquXs+VV/RgXBCyejLDfxmh /tIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rPvPWOfw9gxBJUIgR2g0hYWJxDjG7PfgkcfZjjTlu/I=; b=SFgDi/CwvRl9i24uGviXEmTPC6AlAyG3fgR84fmfdJ0wSb/iQURoz02XqHuA4Zlnsr nmbG85POPzEzNEZk4ydkgLubLiFcmu3fvt2Jnc1m0NJnEf3feDBEGjpl3nKkgpFMLVHI dWtJVknzF/wvGZmZC/mujMHOT4ZbiN3dNVDw9z8i5REGqWxvGrVbf2OY5sLkrpU4fCcY Cg+ocgrGezuyluDnWcx4lRzKdH1PlT/jNyeIjCfQfXn8FutHYphNFsRWUV9+uCeQopad qFJfaW/d45jpv9AiCYv5SO0k30rK0R356uTjB7x40sdwSHmOq2gigoMF63wM8qnf5CFi 9hdA== X-Gm-Message-State: APjAAAWaOCXZyppp+QpZ6bjOlLqdBFbGJ6dzaItq0q/vQN5hKKLWvCmm e2SBDOIsHPPc/2RZLpAMAQzz6+ih8ok= X-Received: by 2002:a63:1918:: with SMTP id z24mr11162633pgl.94.1568935799385; Thu, 19 Sep 2019 16:29:59 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id h8sm103340pfo.64.2019.09.19.16.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 16:29:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 4/7] exec: Restrict TARGET_PAGE_BITS_VARY assert to CONFIG_DEBUG_TCG Date: Thu, 19 Sep 2019 16:29:49 -0700 Message-Id: <20190919232952.6382-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190919232952.6382-1-richard.henderson@linaro.org> References: <20190919232952.6382-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This reduces the size of a release build by about 10k. Noticably, within the tlb miss helpers. Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index a53b761b48..b11ee1f711 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -215,7 +215,11 @@ typedef struct { int bits; } TargetPageBits; extern const TargetPageBits target_page; -#define TARGET_PAGE_BITS (assert(target_page.decided), target_page.bits) +# ifdef CONFIG_DEBUG_TCG +# define TARGET_PAGE_BITS (assert(target_page.decided), target_page.bits) +# else +# define TARGET_PAGE_BITS target_page.bits +# endif #else #define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS #endif From patchwork Thu Sep 19 23:29:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 174114 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1674343ill; Thu, 19 Sep 2019 16:35:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1nyim6J1suIqNOJNp5JrKhQl1V0fCbuGkr0NgFviItG0MdwIdWu0veOl3bJ8Nn4JWuuFd X-Received: by 2002:ad4:42af:: with SMTP id e15mr5815262qvr.186.1568936138980; Thu, 19 Sep 2019 16:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568936138; cv=none; d=google.com; s=arc-20160816; b=LCnV2xOr9OxuhbUWadnveyn4+hzq99lwlwXTk31tlp8PqcxFXdtugyj3CAnGVM/XlJ V46Y5R+DFQpuE3GBqRf+SdX+qsvaBKy3K4YMx/bwu9rB246+uI/kADoLI3hEpdlUOFN8 mBMAttJiynQrCnfmpHkD80OiI5Njo18orj3Z37q/4Nc9bHib5V7t1HOSEwBLYTZ5xGQT Wd3YZrflfynSeC+GwF1xMyM60rCr88heGgXi32N56qqf0tHV+u9P9RCNfOtEJmx4nnWw 0b1qo7OvNw3Wl+Uax5sh9p90hqwwYKLu2zD/Z6PIerBOt7PrYhMrCkeePinFFPKVYbUK ZCqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=3xo3uadk4TAHtPwy0OEr5aDTmDZwQ+SU4GyeG6+uHcw=; b=pld+acYxNhRbYwbrVOWCCTHl1FiURNu7A5p+MnVjdEKMhC5459vxNXJXA031Cpx/UJ wNcKcUez/8jzZ+ArJxsyCyHE4NYLkSl44JqRrw6yfyW/X1RilbwK+x3CLd48qD659GCH t+m92ZBZnyRr6ooq7RaSYBtx7BCUG1fepYkrLdmBWF42VkNjpXgUI/8XGr/pC9JhKRRd 9iDekMwxtcA5mVFAy1PH+g9lAJ+PqPfbKB7l6AJpYcJD5ifDo0ukSXH6TLhEB2780sEC LzUaY1L6JxMMr6Dg8Pn2R+S/weLGXYmpCFXwJzp6CYB2bog7k6dgte9quoEpDtILNlzF Ezuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="a46hdUq/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s33si250699qtd.177.2019.09.19.16.35.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Sep 2019 16:35:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="a46hdUq/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5xZ-0002t6-R4 for patch@linaro.org; Thu, 19 Sep 2019 19:35:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39298) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5sB-0006L3-DN for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iB5sA-0000lq-4X for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:03 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:42686) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iB5s9-0000lQ-Tp for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:02 -0400 Received: by mail-pg1-x544.google.com with SMTP id z12so2722886pgp.9 for ; Thu, 19 Sep 2019 16:30:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3xo3uadk4TAHtPwy0OEr5aDTmDZwQ+SU4GyeG6+uHcw=; b=a46hdUq/Uplx3ALd41T3Y825t5C6Ac10mta7RtSqNUsbENNIPYV48/5HZE9t4RhCHt LvPkx4U3VY+Cbgg0/igei+MbVxlOnXPO5d2lpLASe0AYRqLy9VSoO7it8Pl7YIiuoncX bilSp+Z753KWPwh3p0tGBicHbGZQ68m/APNXzbxB/wXlFvbcQQYpJpfjTCuS2XoZv9DB MCAJCFaAog/R0G8ge4Qf1z6p8pPK/uswNDCIs0T9p3QVfag2l9Y28MmlXGnwa/2Xm/S7 XShD9lxQybseO7V3Ru9vaFbrXPQSYYssK6vtyhqbq50O+HV3EzqWhM5OgkKR9d1weoyB e5hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3xo3uadk4TAHtPwy0OEr5aDTmDZwQ+SU4GyeG6+uHcw=; b=p8TLCnPwBH260VjDXKdcBiCN6Z+KoXALsu0OkY0fuwKONdz5GDrALJnCCdjRsLB2jW WxG1jG1jicHBZiHVf59K9g2JeScOYuqhkzYSCKSkcXSDzqX788Jt0Ib2nVCiZIqr5hlF aXYWdIoFXCrCtgsdk9gvk11z378wVF8MNV5aZ1nQRHHHBD/OVzkfMMgJm56K+B0/PY6o ZvScqGKlmlbkbNDnuU2mcdOl6X5qjwtfzFNW8ydoT6Qlq/4vAEAT/pdCfMisLYTGjtdW 4ReKO9YAYWBY9jlg6rKCHF6wTQ3GeVabe/aIpPKQVGIlV3V9oLZG9bYCBBIz+TOmzd+J 7B+g== X-Gm-Message-State: APjAAAUGWCdKa5jYiyaHfV1cmut8SM8R/BL4vlMDPIuDmNsVrC63jQTj iPUB1knq20vcLcOBQE9MpvuphlRXb+M= X-Received: by 2002:a63:225f:: with SMTP id t31mr11575495pgm.50.1568935800607; Thu, 19 Sep 2019 16:30:00 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id h8sm103340pfo.64.2019.09.19.16.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 16:30:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 5/7] exec: Promote TARGET_PAGE_MASK to target_long Date: Thu, 19 Sep 2019 16:29:50 -0700 Message-Id: <20190919232952.6382-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190919232952.6382-1-richard.henderson@linaro.org> References: <20190919232952.6382-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" There are some uint64_t uses that expect TARGET_PAGE_MASK to extend for a 32-bit, so this must continue to be a signed type. Define based on TARGET_PAGE_BITS not TARGET_PAGE_SIZE; this will make a following patch more clear. This should not have a functional effect so far. Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index b11ee1f711..34d36cebca 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -225,7 +225,7 @@ extern const TargetPageBits target_page; #endif #define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) -#define TARGET_PAGE_MASK ~(TARGET_PAGE_SIZE - 1) +#define TARGET_PAGE_MASK ((target_long)-1 << TARGET_PAGE_BITS) #define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) /* Using intptr_t ensures that qemu_*_page_mask is sign-extended even From patchwork Thu Sep 19 23:29:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 174111 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1671635ill; Thu, 19 Sep 2019 16:32:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsZdUO+tEFrDmmjIR/Fs5qPwaDp7lqarwT6OSCsuTyDUMy5TWCxMm8um0XxB1QCwJX/8qr X-Received: by 2002:a05:6214:30d:: with SMTP id i13mr10401272qvu.101.1568935943359; Thu, 19 Sep 2019 16:32:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568935943; cv=none; d=google.com; s=arc-20160816; b=eEw/s9XqK8Tw6UsPG82sUPDCER5RX6wTo0FBmhzdtVck2VlBupwcUt3MXN03xpsqbj 8HmnwWEDumrNfwb7tL8G12aJnutxmk3sX/uTCv7zHAtKBCcJZUKWx/jzcVG8zsDcteUm 6TwtdBmLJ8j3z02RVYCg5Nj8Dl0mV6vBSBYRvMNAZFD2Ar6vppm9jnyZYdAwKwGj1QPj jd/8aCw2R5AT/6XBiFwAow5+cFFs3vLj1/38ekUTX+/Jsj00w9ZPagb8aSCsBK17LI8a MB1t8wstbj/OLiBcLmM+YRv9MbXKt6xtcvEZvLLGx9xDF4UxGI6vy5wFkOHlrg90pV8B cc7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=gR0jg0QcrjTmZyLiyBAs7/D2tb3kDYy6vyz4PCvILE8=; b=0gam39+1SEVG3q4leoxBkIZRT8feC3P9EPWqi6ayTbsy2VRe18aUay+IUuX8vBpTZz mQ+fLfeAqfm1+gcrtzIu36EL6g4IDcOxhUNjsAAQOS3yIYVOiFT1HEFx1P9LVwNyCpRH AWm2+7oFBpWvA5EIoJ73lMvu6TrXiqcQSMR6mCTsIa3kfpiRdS6Vfttj/vgS9v0eDA+N 4lscl140D774bOn3bgn/HPzHet67F766vrPtVx6VOroVVmzpsIliYrWOwk6Tk8qSmli5 G4lAyNjd4B3+QDDOZsBAJaDkco2RYKrZypM8gQXMG71m07eXAerA3aVbK0C1xbAKJbez G/7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HA9NGZ4q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o6si362305qkf.155.2019.09.19.16.32.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Sep 2019 16:32:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HA9NGZ4q; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5uM-0006U1-2X for patch@linaro.org; Thu, 19 Sep 2019 19:32:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39310) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5sC-0006Lw-B1 for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iB5sB-0000oN-A6 for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:04 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:43455) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iB5sB-0000m5-4b for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:03 -0400 Received: by mail-pl1-x641.google.com with SMTP id 4so2294009pld.10 for ; Thu, 19 Sep 2019 16:30:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gR0jg0QcrjTmZyLiyBAs7/D2tb3kDYy6vyz4PCvILE8=; b=HA9NGZ4qOs7I31WceYz6oYBUUcRBhIxSzgYAaxwKXh0hn5zntw8+o7PvsrZaayuFMi wD6WPUCtgE5KoV6U5psG8k0RF6cUo1WjN99Aean9PdaTEXB5PPu2T8XQ/CkrAJVMzuuB 1bRspCxe05i1fHHvbt/38wiVdhqi0Sf+BOHeX3wOPpVaW+ExSdm4IO0eKIDvc9IHZrI5 IlpwSmkZD0kGfd9Xg5iBS+FQ6sod+WPmVSxQyrYzzTRu9YIGThVgQPbqvN65yRRkTL5x C6dt/54d3gJR6mgtqmp69cs5f+kFhDNQz/3PZLCDPvdJqkQ2ikYXQdVsPfR62vjGZIor HZUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gR0jg0QcrjTmZyLiyBAs7/D2tb3kDYy6vyz4PCvILE8=; b=XFUfaZ2RfRZg5ueg34FTWxEMYsddkSpQO6u8k0KeOQk5KqiJ/MBoJdxebBQzPbswbw JBLXFwG4Vd+FvnNthLKTs4n8FVNbgU1BdD6QM6MDXr5pyAddyrWIYX4mguEQ/1m1HgN4 eGGSCzarfaoiNW28Ppd2DdHmo7CLIpy1VbfoCrs1sO7l2XUDvBORSTQqPX4/O6AZODIY Kgq0gnzoi3w3XeHCFg1tjJ1XSTfXtddMVeWD0Zi0a7MZ7lDIJtaayw8WLzIqCopNnoZb FO2t1uBbCRQsqIag+iWYusDSxyKQZntqd8lLkm6wh/g50OamgWX78TxNW8D9brl4dW4E UxMg== X-Gm-Message-State: APjAAAW47i8yhk7cu57gGMDlLe5Oq6G5S9vh8bLt8pXtDv7pX1osw03B W5430MpibApL3Ftyh1hTKews2JjHBq4= X-Received: by 2002:a17:902:a50d:: with SMTP id s13mr12808974plq.248.1568935801836; Thu, 19 Sep 2019 16:30:01 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id h8sm103340pfo.64.2019.09.19.16.30.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 16:30:01 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 6/7] exec: Tidy TARGET_PAGE_ALIGN Date: Thu, 19 Sep 2019 16:29:51 -0700 Message-Id: <20190919232952.6382-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190919232952.6382-1-richard.henderson@linaro.org> References: <20190919232952.6382-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use TARGET_PAGE_MASK twice instead of TARGET_PAGE_SIZE once. This is functionally identical, but will help a following patch. Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 34d36cebca..5246770271 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -226,7 +226,8 @@ extern const TargetPageBits target_page; #define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) #define TARGET_PAGE_MASK ((target_long)-1 << TARGET_PAGE_BITS) -#define TARGET_PAGE_ALIGN(addr) (((addr) + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK) +#define TARGET_PAGE_ALIGN(addr) \ + (((addr) + ~TARGET_PAGE_MASK) & TARGET_PAGE_MASK) /* Using intptr_t ensures that qemu_*_page_mask is sign-extended even * when intptr_t is 32-bit and we are aligning a long long. From patchwork Thu Sep 19 23:29:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 174112 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1673744ill; Thu, 19 Sep 2019 16:34:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBgCL4vtxgvMtaMF/xDKPQ9Feta3uRmLnBnRAloMnWL0jb7ez9PkEyoOkgNRL+rR8s5kTO X-Received: by 2002:aed:3ef2:: with SMTP id o47mr6074498qtf.314.1568936091622; Thu, 19 Sep 2019 16:34:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568936091; cv=none; d=google.com; s=arc-20160816; b=inX9Odv7QcODDPwCOMxooDYwk4oNM4u4Qf7gIax+tYO5DCH87JiXPksKQL6+YQDBZB +gW/UjBsrZHTgEl9WmjdMvhi0VZZfMXodaJd/M2wkQpZ2e4JG2gEdkP6pDI6SEfIjrS7 U9JxzH4FwhQA6OmfVxSmUKvu+cJkVIHFo8ZC6CsgT8Dd70xbPha/ep3jq/XcMvx0T2pp cMAVTdr9aTg/WxVw//wBsF8WXjONLs6qI63Ph/sxKq6dDAXECjwLnrwDwtG6LaAbeUs0 UgtT33iVDPMQ58OoOV9gFLIErwV7UtwCKCc/IOhR8bGClx+GD1SMHcvP+m2d47E4JEHU 7b0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=eTxCu2cA0J5WLFUs9gnavWyyP8aOc6nLl3OMieDyOi4=; b=RWkSQU0GTnqVGZGW/qATx6TjnFURR3wkdUSYyl8C4OniWo1fyUiXjEvPX0gZ7+bCdW VkbWfM1nBm6+rSNVM5fHtgBdpVN2oYnQqjbx7SqSdBf91kDi3WhpYblxTZVzsEl6deXO REskqEnni3StD7ElGyQM6Ua28yBYKzo/SGdxgzSPPD7qTRw+CWhEnof2bHWhVpX5ATAs u0Tye9gaV/pg2ShT9W1JXSu1bJ+Kxsc6+h75U60Txr38Qnqm0edvnJD6oYfXvwHt/S8Z 2jGEssrfRHvAZqGBfJcwckdCaLaWYfRgndlD/5kEEK5AN/bEbjVyJE3eXCQuERdi8yjn TENw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xoEDfWuR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 198si374751qkj.34.2019.09.19.16.34.51 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Sep 2019 16:34:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xoEDfWuR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5wo-0002iD-M3 for patch@linaro.org; Thu, 19 Sep 2019 19:34:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39323) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iB5sD-0006N2-Si for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iB5sC-0000or-Do for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:05 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:37745) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iB5sC-0000ob-8X for qemu-devel@nongnu.org; Thu, 19 Sep 2019 19:30:04 -0400 Received: by mail-pg1-x544.google.com with SMTP id c17so2740479pgg.4 for ; Thu, 19 Sep 2019 16:30:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eTxCu2cA0J5WLFUs9gnavWyyP8aOc6nLl3OMieDyOi4=; b=xoEDfWuROv4YFw1LWKYMRw2b9hAAwTGmud08hZSU5t1+yR/CkGrEmolBOqpNUU/6bU EnH1o4MNLUHLkiittMyysm+wsy4b+fPUPAM2R5asjkTqQU5xNm3PF+LqS7uwsi4Y3gaC 40JESRBLKt0WSFFa82fu09B4QkLWX7Z1OTZR779n8HeXfQLHtHssmxJ75/uKWR0/Pnco jURXiY/bDMgGUaUeSr27SL+7rCsSqg5z4QkARxJHCXHkYdUvkx+afuyY4LSzGIdpGPpa zAFtn/bR1WtTSq6WhQNJZY0W5IFJJ0VDbRSlce858WUlAc/HJFdZN3roEWSEREdaUnOw AVeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eTxCu2cA0J5WLFUs9gnavWyyP8aOc6nLl3OMieDyOi4=; b=tQJLi2n3R9f42dpJsR0qY27H/10lVOHAsN8G61IDZGI9NIpSdZMzIolqWKTDPNP3x9 ADE7c9UiXB1CQTBTkxK6u3BEAxzeoUe6l0WQx8lX4zbbhob3D86Bk9OMjv/yvjanlLKw gMz+VvkjYZf/yMzV7fzJoVEZ8ZwP6WsewtKw6bg0fNF1IFDvqsgUsoulDiKgpfdOfL2b pXm6ePVxvwB3oYOEHa4W3HaAdqtL5b6lhNCh9CfZQSU+TcqrxGZCQa0AxV0YAc+gzJM5 cBG4ZvJe24XumciI705wR/bM7jy3X+rdkUemGKKmBUukN2lohVA6J/InWaXIZ/Lq8EEv XUtw== X-Gm-Message-State: APjAAAUAkL9lv6ySwnEaRbEe/ZftExSjgN9eLB9QRHFXEv1+71LGTP5v O6HaWT99cht2Z1Huitv2qKQgCst+/AM= X-Received: by 2002:a63:1b66:: with SMTP id b38mr11652296pgm.54.1568935802877; Thu, 19 Sep 2019 16:30:02 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id h8sm103340pfo.64.2019.09.19.16.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 16:30:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 7/7] exec: Cache TARGET_PAGE_MASK for TARGET_PAGE_BITS_VARY Date: Thu, 19 Sep 2019 16:29:52 -0700 Message-Id: <20190919232952.6382-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190919232952.6382-1-richard.henderson@linaro.org> References: <20190919232952.6382-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This eliminates a set of runtime shifts. It turns out that we require TARGET_PAGE_MASK more often than TARGET_PAGE_SIZE, so redefine TARGET_PAGE_SIZE based on TARGET_PAGE_MASK instead of the other way around. Signed-off-by: Richard Henderson --- include/exec/cpu-all.h | 8 ++++++-- exec-vary.c | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 5246770271..2db73c7a27 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -213,19 +213,23 @@ static inline void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val typedef struct { bool decided; int bits; + target_long mask; } TargetPageBits; extern const TargetPageBits target_page; # ifdef CONFIG_DEBUG_TCG # define TARGET_PAGE_BITS (assert(target_page.decided), target_page.bits) +# define TARGET_PAGE_MASK (assert(target_page.decided), target_page.mask) # else # define TARGET_PAGE_BITS target_page.bits +# define TARGET_PAGE_MASK target_page.mask # endif +# define TARGET_PAGE_SIZE ((int)-TARGET_PAGE_MASK) #else #define TARGET_PAGE_BITS_MIN TARGET_PAGE_BITS +#define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) +#define TARGET_PAGE_MASK ((target_long)-1 << TARGET_PAGE_BITS) #endif -#define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS) -#define TARGET_PAGE_MASK ((target_long)-1 << TARGET_PAGE_BITS) #define TARGET_PAGE_ALIGN(addr) \ (((addr) + ~TARGET_PAGE_MASK) & TARGET_PAGE_MASK) diff --git a/exec-vary.c b/exec-vary.c index 67cdf57a9c..26daf281f2 100644 --- a/exec-vary.c +++ b/exec-vary.c @@ -83,5 +83,6 @@ void finalize_target_page_bits(void) init_target_page.bits = TARGET_PAGE_BITS_MIN; } init_target_page.decided = true; + init_target_page.mask = (target_long)-1 << init_target_page.bits; #endif }