Re: [PATCH v2 12/39] x86/mm: Update ptep_set_wrprotect() and pmdp_set_wrprotect() for transition from _PAGE_DIRTY to _PAGE_COW

From: Nadav Amit
Date: Mon Oct 03 2022 - 20:40:47 EST


On Oct 3, 2022, at 4:38 PM, Edgecombe, Rick P <rick.p.edgecombe@xxxxxxxxx> wrote:

> I think the HW dirty bit will not be set here. How it works is,
> pte_mkdirty() will not actually set the HW dirty bit, but instead the
> software COW bit. Here is the relevant snippet:
>
> static inline pte_t pte_mkdirty(pte_t pte)
> {
> pteval_t dirty = _PAGE_DIRTY;
>
> /* Avoid creating Dirty=1,Write=0 PTEs */
> if (cpu_feature_enabled(X86_FEATURE_SHSTK) && !pte_write(pte))
> dirty = _PAGE_COW;
>
> return pte_set_flags(pte, dirty | _PAGE_SOFT_DIRTY);
> }
>
> So for a !VM_WRITE vma, you end up with Write=0,Cow=1 PTE passed
> into ptep_set_access_flags(). Does it make sense?

Thanks for your patience with me. I should have read the series in order.