From patchwork Fri Jul 19 21:03:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 169276 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4325071ilk; Fri, 19 Jul 2019 14:05:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqVU0Cfe9Ef2zH5nMxowXOvzAXlaNGUwoxnuVPRfP54QPP81miuoeIGee1PjkNzNNU5tWq X-Received: by 2002:a50:f98a:: with SMTP id q10mr48417886edn.267.1563570349673; Fri, 19 Jul 2019 14:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563570349; cv=none; d=google.com; s=arc-20160816; b=0XCe+MuoW/Twb7s4b8ECg4gOE6l5MZ59ZvGDcupf7I+3pu0267qyjXvJ1QRtJb0YpE lakooI5jnGqHUYZu539FzK7vnTck7A5MKZrdUB7lfXdHEQlOsYgks9snzDuaMyD7kZ/Y RTgqN6SRsKHQUp5dXWcJxwPOGtPEj1adiAv+epuRMRxumL2ExqgWJialx6DtS9v7Z2Lh 04i0zqFVrhgDnLQgeU64gUtr/gHfOC+85L93oqmJAJyMn+BBy/n/oEbd7GAe4QZwdklu U64PTcN9+IqLOycWoldB8pzZh1nn9kucEY67vfR2xkygXblR1ZKGhyc2Yrfc3dJCge0e NbWw== 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=GHJ3UWi076gcoHxg1DQBmNZO36QuD3aqqu+CJJcjV+8=; b=zN62FWRRb0KmWVZAM12nt4hm3cRs/BHYoESIYaGzylfTQPRBuVCIdAqMkgGcxP6L/j DduKN42gW8xw8QW3pB9P/8dQFDbGidJrLpdiWypDfFfbk/ysqesZSfBeAD8tJ9cXF9aj 11ehs9r2S77t4FnghOlwh7xarO3hyi1+pxkPnPICD0DUz7fcMK2L2o7j70FJzxCjesCw tmVBl1tVeX/q4L/1UHu3rn01S5uEpyzoOxYUOkI769F47LThKOSv8sWERLrpwUQgQ5oD alu9GmqmfQPq6PcSz/JIIwkYLgq+whDaa3JbQpe+qRGRtgsJLwIfTlMcCTs6npu2kayg YsSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UI0M0X5d; 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 a1si815943eju.202.2019.07.19.14.05.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2019 14:05: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=UI0M0X5d; 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]:48194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoa4a-0002iR-88 for patch@linaro.org; Fri, 19 Jul 2019 17:05:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55195) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoa3a-00088Y-9T for qemu-devel@nongnu.org; Fri, 19 Jul 2019 17:04:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hoa3X-0005Yb-56 for qemu-devel@nongnu.org; Fri, 19 Jul 2019 17:04:44 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:34092) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hoa3W-0005CR-I0 for qemu-devel@nongnu.org; Fri, 19 Jul 2019 17:04:42 -0400 Received: by mail-pg1-x544.google.com with SMTP id n9so8750472pgc.1 for ; Fri, 19 Jul 2019 14:03:52 -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=GHJ3UWi076gcoHxg1DQBmNZO36QuD3aqqu+CJJcjV+8=; b=UI0M0X5duZMFsvuhBKChZV8Q3IonwiWAvOKRQ0Zetrx3KdqfFTWFMvrb/GUXs6gTSP EJyKZrpz2Txv9Prlf3TLzTKim9DwpUXm72h8g5B39M6yWVqCoL0cpJA/1h5sQen/Q24I YHbi66ttPl5iR+r89O/R/IXLYjZFhbI3oErz75Jn5QaQRPcjzXIvr162ErZL8fJI04tG Qcjey2zEWw+G+nR+YVLT682IIf6xTNFRt2pJ3pYh5jGdrC8A9M0af4UzelwlinfSKtAt 6292CfGkz3RpCHAuarBJmHBBcfpeFAlKzZX4bcJSH0rodErlzpmCv6+qjUejenzTVw6C A+vQ== 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=GHJ3UWi076gcoHxg1DQBmNZO36QuD3aqqu+CJJcjV+8=; b=nfqTe1xcJbD0NiXkQdZBj24ZyIMZyTBSqBasvhzwvcgiFuhcnVUlynAbN8uuW5+zRU uUO8XgXP9cj5KC8PXfcD7LNPqqUNLYUV6tKgDJ5sCnTrGOxm67u2C83aH/dYHKuh5+7t yi0anfOBzLR+VnbDTJrTiT4Taphj39vrSoe2d4G86HXk1nQgvgep+6nJ7vKPGA/VhAhy Gw7/DbnPmSiCKOsnJ8c6kvyZhgw1LxkRY9MFMTQswwyE+Wu25obU8gOneA9d7RYdc20Y 9JjRaJi6uKYpG/C0cI9R/da9ANXn6chwtL01aNKBuDJFbjY5uTA0lVGKi/p3pDXEsKyX PtPg== X-Gm-Message-State: APjAAAW4UOVNws6d40IHGo5dXVDdvOfNwz4bfj1La2vUrt4LLsFYb9b+ wEeUMvqYnAkU7kn/A3iLY/lSttr09JE= X-Received: by 2002:a63:89c7:: with SMTP id v190mr54263084pgd.299.1563570231150; Fri, 19 Jul 2019 14:03:51 -0700 (PDT) Received: from localhost.localdomain (97-126-117-207.tukw.qwest.net. [97.126.117.207]) by smtp.gmail.com with ESMTPSA id i6sm32724751pgi.40.2019.07.19.14.03.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 19 Jul 2019 14:03:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 19 Jul 2019 14:03:21 -0700 Message-Id: <20190719210326.15466-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190719210326.15466-1-richard.henderson@linaro.org> References: <20190719210326.15466-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 for-4.2 19/24] 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, beata.michalska@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When clearing HCR_E2H, this involves re-installing the E1&0 asid. Signed-off-by: Richard Henderson --- target/arm/helper.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index db13a8f9c0..22eb056b27 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3516,12 +3516,28 @@ 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_E2 | ARMMMUIdxBit_E0; + 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) { - /* The ASID field is active. */ + /* We are running with EL2&0 regime and the ASID is active. */ + update_el2_asid(env); } } @@ -4652,6 +4668,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; @@ -4678,15 +4695,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