From patchwork Thu Jun 9 09:05:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 580264 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp630132max; Thu, 9 Jun 2022 03:11:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyK3ULdqxbVGaO/5VjO8gvMGennvug/nww4cIj7U9iACAFe8VVz0tlgDkSx1hxbtJnhTVTK X-Received: by 2002:ac8:5a53:0:b0:305:12:fc8f with SMTP id o19-20020ac85a53000000b003050012fc8fmr7235689qta.446.1654769503883; Thu, 09 Jun 2022 03:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654769503; cv=none; d=google.com; s=arc-20160816; b=uhsEq7/zrsl+GzB9stxUchupyPCeyavwM5mDoBCrcrs9FUmX84dUcxQHp4mcBzftr8 fm+dh5z3d2y2L9v/vSFoaER0Tp3UBSiJWjiklHfduTlRhNRXLgyo3ZC4Wp+GeTbcdMZv IaY8Jq2zrrSLjfgsU1PrPT3kdlLeQK3IGASUgUHVpxC3IB0FVSst6rM8ruyEw53aWvE5 a7O6QKDYgFORIH/YfvoUVDf06RcOA5ZWwhQ5vXSczP6vlLpvg08S1UkC0tR90XImB9b7 1lKVSsH05BaH7y2eqZ5NVbcPcdl9UEniIgHO5XLBkV1EYQpIryl7gEVf72mXqlfUs8+T SdLg== 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:to:from :dkim-signature; bh=7iWAmr8aLaBxhjnqmS0IabAjJ74tn9UJA1n63C3136o=; b=0oFpmN2aoWEV9M4cJkVau1WYW+S8Y+CO8QHFzBTVvbwtu9XGW/i4exifM1Jvco/XRW 1NLmilw19S6jkXkCpUe4mQQ6KrvzP0V5cDcuXfJ7k8LvKWBaSZhCJL2ZnlYJ+fIngH+0 x2YjydEIGBhhgAEXnMxYiaRe8HU6UFUz7qjhquHlvunuRiCc8F1DnHyb2pCTJFNeCg6H ImquEcbgavqknP9JdOMjEo8HvMRgkHvRtRzq+WFTcW4NZ3dqRtOtvCEkQ0u389yHlejP 29y7db4eZixHBTrVQV5ZbXnM/5J0to6Sl5cf6yR2HnfyKd8tDFnUOyQlLVC+OyFCygRc 8Rcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HNL4ROPL; 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 b23-20020a05620a119700b006a6ab2932f3si7978518qkk.642.2022.06.09.03.11.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Jun 2022 03:11:43 -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=HNL4ROPL; 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]:57416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nzF8h-00055p-3j for patch@linaro.org; Thu, 09 Jun 2022 06:11:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nzE7L-0001Ys-U6 for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:18 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:46819) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nzE7H-0005xd-GH for qemu-devel@nongnu.org; Thu, 09 Jun 2022 05:06:15 -0400 Received: by mail-wr1-x435.google.com with SMTP id u8so27137707wrm.13 for ; Thu, 09 Jun 2022 02:06:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7iWAmr8aLaBxhjnqmS0IabAjJ74tn9UJA1n63C3136o=; b=HNL4ROPLJvjh4JaPHTWCeUuweTRQ81y7PyFIBHd8wx4uAjAR7e8JuBTNbKpZ5Y4sM1 B/4dZpBRuvmT8LhC8EsqHjb/ebNsHqM3pvSfiswEk0PaQHHt9vYFIhumMcRglNlkFwCS 80rzdEVa0xIG1NacQAeV2TK+8IWK0trkcpEt7QwYFxBrauGgeY2L9I5fxcaDGnuL7OwV STS0II2jv8amtgt6r48vq9Y0AGK3NPpRGCUVDWESqJToqwQckfKKT4L8hOefQmQHU5w8 lYR9AFPAT/2FbqkqTOPj6hydajpOWmBsNgj4y3609MxIQOn7HNg3X0gXIa49CCx/fsBa m7hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7iWAmr8aLaBxhjnqmS0IabAjJ74tn9UJA1n63C3136o=; b=Pd8yJRLdVAcReDENDMQzyyC0is3nJERN49fAi1Z330x1xJEu68npVkpJuZ4A0CHlt7 +fLf+5CJBOoNxnS408bOd/qPDCaG4c0/Tq8Uqpp1cRu4pMqhZeq5zV5SnJ7nyIsPOIqz +KjJkupABarHsSjXJeMsOPJTLzep5iWq4QPu8WI5cj9AJg3w/Ft/3f4FsTqMcG5glr/+ 1pErzJajFtI9nA/82/3ueR+6w7WsTxbciTkP/2gDYakKjnyWhotI4BM51r9GVI6GaxCa W3/9MOeTFyza4Q9Vbo/DviLJeum2rBLeMyTF3Zvjb4zirfTbjEYuWXKBYLlyskPZTqff bu+A== X-Gm-Message-State: AOAM533CKrpbzijRKLfq209oKLvAuUu6wEKeelbyiT1mTqFD6mqbPTnl zOO0FiwOVCQgwWd5nvqWvJ/ZBg3Q9cNEUw== X-Received: by 2002:a5d:620b:0:b0:210:11d9:770 with SMTP id y11-20020a5d620b000000b0021011d90770mr37270326wru.11.1654765570493; Thu, 09 Jun 2022 02:06:10 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id c13-20020adffb0d000000b002183cf9cd69sm11349796wrr.15.2022.06.09.02.06.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jun 2022 02:06:10 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 27/55] target/arm: Move check_s2_mmu_setup to ptw.c Date: Thu, 9 Jun 2022 10:05:09 +0100 Message-Id: <20220609090537.1971756-28-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609090537.1971756-1-peter.maydell@linaro.org> References: <20220609090537.1971756-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Signed-off-by: Richard Henderson Message-id: 20220604040607.269301-21-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/ptw.h | 2 -- target/arm/helper.c | 70 --------------------------------------------- target/arm/ptw.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 72 deletions(-) diff --git a/target/arm/ptw.h b/target/arm/ptw.h index 93147e0b065..a71161b01bd 100644 --- a/target/arm/ptw.h +++ b/target/arm/ptw.h @@ -27,8 +27,6 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap) ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va, ARMMMUIdx mmu_idx); -bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, - int inputsize, int stride, int outputsize); #endif /* !CONFIG_USER_ONLY */ #endif /* TARGET_ARM_PTW_H */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 148eb28ba8c..2526f4c6c4a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10614,76 +10614,6 @@ int simple_ap_to_rw_prot_is_user(int ap, bool is_user) g_assert_not_reached(); } } - -/* - * check_s2_mmu_setup - * @cpu: ARMCPU - * @is_aa64: True if the translation regime is in AArch64 state - * @startlevel: Suggested starting level - * @inputsize: Bitsize of IPAs - * @stride: Page-table stride (See the ARM ARM) - * - * Returns true if the suggested S2 translation parameters are OK and - * false otherwise. - */ -bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, - int inputsize, int stride, int outputsize) -{ - const int grainsize = stride + 3; - int startsizecheck; - - /* - * Negative levels are usually not allowed... - * Except for FEAT_LPA2, 4k page table, 52-bit address space, which - * begins with level -1. Note that previous feature tests will have - * eliminated this combination if it is not enabled. - */ - if (level < (inputsize == 52 && stride == 9 ? -1 : 0)) { - return false; - } - - startsizecheck = inputsize - ((3 - level) * stride + grainsize); - if (startsizecheck < 1 || startsizecheck > stride + 4) { - return false; - } - - if (is_aa64) { - switch (stride) { - case 13: /* 64KB Pages. */ - if (level == 0 || (level == 1 && outputsize <= 42)) { - return false; - } - break; - case 11: /* 16KB Pages. */ - if (level == 0 || (level == 1 && outputsize <= 40)) { - return false; - } - break; - case 9: /* 4KB Pages. */ - if (level == 0 && outputsize <= 42) { - return false; - } - break; - default: - g_assert_not_reached(); - } - - /* Inputsize checks. */ - if (inputsize > outputsize && - (arm_el_is_aa64(&cpu->env, 1) || inputsize > 40)) { - /* This is CONSTRAINED UNPREDICTABLE and we choose to fault. */ - return false; - } - } else { - /* AArch32 only supports 4KB pages. Assert on that. */ - assert(stride == 9); - - if (level == 0) { - return false; - } - } - return true; -} #endif /* !CONFIG_USER_ONLY */ int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index af9ad420288..525272e99af 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -615,6 +615,76 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, return prot_rw | PAGE_EXEC; } +/* + * check_s2_mmu_setup + * @cpu: ARMCPU + * @is_aa64: True if the translation regime is in AArch64 state + * @startlevel: Suggested starting level + * @inputsize: Bitsize of IPAs + * @stride: Page-table stride (See the ARM ARM) + * + * Returns true if the suggested S2 translation parameters are OK and + * false otherwise. + */ +static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, + int inputsize, int stride, int outputsize) +{ + const int grainsize = stride + 3; + int startsizecheck; + + /* + * Negative levels are usually not allowed... + * Except for FEAT_LPA2, 4k page table, 52-bit address space, which + * begins with level -1. Note that previous feature tests will have + * eliminated this combination if it is not enabled. + */ + if (level < (inputsize == 52 && stride == 9 ? -1 : 0)) { + return false; + } + + startsizecheck = inputsize - ((3 - level) * stride + grainsize); + if (startsizecheck < 1 || startsizecheck > stride + 4) { + return false; + } + + if (is_aa64) { + switch (stride) { + case 13: /* 64KB Pages. */ + if (level == 0 || (level == 1 && outputsize <= 42)) { + return false; + } + break; + case 11: /* 16KB Pages. */ + if (level == 0 || (level == 1 && outputsize <= 40)) { + return false; + } + break; + case 9: /* 4KB Pages. */ + if (level == 0 && outputsize <= 42) { + return false; + } + break; + default: + g_assert_not_reached(); + } + + /* Inputsize checks. */ + if (inputsize > outputsize && + (arm_el_is_aa64(&cpu->env, 1) || inputsize > 40)) { + /* This is CONSTRAINED UNPREDICTABLE and we choose to fault. */ + return false; + } + } else { + /* AArch32 only supports 4KB pages. Assert on that. */ + assert(stride == 9); + + if (level == 0) { + return false; + } + } + return true; +} + /** * get_phys_addr_lpae: perform one stage of page table walk, LPAE format *