[MODERATED] Re: [PATCH] NX build fixup

Josh Poimboeuf <[email protected]> Fri, 1 Nov 2019 11:31:50 -0500
Newsgroups org.kernel.lore.historical-speck
Message-ID <20191101163150.z7qlfwp6vai3ttp5@treble>
On Fri, Nov 01, 2019 at 03:43:31PM +0000, speck for Tyler Hicks wrote:
> From: Tyler Hicks <[email protected]>
> Subject: [PATCH] cpu/speculation: Uninline and export CPU mitigations helpers
> 
> A kernel module may need to check the value of the "mitigations=" kernel
> command line parameter as part of its setup when the module needs
> to perform software mitigations for a CPU flaw. Uninline and export the
> helper functions surrounding the cpu_mitigations enum to allow for their
> usage from a module.
> 
> Signed-off-by: Tyler Hicks <[email protected]>
> ---
> 
> Only compile tested, with both CONFIG_KVM=y and CONFIG_KVM=m. Paolo, if
> this looks good to you and Pawan, please include it in NX v9.
> 
>  include/linux/cpu.h | 13 ++-----------
>  kernel/cpu.c        | 14 ++++++++++++++
>  2 files changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/include/linux/cpu.h b/include/linux/cpu.h
> index 2a093434e975..f1965255526a 100644
> --- a/include/linux/cpu.h
> +++ b/include/linux/cpu.h
> @@ -230,16 +230,7 @@ enum cpu_mitigations {
>  
>  extern enum cpu_mitigations cpu_mitigations;
>  
> -/* mitigations=off */
> -static inline bool cpu_mitigations_off(void)
> -{
> -	return cpu_mitigations == CPU_MITIGATIONS_OFF;
> -}
> -
> -/* mitigations=auto,nosmt */
> -static inline bool cpu_mitigations_auto_nosmt(void)
> -{
> -	return cpu_mitigations == CPU_MITIGATIONS_AUTO_NOSMT;
> -}
> +extern bool cpu_mitigations_off(void);
> +extern bool cpu_mitigations_auto_nosmt(void);

You could probably also remove the "extern enum cpu_mitigations
cpu_mitigations" and just make it a static variable in kernel/cpu.c.

Same with the enum itself, it could be made private.

Or, as a completely different approach, cpu_mitigations could be
exported.  Then it's just a one-liner patch.  Either way works for me...

-- 
Josh