Skip to content

Commit 57e784b

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Remove alternatives from sysreg accessors in VHE hypervisor context
In the VHE hypervisor code, we should be using the remapped VHE accessors, no ifs, no buts. No need to generate any alternative. Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230609162200.2024064-9-maz@kernel.org Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 659803a commit 57e784b

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

arch/arm64/include/asm/kvm_hyp.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@ DECLARE_PER_CPU(struct kvm_cpu_context, kvm_hyp_ctxt);
1616
DECLARE_PER_CPU(unsigned long, kvm_hyp_vector);
1717
DECLARE_PER_CPU(struct kvm_nvhe_init_params, kvm_init_params);
1818

19+
/*
20+
* Unified accessors for registers that have a different encoding
21+
* between VHE and non-VHE. They must be specified without their "ELx"
22+
* encoding, but with the SYS_ prefix, as defined in asm/sysreg.h.
23+
*/
24+
25+
#if defined(__KVM_VHE_HYPERVISOR__)
26+
27+
#define read_sysreg_el0(r) read_sysreg_s(r##_EL02)
28+
#define write_sysreg_el0(v,r) write_sysreg_s(v, r##_EL02)
29+
#define read_sysreg_el1(r) read_sysreg_s(r##_EL12)
30+
#define write_sysreg_el1(v,r) write_sysreg_s(v, r##_EL12)
31+
#define read_sysreg_el2(r) read_sysreg_s(r##_EL1)
32+
#define write_sysreg_el2(v,r) write_sysreg_s(v, r##_EL1)
33+
34+
#else // !__KVM_VHE_HYPERVISOR__
35+
1936
#define read_sysreg_elx(r,nvh,vh) \
2037
({ \
2138
u64 reg; \
@@ -35,19 +52,15 @@ DECLARE_PER_CPU(struct kvm_nvhe_init_params, kvm_init_params);
3552
: : "rZ" (__val)); \
3653
} while (0)
3754

38-
/*
39-
* Unified accessors for registers that have a different encoding
40-
* between VHE and non-VHE. They must be specified without their "ELx"
41-
* encoding, but with the SYS_ prefix, as defined in asm/sysreg.h.
42-
*/
43-
4455
#define read_sysreg_el0(r) read_sysreg_elx(r, _EL0, _EL02)
4556
#define write_sysreg_el0(v,r) write_sysreg_elx(v, r, _EL0, _EL02)
4657
#define read_sysreg_el1(r) read_sysreg_elx(r, _EL1, _EL12)
4758
#define write_sysreg_el1(v,r) write_sysreg_elx(v, r, _EL1, _EL12)
4859
#define read_sysreg_el2(r) read_sysreg_elx(r, _EL2, _EL1)
4960
#define write_sysreg_el2(v,r) write_sysreg_elx(v, r, _EL2, _EL1)
5061

62+
#endif // __KVM_VHE_HYPERVISOR__
63+
5164
/*
5265
* Without an __arch_swab32(), we fall back to ___constant_swab32(), but the
5366
* static inline can allow the compiler to out-of-line this. KVM always wants

0 commit comments

Comments
 (0)