lkml.org 
[lkml]   [2022]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v2 10/39] x86/mm: Introduce _PAGE_COW
Date
On Fri, 2022-10-14 at 11:42 +0200, Peter Zijlstra wrote:
> On Thu, Sep 29, 2022 at 03:29:07PM -0700, Rick Edgecombe wrote:
> > @@ -300,6 +324,44 @@ static inline pte_t pte_clear_flags(pte_t pte,
> > pteval_t clear)
> > return native_make_pte(v & ~clear);
> > }
> >
> > +/*
> > + * Normally the Dirty bit is used to denote COW memory on x86. But
>
> This is misleading; this isn't an x86 specific thing. The core-mm
> code
> does this.

Well pte_mkdirty() does map to other HW bits on different
architectures. But yea, it's confusing.

Hmm, is this comment a bit stale either way now though? In the past it
was probably more accurate to say core MM code used it to "detect"
cowed memory. But the GUP pte_dirty() check was changed recently:


https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5535be3099717646781ce1540cf725965d680e7b

I don't think any code is looking specifically for COWed memory using
the PTE dirty bit anymore, it just happens to coincide with it. Double
checking my understanding...

Maybe this would be more accurate?

/*
* Normally COW memory can result in Dirty=1,Write=0 PTEs. But in the
* case of X86_FEATURE_SHSTK, the software COW bit is used, since the
* Dirty=1,Write=0 will result in the memory being treated as shaodw
* stack by the HW. So when creating COW memory, a software bit is used
* _PAGE_BIT_COW. The following functions pte_mkcow() and
* pte_clear_cow() take a PTE marked conventially COW (Dirty=1) and
* transition it to the shadow stack compatible version of COW (Cow=1).
*/
\
 
 \ /
  Last update: 2022-10-14 20:06    [W:0.284 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site