]> Git Repo - linux.git/commitdiff
KVM: arm64: Factor out is_{vhe,nvhe}_hyp_code()
authorMark Rutland <[email protected]>
Mon, 26 Oct 2020 13:49:29 +0000 (13:49 +0000)
committerMarc Zyngier <[email protected]>
Fri, 30 Oct 2020 08:52:51 +0000 (08:52 +0000)
Currently has_vhe() detects whether it is being compiled for VHE/NVHE
hyp code based on preprocessor definitions, and uses this knowledge to
avoid redundant runtime checks.

There are other cases where we'd like to use this knowledge, so let's
factor the preprocessor checks out into separate helpers.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
Acked-by: Will Deacon <[email protected]>
Cc: David Brazdil <[email protected]>
Cc: Marc Zyngier <[email protected]>
Cc: Will Deacon <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
arch/arm64/include/asm/virt.h

index 09977acc007d1562c53ad74c6d0da3d32558a1cd..300be14ba77b211129081a6ee0816b11ab4e6da0 100644 (file)
@@ -83,16 +83,27 @@ static inline bool is_kernel_in_hyp_mode(void)
        return read_sysreg(CurrentEL) == CurrentEL_EL2;
 }
 
+static __always_inline bool is_vhe_hyp_code(void)
+{
+       /* Only defined for code run in VHE hyp context */
+       return __is_defined(__KVM_VHE_HYPERVISOR__);
+}
+
+static __always_inline bool is_nvhe_hyp_code(void)
+{
+       /* Only defined for code run in NVHE hyp context */
+       return __is_defined(__KVM_NVHE_HYPERVISOR__);
+}
+
 static __always_inline bool has_vhe(void)
 {
        /*
-        * The following macros are defined for code specic to VHE/nVHE.
-        * If has_vhe() is inlined into those compilation units, it can
-        * be determined statically. Otherwise fall back to caps.
+        * Code only run in VHE/NVHE hyp context can assume VHE is present or
+        * absent. Otherwise fall back to caps.
         */
-       if (__is_defined(__KVM_VHE_HYPERVISOR__))
+       if (is_vhe_hyp_code())
                return true;
-       else if (__is_defined(__KVM_NVHE_HYPERVISOR__))
+       else if (is_nvhe_hyp_code())
                return false;
        else
                return cpus_have_final_cap(ARM64_HAS_VIRT_HOST_EXTN);
This page took 0.05553 seconds and 4 git commands to generate.