Re: [patch V3 41/66] x86/cpu: Sanitize X86_FEATURE_OSPKE

From: Borislav Petkov
Date: Tue Jun 22 2021 - 10:16:00 EST


On Fri, Jun 18, 2021 at 04:19:04PM +0200, Thomas Gleixner wrote:
> X86_FEATURE_OSPKE is enabled first on the boot CPU and the feature flag is
> set. Secondary CPUs have to enable CR4.PKE as well and set their per CPU
> feature flag. That's ineffective because all call sites have checks for
> boot_cpu_data.
>
> Make it smarter and force the feature flag when PKU is enabled on the boot
> cpu which allows then to use cpu_feature_enabled(X86_FEATURE_OSPKE) all
> over the place. That either compiles the code out when PKEY support is
> disabled in Kconfig or uses a static_cpu_has() for the feature check which
> makes a significant difference in hotpathes, e.g. context switch.

"hotpaths"

>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> ---
> arch/x86/include/asm/pkeys.h | 8 ++++----
> arch/x86/include/asm/pkru.h | 4 ++--
> arch/x86/kernel/cpu/common.c | 24 +++++++++++-------------
> arch/x86/kernel/fpu/core.c | 2 +-
> arch/x86/kernel/fpu/xstate.c | 2 +-
> arch/x86/kernel/process_64.c | 2 +-
> arch/x86/mm/fault.c | 2 +-
> 7 files changed, 21 insertions(+), 23 deletions(-)

Other than that:

Reviewed-by: Borislav Petkov <bp@xxxxxxx>

--
Regards/Gruss,
Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg