arm64: Allow ID_AA64MMFR1_EL1.VH to be overridden from the command line
authorMarc Zyngier <maz@kernel.org>
Mon, 8 Feb 2021 09:57:23 +0000 (09:57 +0000)
committerWill Deacon <will@kernel.org>
Tue, 9 Feb 2021 13:50:56 +0000 (13:50 +0000)
As we want to be able to disable VHE at runtime, let's match
"id_aa64mmfr1.vh=" from the command line as an override.
This doesn't have much effect yet as our boot code doesn't look
at the cpufeature, but only at the HW registers.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Acked-by: David Brazdil <dbrazdil@google.com>
Acked-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Link: https://lore.kernel.org/r/20210208095732.3267263-15-maz@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/include/asm/cpufeature.h
arch/arm64/kernel/cpufeature.c
arch/arm64/kernel/idreg-override.c

index b5bf7af..570f1b4 100644 (file)
@@ -818,6 +818,8 @@ static inline unsigned int get_vmid_bits(u64 mmfr1)
        return 8;
 }
 
+extern struct arm64_ftr_override id_aa64mmfr1_override;
+
 u32 get_kvm_ipa_limit(void);
 void dump_cpu_features(void);
 
index 97da9ed..faada5d 100644 (file)
@@ -557,6 +557,8 @@ static const struct arm64_ftr_bits ftr_raz[] = {
 
 #define ARM64_FTR_REG(id, table) ARM64_FTR_REG_OVERRIDE(id, table, &no_override)
 
+struct arm64_ftr_override __ro_after_init id_aa64mmfr1_override;
+
 static const struct __ftr_reg_entry {
        u32                     sys_id;
        struct arm64_ftr_reg    *reg;
@@ -604,7 +606,8 @@ static const struct __ftr_reg_entry {
 
        /* Op1 = 0, CRn = 0, CRm = 7 */
        ARM64_FTR_REG(SYS_ID_AA64MMFR0_EL1, ftr_id_aa64mmfr0),
-       ARM64_FTR_REG(SYS_ID_AA64MMFR1_EL1, ftr_id_aa64mmfr1),
+       ARM64_FTR_REG_OVERRIDE(SYS_ID_AA64MMFR1_EL1, ftr_id_aa64mmfr1,
+                              &id_aa64mmfr1_override),
        ARM64_FTR_REG(SYS_ID_AA64MMFR2_EL1, ftr_id_aa64mmfr2),
 
        /* Op1 = 0, CRn = 1, CRm = 2 */
index 3a347b4..2da11bf 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/libfdt.h>
 
 #include <asm/cacheflush.h>
+#include <asm/cpufeature.h>
 #include <asm/setup.h>
 
 #define FTR_DESC_NAME_LEN      20
@@ -25,7 +26,17 @@ struct ftr_set_desc {
        }                               fields[];
 };
 
+static const struct ftr_set_desc mmfr1 __initconst = {
+       .name           = "id_aa64mmfr1",
+       .override       = &id_aa64mmfr1_override,
+       .fields         = {
+               { "vh", ID_AA64MMFR1_VHE_SHIFT },
+               {}
+       },
+};
+
 static const struct ftr_set_desc * const regs[] __initconst = {
+       &mmfr1,
 };
 
 static int __init find_field(const char *cmdline,