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

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


  • To: "Halder, Ayan Kumar" <ayankuma@xxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Fri, 13 Feb 2026 09:19:01 +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=s00ztgLAbziHEm6vt3o+FjLtKmooLKSneQ4KQrIXGdY=; b=zEfQYCGpexGBu1CyubaJAWvl4U6FfcjmQWwWADg0B2WeHFOoSrzegSQslYiVA1zAM2DbRipYHKvBfbjiRxqH3a9+6pSb4PTAW3nDlezbOxSnk/pE40wqENnDQ6MYD/lJY84Ui3D6tJcXl0XujFgTru8LpZJ78kskqIOyPPKsBhtQXqfnHk9zxd8mS7TSve8y9luxnlQ3mPdMWjJ5AAsHBDMUWZA69goU7xmFNOe1zfQaQRYG38FZNws8T36AyQBFC2sDNhZ8EWb2FD1D1gz62J9dWfuxvrUl6WkyTaIWEtR95x+6IkNO7CSGCzAU2W1y02l7ngdl2sGyq38K2cMPhw==
  • 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=s00ztgLAbziHEm6vt3o+FjLtKmooLKSneQ4KQrIXGdY=; b=UtWkdw2Ja7QyRGG5WGnlJfHNcbFRh4DHtGyzC24EnTe/6WrESl42fdhEUIHvGkAbUsbGV0yOhXwCqUNUrG2lpQRyZO4SJu7zzCcmgD9WRDyMFbSE28DrEdRnmdeZW+ZzVgnlfDdoLavR4tCMTtvTfL4gedSKly1Nuj2He7C0KGS/jNmeetmqfApQGo9CwjoOawUFSJQbV38MqyWqELv7aaEhs+Xc5iA340szojdcsWKu7EMEgP9M5dBzpDB8r/MB8MJqdeMRvSNbAi9dIKovyAp+65S864pSDgW3+51NDPdRaz+MfK/yU/madGeNJI5L80yl4G2Q/w5R4qHZS0LYWw==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=sQZPqksH8ZeKwq2w5sjhi2qSkdTTMrNYDRFBO8EskHC+pR//UoPL21MxR/7JLWs+U5OWEeRnfOxQ+wuEHxZWf6EO5rbTcG3c58DA5rk5DJVqjnbJZEpZw0NoOU8S4eNApnlqNNRoP+g7hYtOF3t886Mg8fkx++7DBzX0rgq1l2sVRtldcsFIdVGckMpO70yONGd3bwoz0dy5+V8Uj86MbOjl3uCpHjtEra2M7FjQ7CBm5fnQnjCo6/BvRvOjwNYj8AGzU/zJroP5PkYGB5OYgz+ewckGr/T1UtVlZWGESvVIJMlKgSu2sIoLBkKLfIByqL0CooHYjOIWho0jIKFfeA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AEz387b4b6HZ3+B7AuoGOxTF7bkp89d5OJW0FC4bM52gw3WKhwWJeqiYXoTMHxpMjNoNIqhnZQ6KMcyHPSLZSbp4iohFAG+rYmopYbYwLrIfEyqeh10mBvILhFgkpGVPj2CpRoFk1jRbowhwDsgJA+qZSaWRE7Vt1jDlEDtkku0ZL7JN010aq2FrRI7GNFwLyYlxseIh72lTeO3Z6i4YlMkFHHdR8p09bg5FCu0JmqReaCHHXD7hSnf7HC3ga5VDS8NEkazIFE8NIbTF4Y3lbourxWKyg0Vvzwk+0mn28y/sGKLAbC1UDanXeryZnB8N6AnbYwqS4lSj8k+kAzC+KA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Harry Ramsey <Harry.Ramsey@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, Hari Limaye <Hari.Limaye@xxxxxxx>
  • Delivery-date: Fri, 13 Feb 2026 09:20:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHcnEZRjsHb6xYG00e+PVxLnB1X4LWAWuIA
  • Thread-topic: [PATCH 1/3] arm/mpu: implement setup_virt_paging for MPU system

Hi Ayan,

>>    void __init setup_virt_paging(void)
>>  {
>> -    BUG_ON("unimplemented");
>> +    uint64_t vtcr_el2 = READ_SYSREG(VTCR_EL2),
> 
> I think this register is redefined for R82 . See
> 
> https://developer.arm.com/documentation/102670/0301/AArch64-registers/AArch64-register-descriptions/AArch64-Generic-System-control-register-description/VTCR-EL2--Virtualization-Translation-Control-Register?lang=en
>  . So
> 
>>  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];
>> +
>> +    /*
>> +     * 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;
> 
> But the TRM says this
> 
> This bit behaves as 1 for all purposes other than reading back the value of 
> the bit when the value of AArch64-VSTCR_EL2.SA is 1.
> 
> So shouldn't we keep it as 1.
> 

The way I’m reading the armv8-r aarch64 reference manual [1] is that if we set
VSTCR_EL2.SA to 0, we need to clear also this one.


>> +
>> +    /*
>> +     * 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_NONE_SUPPORT )
>> +        goto fault;
>> +
>> +    /*
>> +     * cpuinfo sanitization makes sure we support 16bits VMID only if all 
>> cores
>> +     * are supporting it.
>> +     */
>> +    if ( system_cpuinfo.mm64.vmid_bits == MM64_VMID_16_BITS_SUPPORT )
>> +        max_vmid = MAX_VMID_16_BIT;
>> +
>> +    /* Set the VS bit only if 16 bit VMID is supported. */
>> +    if ( max_vmid == MAX_VMID_16_BIT )
>> +        vtcr_el2 |= VTCR_VS;
> this field does not exist.

yes this exists in armv8-r aarch64 [1]

>> 
>> +/* Not used on MPU system */
>>  static inline void p2m_clear_root_pages(struct p2m_domain *p2m) {}
>>    static inline void p2m_tlb_flush_sync(struct p2m_domain *p2m) {}
>> diff --git a/xen/arch/arm/include/asm/p2m.h b/xen/arch/arm/include/asm/p2m.h
>> index 010ce8c9eb..ed1b6dd40f 100644
>> --- a/xen/arch/arm/include/asm/p2m.h
>> +++ b/xen/arch/arm/include/asm/p2m.h
>> @@ -48,8 +48,13 @@ struct p2m_domain {
>>      /* Current VMID in use */
>>      uint16_t vmid;
>>  +#ifdef CONFIG_MMU
>>      /* Current Translation Table Base Register for the p2m */
>>      uint64_t vttbr;
>> +#else
>> +    /* Current Virtualization System Control Register for the p2m */
>> +    register_t vsctlr;
> This exist only for Arm64 MPU. Should we enclose this in ARM_64  ?

I can see it exists in armv8-r aarch32 [2].

Cheers,
Luca

[1] https://developer.arm.com/documentation/ddi0628/latest
[2] https://developer.arm.com/documentation/ddi0568/latest/



 


Rackspace

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