arm64: Add ARM64_HAS_VIRT_HOST_EXTN feature
authorMarc Zyngier <marc.zyngier@arm.com>
Thu, 29 Jan 2015 11:24:05 +0000 (11:24 +0000)
committerAlex Shi <alex.shi@linaro.org>
Wed, 9 Nov 2016 14:15:48 +0000 (22:15 +0800)
Add a new ARM64_HAS_VIRT_HOST_EXTN features to indicate that the
CPU has the ARMv8.1 VHE capability.

This will be used to trigger kernel patching in KVM.

Acked-by: Christoffer Dall <christoffer.dall@linaro.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
(cherry picked from commit d88701bea3664cea99b8b7380f63a3bd0ec3ead3)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
Conflicts:
arch/arm64/include/asm/cpufeature.h

arch/arm64/include/asm/cpufeature.h
arch/arm64/kernel/cpufeature.c

index 8136afc9df0d7c3ce4db25fe814c8ebd270fc30d..f1a134900ae5779dfacef0d0ec1bd5e9fbd34dca 100644 (file)
 #define ARM64_WORKAROUND_834220                        7
 #define ARM64_WORKAROUND_CAVIUM_27456          8
 
-#define ARM64_NCAPS                            9
+/* #define ARM64_HAS_NO_HW_PREFETCH            8 */
+/* #define ARM64_HAS_UAO                       9 */
+/* #define ARM64_ALT_PAN_NOT_UAO               10 */
+#define ARM64_HAS_VIRT_HOST_EXTN               11
+
+#define ARM64_NCAPS                            12
 
 #ifndef __ASSEMBLY__
 
index 0669c63281ea01a93ef9794f9731b424b6afd28e..ab68e7c9808d1c6e7168f38749f39e543b759394 100644 (file)
@@ -26,6 +26,7 @@
 #include <asm/cpu_ops.h>
 #include <asm/processor.h>
 #include <asm/sysreg.h>
+#include <asm/virt.h>
 
 unsigned long elf_hwcap __read_mostly;
 EXPORT_SYMBOL_GPL(elf_hwcap);
@@ -621,6 +622,11 @@ static bool has_useable_gicv3_cpuif(const struct arm64_cpu_capabilities *entry)
        return has_sre;
 }
 
+static bool runs_at_el2(const struct arm64_cpu_capabilities *entry)
+{
+       return is_kernel_in_hyp_mode();
+}
+
 static const struct arm64_cpu_capabilities arm64_features[] = {
        {
                .desc = "GIC system register CPU interface",
@@ -651,6 +657,11 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
                .min_field_value = 2,
        },
 #endif /* CONFIG_AS_LSE && CONFIG_ARM64_LSE_ATOMICS */
+       {
+               .desc = "Virtualization Host Extensions",
+               .capability = ARM64_HAS_VIRT_HOST_EXTN,
+               .matches = runs_at_el2,
+       },
        {},
 };