Re: [tip:x86/pti] module/retpoline: Warn about missing retpoline in module

From: Randy Dunlap
Date: Fri Jan 26 2018 - 12:51:55 EST


On 01/26/2018 06:59 AM, tip-bot for Andi Kleen wrote:
> Commit-ID: caf7501a1b4ec964190f31f9c3f163de252273b8
> Gitweb: https://git.kernel.org/tip/caf7501a1b4ec964190f31f9c3f163de252273b8
> Author: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> AuthorDate: Thu, 25 Jan 2018 15:50:28 -0800
> Committer: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> CommitDate: Fri, 26 Jan 2018 15:03:56 +0100
>
> module/retpoline: Warn about missing retpoline in module


> diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
> index 390b3dc..4a39d7b 100644
> --- a/arch/x86/kernel/cpu/bugs.c
> +++ b/arch/x86/kernel/cpu/bugs.c
> @@ -11,6 +11,7 @@
> #include <linux/init.h>
> #include <linux/utsname.h>
> #include <linux/cpu.h>
> +#include <linux/module.h>
>
> #include <asm/nospec-branch.h>
> #include <asm/cmdline.h>
> @@ -93,6 +94,19 @@ static const char *spectre_v2_strings[] = {
> #define pr_fmt(fmt) "Spectre V2 mitigation: " fmt
>
> static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE;
> +static bool spectre_v2_bad_module;
> +
> +#ifdef RETPOLINE
> +bool retpoline_module_ok(bool has_retpoline)
> +{
> + if (spectre_v2_enabled == SPECTRE_V2_NONE || has_retpoline)
> + return true;
> +
> + pr_err("System may be vunerable to spectre v2\n");

vulnerable

> + spectre_v2_bad_module = true;
> + return false;
> +}
> +#endif



--
~Randy