Re: [RFC PATCH 4/4] x86/mm: write protect (most) page tables

From: Edgecombe, Rick P
Date: Mon Aug 23 2021 - 16:08:46 EST


On Mon, 2021-08-23 at 16:25 +0300, Mike Rapoport wrote:
> From: Mike Rapoport <rppt@xxxxxxxxxxxxx>
>
> Allocate page table using __GFP_PTE_MAPPED so that they will have 4K
> PTEs
> in the direct map. This allows to switch _PAGE_RW bit each time a
> page
> table page needs to be made writable or read-only.
>
> The writability of the page tables is toggled only in the lowest
> level page
> table modifiction functions and immediately switched off.
>
> The page tables created early in the boot (including the direct map
> page
> table) are not write protected.
>
> Co-developed-by: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>
> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>
> Signed-off-by: Mike Rapoport <rppt@xxxxxxxxxxxxx>
> ---
I have a second version of the PKS tables series that I think gets all
of them.

Also, I didn't see any flush anywhere when toggling. I guess the
spurious kernel fault handler is doing the work? It might be better to
just do a local flush of the address.