Messages in this thread | | | Date | Thu, 9 Feb 2023 15:08:39 +0100 | From | Borislav Petkov <> | Subject | Re: [PATCH v5 11/39] x86/mm: Update pte_modify for _PAGE_COW |
| |
On Thu, Jan 19, 2023 at 01:22:49PM -0800, Rick Edgecombe wrote: > From: Yu-cheng Yu <yu-cheng.yu@intel.com> > > The Write=0,Dirty=1 PTE has been used to indicate copy-on-write pages. > However, newer x86 processors also regard a Write=0,Dirty=1 PTE as a > shadow stack page. In order to separate the two, the software-defined > _PAGE_DIRTY is changed to _PAGE_COW for the copy-on-write case, and > pte_*() are updated to do this.
"In order to separate the two, change the software-defined ..."
From section "2) Describe your changes" in Documentation/process/submitting-patches.rst:
"Describe your changes in imperative mood, e.g. "make xyzzy do frotz" instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy to do frotz", as if you are giving orders to the codebase to change its behaviour."
> +static inline pte_t __pte_mkdirty(pte_t pte, bool soft) > +{ > + pteval_t dirty = _PAGE_DIRTY; > + > + if (soft) > + dirty |= _PAGE_SOFT_DIRTY; > + > + return pte_set_flags(pte, dirty); > +}
Dunno, do you even need that __pte_mkdirty() helper?
AFAIU, pte_mkdirty() will always set _PAGE_SOFT_DIRTY too so whatever the __pte_mkdirty() thing needs to do, you can simply do it by foot in the two callsites.
And this way you won't have the confusion: should I use pte_mkdirty() or __pte_mkdirty()?
Ditto for the pmd variants.
Otherwise, this is starting to make more sense now.
Thx.
-- Regards/Gruss, Boris.
https://people.kernel.org/tglx/notes-about-netiquette
| |