Skip to content

Commit 6f617d3

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Key use of VHE instructions in nVHE code off ARM64_KVM_HVHE
We can now start with the fun stuff: if we enable VHE *only* for the hypervisor, we need to generate the VHE instructions when accessing the system registers. For this, reporpose the alternative sequence to be keyed off ARM64_KVM_HVHE in the nVHE hypervisor code, and only there. Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230609162200.2024064-10-maz@kernel.org Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 57e784b commit 6f617d3

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

arch/arm64/include/asm/kvm_hyp.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,18 @@ DECLARE_PER_CPU(struct kvm_nvhe_init_params, kvm_init_params);
3333

3434
#else // !__KVM_VHE_HYPERVISOR__
3535

36+
#if defined(__KVM_NVHE_HYPERVISOR__)
37+
#define VHE_ALT_KEY ARM64_KVM_HVHE
38+
#else
39+
#define VHE_ALT_KEY ARM64_HAS_VIRT_HOST_EXTN
40+
#endif
41+
3642
#define read_sysreg_elx(r,nvh,vh) \
3743
({ \
3844
u64 reg; \
39-
asm volatile(ALTERNATIVE(__mrs_s("%0", r##nvh), \
45+
asm volatile(ALTERNATIVE(__mrs_s("%0", r##nvh), \
4046
__mrs_s("%0", r##vh), \
41-
ARM64_HAS_VIRT_HOST_EXTN) \
47+
VHE_ALT_KEY) \
4248
: "=r" (reg)); \
4349
reg; \
4450
})
@@ -48,7 +54,7 @@ DECLARE_PER_CPU(struct kvm_nvhe_init_params, kvm_init_params);
4854
u64 __val = (u64)(v); \
4955
asm volatile(ALTERNATIVE(__msr_s(r##nvh, "%x0"), \
5056
__msr_s(r##vh, "%x0"), \
51-
ARM64_HAS_VIRT_HOST_EXTN) \
57+
VHE_ALT_KEY) \
5258
: : "rZ" (__val)); \
5359
} while (0)
5460

0 commit comments

Comments
 (0)