From nobody Mon Feb 9 19:55:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1629714842106451.95500787742697; Mon, 23 Aug 2021 03:34:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.170310.311099 (Exim 4.92) (envelope-from ) id 1mI7H2-0003pm-Fk; Mon, 23 Aug 2021 10:33:48 +0000 Received: by outflank-mailman (output) from mailman id 170310.311099; Mon, 23 Aug 2021 10:33:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mI7H2-0003pc-Bs; Mon, 23 Aug 2021 10:33:48 +0000 Received: by outflank-mailman (input) for mailman id 170310; Mon, 23 Aug 2021 10:33:47 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mI7H1-0003ow-Oz for xen-devel@lists.xenproject.org; Mon, 23 Aug 2021 10:33:47 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 0b419d2f-719e-45f0-8c18-b29c48eb347e; Mon, 23 Aug 2021 10:33:46 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 81471143D; Mon, 23 Aug 2021 03:33:46 -0700 (PDT) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D1B433F66F; Mon, 23 Aug 2021 03:33:45 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 0b419d2f-719e-45f0-8c18-b29c48eb347e From: Bertrand Marquis To: xen-devel@lists.xenproject.org Cc: Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [PATCH v2 5/7] xen/arm: Use sanitize values for p2m Date: Mon, 23 Aug 2021 11:32:14 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-ZM-MESSAGEID: 1629714842729100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Replace the code in p2m trying to find a sane value for the VMID size supported and the PAR to use. We are now using the boot cpuinfo as the values there are sanitized during boot and the value for those parameters is now the safest possible value on the system. On arm32, the system will panic if there are different types of core so those checks were not needed anyway. Signed-off-by: Bertrand Marquis --- Changes in v2: - use system_cpuinfo --- xen/arch/arm/p2m.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index eff9a105e7..41b6430c30 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -2045,31 +2045,21 @@ void __init setup_virt_paging(void) [7] =3D { 0 } /* Invalid */ }; =20 - unsigned int i, cpu; + unsigned int i; unsigned int pa_range =3D 0x10; /* Larger than any possible value */ - bool vmid_8_bit =3D false; - - for_each_online_cpu ( cpu ) - { - const struct cpuinfo_arm *info =3D &cpu_data[cpu]; =20 - /* - * Restrict "p2m_ipa_bits" if needed. As P2M table is always confi= gured - * with IPA bits =3D=3D PA bits, compare against "pabits". - */ - if ( pa_range_info[info->mm64.pa_range].pabits < p2m_ipa_bits ) - p2m_ipa_bits =3D pa_range_info[info->mm64.pa_range].pabits; - - /* Set a flag if the current cpu does not support 16 bit VMIDs. */ - if ( info->mm64.vmid_bits !=3D MM64_VMID_16_BITS_SUPPORT ) - vmid_8_bit =3D true; - } + /* + * Restrict "p2m_ipa_bits" if needed. As P2M table is always configured + * with IPA bits =3D=3D PA bits, compare against "pabits". + */ + if ( pa_range_info[system_cpuinfo.mm64.pa_range].pabits < p2m_ipa_bits= ) + p2m_ipa_bits =3D pa_range_info[system_cpuinfo.mm64.pa_range].pabit= s; =20 /* - * If the flag is not set then it means all CPUs support 16-bit - * VMIDs. + * cpu info sanitization made sure we support 16bits VMID only if all + * cores are supporting it. */ - if ( !vmid_8_bit ) + if ( system_cpuinfo.mm64.vmid_bits =3D=3D MM64_VMID_16_BITS_SUPPORT ) max_vmid =3D MAX_VMID_16_BIT; =20 /* Choose suitable "pa_range" according to the resulted "p2m_ipa_bits"= . */ --=20 2.17.1