refactor: move tlbi macros to mmu header
For cleanliness, move tlbi / tlbi_reg macros from aarch64 mm.c to mmu.h.
Use tlbi macro in invalidate_vm_tlb.
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Change-Id: I8b4ba6e11358d73095768ab5b9aa80c95569492a
diff --git a/src/arch/aarch64/hypervisor/handler.c b/src/arch/aarch64/hypervisor/handler.c
index 0d38365..f38c571 100644
--- a/src/arch/aarch64/hypervisor/handler.c
+++ b/src/arch/aarch64/hypervisor/handler.c
@@ -164,7 +164,7 @@
*/
isb();
- __asm__ volatile("tlbi vmalle1");
+ tlbi(vmalle1);
/*
* Ensure that no instructions are fetched for the VM until after the
diff --git a/src/arch/aarch64/inc/hf/arch/mmu.h b/src/arch/aarch64/inc/hf/arch/mmu.h
index 8c45cdb..d6eb366 100644
--- a/src/arch/aarch64/inc/hf/arch/mmu.h
+++ b/src/arch/aarch64/inc/hf/arch/mmu.h
@@ -15,3 +15,12 @@
/** Page mapping mode for tagged normal memory. */
#define MM_MODE_T UINT32_C(0x0400)
+
+#define tlbi(op) \
+ do { \
+ __asm__ volatile("tlbi " #op); \
+ } while (0)
+#define tlbi_reg(op, reg) \
+ do { \
+ __asm__ __volatile__("tlbi " #op ", %0" : : "r"(reg)); \
+ } while (0)
diff --git a/src/arch/aarch64/mm.c b/src/arch/aarch64/mm.c
index db911ef..3ec6e97 100644
--- a/src/arch/aarch64/mm.c
+++ b/src/arch/aarch64/mm.c
@@ -111,15 +111,6 @@
/* clang-format on */
-#define tlbi(op) \
- do { \
- __asm__ volatile("tlbi " #op); \
- } while (0)
-#define tlbi_reg(op, reg) \
- do { \
- __asm__ __volatile__("tlbi " #op ", %0" : : "r"(reg)); \
- } while (0)
-
/** Mask for the address bits of the pte. */
#define PTE_ADDR_MASK \
(((UINT64_C(1) << 48) - 1) & ~((UINT64_C(1) << PAGE_BITS) - 1))