xen: arm: let the compiler choose the dummy register for TLB flush asm
PATCH 1/1 xen: arm: let the compiler choose the dummy register for TLB flush asm
While staring at some disassembly I noticed that the compiler was jumping through hoops to preserve the function argument (in r0) simply so it could use r0 as the dummy argument to the tlb flush cp register writes.
Remove the enforced use of r0 and use an output constraint for the dummy register so there is no need to initialise the dummy.
--- xen/include/asm-arm/arm32/page.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
xen/include/asm-arm/arm32/page.h +4 -4
@@ -35,7 +35,7 @@ static inline void write_pte(lpae_t *p, lpae_t pte)*/ static inline void flush_xen_text_tlb (void ) { - registerunsigned long r0 asm ("r0" ); +unsigned long dummy; asmvolatile ("isb;" /* Ensure synchronization with previous changes to text */ STORE_CP32(0, TLBIALLH) /* Flush hypervisor TLB */
@@ -43,7 +43,7 @@ static inline void flush_xen_text_tlb(void) STORE_CP32(0, BPIALL) /* Flush branch predictor */ "dsb;" /* Ensure completion of TLB+BP flush */ "isb;" - : : "r" (r0) /*dummy*/ : "memory"); + : "=r" (dummy) : : "memory"); }/*
@@ -52,12 +52,12 @@ static inline void flush_xen_text_tlb(void)*/ static inline void flush_xen_data_tlb (void ) { - registerunsigned long r0 asm ("r0" ); +unsigned long dummy; asmvolatile ("dsb;" /* Ensure preceding are visible */ STORE_CP32(0, TLBIALLH) "dsb;" /* Ensure completion of the TLB flush */ "isb;" - : : "r" (r0) /* dummy */: "memory"); + : "=r" (dummy) : : "memory"); }/*
Signature · 1 line
1.7.2.5
Quoted 6 lines · Ian Campbell
While staring at some disassembly I noticed that the compiler was jumping through hoops to preserve the function argument (in r0) simply so it could use r0 as the dummy argument to the tlb flush cp register writes.
Remove the enforced use of r0 and use an output constraint for the dummy register so there is no need to initialise the dummy.
Since we don't care about the register's contents and it's not changed, can we just drop the variable and constraint entirely?
Tim.
Quoted 45 lines
Signed-off-by Ian Campbell <[email protected]>--- xen/include/asm-arm/arm32/page.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)xen/include/asm-arm/arm32/page.h +4
-4@@ -35,7 +35,7 @@ static inline void write_pte(lpae_t *p, lpae_t pte)*/ static inline void flush_xen_text_tlb (void ) { - registerunsigned long r0 asm ("r0" ); +unsigned long dummy; asmvolatile ("isb;" /* Ensure synchronization with previous changes to text */ STORE_CP32(0, TLBIALLH) /* Flush hypervisor TLB */@@ -43,7 +43,7 @@ static inline void flush_xen_text_tlb(void) STORE_CP32(0, BPIALL) /* Flush branch predictor */ "dsb;" /* Ensure completion of TLB+BP flush */ "isb;" - : : "r" (r0) /*dummy*/ : "memory"); + : "=r" (dummy) : : "memory"); }/* @@ -52,12 +52,12 @@ static inline void flush_xen_text_tlb(void)*/ static inline void flush_xen_data_tlb (void ) { - registerunsigned long r0 asm ("r0" ); +unsigned long dummy; asmvolatile ("dsb;" /* Ensure preceding are visible */ STORE_CP32(0, TLBIALLH) "dsb;" /* Ensure completion of the TLB flush */ "isb;" - : : "r" (r0) /* dummy */: "memory"); + : "=r" (dummy) : : "memory"); }/* Signature · 1 line
1.7.2.5
Quoted 10 lines · Tim Deegan
Quoted 6 lines · Ian Campbell
While staring at some disassembly I noticed that the compiler was jumping through hoops to preserve the function argument (in r0) simply so it could use r0 as the dummy argument to the tlb flush cp register writes.
Remove the enforced use of r0 and use an output constraint for the dummy register so there is no need to initialise the dummy.
Since we don't care about the register's contents and it's not changed, can we just drop the variable and constraint entirely?
and just hard code the r0? I hadn't though of that, I suppose we could yes.
Ian.
Quoted 6 lines · Ian Campbell
Quoted 5 lines · Tim Deegan
Quoted 4 lines · Ian Campbell
While staring at some disassembly I noticed that the compiler was jumping through hoops to preserve the function argument (in r0) simply so it could use r0 as the dummy argument to the tlb flush cp register writes.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Remove the enforced use of r0 and use an output constraint for the dummy register so there is no need to initialise the dummy.
Since we don't care about the register's contents and it's not changed, can we just drop the variable and constraint entirely?
and just hard code the r0? I hadn't though of that, I suppose we could yes.
Scuppered because our clever STORE_CP32 macros add % to their argument. I don't really want to change those macros, I suppose I could add DUMMY_CP32 which just takes a name and inputs a dummy reigster.
Ian