Message ID | 20210125105019.2946057-14-maz@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | arm64: Early CPU feature override, and applications to VHE, BTI and PAuth | expand |
On 1/25/21 10:50 AM, Marc Zyngier wrote: > 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> > --- > arch/arm64/include/asm/cpufeature.h | 2 ++ > arch/arm64/kernel/cpufeature.c | 5 ++++- > arch/arm64/kernel/idreg-override.c | 11 +++++++++++ > 3 files changed, 17 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h > index 4179cfc8ed57..b0ed37da4067 100644 > --- a/arch/arm64/include/asm/cpufeature.h > +++ b/arch/arm64/include/asm/cpufeature.h > @@ -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); > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index 4b84a1e1dc51..c1d6712c4249 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -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 id_aa64mmfr1_override; Does this need to be ro_after_init ? Otherwise, looks good to me: Acked-by: Suzuki K Poulose <suzuki.poulose@arm.com>
On 2021-01-25 13:15, Suzuki K Poulose wrote: > On 1/25/21 10:50 AM, Marc Zyngier wrote: >> 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> >> --- >> arch/arm64/include/asm/cpufeature.h | 2 ++ >> arch/arm64/kernel/cpufeature.c | 5 ++++- >> arch/arm64/kernel/idreg-override.c | 11 +++++++++++ >> 3 files changed, 17 insertions(+), 1 deletion(-) >> >> diff --git a/arch/arm64/include/asm/cpufeature.h >> b/arch/arm64/include/asm/cpufeature.h >> index 4179cfc8ed57..b0ed37da4067 100644 >> --- a/arch/arm64/include/asm/cpufeature.h >> +++ b/arch/arm64/include/asm/cpufeature.h >> @@ -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); >> diff --git a/arch/arm64/kernel/cpufeature.c >> b/arch/arm64/kernel/cpufeature.c >> index 4b84a1e1dc51..c1d6712c4249 100644 >> --- a/arch/arm64/kernel/cpufeature.c >> +++ b/arch/arm64/kernel/cpufeature.c >> @@ -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 id_aa64mmfr1_override; > > Does this need to be ro_after_init ? Could do, together with the other two override targeting system registers. > Otherwise, looks good to me: > > Acked-by: Suzuki K Poulose <suzuki.poulose@arm.com> Thanks, M.
On Mon, Jan 25, 2021 at 10:50:11AM +0000, Marc Zyngier wrote: > 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> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 4179cfc8ed57..b0ed37da4067 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -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); diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 4b84a1e1dc51..c1d6712c4249 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -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 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 */ diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c index 2d184d6674fd..489aa274e3ec 100644 --- a/arch/arm64/kernel/idreg-override.c +++ b/arch/arm64/kernel/idreg-override.c @@ -10,6 +10,7 @@ #include <linux/libfdt.h> #include <asm/cacheflush.h> +#include <asm/cpufeature.h> #include <asm/setup.h> struct ftr_set_desc { @@ -21,7 +22,17 @@ struct ftr_set_desc { } fields[]; }; +static const struct ftr_set_desc mmfr1 __initdata = { + .name = "id_aa64mmfr1", + .override = &id_aa64mmfr1_override, + .fields = { + { "vh", ID_AA64MMFR1_VHE_SHIFT }, + {} + }, +}; + static const struct ftr_set_desc * const regs[] __initdata = { + &mmfr1, }; static char *cmdline_contains_option(const char *cmdline, const char *option)