From patchwork Thu Feb 10 04:04:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 541385 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp1929659imo; Wed, 9 Feb 2022 20:26:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzT/XI5J3XXDVicJvlslmvzOUEG02CcBp+TIGnvjonTl5XdKAJwiGRtTCmDQnx1LzrjZqih X-Received: by 2002:a05:6902:114d:: with SMTP id p13mr6065492ybu.335.1644467160415; Wed, 09 Feb 2022 20:26:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644467160; cv=none; d=google.com; s=arc-20160816; b=ojVkrvFC1cHKvuomsGm4LaDpYsn2qP6k27WoIC/B/prS0ZM0YJRCI0xis9HC8gewmr Fi9NPcfEqcI8d1qGnetzRaiaDm7eopsgcc/1O6b0o4leBp3VL5axltJVsTkiO5rjK/HM iWJJxLkS3HIaL3dKDgKhKMsQixsfDzLbZiqC7Ib2anPLfXMokjhThAkXX2QJ44yujz39 KraOtWo5Ydea8mEOgr0RGIN0Gtha3eNmG6mOos9u3Hl89ey0I5fynY28eRiYeZm+y22x 6vam1fqOe25UomWJHrVTPdh+TUrseenybr+kiLROXRbnXQYWYu4Pz1lgzBfT68sFUvYR Jcow== 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=/PyGX3z0esgQKjWtAq0OXlyQ3FBYa3KsBIg46iOmGfg=; b=Dpv7UtdVtmoUJViy/cQ6QHNlh1f3hwGr8dUnGoxhTvfsqaGvtCLPl6zWhypBIvOrSG P0juthdfjo6GXESfrconTOZht406eFR0GR77eG+vURAoaVtFEzQRQe8W925/Iv/ptess FijO7ma8IS9MzkzLPr7TaZwoRKDEWotax6s90ANY795bNu2+qBfHxhkNv0S+W7dymtFA Nr2Do4dnYcZqLNjTmELW6SMa+CPhbKbIyIXZKagQxfYM9m34yj6ntivSbm8YMrZJJzwj QavbOfR4tTdUar0DDvQaGdI/lxH21g6KjPQRxpSGjsLGVPnAmKj8PNOJCiW1weFA5H8t bGzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kfqC3NK4; 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 x10si18922676ybt.512.2022.02.09.20.26.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Feb 2022 20:26:00 -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=kfqC3NK4; 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]:55512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI11r-0005Vf-Us for patch@linaro.org; Wed, 09 Feb 2022 23:25:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nI0jd-0004OK-0N for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:07:09 -0500 Received: from [2607:f8b0:4864:20::1036] (port=43962 helo=mail-pj1-x1036.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nI0jU-0004ME-PT for qemu-devel@nongnu.org; Wed, 09 Feb 2022 23:07:04 -0500 Received: by mail-pj1-x1036.google.com with SMTP id t14-20020a17090a3e4e00b001b8f6032d96so4321719pjm.2 for ; Wed, 09 Feb 2022 20:05:12 -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=/PyGX3z0esgQKjWtAq0OXlyQ3FBYa3KsBIg46iOmGfg=; b=kfqC3NK4ri29kF9NBPjhhpz6IjztxGGBsIcc2ETKQDQVMot/koXli4OmLUFxRRQdf6 4fPCqGpCdyHxBjxgkX5fpmzdI+4n6xHK1Dbfpz2UMBEwq0MIjUInvqnZVzXhAzkcRy0w avttEZx4P4phkTLj6EtCAL4Sb9IFwISptCpcweYvX70tpCJi2Tg2nSnqI16q7Ig+2ILw K7OvAh23uar0xAKByTOcWDbqR1hlRqcPWMzrIliaZleexRI1KDAzUk101vd1q2kyRJTD RaNws58VWuIkaXJVSm0w4cmLlvWAKl1TNmGYgQX8BVp9LqlAyWlADlie3Rni/P5KvDdb 5FAw== 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=/PyGX3z0esgQKjWtAq0OXlyQ3FBYa3KsBIg46iOmGfg=; b=pQJxlPHYDwamhiUfBAGz36ull/W+ofW+wdaIscFaqDRMLR4MjKlnVPDWvj8TtkWPBV lyPASX7fvrM3DYHCa4XC+LQVf/DN+5caTucE3jn/PReHRackDqzQz3pASq1LhGv1nrpI y48+oOVsRCel2GMVuhGo3l+oyoVxVtfTyaRb8V2BaNKmyETvyLPUtIkSc9B5yTul143E JjHtB0mvsNC/Pxg33rx/dhpAoGxsRZbQAtz9xsgvcX0vVO3rgI3YRPH9CP3AcSGnZR+A QR+clFi340pe8Tbwf2EZGpOgaKmfUGu06X3QDyhW3dm84eLm2TtswCCLViNpvPywTL0s WY1g== X-Gm-Message-State: AOAM5304i1s0zd5MdZwYjzazP98FCxgcoa2CApIkgZjY+YpDQWoTQfqL KiqwQ9mA+AUgJ6J4089CnH21OLuJOf1YfVQP X-Received: by 2002:a17:90a:19c2:: with SMTP id 2mr744294pjj.132.1644465911851; Wed, 09 Feb 2022 20:05:11 -0800 (PST) Received: from localhost.localdomain ([124.189.222.164]) by smtp.gmail.com with ESMTPSA id y4sm9749814pgp.5.2022.02.09.20.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 20:05:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 14/15] target/arm: Validate tlbi TG matches translation granule in use Date: Thu, 10 Feb 2022 15:04:22 +1100 Message-Id: <20220210040423.95120-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210040423.95120-1-richard.henderson@linaro.org> References: <20220210040423.95120-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1036 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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.001, 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. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- 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 e2551e693b..771de959dd 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4518,12 +4518,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; } @@ -4535,7 +4539,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);