This commit introduces macros for switching and restoring the vttbr
considering the currently set irq flags. We define these macros, as the
following commits will use the associated functionality multiple times
throughout different files.
Signed-off-by: Sergej Proskurin
---
Cc: Stefano Stabellini
Cc: Julien Grall
---
v4: Save the content of VTTBR_EL2 inside of the introduced macro
"p2m_switch_vttbr_and_get_flags".
Move the introduced macros into ./xen/include/asm-arm/p2m.h, as they will
be used by different files in the future commits.
---
xen/arch/arm/p2m.c| 15 ++-
xen/include/asm-arm/p2m.h | 21 +
2 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index c484469e6c..4334e3bc81 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -147,22 +147,11 @@ static void p2m_flush_tlb(struct p2m_domain *p2m)
* ARM only provides an instruction to flush TLBs for the current
* VMID. So switch to the VTTBR of a given P2M if different.
*/
-ovttbr = READ_SYSREG64(VTTBR_EL2);
-if ( ovttbr != p2m->vttbr )
-{
-local_irq_save(flags);
-WRITE_SYSREG64(p2m->vttbr, VTTBR_EL2);
-isb();
-}
+p2m_switch_vttbr_and_get_flags(ovttbr, p2m->vttbr, flags);
flush_tlb();
-if ( ovttbr != READ_SYSREG64(VTTBR_EL2) )
-{
-WRITE_SYSREG64(ovttbr, VTTBR_EL2);
-isb();
-local_irq_restore(flags);
-}
+p2m_restore_vttbr_and_set_flags(ovttbr, flags);
}
/*
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index aa0d60ae3a..500dc88fbc 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -12,6 +12,27 @@
#define paddr_bits PADDR_BITS
+#define p2m_switch_vttbr_and_get_flags(ovttbr, nvttbr, flags) \
+({ \
+ ovttbr = READ_SYSREG64(VTTBR_EL2); \
+ if ( ovttbr != nvttbr )\
+ { \
+local_irq_save(flags); \
+WRITE_SYSREG64(nvttbr, VTTBR_EL2); \
+isb(); \
+ } \
+})
+
+#define p2m_restore_vttbr_and_set_flags(ovttbr, flags) \
+({ \
+ if ( ovttbr != READ_SYSREG64(VTTBR_EL2) ) \
+ { \
+WRITE_SYSREG64(ovttbr, VTTBR_EL2); \
+isb(); \
+local_irq_restore(flags); \
+ } \
+})
+
/* Holds the bit size of IPAs in p2m tables. */
extern unsigned int p2m_ipa_bits;
--
2.13.3
___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel