From patchwork Tue Oct 11 03:19:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 614166 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2376299pvb; Mon, 10 Oct 2022 20:47:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7fpcVWIxG+oXW6kaXhsW9X3mI+LyDdw/3PMKGIWK2gzgMYMJWkAxyj/z6oe6F7t16JrmI9 X-Received: by 2002:ae9:e895:0:b0:6ee:74f7:d0e6 with SMTP id a143-20020ae9e895000000b006ee74f7d0e6mr2298761qkg.398.1665460028016; Mon, 10 Oct 2022 20:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665460028; cv=none; d=google.com; s=arc-20160816; b=Xj9+U9EAZHESq3FxoTMUGcQN5w0aYVv3oLXtQS7ne2Ru14qoU17VVtgQKyCtzd33Or XiYvzRGXiGxAzPd2YFMPAxUJ0GlrdFQqWxb/BQnWR22FBAK62/W/rdXANv1NucMyQuk0 wcUP+W4nETXRFQRyepVMskZ5mwl+4QvOJA3Ie2NE0XVC2plDblsh73xYqFiwzsdXoeyJ 6p94eyWtFmLyHsVrbZMqCoI9iW5klwKbO+ZzOUJEAu7S/9es63TvsPoy59JnI80Zb5b+ WQp/5WHrHE73hIqwncN1+Jcr2hBUU+odY3eP2tPMaYW2z4AlepIW1AKdczv7emsj0XPc YV3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=+7jRVgDoKz3lej+ZaMULQKKS6huX/14P3OCNEftnZ1M=; b=0b42DaiJdTBRED3ucH9l0Dq0Pzo89lFcPAFFwGC2zwhKYq0c0ovwFwx4frhhUioVei v3HSVftbb7o0yW7BjIa0XgJ43ytZhTEMgbbfoPp+KUnQxDZjMkIGgF8r4Jnz6pAf8Y6A 31fo5/8jQF9Pek+ObBTMT44ii4WKy8fO5HM8m2uZDtAY1bZCl+Xk+DH5seaMDtRpgkaM Av9IpSG7WdpgGA9hlrlhd5OZcO+OME/iT7UkEnY6vod1kTIyNrbZRbwYMgpA7NVRCp6I yDdAvnkveRloI301+WSxysdbx05iMRXze6rLQZM2/3gcYzzVPjPUB83i6ofuU7l8sdAz FvSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j4bYr2XK; 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 bq7-20020a05622a1c0700b00342f8bbd9d0si628981qtb.671.2022.10.10.20.47.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 20:47:08 -0700 (PDT) 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=j4bYr2XK; 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]:44106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oi6EV-000286-IT for patch@linaro.org; Mon, 10 Oct 2022 23:47:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oi5oZ-0003Dd-Sc for qemu-devel@nongnu.org; Mon, 10 Oct 2022 23:20:24 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:50722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oi5oM-0003Lk-BN for qemu-devel@nongnu.org; Mon, 10 Oct 2022 23:20:19 -0400 Received: by mail-pj1-x1036.google.com with SMTP id h12so5625002pjk.0 for ; Mon, 10 Oct 2022 20:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+7jRVgDoKz3lej+ZaMULQKKS6huX/14P3OCNEftnZ1M=; b=j4bYr2XKuchTNZKteEefZpZt0QG45dJnXRNntSMEGb7Q5dbpJAOqHoUvnNJw4LkK7N VNCYqqQYVPYk95epRH9U4/Ixa2cc4yGg6xJMHGlvXzRIcNWlaVoXeydcMutHYyt4cmnO CNGVBqVjPcmoavwgFjG8FIfaa2uZVYu9FfFMsM9VnC+TOq9zaCYz0PNC340Kuu2LctOU UCEfHXcJgkqPysLi5lfHbyL17y2G2aIKffpIfLaA4ShbROtthk0vxiUQBl7W21vzqIW3 kEEiwkVd1cs3mHptz3oYsDSTa6w8AvoqgGs3FEiWDojv6bUPKadSDDtZpDEOPp9BrGXl sLeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+7jRVgDoKz3lej+ZaMULQKKS6huX/14P3OCNEftnZ1M=; b=MwP64wZgT2V/VEJMFOJSANVQijlLnxhsPU1RBYCnbk/70YqkUeCniXZBXzinkm2SNy +/d0iQFMdfWVOrG1HfoYBFgMiFD86rE/vMGBxEwRE1ZmYOj8uJ29D/eABl7vVWCIBZHU 7wWdMpxqQXlC81MaE83v/aAjBwN85fjosEMCLhGJKX9f2qxOYVNIh6gLl34/wuLzTW/S 2V8sKtdSUQ3rFeHpCyXgSa+659sqgE+XDxMgMOvQnEv2OdZt3TBYV1842zo6jp41KjVs DShpw8bWdHnQyubHZ3S9noFsplL7E6RgMv464gaZJiIq8cYzSiFYJpOteG4AwC79ssbU 30DA== X-Gm-Message-State: ACrzQf0nxScF9qHt4cI0Q+sFGO18zRqzROsz4L7GmbYL/bbycEDOsgdh fyQaD+XPDWt09AEUamahQjZBL3MkXFUtQw== X-Received: by 2002:a17:902:ab1d:b0:180:4030:757d with SMTP id ik29-20020a170902ab1d00b001804030757dmr18384506plb.155.1665458402989; Mon, 10 Oct 2022 20:20:02 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:5aa4:aba1:1c91:a9b7]) by smtp.gmail.com with ESMTPSA id o74-20020a62cd4d000000b0055f209690c0sm7663567pfg.50.2022.10.10.20.20.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 20:20:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Marc Zyngier , Peter Maydell Subject: [PATCH v4 24/24] target/arm: Use the max page size in a 2-stage ptw Date: Mon, 10 Oct 2022 20:19:11 -0700 Message-Id: <20221011031911.2408754-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221011031911.2408754-1-richard.henderson@linaro.org> References: <20221011031911.2408754-1-richard.henderson@linaro.org> MIME-Version: 1.0 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We had only been reporting the stage2 page size. This causes problems if stage1 is using a larger page size (16k, 2M, etc), but stage2 is using a smaller page size, because cputlb does not set large_page_{addr,mask} properly. Fix by using the max of the two page sizes. Reported-by: Marc Zyngier Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 0dbbb7d4d4..b8934765ec 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2584,7 +2584,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, ARMMMUFaultInfo *fi) { hwaddr ipa; - int s1_prot; + int s1_prot, s1_lgpgsz; bool is_secure = ptw->in_secure; bool ret, ipa_secure, s2walk_secure; ARMCacheAttrs cacheattrs1; @@ -2620,6 +2620,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, * Save the stage1 results so that we may merge prot and cacheattrs later. */ s1_prot = result->f.prot; + s1_lgpgsz = result->f.lg_page_size; cacheattrs1 = result->cacheattrs; memset(result, 0, sizeof(*result)); @@ -2634,6 +2635,14 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, return ret; } + /* + * Use the maximum of the S1 & S2 page size, so that invalidation + * of pages > TARGET_PAGE_SIZE works correctly. + */ + if (result->f.lg_page_size < s1_lgpgsz) { + result->f.lg_page_size = s1_lgpgsz; + } + /* Combine the S1 and S2 cache attributes. */ hcr = arm_hcr_el2_eff_secstate(env, is_secure); if (hcr & HCR_DC) {