On 10/3/22 11:11, Nadav Amit wrote: >> +#ifdef CONFIG_X86_SHADOW_STACK >> + /* >> + * Avoid accidentally creating shadow stack PTEs >> + * (Write=0,Dirty=1). Use cmpxchg() to prevent races with >> + * the hardware setting Dirty=1. >> + */ >> + if (cpu_feature_enabled(X86_FEATURE_SHSTK)) { >> + pte_t old_pte, new_pte; >> + >> + old_pte = READ_ONCE(*ptep); >> + do { >> + new_pte = pte_wrprotect(old_pte); >> + } while (!try_cmpxchg(&ptep->pte, &old_pte.pte, new_pte.pte)); >> + >> + return; >> + } >> +#endif > There is no way of using IS_ENABLED() here instead of these ifdefs? Actually, both the existing #ifdef and an IS_ENABLED() check would be is superfluous as-is. Adding X86_FEATURE_SHSTK disabled-features.h gives cpu_feature_enabled() compile-time optimizations for free. No need for *any* additional CONFIG_* checks. The only issue would be if the #ifdef'd code won't even compile with X86_FEATURE_SHSTK disabled.