[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,

On 10/07/2026 17:08, Halder, Ayan Kumar wrote:
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;
+
  void __init setup_virt_paging(void)
  {
      register_t vtcr_el2 = READ_SYSREG(VTCR_EL2);
@@ -58,6 +62,7 @@ void __init setup_virt_paging(void)
      else
          vtcr_el2 &= ~VTCR_VS;
+    vtcr = vtcr_el2;
      WRITE_SYSREG(vtcr_el2, VTCR_EL2);
      p2m_vmid_allocator_init();
@@ -89,6 +94,16 @@ void __init setup_virt_paging(void)
      panic("Hardware with no PMSAv8-64 support in any translation regime\n");
  }
+void p2m_save_vtcr(struct vcpu *p)
+{
+    p->arch.vtcr_el2 = READ_SYSREG(VTCR_EL2);
+}
+
VTCR_EL2 is an EL2 register the guest cannot touch, and set_v8r_vtcr_msa()
already fixes each vCPU's value at creation. Reading it back on every save is
redundant
I would at least consider adding an ASSERT() to confirm the two matches. This will catch any issues during debug build.

Cheers,

--
Julien Grall




 


Rackspace

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