Message ID | 20210118094533.2874082-16-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 Mon, Jan 18, 2021 at 09:45:27AM +0000, Marc Zyngier wrote: > In order to map the override of idregs to options that a user > can easily understand, let's introduce yet another option > array, which maps an option to the corresponding idreg options. > > Signed-off-by: Marc Zyngier <maz@kernel.org> Acked-by: David Brazdil <dbrazdil@google.com> > --- > arch/arm64/kernel/idreg-override.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c > index 75d9845f489b..16bc8b3b93ae 100644 > --- a/arch/arm64/kernel/idreg-override.c > +++ b/arch/arm64/kernel/idreg-override.c > @@ -37,6 +37,12 @@ static const struct reg_desc * const regs[] __initdata = { > &mmfr1, > }; > > +static const struct { > + const char * const alias; > + const char * const feature; > +} aliases[] __initdata = { > +}; > + > static int __init find_field(const char *cmdline, const struct reg_desc *reg, > int f, u64 *v) > { > @@ -80,6 +86,18 @@ static void __init match_options(const char *cmdline) > } > } > > +static __init void match_aliases(const char *cmdline) > +{ > + int i; > + > + for (i = 0; i < ARRAY_SIZE(aliases); i++) { > + char *str = strstr(cmdline, aliases[i].alias); > + > + if ((str == cmdline || (str > cmdline && *(str - 1) == ' '))) nit: Extract to a 'cmdline_contains' helper? Took me a good few seconds to parse this in the previous patch. Giving it a name would help, and now it's also shared. > + match_options(aliases[i].feature); > + } > +} > + > static __init void parse_cmdline(void) > { > if (!IS_ENABLED(CONFIG_CMDLINE_FORCE)) { > @@ -100,6 +118,7 @@ static __init void parse_cmdline(void) > goto out; > > match_options(prop); > + match_aliases(prop); > > if (!IS_ENABLED(CONFIG_CMDLINE_EXTEND)) > return; > @@ -107,6 +126,7 @@ static __init void parse_cmdline(void) > > out: > match_options(CONFIG_CMDLINE); > + match_aliases(CONFIG_CMDLINE); > } > > void __init init_shadow_regs(void) > -- > 2.29.2 >
On Mon, Jan 18, 2021 at 09:45:27AM +0000, Marc Zyngier wrote: > diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c > index 75d9845f489b..16bc8b3b93ae 100644 > --- a/arch/arm64/kernel/idreg-override.c > +++ b/arch/arm64/kernel/idreg-override.c > @@ -37,6 +37,12 @@ static const struct reg_desc * const regs[] __initdata = { > &mmfr1, > }; > > +static const struct { > + const char * const alias; > + const char * const feature; > +} aliases[] __initdata = { > +}; As before, do we need the second 'const' for alias and feature? The aliases array is already a const. Otherwise, Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
On Mon, 18 Jan 2021 13:18:39 +0000, David Brazdil <dbrazdil@google.com> wrote: > > On Mon, Jan 18, 2021 at 09:45:27AM +0000, Marc Zyngier wrote: > > In order to map the override of idregs to options that a user > > can easily understand, let's introduce yet another option > > array, which maps an option to the corresponding idreg options. > > > > Signed-off-by: Marc Zyngier <maz@kernel.org> > Acked-by: David Brazdil <dbrazdil@google.com> > > > --- > > arch/arm64/kernel/idreg-override.c | 20 ++++++++++++++++++++ > > 1 file changed, 20 insertions(+) > > > > diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c > > index 75d9845f489b..16bc8b3b93ae 100644 > > --- a/arch/arm64/kernel/idreg-override.c > > +++ b/arch/arm64/kernel/idreg-override.c > > @@ -37,6 +37,12 @@ static const struct reg_desc * const regs[] __initdata = { > > &mmfr1, > > }; > > > > +static const struct { > > + const char * const alias; > > + const char * const feature; > > +} aliases[] __initdata = { > > +}; > > + > > static int __init find_field(const char *cmdline, const struct reg_desc *reg, > > int f, u64 *v) > > { > > @@ -80,6 +86,18 @@ static void __init match_options(const char *cmdline) > > } > > } > > > > +static __init void match_aliases(const char *cmdline) > > +{ > > + int i; > > + > > + for (i = 0; i < ARRAY_SIZE(aliases); i++) { > > + char *str = strstr(cmdline, aliases[i].alias); > > + > > + if ((str == cmdline || (str > cmdline && *(str - 1) == ' '))) > > nit: Extract to a 'cmdline_contains' helper? Took me a good few seconds to > parse this in the previous patch. Giving it a name would help, and now it's > also shared. Good point. Adopted! Thanks, M.
diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c index 75d9845f489b..16bc8b3b93ae 100644 --- a/arch/arm64/kernel/idreg-override.c +++ b/arch/arm64/kernel/idreg-override.c @@ -37,6 +37,12 @@ static const struct reg_desc * const regs[] __initdata = { &mmfr1, }; +static const struct { + const char * const alias; + const char * const feature; +} aliases[] __initdata = { +}; + static int __init find_field(const char *cmdline, const struct reg_desc *reg, int f, u64 *v) { @@ -80,6 +86,18 @@ static void __init match_options(const char *cmdline) } } +static __init void match_aliases(const char *cmdline) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(aliases); i++) { + char *str = strstr(cmdline, aliases[i].alias); + + if ((str == cmdline || (str > cmdline && *(str - 1) == ' '))) + match_options(aliases[i].feature); + } +} + static __init void parse_cmdline(void) { if (!IS_ENABLED(CONFIG_CMDLINE_FORCE)) { @@ -100,6 +118,7 @@ static __init void parse_cmdline(void) goto out; match_options(prop); + match_aliases(prop); if (!IS_ENABLED(CONFIG_CMDLINE_EXTEND)) return; @@ -107,6 +126,7 @@ static __init void parse_cmdline(void) out: match_options(CONFIG_CMDLINE); + match_aliases(CONFIG_CMDLINE); } void __init init_shadow_regs(void)
In order to map the override of idregs to options that a user can easily understand, let's introduce yet another option array, which maps an option to the corresponding idreg options. Signed-off-by: Marc Zyngier <maz@kernel.org> --- arch/arm64/kernel/idreg-override.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)