From patchwork Wed Oct 23 15:45:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 177323 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp927647ill; Wed, 23 Oct 2019 09:04:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlcK6JtrZb3ydpznDcid+7FtaFrjQingM012Cf94ud3KqSYYLaY83z6qfr77aXKpI+Yqid X-Received: by 2002:a37:396:: with SMTP id 144mr9077169qkd.479.1571846682678; Wed, 23 Oct 2019 09:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571846682; cv=none; d=google.com; s=arc-20160816; b=tKn69HnYz0jJSuXVozwW/cFVAgX3j90Ni30ZltGIYLyXWlDgGbQ8W36eI2oqvC5QLE QCh8FLVz9nHbFkCJG89pIhJ2gzWidZCPBRLWTksFYFOixzK87Fm1Sgvgc3dcI1cW9nH4 omJ1QVFIFVYkMl1WM3cgNdt6sLj4i3IKSWptANPWP8CJU7ZuKY1hsd51QdywqGa8HIDv sCMvZJ737UBMrIVp97ocmIU6mm7IzHl6fpyHBvgM8iAim8sMSY+EyRtH9USfS7ASGqt7 Oj8Y6eE+Rrn3jj+c42NgfjEFAzutoUPdTRquNOueb7Si6wH9EZ88Y1RdzfZXrb0ffhB4 6MlA== 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=JjWcaTsnfa9rn5Sr9u0qn7xbDpDf/Xngde06dSTH5/8=; b=CqQ9uReVkTzpUL2mI2gEIVsDbB/W2EIaiLrgv76px4O/aJkYCdEn0jsMChl4Oc8CJf 64YyZ+/GkkdRXSkxQ+t5VDpSMUcUmljXHFMv+hNO7UYIlSwW6yzeOznibJ3LUjHP5kOW 46Cgp8nJqgPL9c2wfsEry5cfZP8V6A77Km0NPXVZd2q11i9bV9lCydP0BPUW3DZ92ZPq 1eA878xIoQRH8pZnTZcgLgqoqgBzFBLNfaw1hF03tMemyiHidOyFlEQro31021uTbeBl lk/L6JDkSN62wjA8z1M5AyehnbkMgQm6ltKpgiDeOVkCxwbqB9ZwzG5LQ+My7CTJbYk4 IBmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xvAGOaSr; 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 c27si19887282qtc.318.2019.10.23.09.04.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Oct 2019 09:04:42 -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=xvAGOaSr; 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]:40468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNJ7p-0005KM-EI for patch@linaro.org; Wed, 23 Oct 2019 12:04:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42576) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNIp4-0004mY-RS for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNIp3-0005aY-FS for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:18 -0400 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]:42626) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNIp3-0005Zd-Au for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:45:17 -0400 Received: by mail-qk1-x741.google.com with SMTP id m4so3244209qke.9 for ; Wed, 23 Oct 2019 08:45:17 -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=JjWcaTsnfa9rn5Sr9u0qn7xbDpDf/Xngde06dSTH5/8=; b=xvAGOaSrw0eVg5PLraV/c3pa1IsjmiLrQ/GZQUHU+4DVYyTs58Qbmsa1U1sihy0SAM HhhkF41bkgIkLMwVGC59UrY/Vrvnx2BzoI41MRbR/68WItfrITAdhNc3UG+1cnENG6Y0 XMjcb9Wo2zYhdrHKYzC/8bvDSqpwKS96tEKnGo2DUzN0fI0/kfyvMxu91p97az6Gkbgk LWmAMQsOBR+8pEu3XqtXlNmAaw6h35WxTFW8CPe/K4Txmb0aaDNbiklT9ZqV1DkFWZoo zJQZzOvkfFsocg8SWY9T3zmy9+m8TVDYF5G6SwG3IK1pxd4fwp0lrtm+5Z7fOSRFbhkH yW6A== 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=JjWcaTsnfa9rn5Sr9u0qn7xbDpDf/Xngde06dSTH5/8=; b=Tx+hS39Zh7YzTLeeihcxoinddu8sZeU5EM+ivinIlYBVxKpQYlifuDxxrheAIEoY8Z o65svB2J2zN69Hx/6cmkeYstIjDyTvxvmIlsBji8yqua7j0SmqfpWzUDlZeH7SIvs2D3 iROwWBL047lAZ5JfzBN5RqE2pSmDD9jYnAxhAzN1asSSiGObB/RLlw52FMwTELkfIZnW zqC0LZBP7TBHLY8wt6NX+MG48VoqWbsqVz9l2l0FDlpg2FLw1lgC7te+PI+hQAHGIrX3 BL1kwSVqrkLlQRnZA4Vd3biKLw7IYvL8+w01XSmlP6Qv6FE9SRBufIysPonGQ7dh8bSH XBMQ== X-Gm-Message-State: APjAAAUIQMRUhleTexGBbDgy83vfV+q7oQ+9LGK4vHipALVUKeGS/Wyn pYGkewmwC5SncKweh/Cm/UboRnWxclM= X-Received: by 2002:a37:90c2:: with SMTP id s185mr1977393qkd.377.1571845516352; Wed, 23 Oct 2019 08:45:16 -0700 (PDT) Received: from localhost.localdomain (rrcs-172-254-253-50.nyc.biz.rr.com. [172.254.253.50]) by smtp.gmail.com with ESMTPSA id o1sm2456272qtb.82.2019.10.23.08.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 08:45:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 7/7] exec: Cache TARGET_PAGE_MASK for TARGET_PAGE_BITS_VARY Date: Wed, 23 Oct 2019 11:45:05 -0400 Message-Id: <20191023154505.30521-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023154505.30521-1-richard.henderson@linaro.org> References: <20191023154505.30521-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::741 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, alex.bennee@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. Reviewed-by: David Hildenbrand Reviewed-by: Paolo Bonzini 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 ba6d3306bf..08b3a5ab06 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -213,6 +213,7 @@ static inline void stl_phys_notdirty(AddressSpace *as, hwaddr addr, uint32_t val typedef struct { bool decided; int bits; + target_long mask; } TargetPageBits; # if defined(CONFIG_ATTRIBUTE_ALIAS) || !defined(IN_EXEC_VARY) extern const TargetPageBits target_page; @@ -221,15 +222,18 @@ extern TargetPageBits target_page; # endif # 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) ROUND_UP((addr), TARGET_PAGE_SIZE) /* Using intptr_t ensures that qemu_*_page_mask is sign-extended even diff --git a/exec-vary.c b/exec-vary.c index e0befd502a..0594f61fef 100644 --- a/exec-vary.c +++ b/exec-vary.c @@ -97,5 +97,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 }