From patchwork Wed Feb 23 22:31:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 545231 Delivered-To: patch@linaro.org Received: by 2002:ac0:e142:0:0:0:0:0 with SMTP id r2csp1093921imn; Wed, 23 Feb 2022 14:50:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyeUibRQSrOZBqSYk3uhBl0R1QLG7XfD5iJuKbnluG2P4kMhiUYhhYz/lhEdhKqb6Yaifdj X-Received: by 2002:a37:a487:0:b0:60d:d3a1:a660 with SMTP id n129-20020a37a487000000b0060dd3a1a660mr7899qke.178.1645656628482; Wed, 23 Feb 2022 14:50:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645656628; cv=none; d=google.com; s=arc-20160816; b=b4+KB4N75P1S6X4ClQxvmVUhKwoJPNOcMP1MKHbymiUL8QcV1OsPKQUDmHfvUSX4jO BNru+Bn6oxjCGeIW/ge4Xc1rhwhV2GSH7W3FAZO+5VC9N4gFuJlDteG4mF5rX+5hP3SQ eIeNimMSGbwNSNg6kPAwQyjbhsm8WaC0L9fSHdceK+c5peREELPSKIMJP74N+6hdFHOJ +X6RLq4aqicalde5wSgHnBirG40BGgDZ2nMlaJDwW/8ZMfYn+Ub6YtHlXIcdwymY1I3q nExZJevUTIfZouEZhUENQ4EkVXdQl6to60FFPE9IfFkvjUV3HzGXApMASpuMB6YMLkBq UNvw== 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=WFTKQrLiJ3VwSgvkt/IhaEgBVQ3+b8tLX7nUBsUG9rM=; b=Nr1szpnF2hR75aWGFMHqLlkSiuZWPzeqQ2kqgOzA3i3YcVm1QfH5UUfdE8H4wNJZjv XvmwWkg5px+lKR/ULzRjKQWGC0QSwe/rkIoJYlSujfbrTXJotKl5VWiMHfxaUlKLfzU+ vmh5n8PudKWdwwqg2IIYA/Oiz2y7b/9CVIsl2HYqmR1/lcTyIlj5iWr7kfq65zREIImG IKICq1STfKfDAiLmZpfI0RDQBcxETf3iOw6lttVh6yFD4AqD4temlX3reAzJFJCCB4eQ 7mMCbE1bnHDEVSdxSeneOSIj4mMmefYMwUCmX6b1ikffTWaVLadWCGjqihe48jdPeF3P 8ziQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nWPSZzl1; 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 s12si557562qtw.650.2022.02.23.14.50.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Feb 2022 14:50:28 -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=fail header.i=@linaro.org header.s=google header.b=nWPSZzl1; 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]:50298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nN0Sq-0005iF-2l for patch@linaro.org; Wed, 23 Feb 2022 17:50:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nN0B7-0007BX-MI for qemu-devel@nongnu.org; Wed, 23 Feb 2022 17:32:11 -0500 Received: from [2607:f8b0:4864:20::431] (port=35512 helo=mail-pf1-x431.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nN0B3-0001HK-6D for qemu-devel@nongnu.org; Wed, 23 Feb 2022 17:32:08 -0500 Received: by mail-pf1-x431.google.com with SMTP id l19so217576pfu.2 for ; Wed, 23 Feb 2022 14:32:03 -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=WFTKQrLiJ3VwSgvkt/IhaEgBVQ3+b8tLX7nUBsUG9rM=; b=nWPSZzl1BCWj/NZFxKS0xZWxznh190caDQn90GNbYNatDKrYpUUZ3tmS4mTitmHWkE AG+o+jKuOmr+O5p96aQWAW/3vlYCRsjsKjWmZ2kmvc0pRcoYv7pCjgHd1KhAdetf3Q7C oYeiOyArEHmyEbapSM+Jtla6f6/ghxgR2NE9rmRe5OUCXR2dQGv2jPpV+XT0Qrx+Z6ct n2qXuKa/nBKsuxKLtNdh9jfKGIjNmdSnVoDO4GFck3++1YGDmXyS2bTTlkhRy2NpH3RO dCzBZ/FEzAtY7R2DqizVc6YUjHvd5ns/BsTwCc9gZIFZiFi7caXsjbG42OfotEjcrU48 pl7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WFTKQrLiJ3VwSgvkt/IhaEgBVQ3+b8tLX7nUBsUG9rM=; b=S0NQauqCwUEHkI7EHByoy0xi4+mUoEmmUKUYeHu30I7qEav+aB2zK9C3TZb9kAYk76 7nxQrFJ/g69Y8aCDVqSPNGu4MAwW+B9gCvyuUpshxTYWmqcVKQub/nltKq8YrHPlXdMa B/DwjwabGBjZ9xdY2vJkoJZK8FIEkToxzWCo/tA6u+UgXM5s49l7AJHbene87x9161nP B1LPQFDxvO3KV/+qKkEdwsEP9HVPkD/GabO3oEZNjL1/HWeDyBY/nJM67tzkHM0DVeNi qP0usEeLG2PIypmsj5OSwqlPChW4Oy6d8hsk8kOwDdHZTtlw0Gq4otRFTBCJBH1uweYR RcXA== X-Gm-Message-State: AOAM5319XTEPDMoXytEyDFVqiNDw4PLlVuaRo8hiu8i6yz52hGQ4VGqd RHJlbMHSC2zOPyudaDK9JA1da6ruug/vYA== X-Received: by 2002:a63:af02:0:b0:375:57f0:8af1 with SMTP id w2-20020a63af02000000b0037557f08af1mr1400927pge.188.1645655523076; Wed, 23 Feb 2022 14:32:03 -0800 (PST) Received: from localhost.localdomain (cpe-50-113-46-110.hawaii.res.rr.com. [50.113.46.110]) by smtp.gmail.com with ESMTPSA id f8sm533815pfv.100.2022.02.23.14.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 14:32:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 14/17] target/arm: Validate tlbi TG matches translation granule in use Date: Wed, 23 Feb 2022 12:31:34 -1000 Message-Id: <20220223223137.114264-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220223223137.114264-1-richard.henderson@linaro.org> References: <20220223223137.114264-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::431 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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" For FEAT_LPA2, we will need other ARMVAParameters, which themselves depend on the translation granule in use. We might as well validate that the given TG matches; the architecture "does not require that the instruction invalidates any entries" if this is not true. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index e455397fb5..3a7f5cf6f0 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4520,12 +4520,16 @@ static TLBIRange tlbi_aa64_get_range(CPUARMState *env, ARMMMUIdx mmuidx, uint64_t value) { unsigned int page_size_granule, page_shift, num, scale, exponent; + /* Extract one bit to represent the va selector in use. */ + uint64_t select = sextract64(value, 36, 1); + ARMVAParameters param = aa64_va_parameters(env, select, mmuidx, true); TLBIRange ret = { }; page_size_granule = extract64(value, 46, 2); - if (page_size_granule == 0) { - qemu_log_mask(LOG_GUEST_ERROR, "Invalid page size granule %d\n", + /* The granule encoded in value must match the granule in use. */ + if (page_size_granule != (param.using64k ? 3 : param.using16k ? 2 : 1)) { + qemu_log_mask(LOG_GUEST_ERROR, "Invalid tlbi page size granule %d\n", page_size_granule); return ret; } @@ -4537,7 +4541,7 @@ static TLBIRange tlbi_aa64_get_range(CPUARMState *env, ARMMMUIdx mmuidx, ret.length = (num + 1) << (exponent + page_shift); - if (regime_has_2_ranges(mmuidx)) { + if (param.select) { ret.base = sextract64(value, 0, 37); } else { ret.base = extract64(value, 0, 37);