Skip to content

Commit 53b6711

Browse files
David BrazdilMarc Zyngier
authored andcommitted
KVM: arm64: Use build-time defines in has_vhe()
Build system compiles hyp code with macros specifying if the code belongs to VHE or nVHE. Use these macros to evaluate has_vhe() at compile time. Signed-off-by: David Brazdil <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7621712 commit 53b6711

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

arch/arm64/include/asm/virt.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,17 @@ static inline bool is_kernel_in_hyp_mode(void)
8585

8686
static __always_inline bool has_vhe(void)
8787
{
88-
if (cpus_have_final_cap(ARM64_HAS_VIRT_HOST_EXTN))
88+
/*
89+
* The following macros are defined for code specic to VHE/nVHE.
90+
* If has_vhe() is inlined into those compilation units, it can
91+
* be determined statically. Otherwise fall back to caps.
92+
*/
93+
if (__is_defined(__KVM_VHE_HYPERVISOR__))
8994
return true;
90-
91-
return false;
95+
else if (__is_defined(__KVM_NVHE_HYPERVISOR__))
96+
return false;
97+
else
98+
return cpus_have_final_cap(ARM64_HAS_VIRT_HOST_EXTN);
9299
}
93100

94101
#endif /* __ASSEMBLY__ */

0 commit comments

Comments
 (0)