From patchwork Tue Dec 3 02:29:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 180679 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp949969ile; Mon, 2 Dec 2019 18:49:25 -0800 (PST) X-Google-Smtp-Source: APXvYqyqjL9q70HJReu0mweihewR0ONsfXa29SSvZnLjC9wNpv2HOTdbiCeUH1NOZSYqmD81Wscj X-Received: by 2002:aa7:c24d:: with SMTP id y13mr621735edo.94.1575341365123; Mon, 02 Dec 2019 18:49:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575341365; cv=none; d=google.com; s=arc-20160816; b=VKkQP8V0eXuvpsUDjB4heXXvX+m2FHQClbT/EjpCkavYNRK2GngbGEdDWWVqoC8CHk HTMEvj8kwcngmsrmmfC7Oc/lsBgpr0Xnhl9w7UukEM12maVnnINzq+e5O3s3j9RnASPd MrbzcP06b3XN0dlcrEcRZrkEPrcurdjB/yAqbFW3i8mAYS2tnvlEQMYLqW0MlCG3P4te 24MLV9up6fkRTQw7C8nyVAdYqArYDzWTv8Kxa5CBynyPVI7H7fB7SDZ3D/+k90mjybJS 0GYyNDYOm5PwdcyzagG5bhK+kFI64az9GCBCqLf0lLIW64ser+saQqJs2fZ9WCH8oedw NLBQ== 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=sgf9PjMDcr7YkI/Fw1uObi5dAB9s8zvthtA9mINjU3o=; b=T31P+dkMgEEhxZGrA8RebXYii9Erfw0GjqwS+kcjDb2ib8lbb5s1vxSiJdcOpJSW5K Pw0M0zjvgCQDpa/St+eQZmxJmGZAHp9d7DnNG5WIR6Y5UGybrTi6V3PQIGCG3YTdjwjd X9qRMkD4qtuZAlpmxkuiku+tkfRIWvpaecikWNCve4DEisFLW997FjRvKMi0MKE1b3Kv 1Izp6WGgjkSfitH2me2Y9Cz8DiaidofKsXUEpZl2joHlXtT2bTyVIdiJe6y4yZHQPn5T 4SYtIL1KJ/g42GL/++VpANVQ2f7ASby8LhNvufoFitCZSZ5t8/8c1Vl11xrQM2kUnR6+ lvEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GUBiTl0d; 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=fail (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 b29si1267240ede.118.2019.12.02.18.49.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Dec 2019 18:49:25 -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=fail header.i=@linaro.org header.s=google header.b=GUBiTl0d; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibyFf-00015v-NM for patch@linaro.org; Mon, 02 Dec 2019 21:49:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:32802) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibxxI-0003M9-Tg for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:30:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ibxxF-000094-OM for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:30:23 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:33602) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ibxxD-0008VY-EQ for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:30:19 -0500 Received: by mail-pl1-x641.google.com with SMTP id ay6so1016845plb.0 for ; Mon, 02 Dec 2019 18:30:18 -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; bh=sgf9PjMDcr7YkI/Fw1uObi5dAB9s8zvthtA9mINjU3o=; b=GUBiTl0d9K/QvgfTFCt5yHLT4hoEcCy4anS6I8v6lAkd5BdOr5vEC5hCDeI5QNv9+S 2JZYtdqUcnPVm1bCELOZs8qoeh9RJCCsTcV4Mwa6UVXszo3w1kloqf1h/Y0NsYA0BBPZ yrPX4mqtIlHjZK69JDGSA70e4exqI6puK7JuV3w570SEYgq2LYltOhhojViW5es9ScM6 dwR9GTZuuxlBsysrINzuY1Bd2jzVUWagg4gjOW8fd83KQiZPQmLdoviq5OqvtUkspoRr UuTvyz+KpW9avgrBWaibvT6kc+kd/XvVCJeTr22Z8LGFNzMY0pv/ZDr/pIrgi7qeZf7I xhUQ== 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=sgf9PjMDcr7YkI/Fw1uObi5dAB9s8zvthtA9mINjU3o=; b=mrUAbEjJEgaRe0i3rKTDAgCvoQGyQojU12doPpOxtBm+Bivw9aOgdNfMnTQGQbim1P pGsXmnubr2Jl3EVuo6xkl7nGkvRRp5UAW/FAVrwTFMLLqWLEXvyyx2I1bxAMe4226PGI QwVKJXwF9ZndPQRlx0+oUArqQRr8PD3umru5wHjYaX5fnAUmN62pFTh7kvt5nbI7zoSE YoEcy2nHgtMRh7r2fdtBiMmK6DyQZxtBAL2HsJAh+sVyxyOxnmqlW0xjiHm4VAIvGa2l 7eXtOTVA4A5x3ST1icOc5Mo/ERy+CT+VeEhz6oBzfM4OtJEuH+Gg+vNvTNngPi/GRDcK m4sA== X-Gm-Message-State: APjAAAWF8WJvVvU3x92j90Xti0LqoFjtx9+FNSstdHZEeQaa82pmry3m YXvQNcgdaAO1HzUZk4UtQvjCr6Qz6qA= X-Received: by 2002:a17:90a:ae01:: with SMTP id t1mr2959645pjq.32.1575340217654; Mon, 02 Dec 2019 18:30:17 -0800 (PST) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q22sm873695pfg.170.2019.12.02.18.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 18:30:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 30/40] target/arm: Flush tlbs for E2&0 translation regime Date: Mon, 2 Dec 2019 18:29:27 -0800 Message-Id: <20191203022937.1474-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191203022937.1474-1-richard.henderson@linaro.org> References: <20191203022937.1474-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: peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/helper.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 2a4d4c2c0d..b059d9f81a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4123,8 +4123,12 @@ static CPAccessResult aa64_cacheop_access(CPUARMState *env, static int vae1_tlbmask(CPUARMState *env) { + /* Since we exclude secure first, we may read HCR_EL2 directly. */ if (arm_is_secure_below_el3(env)) { return ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0; + } else if ((env->cp15.hcr_el2 & (HCR_E2H | HCR_TGE)) + == (HCR_E2H | HCR_TGE)) { + return ARMMMUIdxBit_EL20_2 | ARMMMUIdxBit_EL20_0; } else { return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; } @@ -4158,9 +4162,14 @@ static int vmalle1_tlbmask(CPUARMState *env) * Note that the 'ALL' scope must invalidate both stage 1 and * stage 2 translations, whereas most other scopes only invalidate * stage 1 translations. + * + * Since we exclude secure first, we may read HCR_EL2 directly. */ if (arm_is_secure_below_el3(env)) { return ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0; + } else if ((env->cp15.hcr_el2 & (HCR_E2H | HCR_TGE)) + == (HCR_E2H | HCR_TGE)) { + return ARMMMUIdxBit_EL20_2 | ARMMMUIdxBit_EL20_0; } else if (arm_feature(env, ARM_FEATURE_EL2)) { return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0 | ARMMMUIdxBit_Stage2; } else { @@ -4177,13 +4186,22 @@ static void tlbi_aa64_alle1_write(CPUARMState *env, const ARMCPRegInfo *ri, tlb_flush_by_mmuidx(cs, mask); } +static int vae2_tlbmask(CPUARMState *env) +{ + if (arm_hcr_el2_eff(env) & HCR_E2H) { + return ARMMMUIdxBit_EL20_0 | ARMMMUIdxBit_EL20_2; + } else { + return ARMMMUIdxBit_E2; + } +} + static void tlbi_aa64_alle2_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - ARMCPU *cpu = env_archcpu(env); - CPUState *cs = CPU(cpu); + CPUState *cs = env_cpu(env); + int mask = vae2_tlbmask(env); - tlb_flush_by_mmuidx(cs, ARMMMUIdxBit_E2); + tlb_flush_by_mmuidx(cs, mask); } static void tlbi_aa64_alle3_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4208,8 +4226,9 @@ static void tlbi_aa64_alle2is_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { CPUState *cs = env_cpu(env); + int mask = vae2_tlbmask(env); - tlb_flush_by_mmuidx_all_cpus_synced(cs, ARMMMUIdxBit_E2); + tlb_flush_by_mmuidx_all_cpus_synced(cs, mask); } static void tlbi_aa64_alle3is_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4227,11 +4246,11 @@ static void tlbi_aa64_vae2_write(CPUARMState *env, const ARMCPRegInfo *ri, * Currently handles both VAE2 and VALE2, since we don't support * flush-last-level-only. */ - ARMCPU *cpu = env_archcpu(env); - CPUState *cs = CPU(cpu); + CPUState *cs = env_cpu(env); + int mask = vae2_tlbmask(env); uint64_t pageaddr = sextract64(value << 12, 0, 56); - tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_E2); + tlb_flush_page_by_mmuidx(cs, pageaddr, mask); } static void tlbi_aa64_vae3_write(CPUARMState *env, const ARMCPRegInfo *ri,