Re: [patch 1/2] x86,module: Detect VMX modules and disable Split-Lock-Detect

From: Jessica Yu
Date: Fri Apr 03 2020 - 14:35:23 EST


+++ Peter Zijlstra [03/04/20 18:41 +0200]:
On Fri, Apr 03, 2020 at 09:36:05AM -0700, Sean Christopherson wrote:
On Thu, Apr 02, 2020 at 02:32:59PM +0200, Thomas Gleixner wrote:
> --- a/arch/x86/kernel/module.c
> +++ b/arch/x86/kernel/module.c
> @@ -24,6 +24,7 @@
> #include <asm/pgtable.h>
> #include <asm/setup.h>
> #include <asm/unwind.h>
> +#include <asm/cpu.h>
>
> #if 0
> #define DEBUGP(fmt, ...) \
> @@ -253,6 +254,11 @@ int module_finalize(const Elf_Ehdr *hdr,
> tseg, tseg + text->sh_size);
> }
>
> + if (text && !me->sld_safe) {

As also reported by the test bot, sld_safe only exist if CPU_SUP_INTEL=y.

This can also be conditioned on boot_cpu_has(X86_FEATURE_VMX), or the
static variant. If CPU_SUP_INTEL=y, X86_FEATURE_VMX will be set if and
only if VMX is fully enabled, i.e. supported by the CPU and enabled in
MSR_IA32_FEATURE_CONTROl.

> + void *tseg = (void *)text->sh_addr;
> + split_lock_validate_module_text(me, tseg, tseg + text->sh_size);
> + }

Ideally we push it all into arch code, but load_info isn't exposed to
arch module code :/.

Hm, I can look into exposing load_info to arch module code and will
post a patch on Monday.

Jessica