From patchwork Wed Jul 31 20:38:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170268 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4481702ile; Wed, 31 Jul 2019 13:52:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsHI90K6t75sx3uFoRDx2GlDrpdT5U+/zB1rsA/7O7gAvzIPLiuMI0kW5nxay0ig330TaQ X-Received: by 2002:a17:906:5806:: with SMTP id m6mr33538790ejq.80.1564606369350; Wed, 31 Jul 2019 13:52:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564606369; cv=none; d=google.com; s=arc-20160816; b=d6mbT7Pae70KPN8s/7Kd2F9aUrxrf3Zx3We5w4G7qGhEW8LYHffCwA0V6wiyyLWTKZ 5glUq7HLGL4hkgwDp+mx7MfkUF8/UWWPLV9WlGzJ8tKalNj/0bcPhZExjm3RCrBvK8it 29g9Qk0TQxdlPXPHuCjmcOrWASC+nQgGCJqwQWHtcxw4fyXF22ONrFnS/BEQyHY0NhPp 27JkYQn4iJKYcOjzydX2zVGz/IN/YmfqYbxOVzVNS45BXDuEiHNkhN8YMvv1PSlU4/45 pj2vYlQd+QW5UdsCwdYIR7SIOJ+JFtyYvMiB1cZlLGZ22pGVdHX0A5n9Qj5h2cqgnnEU LLYQ== 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=YBFs9iOiLgu7VKenmzw4aXW6nYPbjotzvVPML6HKYTM=; b=hVRPxzeLP95yTP/RzqDxvK4yKuAr0B75Gg2YunNnC1v3p1IfAwQ8WQDkhgOhu0n5h9 7MhVq0Qro4lbtSp9TNl3GeopCn7o2t3oi9v8lehtvdT/2YR0P+BGatSuyFktNDLpI9+P q9B/y6+NSbhZ4kSA1S2KYqtay2RnzMIxaUgvgiNjDZcwTuVj63y8EK2IK6F62BeL5TP1 QWny6jbZVXZd5OrbHZcwZDkiAxslCHriQtpgnjN+APoGyQALcuHFnDeQmzB9nJ2zM/jZ 57btFrQi5l9fhDGAmPzXfFJaXiF5iiH2aylNeTb1eNTfjgc80jPF6mEQ0sZixXv90TOj oLrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=k6Yc8ZuB; 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 s49si20953215eda.99.2019.07.31.13.52.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Jul 2019 13:52:49 -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=k6Yc8ZuB; 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]:44520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvaa-00039d-Cg for patch@linaro.org; Wed, 31 Jul 2019 16:52:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33092) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvN6-0005Tj-UP for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvN2-0003jd-SB for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:51 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:42599) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvN2-0003iX-Kq for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:48 -0400 Received: by mail-pg1-x544.google.com with SMTP id t132so32632817pgb.9 for ; Wed, 31 Jul 2019 13:38:48 -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=YBFs9iOiLgu7VKenmzw4aXW6nYPbjotzvVPML6HKYTM=; b=k6Yc8ZuBX4U2Cf5P4Q38L4WBfL+KxeqRknh+AXILTGEQ6PRNkpVJa9gf4KdGj+GTcb 0bD1ELvDm4LRZtVLcHYvYdHus+mHicLOuU/hMLVTVWhC5jdvQCLcohfYwzVSMDEbsGB3 XTIqIhLnFrOXrR02pYdmjKHgqZDgwekvj+c8V2mIjYs1H1tvwDM+UrSqeVJAkFFcOm0z sn9sGlpsNaLxmcU/Z4QzX91A18J/jZy7uRcR2s5cF1WdcAcG1gh22MRBMoB0ymTvQU+9 2fsn9g5XmvZKmGwvzrMTyaFFzNeNajzhzUfcUmlfYNK1AeXUWuvHDkO+OqBexipY0/+i hD6w== 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=YBFs9iOiLgu7VKenmzw4aXW6nYPbjotzvVPML6HKYTM=; b=YfhhTWSvf94qBkgdMk/DV4YeYuBCxb3YuBnLDkKULA4YU7iJzTiR0ELYf9TmI48bAz n2vnjddb3MioYifddWBHRAN87mEts0hl+Yh1XmEMi8i0V8vd94uy9uk5RJlSwUCqWyGp JvS85zZYsUlnPHcqh/g9DSLTghH46mrS9+XtmOw3hRWgq4JTqcvNego2mVpoxkc7QpRd YhVyzKys2LRBhL8GHkRB4hehvbveDquqD0ScvWZHtg3i4/pfzOXEkP5sKutdFZsDcflZ o/M4aDFNQIQZXKxWS0D/c9ndqHfiRUoHt3Dt3/z9aNc1GBeD/GWz/22E/0fATrQqnGEj 3uVA== X-Gm-Message-State: APjAAAU+pxfMb8gEhvmWNQ+8aBaVZr6uLrrtUgvAg4T2sGVs6AELDrw0 g8geTC5WsJTzn9+y7Qpf9NJrb1bi2o8= X-Received: by 2002:a62:8246:: with SMTP id w67mr50443183pfd.226.1564605527448; Wed, 31 Jul 2019 13:38:47 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.45 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:07 -0700 Message-Id: <20190731203813.30765-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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::544 Subject: [Qemu-devel] [PATCH v2 26/32] 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 30f93f4792..b9f0d387f4 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,