Skip to content

Commit 69c31e6

Browse files
committed
x86/mm/cpa: Avoid static protection checks on unmap
If the new pgprot has the PRESENT bit cleared, then conflicts vs. RW/NX are completely irrelevant. Before: 1G pages checked: 2 1G pages sameprot: 0 1G pages preserved: 0 2M pages checked: 540 2M pages sameprot: 466 2M pages preserved: 47 4K pages checked: 800770 4K pages set-checked: 7668 After: 1G pages checked: 2 1G pages sameprot: 0 1G pages preserved: 0 2M pages checked: 540 2M pages sameprot: 466 2M pages preserved: 47 4K pages checked: 800709 4K pages set-checked: 7668 Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Dave Hansen <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Bin Yang <[email protected]> Cc: Mark Gross <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 5c280cf commit 69c31e6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

arch/x86/mm/pageattr.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long start,
526526
pgprotval_t forbidden, res;
527527
unsigned long end;
528528

529+
/*
530+
* There is no point in checking RW/NX conflicts when the requested
531+
* mapping is setting the page !PRESENT.
532+
*/
533+
if (!(pgprot_val(prot) & _PAGE_PRESENT))
534+
return prot;
535+
529536
/* Operate on the virtual address */
530537
end = start + npg * PAGE_SIZE - 1;
531538

0 commit comments

Comments
 (0)