Received: by 2002:a19:cb43:0:0:0:0:0 with SMTP id b64csp1317814lfg; Fri, 28 Feb 2020 17:29:14 -0800 (PST) X-Google-Smtp-Source: APXvYqzT+I5Ip+EE5GqPJy8fLu4FdIIVs0BBY8z9VIEGZC1GotCsSSBwF4H6o0Z0i5gZUpBDViaY X-Received: by 2002:ac8:60cf:: with SMTP id i15mr6727452qtm.6.1582939754653; Fri, 28 Feb 2020 17:29:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582939754; cv=none; d=google.com; s=arc-20160816; b=JNkDxj+9bTVBi/0o6QPBy7K/3uyLsclrI2VV7FxAiV7Y1Adh3Exrjn31BV3/95qptC qszG3rYoP643hdKB7nlhlt5c7RRqW5TmXmRvFB30dJVxnEVgKHo0pUi9AUpBa0V5Ct0S f9NyhoFmEZ4S2xQTB6ZEL1rEJwNun5/bKzjTmFnU5ScyLZkBXHC7y+Js3pMfXsQHrEyt wGyi5LwEcKTau2zbQBshqNFUBLqBsrQRnfNzLCoPew6Hca7ABBOGduHq3euzRlnbl1bK zQGfIZ3oc84SePSfKTanCI0NZejhYZlEmTPagYLITW9N7Y4tWmuuQGX4fbQUpSQdNmaD A8OA== 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=0ipK9kFE8pxqsDucnEBvpSKK+J0THs+UdUp0h/ExkVq3d4vXMIfnIpe6rlOEBA0p1y u+Gp6bGxierE/xBfzoZghwhMgviVJn8JT5cLl4WLl06PIVo6JNwK+3t5mVCanGj8I+yc eb3BNvEafeSpirpSxlLcBBNA0U8uKFE7qN7kwvSJP5MAMxUfHh2dhhvlkCu78/W9jmNA 7O3MZhGifG2KnX3mK3GvY+zbWs58SNCS6PFnV4CUFjWYo4lqGetU/YMmTSxzWa/6empr JXkWpdOoPmvD2Ays2QnvCe34zJKc098h/a7qczCQT6do/1zDgtWw//BYIzeIe3jXu6aH 5aYA== 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+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=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 x1si2077583qvu.95.2020.02.28.17.29.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 28 Feb 2020 17:29:14 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=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+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=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 1j7qwM-0005Tt-0I for alex.bennee@linaro.org; Fri, 28 Feb 2020 20:29:14 -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 Content-Transfer-Encoding: 8bit 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+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-devel" X-TUID: c/P+DoZAAF4w 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(-) 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; } -- 2.20.1