From patchwork Mon Mar 2 17:58:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 184101 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp2685630ile; Mon, 2 Mar 2020 10:03:35 -0800 (PST) X-Google-Smtp-Source: ADFU+vuZT20NijU8TPizl1AaNCZV+LKwxlppO01wjKoUWl+C0AjrS7PhO+B1i41LshmncGgUWth5 X-Received: by 2002:a05:620a:94e:: with SMTP id w14mr423248qkw.277.1583172215536; Mon, 02 Mar 2020 10:03:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583172215; cv=none; d=google.com; s=arc-20160816; b=K4P35rnPnu4o7WindBSjP4g7b+8K1JmXCTpcJ9o852Hwa1WHGDihqcTiRs17Nl4uPf ODwXaihlTyhH4ZACMLunGhrsPu3hdAUr8ipysIWOp/x8Fsa+HCE0/UkPItlPVFDfzXnq IBuJ3lO8e55+PYlVgVm8KGdQtfY6uYyE+fVzCc5pUhXFy3OQbcSGAH5hNpxfkJOIn+Pw 4sr5tuBwMP17bvzBY0hRgIgY600fwpV6567mZy1Sw9yOOjJv1e8rheuEOwGEM1LnsSAE 5ZdtvNBapwwFtH7pHf030sUwsecdw0N6tUDbX678WzgEagGDE3DIC517KApn32l+3sAz aRrg== 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=nnZb8apL5HPwafrnPocDxPavn/5fOqQOkEGFTZ+nDV0=; b=Wh3P9lglVGh19vyTO2dfuHtAYvoi19G6PFmjZZR/T5xY/3i1l47t9GO0n6zqC4ogn/ HTqP1+jGYd1dX77aj9UG1YC5guk5EIOZi1V8Es8JkXwi+ylQ5AT02jqusiBv6/8SeM+W 9PU/x4R7rg7aK9RZbqvbuPSaDR6XvZYxfMjNOtEY/P6XzR3oxpr+dgPv/skhrToNQtmn xqgecft0gxDBsObVyj+QQk1nD3XDaJaCrgrndsjzvPBUPVFA4bKCHqYacyR2dWdBcQVw 6EBZpwLVgLyfq6EghAxG/vBy8cvC0be68qeCBqjBZt2aIdqyxOPke+gJq0ciJ79P6Erd 8yvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VhZvQJ5+; 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 g24si2408750qkk.377.2020.03.02.10.03.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Mar 2020 10:03:35 -0800 (PST) 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=VhZvQJ5+; 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]:36466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j8pPj-0006Rw-3J for patch@linaro.org; Mon, 02 Mar 2020 13:03:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39045) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j8pKu-0006b5-Kj for qemu-devel@nongnu.org; Mon, 02 Mar 2020 12:58:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j8pKt-0007YJ-IH for qemu-devel@nongnu.org; Mon, 02 Mar 2020 12:58:36 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:35002) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j8pKt-0007Xv-DF for qemu-devel@nongnu.org; Mon, 02 Mar 2020 12:58:35 -0500 Received: by mail-pg1-x543.google.com with SMTP id 7so189880pgr.2 for ; Mon, 02 Mar 2020 09:58:35 -0800 (PST) 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=nnZb8apL5HPwafrnPocDxPavn/5fOqQOkEGFTZ+nDV0=; b=VhZvQJ5+cEChkiR9dxCzGSXsj/jtGkqJTGx1BXvvtyqFUGAMI57XDLSJoLzR0/1vS8 7v56MN29PvZvjR+d/fTNJRIlIvVUutbWdPLmlq7gzoIboMHF6LSCI3W7PUiZpVY9PGwj JMYJBBJrAiOoA2oRCAOGULv5+Z1I27T7XTeKf39B12c0Asr2A/9zSU23x4vtJN/l67iK lbyRkdqsGW3DZyI0xjVtI5krWchs/EgAOARB6FCCWvL3CMbE/OphCGVjYLFhjBT6FOSj oTBPvGS839DwAw2RAzxcDk/irP8MdkWwoNus9P1o78joaP/y10xj1oXziOIiV8xAj6GP ADLA== 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=nnZb8apL5HPwafrnPocDxPavn/5fOqQOkEGFTZ+nDV0=; b=uRhlumADpCHutZ2+xbvQSCfLSNcnVU7BBa6NXMcoJEG3PW0bpjsnXCA2eIzCSMIIEi MbWeDA0DWxVLRDIdx8qh/XU9ZjmeqH0SY9ZfAqBll3jaPK7dXMHviF+b2QW1owkmAw3y ilvBPoJmLP4J6emL8xQZ6h+swv8I9P4bvVcKGcy+oRjnegTgkXkddhyvrtREjpr9Ghiz D8H5zTnQAVu4HZjtGYcWVUJxmj/r+TMaLwSPZ1up9maBytd57+jOZFuw3YSufNNoxMaK /PHDMiVOb+CTwvBBED5tRm6I4bSDLDR6gVA18weq8dylhafWlWUZ7VVt5i58lNuuDCBU 3YWA== X-Gm-Message-State: ANhLgQ2fKAWTEtoRhQ6GXAiAYlC+FN1+bVTRbn51mt0mW4imDJjHdYxK C4gKmHZxxs8JDIzoh4/nPuVXv+jR/UY= X-Received: by 2002:a62:1dd8:: with SMTP id d207mr234054pfd.78.1583171914087; Mon, 02 Mar 2020 09:58:34 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id s18sm99510pjp.24.2020.03.02.09.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2020 09:58:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 2/9] target/arm: Optimize cpu_mmu_index Date: Mon, 2 Mar 2020 09:58:22 -0800 Message-Id: <20200302175829.2183-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200302175829.2183-1-richard.henderson@linaro.org> References: <20200302175829.2183-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: 2607:f8b0:4864:20::543 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, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We now cache the core mmu_idx in env->hflags. Rather than recompute from scratch, extract the field. All of the uses of cpu_mmu_index within target/arm are within helpers, and env->hflags is always stable within a translation block from whence helpers are called. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 23 +++++++++++++---------- target/arm/helper.c | 5 ----- 2 files changed, 13 insertions(+), 15 deletions(-) -- 2.20.1 Reviewed-by: Peter Maydell diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 0b84742b66..8f1b949c88 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2936,16 +2936,6 @@ typedef enum ARMMMUIdxBit { #define MMU_USER_IDX 0 -/** - * cpu_mmu_index: - * @env: The cpu environment - * @ifetch: True for code access, false for data access. - * - * Return the core mmu index for the current translation regime. - * This function is used by generic TCG code paths. - */ -int cpu_mmu_index(CPUARMState *env, bool ifetch); - /* Indexes used when registering address spaces with cpu_address_space_init */ typedef enum ARMASIdx { ARMASIdx_NS = 0, @@ -3225,6 +3215,19 @@ FIELD(TBFLAG_A64, BTYPE, 10, 2) /* Not cached. */ FIELD(TBFLAG_A64, TBID, 12, 2) FIELD(TBFLAG_A64, UNPRIV, 14, 1) +/** + * cpu_mmu_index: + * @env: The cpu environment + * @ifetch: True for code access, false for data access. + * + * Return the core mmu index for the current translation regime. + * This function is used by generic TCG code paths. + */ +static inline int cpu_mmu_index(CPUARMState *env, bool ifetch) +{ + return FIELD_EX32(env->hflags, TBFLAG_ANY, MMUIDX); +} + static inline bool bswap_code(bool sctlr_b) { #ifdef CONFIG_USER_ONLY diff --git a/target/arm/helper.c b/target/arm/helper.c index 37ffe06c05..addbec91d8 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -12128,11 +12128,6 @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env) return arm_mmu_idx_el(env, arm_current_el(env)); } -int cpu_mmu_index(CPUARMState *env, bool ifetch) -{ - return arm_to_core_mmu_idx(arm_mmu_idx(env)); -} - #ifndef CONFIG_USER_ONLY ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) {