From patchwork Mon Oct 28 14:59:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 177939 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp3183115ocf; Mon, 28 Oct 2019 08:10:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJLj/mbs1ngi5HCwoLn2wTptUhgkhiXhrpqAHMuCXmF1a7k9eh0EK4dgBXhzTP39ku58kg X-Received: by 2002:ac8:46cc:: with SMTP id h12mr10440126qto.18.1572275457313; Mon, 28 Oct 2019 08:10:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572275457; cv=none; d=google.com; s=arc-20160816; b=fMlHXinyyqpdpdINO+ujqjxNW0lyNmA7RrYo1WttV25Vna2fBRDXdGRPTfpboeBBSe aA6DK7NBPZ0JCsho/+nLq3+SwZ+GIzTpDuPIH/qZcGLSsf/Y2/DGtAHWAY3ldT7gMAP7 D+REPWEOUTcXUCYXQ0HsfUWIsUiCZtgbJSBRolTwplKqwzx7y9idbf1F4+T6rnFgXk45 6MY6KnoKRfHiiGgbNYhZjbCRbJ0/WKh6t2zqMVGfF9EWKbxOnXUN8tF3D0LEqpB7Fc/B kJv3YpJPWT1H2HfAaiAZ9tJG8feH2ZLXmFPClh3Z0/dIDYimhkDG/bWKyA6Vn6lkVPrM EsbA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=XDtNc199mjlu+7JCj1BafjGA6Am4dbfp5/ruylFlTXI=; b=dqc4qjDKu+yAqJyMzYTwjjjWc7jvv3111hAl52NlhvUnnsNco1msKXofFFq6vHJb6F VfQ2BkipSeJRnzLLbQ1tbQRNvGzwGoSXyEKGmN7ca1j0IIdsGHD/8kSVDGsfsUlBPRYz 0mdy8t7ba6wajEqeHGSKbLYXf6psDk7UAvqS8JT8yYhI78iVygdVlvx9X4z3t7mbZHn9 ajX8RNKTyd4nL8hcbqFahfse3lUUoYbuWeLsjEn2g3Qa5yhTr++SrDJBFqdhZ3TmmMkT 9NQXlKqJtjU26vBjN3J8VOSUxAIoxKZUgbHmhYMv1bASOnW9gLWLNqm37vQq82vZql8Z s/Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bEpyhl+Z; 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 d17si9760629qtb.155.2019.10.28.08.10.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Oct 2019 08:10:57 -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=bEpyhl+Z; 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]:44882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iP6fX-0004Zq-7U for patch@linaro.org; Mon, 28 Oct 2019 11:10:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44619) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iP6Uq-0007YZ-Ol for qemu-devel@nongnu.org; Mon, 28 Oct 2019 10:59:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iP6Uo-00045f-QM for qemu-devel@nongnu.org; Mon, 28 Oct 2019 10:59:52 -0400 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:46257) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iP6Uo-00044f-0a for qemu-devel@nongnu.org; Mon, 28 Oct 2019 10:59:50 -0400 Received: by mail-wr1-x431.google.com with SMTP id n15so10200204wrw.13 for ; Mon, 28 Oct 2019 07:59:49 -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 :mime-version:content-transfer-encoding; bh=XDtNc199mjlu+7JCj1BafjGA6Am4dbfp5/ruylFlTXI=; b=bEpyhl+Zofj9zcnd/a9GYz56dm3yyb7jvDd3xdyx+b3L39nd8Nv6XoWnDIvpJS/qw/ 60r/cvkP7hPWfOf2jC9uVfO39AIQcMxZA1bqtAK0wippwkpYNFnCTYk2oVv+MBIjziBa g5dUUXsFD5BXISe01kv2PW84wtc11RX00+T3ABZD7/kz2RJMKCgz4jh2DYJk2mj0lMer QvzEucvCW3pc3Nk0o9W2YcisFUpo/ccplbomb7z6aEEbcKQ8K4IwSRnY6vXn8bAU5mUz Qtq6ZLD8EIktiNrQrhBAvV867ilV4ZiBbsdL4UNHZXb5to3Qqz25YRevQQFmzS3CLWA/ EPyQ== 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:mime-version:content-transfer-encoding; bh=XDtNc199mjlu+7JCj1BafjGA6Am4dbfp5/ruylFlTXI=; b=L/29yWNZJ2Q00dU99QVGleQlVMdeE9IpkFKfoU4Ycr6Zyh7kcZKylmwQ177O4Nygxr HX3J0nw6QvU9b21dTNvPGb3Vg9FusLSExj1xVa4M40pfLIUQyOVc0/aQ8AdvQP1SvFm4 rjtmAyKJ1abQQBBCX6eJlni1uSjVHnroTMGLCS2GVymEyNeMqdLoD+ldjHBIWZm3RyFG cNYLZ8621WM5o5LI3Uc+AafGAGZR0DsrDL3z480nMD7+XzXNE1M1HkgGXbcb/A8JCdiR YDj5NEY1+V7JocdokW7ouNuZg8/HgaAz610z7fmUu8A9OTkqemJyFpOFSMsW9Rm+qQda g9Kw== X-Gm-Message-State: APjAAAWPh2QoiH4/+JZGtfenDThOUW0gFQ5mwzfhaCEZOYjvAukfvj3H tLSQK7u4GVRysXGqYCkI4V/dk2L5NOCo/g== X-Received: by 2002:a5d:6a02:: with SMTP id m2mr16483228wru.304.1572274787861; Mon, 28 Oct 2019 07:59:47 -0700 (PDT) Received: from localhost.localdomain (230.106.138.88.rev.sfr.net. [88.138.106.230]) by smtp.gmail.com with ESMTPSA id 143sm14842876wmb.33.2019.10.28.07.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 07:59:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL v2 09/12] exec: Cache TARGET_PAGE_MASK for TARGET_PAGE_BITS_VARY Date: Mon, 28 Oct 2019 15:59:34 +0100 Message-Id: <20191028145937.10914-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028145937.10914-1-richard.henderson@linaro.org> References: <20191028145937.10914-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::431 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: 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. Reviewed-by: Alex Bennée 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 0543359d0f..e96781a455 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 8725fd0285..ff905f2a8f 100644 --- a/exec-vary.c +++ b/exec-vary.c @@ -96,6 +96,7 @@ void finalize_target_page_bits(void) if (init_target_page.bits == 0) { init_target_page.bits = TARGET_PAGE_BITS_MIN; } + init_target_page.mask = (target_long)-1 << init_target_page.bits; init_target_page.decided = true; /*