[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <023ee88b-1f23-acb6-9ac6-c75afbcb09d9@intel.com>
Date: Mon, 3 Oct 2022 11:51:15 -0700
From: Dave Hansen <dave.hansen@...el.com>
To: Nadav Amit <nadav.amit@...il.com>,
Rick Edgecombe <rick.p.edgecombe@...el.com>
Cc: X86 ML <x86@...nel.org>, "H . Peter Anvin" <hpa@...or.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
LKML <linux-kernel@...r.kernel.org>, linux-doc@...r.kernel.org,
Linux MM <linux-mm@...ck.org>,
linux-arch <linux-arch@...r.kernel.org>,
linux-api@...r.kernel.org, Arnd Bergmann <arnd@...db.de>,
Andy Lutomirski <luto@...nel.org>,
Balbir Singh <bsingharora@...il.com>,
Borislav Petkov <bp@...en8.de>,
Cyrill Gorcunov <gorcunov@...il.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Eugene Syromiatnikov <esyr@...hat.com>,
Florian Weimer <fweimer@...hat.com>,
"H . J . Lu" <hjl.tools@...il.com>, Jann Horn <jannh@...gle.com>,
Jonathan Corbet <corbet@....net>,
Kees Cook <keescook@...omium.org>,
Mike Kravetz <mike.kravetz@...cle.com>,
Oleg Nesterov <oleg@...hat.com>, Pavel Machek <pavel@....cz>,
Peter Zijlstra <peterz@...radead.org>,
Randy Dunlap <rdunlap@...radead.org>,
"Ravi V . Shankar" <ravi.v.shankar@...el.com>,
Weijiang Yang <weijiang.yang@...el.com>,
"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
joao.moreira@...el.com, John Allen <john.allen@....com>,
kcc@...gle.com, eranian@...gle.com,
Mike Rapoport <rppt@...nel.org>, jamorris@...ux.microsoft.com,
dethoma@...rosoft.com, Yu-cheng Yu <yu-cheng.yu@...el.com>
Subject: Re: [PATCH v2 12/39] x86/mm: Update ptep_set_wrprotect() and
pmdp_set_wrprotect() for transition from _PAGE_DIRTY to _PAGE_COW
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.
Powered by blists - more mailing lists