Re: [PATCH v21 08/26] x86/mm: Introduce _PAGE_COW

2021-03-03 Thread Borislav Petkov
On Tue, Mar 02, 2021 at 03:46:31PM -0800, Yu, Yu-cheng wrote: > There is a problem of doing that: pmd_write() is defined after this > function. Maybe we can declare it first, or leave this as-is? Or a third option: you lift those two functions in a prepatch and then in this patch use them directl

Re: [PATCH v21 08/26] x86/mm: Introduce _PAGE_COW

2021-03-03 Thread Yu, Yu-cheng
On 3/1/2021 7:52 AM, Borislav Petkov wrote: On Wed, Feb 17, 2021 at 02:27:12PM -0800, Yu-cheng Yu wrote: [...] 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

Re: [PATCH v21 08/26] x86/mm: Introduce _PAGE_COW

2021-03-01 Thread Yu, Yu-cheng
On 3/1/2021 7:52 AM, Borislav Petkov wrote: 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:

Re: [PATCH v21 08/26] x86/mm: Introduce _PAGE_COW

2021-03-01 Thread Borislav Petkov
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 ar

[PATCH v21 08/26] x86/mm: Introduce _PAGE_COW

2021-02-17 Thread Yu-cheng Yu
There is essentially no room left in the x86 hardware PTEs on some OSes (not Linux). That left the hardware architects looking for a way to represent a new memory type (shadow stack) within the existing bits. They chose to repurpose a lightly-used state: Write=0, Dirty=1. The reason it's lightly