[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210301155234.GF6699@zn.tnic>
Date: Mon, 1 Mar 2021 16:52:34 +0100
From: Borislav Petkov <bp@...en8.de>
To: Yu-cheng Yu <yu-cheng.yu@...el.com>
Cc: x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org, linux-mm@...ck.org,
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>,
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>,
Nadav Amit <nadav.amit@...il.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>,
Vedvyas Shanbhogue <vedvyas.shanbhogue@...el.com>,
Dave Martin <Dave.Martin@....com>,
Weijiang Yang <weijiang.yang@...el.com>,
Pengfei Xu <pengfei.xu@...el.com>,
Haitao Huang <haitao.huang@...el.com>
Subject: Re: [PATCH v21 08/26] x86/mm: Introduce _PAGE_COW
On Wed, Feb 17, 2021 at 02:27:12PM -0800, Yu-cheng Yu wrote:
> @@ -182,7 +206,7 @@ static inline int pud_young(pud_t pud)
>
> static inline int pte_write(pte_t pte)
> {
> - return pte_flags(pte) & _PAGE_RW;
Put here a comment along the lines of:
/*
* Shadow stack pages are always writable - but not by normal
* instructions but only by shadow stack operations. Therefore, the
* W=0, D=1 test.
*/
to make it clear what this means.
> + return (pte_flags(pte) & _PAGE_RW) || pte_shstk(pte);
> }
>
> static inline int pte_huge(pte_t pte)
> @@ -314,6 +338,24 @@ static inline pte_t pte_clear_flags(pte_t pte, pteval_t clear)
> return native_make_pte(v & ~clear);
> }
>
> +static inline pte_t pte_make_cow(pte_t pte)
pte_mkcow like the rest of the "pte_mkX" functions.
And below too, for the other newly added pXd_make_* helpers.
> static inline pmd_t pmd_mkdirty(pmd_t pmd)
> {
> - return pmd_set_flags(pmd, _PAGE_DIRTY | _PAGE_SOFT_DIRTY);
> + pmdval_t dirty = _PAGE_DIRTY;
> +
> + /* Avoid creating (HW)Dirty=1, Write=0 PMDs */
> + if (cpu_feature_enabled(X86_FEATURE_SHSTK) && !(pmd_flags(pmd) & _PAGE_RW))
!(pmd_write(pmd))
> + dirty = _PAGE_COW;
> +
> + return pmd_set_flags(pmd, dirty | _PAGE_SOFT_DIRTY);
> +}
...
> static inline pud_t pud_mkdirty(pud_t pud)
> {
> - return pud_set_flags(pud, _PAGE_DIRTY | _PAGE_SOFT_DIRTY);
> + pudval_t dirty = _PAGE_DIRTY;
> +
> + /* Avoid creating (HW)Dirty=1, Write=0 PUDs */
> + if (cpu_feature_enabled(X86_FEATURE_SHSTK) && !(pud_flags(pud) & _PAGE_RW))
!(pud_write(pud))
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists