[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 1/3] arm/mpu: implement setup_virt_paging for MPU system


  • To: "Orzel, Michal" <Michal.Orzel@xxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Mon, 13 Apr 2026 09:54:43 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=amd.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LClfXYli9yVq6/36kS7I9hr8lVxTEBSejniR4OcaQts=; b=tMKASntf4+EZYXbe/KZiLFZZV2QUjSjfCyqBAy02pFbv3MDnllKr6vZnZGq3pw9aRG+q2g7TGv+eUiiIBoQ1gPQlIx5Wg557EGXA3xH3nYW2slzLDFziJcCJh/GwtfFSDOaC/QdQjIFWlHsJ42aZy1YBm6/eGwgnxDxOpNjxcLp/xEXrsjN4fcecbLkBJXuaQRDNUB467gARZ3zb5KXD5TW1gbf+D+Nocz4C53c149jIEbgZgeDdmS5hT9cAXsiXfjKZ93/i9wvKjyYNpPh5vpt3keMOUM5vKoqBzhRkoyxDpEeA9dRzBLhKG1W5fUSwdkb8+i6cbXSag04bCPDaLg==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LClfXYli9yVq6/36kS7I9hr8lVxTEBSejniR4OcaQts=; b=YiahNc0yVnOrZPVcIHaGIb8IQdib8Xiqia8vLHdU+lygIwtNCk2f6CMLSii+M+II9CG0U4vzfZfxuwef5rErsvdhR7fdS5nrCoHT6Kx3lIv18co6DIPWS7eOl+Z1wL0BkRO6te3hStj8DMdduePvAMNrXlHhdp8PTVRjOR81TEa7qJNaMtgrYebnUCz/kaXD55BjJs9ce4FzOZzIKIHOZEtZlh2L6QiDtyF2IgqCNoTGUTcijPza8w6/lvhVulxZs8uWDWt66XeJFhH6IgZjx5QaSTj730iGK+KIexkYwTVngWUqVrurXWS+VilkyaYxlegrF32WEFirc0RuktrTjg==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=qlq4KxB3s7UUakxXxfMXNuuRvZul1pwvgMBzMS55Au6FTlI0caVdlGsWJpPlG5i7ARDBqQtfWyMkDNWW//IpOkgqdlwS1BKjZHwVQq9EDuVifPPEgelyTmVEjKMORC9vo8gB14tHV6a14XmzJgQyPYH131wKG4wylMi3Z5I6oHNFjOhKUkeBnCQCWNvrSM9mkCErhisCeOwjz+Sni9rFH7a+20Pop+mqZjskILo10e2X6RfKedp18WPeBDBjg2FRRyTrjcBIO5wcMEwVrqJEn+zIO2Z9/moVBHwWHd6k6/E0+w5EbbOOPkkh7j964+Zs5E9v5R/DwbFcQi9BKbrtmQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bXTlVpcWEVTz4qkr6yIuBTfdW+Opeeh83VG5AZd4g6HZG75GT2p1Nsws/GRWfQ05DMgS5TjLzLlNZtzOW7WdpeGfSZfJI9KzZE8UdxSHWjxtPjum1XoO/zLRXICyvGMrquCbgsSA3Q8DaNoCf38R3/Z2LL614EV0jsuQn3RbGbgV5YAzRizdxpPtTyuRXEY2ujpqnEZ5/CwSGbKq83iHm/XSqxYV75D9JMrOKRSId7JdXk40ez4sNs0jPi++T1aO0vb5ohwbFeJIgU9zYfFo1DD+UeKk817Lio37zmePzKepOtM97fHiOlKuBM8o1sjSN/a/R1fCIxXKXkIQCtfTsQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, Hari Limaye <Hari.Limaye@xxxxxxx>, Harry Ramsey <Harry.Ramsey@xxxxxxx>
  • Delivery-date: Mon, 13 Apr 2026 09:56:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHcx192xSccBJpVr0WTpZ/GMvC6RrXcxNcAgAADXwA=
  • Thread-topic: [PATCH v3 1/3] arm/mpu: implement setup_virt_paging for MPU system

Hi Michal,

