lkml.org 
[lkml]   [2022]   [Jun]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 03/19] x86/cpufeatures: Enable CET CR4 bit for shadow stack
On Thu, Jun 16, 2022 at 04:46:27AM -0400, Yang Weijiang wrote:

> static __always_inline void setup_cet(struct cpuinfo_x86 *c)
> {
> + bool kernel_ibt = HAS_KERNEL_IBT && cpu_feature_enabled(X86_FEATURE_IBT);
> u64 msr = CET_ENDBR_EN;
>
> + if (kernel_ibt)
> + wrmsrl(MSR_IA32_S_CET, msr);
>
> + if (kernel_ibt || cpu_feature_enabled(X86_FEATURE_SHSTK))
> + cr4_set_bits(X86_CR4_CET);

Does flipping the CR4 and S_CET MSR write not result in simpler code?

>
> + if (kernel_ibt && !ibt_selftest()) {
> pr_err("IBT selftest: Failed!\n");
> setup_clear_cpu_cap(X86_FEATURE_IBT);

Looking at this error path; I think I forgot to clear S_CET here.

> return;
> }
> }

\
 
 \ /
  Last update: 2022-06-16 12:27    [W:1.291 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site