From patchwork Tue Oct 25 16:39:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 618131 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp3520930pvb; Tue, 25 Oct 2022 09:50:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4aoC/jI4OEQ5kVTTo2rFiMOh8/c9/K+0Pwova+eqLdlHMito7eMpqubY1Ds1LiwO9Ifiy9 X-Received: by 2002:a05:620a:1204:b0:6ec:db32:18c1 with SMTP id u4-20020a05620a120400b006ecdb3218c1mr27622924qkj.401.1666716655754; Tue, 25 Oct 2022 09:50:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666716655; cv=none; d=google.com; s=arc-20160816; b=ES+jpvCfUv7RCITmO0HbN00eClk41gzxUFSM0FDbbt/jzb3fYDruLIkl2tqNMwE/7i meEzpGGl7eSowNrxfROCCUoNuokgVBA13E9xKRAe5LTFRZoq9Yc2vl0sBG7MCRpTsHGn gMxiTfnwtIjVy73K5ntFSzTG62xRyDEDyHxKADLuZvunQcrTBxJ1PQWgxu0L2x3ST9dQ zyl8WBlSErBGdQ1tkOPSw7937kqzrLrmqyA7X3kbOuDF3t8MwlKRbojrpDIfgh7JOC+o ZsRYgI6zEU6o+889pvknaxEF8W+ZDHHO0x+U1vS8RMmuAULirSTfagNihPJ8sgC7S61D douA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender: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=YF2gaOVZ8h4GLrNXErHddIokoruQLmVA620L7O1U4TA=; b=cQ5LRX0MoAkGNM2nLUN0owY83IgNnwZ0b1qzUS6EQfLUNdX4iXIZsmXjHPlWiGFXft HFGq8N6jdFKJ4+wdFG1cKQl5P8jgSgiNiVqkrW7gl8Bebdqi/OJT2ijtv/e4ttlllAvu vLDT6NG8BpIBLVc3/9vuYL/Qw7B7LZ64pChCFjuLxh4we4iztL8ACNFxQKAmnOCh8Lkh jZKBm/iszsfT9ddUTursNpGBmfTS/V92aTuTdcj0j9h0XAo3t0LPU/uI0bqsWWJLKXXV Pm+ykSb4VcIQFkoIM52LSu7nAdCxHRiKux6Cjqwqw+TFiGSpheZAAAJp9/po4WJDKXRr DgZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yrkClq3w; 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 k23-20020ac81417000000b0039ceb5a5c54si1833013qtj.485.2022.10.25.09.50.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Oct 2022 09:50:55 -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=yrkClq3w; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1onMzg-0007Xb-PP; Tue, 25 Oct 2022 12:41:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1onMz1-0006eO-AW for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:55 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyf-0001mo-Lc for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:49 -0400 Received: by mail-wr1-x432.google.com with SMTP id bk15so22062367wrb.13 for ; Tue, 25 Oct 2022 09:40:30 -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:to:from:from:to:cc:subject:date:message-id :reply-to; bh=YF2gaOVZ8h4GLrNXErHddIokoruQLmVA620L7O1U4TA=; b=yrkClq3wbvHIDB2sAwvpOEyJiZkWYXjJOxnRJvaKmvhTiyyOVxzYIVRE2MNy34HmRR lmPS4M2Ks0mJ9quG7qlhpOceH2d5FekGHZv/MV1EF2JhrYXcuUOKeeJ5u+nfVzQp9eDt bvLaI25If/NYcW8hdH/XlsMeA0dw2s2Y5d+ZXnF6TImFFWSciupDCKfMVu297BbrPUeY 14Z/wPS3WSz/Hg6BLlto7CyoSfjl/jegVuRws3ZIEwaj+atjhL4k5XYXVrl/tnHzfAds oZbMiZ+jOKKtzt8WVxjg/7UO1DJa4jWqluLK++lUjaYx0POMq5nkIqyByZgwtkb5BQS7 DFyA== 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:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YF2gaOVZ8h4GLrNXErHddIokoruQLmVA620L7O1U4TA=; b=NpxBqTuF6k8mOTRJjk3nOF1YdehwC5tboBG43wSghRFMDlHmEr3dxh3mrwTemrb1Eb G+0psfQU7PBSYQN8WSnxng4kG6tJ1y/MLeqRZMwge/2bK3peKAK78ghHkLGIGJSRA+aQ bxsqo9U2xo/3ZHTFJBsvrOqZb9LwlEgNN8Xwr5y3bnpDhWLjxs4LtbblArWn02Vj8Dcv E3R7qNNNNL17pHBS4BsOc58b4iDS7SrdF0YvmO6faaLf6WNDUd2Vlrh/eFifJe8/z2fX 40Mv98n5+GkVMGk5RSLMruRC1CjPjYa2LZss+OuH0Zo5hxwm6MUli9EhL0VSSdaMBZaM jkAA== X-Gm-Message-State: ACrzQf2TbfAI9T3FqdERjo1HBd0k7549uxTCaDoMuWmMQYYSKIl9x6ts L/EIty/27nyPxwP+2T4I+qOBx3s8un8Sjw== X-Received: by 2002:a05:6000:1548:b0:22e:3469:b726 with SMTP id 8-20020a056000154800b0022e3469b726mr25788021wry.10.1666716018542; Tue, 25 Oct 2022 09:40:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z12-20020a05600c220c00b003cd9c26a0basm2971084wml.40.2022.10.25.09.40.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:18 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 20/30] target/arm: Use the max page size in a 2-stage ptw Date: Tue, 25 Oct 2022 17:39:42 +0100 Message-Id: <20221025163952.4131046-21-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221025163952.4131046-1-peter.maydell@linaro.org> References: <20221025163952.4131046-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson 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 Message-id: 20221024051851.3074715-15-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- 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 6b8f14fb3cd..23b1f1e6598 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -2570,7 +2570,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; @@ -2606,6 +2606,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)); @@ -2620,6 +2621,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) {