>> 
>> void __init setup_virt_paging(void)
>> {
>> -    BUG_ON("unimplemented");
>> +    register_t vtcr_el2 = READ_SYSREG(VTCR_EL2);
>> +    register_t vstcr_el2 = READ_SYSREG(VSTCR_EL2);
>> +
>> +    /* PA size */
>> +    const unsigned int pa_range_info[] = {32, 36, 40, 42, 44, 48, 52, 0,
>> +                                          /* Invalid */};
>> +
>> +    /*
>> +     * Restrict "p2m_ipa_bits" if needed. As P2M table is always configured
>> +     * with IPA bits == PA bits, compare against "pabits".
>> +     */
>> +    if ( pa_range_info[system_cpuinfo.mm64.pa_range] < p2m_ipa_bits )
>> +        p2m_ipa_bits = pa_range_info[system_cpuinfo.mm64.pa_range];
>> +
>> +    /*
>> +     * The MSA and MSA_frac fields in the ID_AA64MMFR0_EL1 register 
>> identify the
>> +     * memory system configurations supported. In Armv8-R AArch64, the
>> +     * only permitted value for ID_AA64MMFR0_EL1.MSA is 0b1111.
>> +     */
>> +    if ( system_cpuinfo.mm64.msa != MM64_MSA_PMSA_SUPPORT )
>> +        goto fault;
>> +
>> +    /* Permitted values for ID_AA64MMFR0_EL1.MSA_frac are 0b0001 and 
>> 0b0010. */
>> +    if ( (system_cpuinfo.mm64.msa_frac != MM64_MSA_FRAC_PMSA_SUPPORT) &&
>> +         (system_cpuinfo.mm64.msa_frac != MM64_MSA_FRAC_VMSA_SUPPORT) )
>> +        goto fault;
>> +
>> +    /* Stage 1 EL1&0 translation regime uses PMSAv8 by default */
>> +    vtcr_el2 &= ~VTCR_MSA;
>> +
>> +    /*
>> +     * Clear VTCR_EL2.NSA bit to configure non-secure stage 2 translation 
>> output
>> +     * address space to access the Secure PA space as Armv8r only implements
>> +     * secure state.
>> +     */
>> +    vtcr_el2 &= ~VTCR_NSA;
>> +
>> +    /*
>> +     * cpuinfo sanitization makes sure we support 16bits VMID only if all 
>> cores
>> +     * are supporting it.
>> +     *
>> +     * Set the VS bit only if 16 bit VIMD is supported.
>> +     */
>> +    if ( system_cpuinfo.mm64.vmid_bits == MM64_VMID_16_BITS_SUPPORT )
>> +    {
>> +        vtcr_el2 |= VTCR_VS;
>> +        max_vmid = MAX_VMID_16_BIT;
>> +    }
>> +    else
>> +        vtcr_el2 &= ~VTCR_VS;
> This is the last change to vtcr_el2. Why do you put p2m_vmid_allocator_init()
> in-between this and write to vtcr_el2 register? It looks odd.

ok I can have the write to the register before calling p2m_vmid_allocator_init, 
in the
end what matters is only to call p2m_vmid_allocator_init() after setting 
max_vmid.

> 
>> +
>> +    p2m_vmid_allocator_init();
>> +
>> +    WRITE_SYSREG(vtcr_el2, VTCR_EL2);
>> +
>> +    /*
>> +     * VSTCR_EL2.SA defines secure stage 2 translation output address space.
>> +     * To make sure that all stage 2 translations for the Secure PA space 
>> access
>> +     * the Secure PA space, we keep SA bit as 0.
>> +     *
>> +     * VSTCR_EL2.SC is NS check enable bit. To make sure that Stage 2 NS
>> +     * configuration is checked against stage 1 NS configuration in EL1&0
>> +     * translation regime for the given address, and generates a fault if 
>> they
>> +     * are different, we set SC bit 1.
>> +     */
>> +    vstcr_el2 &= ~VSTCR_EL2_SA;
>> +    vstcr_el2 |= VSTCR_EL2_SC;
>> +    WRITE_SYSREG(vstcr_el2, VSTCR_EL2);
>> +
>> +    printk("P2M: %d-bit IPA with %d-bit PA and %d-bit VMID\n",
> All these are unsigned, so %u.

Oops, blindly copying from MMU code, I realise we have the issue also there

Cheers,
Luca




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.