From patchwork Sat Jun 4 04:05:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 578748 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp2146854max; Fri, 3 Jun 2022 21:40:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweDSbs1xXbH8Z7oKdw2/Vx6uEW60fLwFlmS4c29as3FKOvfO3dZiraSpJdyOCnXHRFLGAF X-Received: by 2002:a05:6214:c4c:b0:468:1689:a1d9 with SMTP id r12-20020a0562140c4c00b004681689a1d9mr4702635qvj.52.1654317649902; Fri, 03 Jun 2022 21:40:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654317649; cv=none; d=google.com; s=arc-20160816; b=AP1l3MqcIg83i54/vS1/rrLoO26xdsVFr2RnEkXbZVGa81nSaXHDKvNr8+6J1J3jwu 8+7lbqX25H75u9M9PjosJFwePu2FYd3bp7XQp/RTHHt+WfTT2zq7NUzze9VSuGQa7gEG 2wSIxUs1ukdjd5oKOYEBgJ/qAPMMKxo0mIdd79XHfCBbxiYk+qv5OvdK6Ms1euG9jSsu elXyhpqcwhgr22DCdufRHVztVjxWlyQv7Fnzy+70BPabny4LvFQ7MWT33BEq2eQ/0UY+ Z+QeRLyT3QF2eOt+ji28TstwJh/3xVYJHL475k1CAcELG7ysFZc9KervxbmDHqKaPvFr 43Aw== 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=wKwxgmTTnQp5W/CZg2mnGE7auUJpNoW6/0mxrOpi9ls=; b=TSk+ApgeVKBr//+Sy+t81owi0dx5rtu8imD/eugizlj/mLxJVE/t9N27CmMIndDssA OpnBRmTb3reloAA5LcJVB8ozaGvOoTIuFV/Enx0+EA1LJMfOazPHQudi6k86wYk7FC0e 2sx8ot5xBALyms1DpyTy/Kr3GzQloUpIeg2gtBkcQQuUwpMNVMMn8q+6zrsHnoJ9b/Sa UgrkkUU09t/iMfTO8mgbsjYMRQ4G2f8D6n3KlXkvdSUh3X6TThFsqdOwdzso8nZpouxA E9VqzSHGQ+ifJErjnnMHz6Zvuc6IB0agtEbgNPXcu5Nz308a+bw4OU9rLbC+ABBJ7t7g IEuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jltRyuAN; 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 v42-20020a05622a18aa00b00304dd83f5fasi2922019qtc.398.2022.06.03.21.40.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Jun 2022 21:40:49 -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=jltRyuAN; 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]:45934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nxLag-00078e-CC for patch@linaro.org; Sat, 04 Jun 2022 00:40:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nxL3W-0008I9-LC for qemu-devel@nongnu.org; Sat, 04 Jun 2022 00:06:30 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]:36412) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nxL3U-00005b-6z for qemu-devel@nongnu.org; Sat, 04 Jun 2022 00:06:30 -0400 Received: by mail-pj1-x1035.google.com with SMTP id u12-20020a17090a1d4c00b001df78c7c209so13537362pju.1 for ; Fri, 03 Jun 2022 21:06:27 -0700 (PDT) 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=wKwxgmTTnQp5W/CZg2mnGE7auUJpNoW6/0mxrOpi9ls=; b=jltRyuAND+N1NSRUviNYNAQ12GjK7A+EjLxjC+donEQ//VD9E+Rr+ularAWcS3PUDg q4FPtpVSn7hxtIEgumtVaO4+WSQfoP63IG1KKGWinvufSGqLpVGMFt8Fm/jQmDGSA43m MSdTXCHVWMwJspAZK5Q/0fREYU97e9WlsBUknEwjX8nzweL5SP1nV/npWRZJN0mRK1E2 xV9wY0YRjDPn/EEgEjCg3xF2Qo3xxz4DE753hjoosR75+9CZQP3NhG4s1Rq54/oWRigV /lK9rNjMs5zVjT3/47vaEFThyPjbaSnCUpEVTNJEV521O6cfGV7jxw5M8hbe9lgHNMAK PdXg== 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=wKwxgmTTnQp5W/CZg2mnGE7auUJpNoW6/0mxrOpi9ls=; b=VnOHTFEWwpn0DYrfcvwioFibQ8N1nXVAONL9Wsh7hA4PNdiD21CmNXOido02Z3lmJJ 6LUXvhXhTvscmfSRhvuCsTsddUzxm5ucbMvBQ2HfYxBikyq2Ki+lBI5uA2KetDTCXGiU c2BYC6vyWIivk5jU37az+x+fqQrGOpwdlDeFOI2N5kzaYAJuX3a8I/OOf9hLTzdulCDi LLVE63Ja28iNEcEsF7pX9qEAgoA8UvF9k2noueXdwCiKOicEoZVcKCPx40rIxo/sEmZt iFZec1Qis8hi4bwfb73XsC0U0+VZOSBr7lHNH+WHNJRtcnBgqY8ymjVI2v4Tf+Oqygm5 elsw== X-Gm-Message-State: AOAM533c/CgtLdzSARLpCTma9NnJoWPuaVVwlwJSDG4Y21RHB6Q3omag YNcFikSk5Goi+Bn/PvJFpZQtBlcnNsvFRQ== X-Received: by 2002:a17:902:cec5:b0:166:3418:5260 with SMTP id d5-20020a170902cec500b0016634185260mr13053523plg.129.1654315587334; Fri, 03 Jun 2022 21:06:27 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:3286:cc26:3d5e:3f94]) by smtp.gmail.com with ESMTPSA id a37-20020a631a65000000b003c14af50626sm6093779pgm.62.2022.06.03.21.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jun 2022 21:06:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH 20/28] target/arm: Move check_s2_mmu_setup to ptw.c Date: Fri, 3 Jun 2022 21:05:59 -0700 Message-Id: <20220604040607.269301-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220604040607.269301-1-richard.henderson@linaro.org> References: <20220604040607.269301-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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" Signed-off-by: Richard Henderson --- 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 93147e0b06..a71161b01b 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 7aadc6eeb9..5dfe1f9cc0 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10578,76 +10578,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 af9ad42028..525272e99a 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 *