Re: [tip: x86/mm] x86/mm: Clear _PAGE_DIRTY when we clear _PAGE_RW

From: Matthew Wilcox
Date: Tue Feb 25 2025 - 23:00:55 EST


On Tue, Feb 25, 2025 at 07:31:01PM -0800, Linus Torvalds wrote:
> > I don't understand why the dirty bit needs to be saved. At least in
> > the vfree() case, we're freeing the memory so any unflushed writes to
> > it may as well disappear. But I don't know all the circumstances in
> > which these functions are called.
>
> I'm not saying that it needs to be saved.
>
> But I *am* saying that it needs to be explained why dropping it is fine.
>
> And I am also saying that your explanation for why it should be
> cleared makes no sense, since two out of three cases also cleared
> _PAGE_PRESENT, at which point the whole shadow stack issue is
> completely irrelevant.
>
> So please explain *why* clearing PAGE_DIRTY is ok. Don't bring up
> issues like the shadow stack setting that is irrelevant for at least
> two of the cases that you changed.
>
> If all of these are purely used for vmalloc() or direct mappings, then
> *that* is a valid explanation ("we don't care about dirty bits on
> kernel mappings"), for example.

I think the entire point of this file is to manipulate kernel mappings.