Commit 1a6511eb authored by Marc Zyngier's avatar Marc Zyngier

KVM: arm64: Elide kern_hyp_va() in VHE-specific parts of the hypervisor

For VHE-specific hypervisor code, kern_hyp_va() is a NOP.

Actually, it is a whole range of NOPs. It'd be much better if
this code simply didn't exist. Let's just do that.
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230330174800.2677007-13-maz@kernel.org
parent 8a5eb2d2
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
* specific registers encoded in the instructions). * specific registers encoded in the instructions).
*/ */
.macro kern_hyp_va reg .macro kern_hyp_va reg
#ifndef __KVM_VHE_HYPERVISOR__
alternative_cb ARM64_ALWAYS_SYSTEM, kvm_update_va_mask alternative_cb ARM64_ALWAYS_SYSTEM, kvm_update_va_mask
and \reg, \reg, #1 /* mask with va_mask */ and \reg, \reg, #1 /* mask with va_mask */
ror \reg, \reg, #1 /* rotate to the first tag bit */ ror \reg, \reg, #1 /* rotate to the first tag bit */
...@@ -70,6 +71,7 @@ alternative_cb ARM64_ALWAYS_SYSTEM, kvm_update_va_mask ...@@ -70,6 +71,7 @@ alternative_cb ARM64_ALWAYS_SYSTEM, kvm_update_va_mask
add \reg, \reg, #0, lsl 12 /* insert the top 12 bits of the tag */ add \reg, \reg, #0, lsl 12 /* insert the top 12 bits of the tag */
ror \reg, \reg, #63 /* rotate back */ ror \reg, \reg, #63 /* rotate back */
alternative_cb_end alternative_cb_end
#endif
.endm .endm
/* /*
...@@ -127,6 +129,7 @@ void kvm_apply_hyp_relocations(void); ...@@ -127,6 +129,7 @@ void kvm_apply_hyp_relocations(void);
static __always_inline unsigned long __kern_hyp_va(unsigned long v) static __always_inline unsigned long __kern_hyp_va(unsigned long v)
{ {
#ifndef __KVM_VHE_HYPERVISOR__
asm volatile(ALTERNATIVE_CB("and %0, %0, #1\n" asm volatile(ALTERNATIVE_CB("and %0, %0, #1\n"
"ror %0, %0, #1\n" "ror %0, %0, #1\n"
"add %0, %0, #0\n" "add %0, %0, #0\n"
...@@ -135,6 +138,7 @@ static __always_inline unsigned long __kern_hyp_va(unsigned long v) ...@@ -135,6 +138,7 @@ static __always_inline unsigned long __kern_hyp_va(unsigned long v)
ARM64_ALWAYS_SYSTEM, ARM64_ALWAYS_SYSTEM,
kvm_update_va_mask) kvm_update_va_mask)
: "+r" (v)); : "+r" (v));
#endif
return v; return v;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment