Re: [PATCH 3/7] x86/cpu: Disable kernel LASS when patching kernel alternatives

From: Chen, Yian
Date: Wed Jan 11 2023 - 19:28:04 EST




On 1/10/2023 2:41 PM, Sohil Mehta wrote:
On 1/9/2023 9:52 PM, Yian Chen wrote:

LASS stops access to a lower half address in kernel,
and this can be deactivated if AC bit in EFLAGS
register is set. Hence use stac and clac instructions
around access to the address to avoid triggering a
LASS #GP fault.


It seems we are implicitly relying on the on stac() and clac() calls that are added for SMAP. Have you tried running with SMAP disabled  i.e "clearcpuid=smap"?

Yes, I tested with clearcpuid=smap.

I believe there needs to be a dependency between LASS and SMAP.

Yes, In kernel mode, LASS depends on SMAP to work. And in user mode, it doesn't, so the dependency description in following may miss user space effect.

diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c
index d95221117129..00bc7e4a65d2 100644
--- a/arch/x86/kernel/cpu/cpuid-deps.c
+++ b/arch/x86/kernel/cpu/cpuid-deps.c
@@ -79,6 +79,7 @@ static const struct cpuid_dep cpuid_deps[] = {
     { X86_FEATURE_XFD,            X86_FEATURE_XSAVES    },
     { X86_FEATURE_XFD,            X86_FEATURE_XGETBV1   },
     { X86_FEATURE_AMX_TILE,            X86_FEATURE_XFD       },
+    { X86_FEATURE_LASS,            X86_FEATURE_SMAP      },
     {}
 };

Thanks,
Yian