From patchwork Sat Feb 29 01:28:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 184040 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp1370861ile; Fri, 28 Feb 2020 17:28:58 -0800 (PST) X-Google-Smtp-Source: APXvYqxV+Le9tCWXSlGV8PNAo+NnPBbd+taz44WDXSYq8dDJVFdw7hffbzc1SkB+iFXPWJNELY23 X-Received: by 2002:ac8:4e4d:: with SMTP id e13mr6932670qtw.272.1582939738755; Fri, 28 Feb 2020 17:28:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582939738; cv=none; d=google.com; s=arc-20160816; b=R5L7GwS/uvJZXfpO6W0qBRfSdqBaIRgVzdIjZ8in8bz/iaeG0d3hgdKjeqi1l3jdc0 8ZWHz/uiGSbv0P1k2gsuJXrOIRIS5UlubY4k3Ng/03VWV9RVZrj3zFdMQlFAU4Bdbu// IWXAGawlsJoP8lld1sWzI0cp/i9awaXJ39S99YtmHD1PIqA2SY93Q56Mi79PldPMIbsp z2i7/8fWeiNvbmcem+r/xvT0PSs48o98BO2aP/twZu5ppVEitl2JRXXByev+pFxr8H2X MdbLkiK/VZLYLx8rHaLdCfG3Z0Xutu3QI+K5kZ3ZHdHT1i3N+yp9aDlREs5XAXWZGEGr om1Q== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=mxAcyusf4U5zXXtEjloBwTbqgFt78dWHMSy3qfj6epQ=; b=OHlxoPfrXbrmHR3+k2vvUqQKZWqXVahUFoRQ2kpeFKSYpRrDULP/F97nQW8jYCp0Sm fn4mm7cNeLpPvikQG6SIMLn3hye92CyvL1vwcHi4M8W/axJSEPeyQROmunxovlv8CWlX ULUt7KnHzg0F7n6e0vwCYZ4iFpK7EdI3Mh2tg06RByRSu0qR6F/cGSW6YFIWqtsf2E6H T/noTAzBlWpgFtF1GCouFVieRN/ThexjgqXPAo/BljJ18XpBLT8e3g7lPVm6g8zwYvks FWK0YxxqSgdbHq4+8p4L7gZznntlx1f9X4CR81n2AmEg3KTtF6oOaw0JRmiN/wP2XuVZ 8fsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kC4x9yEL; 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=pass (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 d195si2278999qkg.312.2020.02.28.17.28.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Feb 2020 17:28:58 -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=pass header.i=@linaro.org header.s=google header.b=kC4x9yEL; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7qw6-0005Tt-7K for patch@linaro.org; Fri, 28 Feb 2020 20:28:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37027) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7qvX-0004nI-KD for qemu-devel@nongnu.org; Fri, 28 Feb 2020 20:28:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7qvW-00061c-Hi for qemu-devel@nongnu.org; Fri, 28 Feb 2020 20:28:23 -0500 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]:37815) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7qvW-00060v-C9 for qemu-devel@nongnu.org; Fri, 28 Feb 2020 20:28:22 -0500 Received: by mail-pj1-x1044.google.com with SMTP id o2so67206pjp.2 for ; Fri, 28 Feb 2020 17:28:22 -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 :mime-version:content-transfer-encoding; bh=mxAcyusf4U5zXXtEjloBwTbqgFt78dWHMSy3qfj6epQ=; b=kC4x9yELE0eX35wwUWRIifYggbo9L7N656Qz267eMcpSg3z+VZP+kzXpacnrDpqAzs NbpnH72gZchXusZ7NXLHwPsAF/ks4ClutNc68Mpz6LEXRETnhFHNIBU+XLJAT8QOFqZ6 mTb/WqfrH8jaf+u9LTeeH+T5FzqYK1CtoDRBuA4DZy19ZDmJA440ood0BCrxs0jYZkVB cvO5Mo87wR3Ty4GjetisAnzlYTIfAygcmOhFEbB7pPsj/XqhmuLr+KHrDKC69xdceCYR XD+csDvBI00NXmgXbhMCx5j3rajWotb8T+UukWjj6LPx1JXkMefbvom0z/thaXyk65Nv WHUA== 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:mime-version:content-transfer-encoding; bh=mxAcyusf4U5zXXtEjloBwTbqgFt78dWHMSy3qfj6epQ=; b=YtWl6Nm5u1RbJxX5zQVdsjnGMTMxi7/kDqP6vzCLzkuUOMs5fWV+VOApXtZCWXNzOZ OZAt/tA8t3V5APFTXei3o6C7SZuVEGoM+GDVqMBa8kOKJX0cEwOrWO0La2krUpHWHuKl xmGkXL/mwBpOs1LBBaWMkjAPbAQLacS7oCNr+gBXO6VTiISLv9i8DkDLVCwQ34Tzlfjc o+JzTFTPstH4guVLmlQDtInGF89udtpsuk0YMPB3/skcYoERT26hN38bGoQ35xwrWJc+ K22W9Fm698GAjGTzHKPbvfarJ7JiTafyxjlREj7aV3bLz73a5A5cFQigVGkLmd6oCPz/ 9vhA== X-Gm-Message-State: APjAAAVmy/sEgAnG/2MbMGCNghjzLW6KzTu/ZzQEvBpTHrV2/YzZkUEh RgOc2yl5cAhKlbgnoAYnuD/i4gB5PiY= X-Received: by 2002:a17:902:8308:: with SMTP id bd8mr6710737plb.210.1582939701020; Fri, 28 Feb 2020 17:28:21 -0800 (PST) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id r3sm4606313pfq.126.2020.02.28.17.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 17:28:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 05/12] target/arm: Improve masking in arm_hcr_el2_eff Date: Fri, 28 Feb 2020 17:28:04 -0800 Message-Id: <20200229012811.24129-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200229012811.24129-1-richard.henderson@linaro.org> References: <20200229012811.24129-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1044 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Update the {TGE,E2H} == '11' masking to ARMv8.6. If EL2 is configured for aarch32, disable all of the bits that are RES0 in aarch32 mode. Signed-off-by: Richard Henderson --- target/arm/helper.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index e68e16b85b..ef3f02d194 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5196,14 +5196,37 @@ uint64_t arm_hcr_el2_eff(CPUARMState *env) * Since the v8.4 language applies to the entire register, and * appears to be backward compatible, use that. */ - ret = 0; - } else if (ret & HCR_TGE) { - /* These bits are up-to-date as of ARMv8.4. */ + return 0; + } + + /* + * For a cpu that supports both aarch64 and aarch32, we can set bits + * in HCR_EL2 (e.g. via EL3) that are RES0 when we enter EL2 as aa32. + * Ignore all of the bits in HCR+HCR2 that are not valid for aarch32. + */ + if (!arm_el_is_aa64(env, 2)) { + uint64_t aa32_valid; + + /* + * These bits are up-to-date as of ARMv8.6. + * For HCR, it's easiest to list just the 2 bits that are invalid. + * For HCR2, list those that are valid. + */ + aa32_valid = MAKE_64BIT_MASK(0, 32) & ~(HCR_RW | HCR_TDZ); + aa32_valid |= (HCR_CD | HCR_ID | HCR_TERR | HCR_TEA | HCR_MIOCNCE | + HCR_TID4 | HCR_TICAB | HCR_TOCU | HCR_TTLBIS); + ret &= aa32_valid; + } + + if (ret & HCR_TGE) { + /* These bits are up-to-date as of ARMv8.6. */ if (ret & HCR_E2H) { ret &= ~(HCR_VM | HCR_FMO | HCR_IMO | HCR_AMO | HCR_BSU_MASK | HCR_DC | HCR_TWI | HCR_TWE | HCR_TID0 | HCR_TID2 | HCR_TPCP | HCR_TPU | - HCR_TDZ | HCR_CD | HCR_ID | HCR_MIOCNCE); + HCR_TDZ | HCR_CD | HCR_ID | HCR_MIOCNCE | + HCR_TID4 | HCR_TICAB | HCR_TOCU | HCR_ENSCXT | + HCR_TTLBIS | HCR_TTLBOS | HCR_TID5); } else { ret |= HCR_FMO | HCR_IMO | HCR_AMO; }