From patchwork Sat Aug 3 18:47:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170493 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2345912ile; Sat, 3 Aug 2019 11:57:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqXb3ub1RPVHwARzOh1IS8GxWg8mrfc64V6S70vQIPr6eedMj5220wqP5NgtiGkbzEq91M X-Received: by 2002:a17:906:b283:: with SMTP id q3mr56131697ejz.153.1564858621899; Sat, 03 Aug 2019 11:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858621; cv=none; d=google.com; s=arc-20160816; b=eEYMR8AIzT1iFBF9JvnB8IXEjIy2xJvTvwdtFWPGtMGBA6iRqgHZlzEvbqmTTWPUjV Skc6CANcwFFoHbuWKo3aRvMpJsZVMpylv51xJHFC16eIQdWHTp5cWXw5a0A19g0Xbyc1 H0h8cw5V7+r24BXXZIowcdBbkWm/o9yxX52OZFmjXUDBPPcLRN8Dc7l4qgE34UKpXKK9 8yWsqHpauAAOGyaJdU4CfSMVSg4pxrnpp9iGPquZU7/Nl8D1xkGuZQrIbY2QDL/P/s18 4vUeVMEUgL5BrOcGNFse97cR3g7xzwZjoJnoZ/RotewqYBtVKuzQ05I2KUXK1t1iHbHv yQGA== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=AKU1gGfJD0fHB3QeRt9QRaO7IOfL7ZvP1zaRZud/BsE=; b=IYPuIlkhXAXQcR+FnbPQNxeSQJjkNKuhQNiYNjAqdmmeniOEvY9OH63shPBNGG2ZKr 45HoT/9RTJs1I8IHORExMbwxcYsUDgrA/MPyjo0fjQ5MwCVH9AvIUeeAZcdONQiGxcGI LG4gKMyx0E+ZcXazfCabppjfCEOekJ17h+GmJsgmOW7NbXIAzYzJKto0W7N6cYAi0GnR 4jFYe8oohFzQ4ZnsqrhWe93XK8/P/n6zR7/EJp4Conb+kGiKvFpItFL22NPafU3SKQld d64wa1/xkhg5tZaTC6B8xhnmFI3EOjnTAOI8RCQ6/BlcPVkWuOoLE0gA4rusL3xPOSG/ I2gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RzRDhP10; 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 um7si24288199ejb.72.2019.08.03.11.57.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 11:57:01 -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=fail header.i=@linaro.org header.s=google header.b=RzRDhP10; 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]:41498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzDA-0006wb-Rh for patch@linaro.org; Sat, 03 Aug 2019 14:57:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32921) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz58-0006rl-Aq for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz53-0007Oe-KB for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:41 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:46549) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz53-0007OJ-DQ for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:37 -0400 Received: by mail-pg1-x542.google.com with SMTP id w3so463131pgt.13 for ; Sat, 03 Aug 2019 11:48:37 -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=AKU1gGfJD0fHB3QeRt9QRaO7IOfL7ZvP1zaRZud/BsE=; b=RzRDhP10pg0B8kssRnKpGMDyeZ0CTYSkr/iXpyetK+I8OqDcpyaHvTOEzBw9q1+vnS yRXRNdfbYkO7LoK95UnEZ+G6QuxWCyTwjDy/eBXf4WpoKjVDPqMUSIS5pHc7BzDaztVT 8f5XPqSlCC5FCy6ick5E2j062jJ91k70CN8IBZxr5CsWTIB29MKBccHdbLbERCCpFMur vS8dfJo8ddRCKHLQzpXt1t+/3sjVieV8Qz0Z01+0EuNNoAJL4eGO3RVvsKoIaltd1syB eBQh2rtbnAiKOx1WHALl/cLcW2DlglBKn8iLF0Bdx8cm3qv2uCP7WuYf68vS057Sy+1Z KX3Q== 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=AKU1gGfJD0fHB3QeRt9QRaO7IOfL7ZvP1zaRZud/BsE=; b=CWo3nh0Okf/xfFRttII0SALON4RbDIJ/wUSIW5f8C2pLd5Zp76lWjhroySFnEDoecE myk3hYVC+88/FOChNm5Idv1pczLNHOXKIC6xPjLjavahP62sYi1kGK8/l/tQ1E2AkR5q 3qvPrWpDcatRjlGvNGu9Wc34lpgloAuO/9jUNlJ3f3wjRtm0Qz5LDbX13nvELfyuUUOu uEvWwt4sxh2tZBBbzkTFybD+EhDSaJtC1mixPUMvfQNV9SU67bSsueXCyqje8tYKzrFr xEV2tA9jra2CHFjAoe1brXZTuD4pkLEcVh8DkyfVt5sPvgmI7XL8ZFdPgplf9DuQxOTj UOHg== X-Gm-Message-State: APjAAAXymRkdADGaHRp77HMvyMaXw5BbGAbC0EawFYoT0qe3rDFhTzq+ oNpd+2HQSJXelb3kGxlXjlpkLUyhCOM= X-Received: by 2002:a65:57ca:: with SMTP id q10mr133449832pgr.52.1564858116151; Sat, 03 Aug 2019 11:48:36 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q69sm15405454pjb.0.2019.08.03.11.48.34 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:54 -0700 Message-Id: <20190803184800.8221-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190803184800.8221-1-richard.henderson@linaro.org> References: <20190803184800.8221-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::542 Subject: [Qemu-devel] [PATCH v3 28/34] target/arm: Flush tlbs for E2&0 translation regime 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, 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 | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index 9d74162bbd..984a441cc4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3917,8 +3917,11 @@ 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) { + return ARMMMUIdxBit_EL20_2 | ARMMMUIdxBit_EL10_0; } else { return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; } @@ -3956,6 +3959,10 @@ static int vmalle1_tlbmask(CPUARMState *env) if (arm_is_secure_below_el3(env)) { return ARMMMUIdxBit_SE1 | ARMMMUIdxBit_SE0; } else if (arm_feature(env, ARM_FEATURE_EL2)) { + /* Since we exclude secure first, we may read HCR_EL2 directly. */ + if (env->cp15.hcr_el2 & HCR_E2H) { + return ARMMMUIdxBit_EL20_2 | ARMMMUIdxBit_EL20_0; + } return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0 | ARMMMUIdxBit_Stage2; } else { return ARMMMUIdxBit_EL10_1 | ARMMMUIdxBit_EL10_0; @@ -3971,13 +3978,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, @@ -4002,8 +4018,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, @@ -4021,11 +4038,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,