From patchwork Tue Mar 1 21:59:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 547261 Delivered-To: patch@linaro.org Received: by 2002:ac0:9f50:0:0:0:0:0 with SMTP id l16csp4064180imf; Tue, 1 Mar 2022 14:03:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8wtCVA/29TldvNy9frhWw02o7+nAvRcpz3yHOjj/QY6n/DsTLezHLbO/bdqzTUYA5DRPF X-Received: by 2002:a25:30d6:0:b0:624:cd97:b907 with SMTP id w205-20020a2530d6000000b00624cd97b907mr25088834ybw.542.1646172212895; Tue, 01 Mar 2022 14:03:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646172212; cv=none; d=google.com; s=arc-20160816; b=RkuythiL9pLgpDPw/UU1Q91TjjtbnMcteZv0JsZugAqL0lj1vroRygIg5v2nNlYfp8 xVkFfMQSyEqsrXe1oWs8rM0OsSZ4M6wOxzS9i1x4Kv+wzgTk+VMzJ9SEybor02znn2cx AJTdGyz6LZ6KdSQxK086wDKsXAvn3z4v0+I/IBC9olRC0Gx7KZhuARBlphNd6sqdOR4J S83Va6PKf9GGp0TCknanrOnZEgKhUBQhFXDSPQ+xv6l66t/N1u0bTm3n6MyLDDuuIZyr +ThdbcKjhoyEWj6lqGMPMPUeZZH9MZGqiV2N8N+zT6JdAw+zpf2GIAc0o5iZ6LCilguI 6k9w== 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=TAU62jUEHWqZmP/omH+DP65D27WXovgj7reF6QpCfzg=; b=CaqCsZV1tWl5juilLTVEy37C8WXdbTimmhDds/witNP/3N7qBIMburrUlhYx9dz1To 9cm2j53CwEXLgTAD7Pkxo1Xy0JzncEDFK4m+VzpAOqoyBtdN2PhiDyNgMAcZeRZ1dekR UAgSJo+UROVNE6O8QowROmygURwm1vJPnKS/FY0s5sJyVJ6ZA5+qMzGI0qNfr6L5UXeS eWaDUof2/PjcRqvTrq8IBowrYqtOl2C2BLrzK7n0YiflY1PcxLsvARb5Nc3MAZ5Pxxmr z4Uu53uw+vgDvZVPeZtuKFeauk5hJ07wolxZlTGstRM61jtvxWeSblcOSwDZIhOW9ZOx xgqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="lx/zx7CQ"; 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 o1-20020a81ef01000000b002d6b7fe8c7fsi12459289ywm.434.2022.03.01.14.03.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 Mar 2022 14:03:32 -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="lx/zx7CQ"; 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]:33686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPAai-00049F-C5 for patch@linaro.org; Tue, 01 Mar 2022 17:03:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPAXY-0001HF-KU for qemu-devel@nongnu.org; Tue, 01 Mar 2022 17:00:16 -0500 Received: from [2607:f8b0:4864:20::435] (port=36659 helo=mail-pf1-x435.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nPAXV-0004wr-3c for qemu-devel@nongnu.org; Tue, 01 Mar 2022 17:00:16 -0500 Received: by mail-pf1-x435.google.com with SMTP id z16so77534pfh.3 for ; Tue, 01 Mar 2022 14:00: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=TAU62jUEHWqZmP/omH+DP65D27WXovgj7reF6QpCfzg=; b=lx/zx7CQmy7S+laRnK1Ai9SXcDDOkBCpkt2dczgZncBdqZ8lXGbfpdGWs31V1X8yhG HclFvpk0Ug62EJjCY0ghcLZjHEhn6BXaNy8/kvFnsueZANzfl3nSXkPvA68mwGWrerQz ktk6iw5s7bn83YEOC0y8LK6wljjLWdFcr2X4SgkSnmBjH3zdVJLqdL0Eda8hnJ4fXkia gaEbT/+jERDSi0nEKZSaCLb2ZADCDgNYNnNfRsBzufQiDRduaHrfJkEdeVt8ajfUKmOg dWm3Tbyfp4xgU6Q89PT+L92eD57PnpWdpk/hXKuRpOeM/P7j6ATwF7TIktxUQ+gzKZDm Ef3g== 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=TAU62jUEHWqZmP/omH+DP65D27WXovgj7reF6QpCfzg=; b=C0vgEFtyMJhEzU/vzrCr2nCBhoGFKwym64+rixRwjR5vc6rtmO9yUvItKWHx120fwn gm2wxbrF5pirFshCo1KJxXc7dd/qglsYifg0MRGNkS5UNwzaVhSRD+95tMCe/iti8KtU St4EGOGYa09abh7bXUQRMeIiVxoXXLNyapX84immnJ1liQwtZ+Dx4RLs/ZMzdaBCu3DW 7lNgAb8aX00N+kLSfe1fxAuTUnIdEH2+aUWKXOFgu1v9lpxSdMjUaRaSGkXKZJ7EVY7j zyfctsxGXjVSkBTURqnm1bRf/Vsr+cQayO1d4FkiWywZbk30CHdec+kOig9WTQU0eIJD G1RQ== X-Gm-Message-State: AOAM5338CH1jH3FXYItt/Mq9zW9Uzz32BnBC3d0iI667+hlzmIPmejyT 46KKhiBmjzZmrXiHKwMjxPn+AC79npYRMA== X-Received: by 2002:a65:6d0a:0:b0:373:9242:3a13 with SMTP id bf10-20020a656d0a000000b0037392423a13mr23744681pgb.452.1646172011103; Tue, 01 Mar 2022 14:00:11 -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 m4-20020a17090a7f8400b001bef3fc3938sm284392pjl.49.2022.03.01.14.00.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Mar 2022 14:00:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 05/18] target/arm: Pass outputsize down to check_s2_mmu_setup Date: Tue, 1 Mar 2022 11:59:45 -1000 Message-Id: <20220301215958.157011-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220301215958.157011-1-richard.henderson@linaro.org> References: <20220301215958.157011-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::435 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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" Pass down the width of the output address from translation. For now this is still just PAMax, but a subsequent patch will compute the correct value from TCR_ELx.{I}PS. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 71e575f352..431b0c1405 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11065,7 +11065,7 @@ do_fault: * false otherwise. */ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, - int inputsize, int stride) + int inputsize, int stride, int outputsize) { const int grainsize = stride + 3; int startsizecheck; @@ -11081,22 +11081,19 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, } if (is_aa64) { - CPUARMState *env = &cpu->env; - unsigned int pamax = arm_pamax(cpu); - switch (stride) { case 13: /* 64KB Pages. */ - if (level == 0 || (level == 1 && pamax <= 42)) { + if (level == 0 || (level == 1 && outputsize <= 42)) { return false; } break; case 11: /* 16KB Pages. */ - if (level == 0 || (level == 1 && pamax <= 40)) { + if (level == 0 || (level == 1 && outputsize <= 40)) { return false; } break; case 9: /* 4KB Pages. */ - if (level == 0 && pamax <= 42) { + if (level == 0 && outputsize <= 42) { return false; } break; @@ -11105,8 +11102,8 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, } /* Inputsize checks. */ - if (inputsize > pamax && - (arm_el_is_aa64(env, 1) || inputsize > 40)) { + if (inputsize > outputsize && + (arm_el_is_aa64(&cpu->env, 1) || inputsize > 40)) { /* This is CONSTRAINED UNPREDICTABLE and we choose to fault. */ return false; } @@ -11392,7 +11389,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, target_ulong page_size; uint32_t attrs; int32_t stride; - int addrsize, inputsize; + int addrsize, inputsize, outputsize; TCR *tcr = regime_tcr(env, mmu_idx); int ap, ns, xn, pxn; uint32_t el = regime_el(env, mmu_idx); @@ -11422,11 +11419,13 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, addrsize = 64 - 8 * param.tbi; inputsize = 64 - param.tsz; + outputsize = arm_pamax(cpu); } else { param = aa32_va_parameters(env, address, mmu_idx); level = 1; addrsize = (mmu_idx == ARMMMUIdx_Stage2 ? 40 : 32); inputsize = addrsize - param.tsz; + outputsize = 40; } /* @@ -11511,7 +11510,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, /* Check that the starting level is valid. */ ok = check_s2_mmu_setup(cpu, aarch64, startlevel, - inputsize, stride); + inputsize, stride, outputsize); if (!ok) { fault_type = ARMFault_Translation; goto do_fault;