From patchwork Sat Aug 3 18:47:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170503 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp2348445ile; Sat, 3 Aug 2019 12:00:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMET9ONtHAXvI1JN+qLextrTk7GvNpq4h3ok+VQMrX427OcbGBxIiy7INgq3dlV8W3qOdm X-Received: by 2002:ad4:4985:: with SMTP id t5mr45002467qvx.193.1564858840342; Sat, 03 Aug 2019 12:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564858840; cv=none; d=google.com; s=arc-20160816; b=xXemTJaLqRfRw8owaiP7boCrVixoJxoeVh3NnTQ3zz2b8FHpB/lA95CT7jjuGnZsoR JJKI1CztAlJhkQEZCzL1U2CaLMJXl8L+DotJtZRkC3U5Moe/x4jLYUd1c8KIahpRM+5k vnUYowXCqYadIuyXezl9ZLzbEeLTihgWb6WUT9qs2JM+cGEBhJKcQHPtceexV0IUE5nI AH+EF6XYxVf6iAcVJsREhn+Z7sHuUblvNeOomrpGM/1gR0Djw+ccnqLc62FEz4v1gsGT nsZ+7QUKSNfkWNO+E5jFN2cyNU+ctkMrZf7FakYvuHrze8pdgCFD4Wt/iGcj5jwejJMv okNA== 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=MpItA1dQTcuKZiJtCdjWs8WMTH2c/gBkJl0/pbYk+Ag=; b=LkDv1zKZWKivr7K+E+wzQu3vM5g9PfQXhGDpfRcgIZXwgy7ZIT54gJZsJfQfq9UhUs AUal74hPgJtH5jmVUVZUyqaJWpBcLtbL+M/OD8Go8OQ+17JKVs01mbOq16CEh/m5QS/y VberHfVtjSsFPQDY9anzdx4zvBIom04zVAes+oHCgJW/GYgeSh/lmiRQaxneUM8ejLO0 GW/xVUnOemrywKui20G6XWPMbkY2zdyqm81zlp+KQoYjZ50Os1BUDXhMjd+902AP/7Xr TtTmIlvfy9AZ7uL98jaHHE+0adETQPovcFmc7f2glGtRshcPtrC4K68jfYkHwrfrm0Dt pjMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dyd6gD5w; 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 d26si49560488qvd.200.2019.08.03.12.00.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 03 Aug 2019 12:00:40 -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=dyd6gD5w; 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]:41586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htzGh-00087N-QB for patch@linaro.org; Sat, 03 Aug 2019 15:00:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32898) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htz53-0006p4-5e for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htz52-0007Nx-2h for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:37 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:37970) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htz51-0007Nc-U0 for qemu-devel@nongnu.org; Sat, 03 Aug 2019 14:48:36 -0400 Received: by mail-pl1-x644.google.com with SMTP id az7so34857836plb.5 for ; Sat, 03 Aug 2019 11:48:35 -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=MpItA1dQTcuKZiJtCdjWs8WMTH2c/gBkJl0/pbYk+Ag=; b=dyd6gD5w/4Z2lzudxNV49llWNQPEJUnKWUVoGSgnqRWeB254Fu61z1VLQlr3V41LAf PUcSyUdJt4beh8L3lxmOq/VU6wJutjNQ9Bm2BEiE+OKjKmv/ef84XRZmNDgk4IEmUbEh X1jSvQReMowgAPMPo40P7JTnmTGiW7nVwAU1FRYBAfV8jHXjWfRNZI6rNiRqGBzlm825 lfBfdP2/EIZlhzW8egdiiEFA8GDjYJIUQwt7pdjWMTU//wYGNPmxPqGhfCtUhtpwWScx +ifF/NZ80NPq3l2CwdHxEuuWSsCV5JhdPP/aBf25qxm66O/OUmdNyRN6y/7A5QW277e2 ozbQ== 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=MpItA1dQTcuKZiJtCdjWs8WMTH2c/gBkJl0/pbYk+Ag=; b=RZHOBlOZQtUq877ifM8BfVWfZg185HsvaQVhzKW96kvGHkoXVZ9fFW5DoO4zChaClk wBrJA5jpvKTuQ1xPA3xJSj+DcrC+66rRQM3JYHdFtsP6o5EARWkJ/6+X5JPYNh8awiHt flBl/taPBb8FIQP8SoxImxGPa8jA8ywy8y+sOX6HHWIx0hCWnEJWBuc3FVT3X44IJUqm VHhBPlocyujMv3+pDyeyxVfJ9axcVBUMBYMq0dZjEUSzVXJxCDlK6RNarIjf40z9ehM3 RhKJPBU6WNuAb0R98w6ctvE6ofHm5aEU8i0TdDuZFRQNsInVwIv3pVJhHkJH/Bwx5yix dy8g== X-Gm-Message-State: APjAAAUM1dpHo3oE7eew92EP0zey11OChAeEzonN9ERw9Nw/9GKKH3/a 7yKrUkYmymGRLhkXX4Cu/3thKRX/fdY= X-Received: by 2002:a17:902:112c:: with SMTP id d41mr126176670pla.33.1564858114794; Sat, 03 Aug 2019 11:48:34 -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.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 03 Aug 2019 11:48:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 3 Aug 2019 11:47:53 -0700 Message-Id: <20190803184800.8221-28-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::644 Subject: [Qemu-devel] [PATCH v3 27/34] target/arm: Install asids 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" When clearing HCR_E2H, this involves re-installing the EL1&0 asid. Signed-off-by: Richard Henderson --- target/arm/helper.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index b8c45eb484..9d74162bbd 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3518,10 +3518,29 @@ static void vmsa_ttbr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, } } +static void update_el2_asid(CPUARMState *env) +{ + CPUState *cs = env_cpu(env); + uint64_t ttbr0, ttbr1, ttcr; + int asid, idxmask; + + ttbr0 = env->cp15.ttbr0_el[2]; + ttbr1 = env->cp15.ttbr1_el[2]; + ttcr = env->cp15.tcr_el[2].raw_tcr; + idxmask = ARMMMUIdxBit_EL20_2 | ARMMMUIdxBit_EL20_0; + asid = extract64(ttcr & TTBCR_A1 ? ttbr1 : ttbr0, 48, 16); + + tlb_set_asid_for_mmuidx(cs, asid, idxmask, 0); +} + static void vmsa_tcr_ttbr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { raw_write(env, ri, value); + if (arm_hcr_el2_eff(env) & HCR_E2H) { + /* We are running with EL2&0 regime and the ASID is active. */ + update_el2_asid(env); + } } static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -4670,6 +4689,7 @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) ARMCPU *cpu = env_archcpu(env); /* Begin with bits defined in base ARMv8.0. */ uint64_t valid_mask = MAKE_64BIT_MASK(0, 34); + uint64_t old_value; if (arm_feature(env, ARM_FEATURE_EL3)) { valid_mask &= ~HCR_HCD; @@ -4696,15 +4716,25 @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) /* Clear RES0 bits. */ value &= valid_mask; - /* These bits change the MMU setup: + old_value = env->cp15.hcr_el2; + env->cp15.hcr_el2 = value; + + /* + * These bits change the MMU setup: * HCR_VM enables stage 2 translation * HCR_PTW forbids certain page-table setups - * HCR_DC Disables stage1 and enables stage2 translation + * HCR_DC disables stage1 and enables stage2 translation + * HCR_E2H enables E2&0 translation regime. */ - if ((env->cp15.hcr_el2 ^ value) & (HCR_VM | HCR_PTW | HCR_DC)) { + if ((old_value ^ value) & (HCR_VM | HCR_PTW | HCR_DC | HCR_E2H)) { tlb_flush(CPU(cpu)); + /* Also install the correct ASID for the regime. */ + if (value & HCR_E2H) { + update_el2_asid(env); + } else { + update_lpae_el1_asid(env, false); + } } - env->cp15.hcr_el2 = value; /* * Updates to VI and VF require us to update the status of