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

Re: [PATCH 8/8] arm/mpu: Save/restore VTCR_EL2 on vCPU context switch



Hi Luca,

On 20/04/2026 15:25, Luca Fancellu wrote:
On AArch64 MPU systems, the VTCR register contains the MSA bit that determines
if the guest is using MPU or MMU at EL1, which is required to be
saved/restored on vCPU context switch.

On AArch64 MPU systems the VTCR_EL2 register configuration will be saved
during setup_virt_paging and will be placed in a new member of
'struct arch_vcpu' named vtcr_el2, to be retrieved by context switch.

AArch32 MPU systems and MMU systems don't need to save/restore this
register because they don't have any MSA bit and related functionality,
so for these architecture a stub is provided.

Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
---
  xen/arch/arm/arm64/mpu/p2m.c                | 15 +++++++++++++++
  xen/arch/arm/domain.c                       |  2 ++
  xen/arch/arm/include/asm/domain.h           |  5 +++++
  xen/arch/arm/include/asm/mmu/domain-build.h |  2 ++
  xen/arch/arm/include/asm/mpu/domain-build.h |  6 ++++++
  xen/arch/arm/include/asm/mpu/p2m.h          | 10 ++++++++++
  xen/arch/arm/mpu/domain-build.c             | 17 +++++++++++++++++
  xen/arch/arm/mpu/p2m.c                      |  4 ++++
  8 files changed, 61 insertions(+)

diff --git a/xen/arch/arm/arm64/mpu/p2m.c b/xen/arch/arm/arm64/mpu/p2m.c
index a1ec9fcd6195..350cbd7ae94c 100644
--- a/xen/arch/arm/arm64/mpu/p2m.c
+++ b/xen/arch/arm/arm64/mpu/p2m.c
@@ -3,8 +3,12 @@
  #include <xen/bug.h>
  #include <xen/init.h>
  #include <xen/lib.h>
+#include <xen/sched.h>
  #include <asm/p2m.h>
+/* VTCR_EL2 value to be configured for the boot CPU. */
+register_t __read_mostly vtcr;

You don't seem to use it. Is it necessary? But the name of the global variable is a bit too generic. If we want one, it ought to be "boot_vtcr". Also doesn't this need to be writeable after boot? If not, it should be called "boot_vtcr".

Cheers,

--
Julien Grall




 


Rackspace

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