Skip to content

Commit b3ecd51

Browse files
hansendcIngo Molnar
authored andcommitted
x86/mm/pkeys: Add new 'PF_PK' page fault error code bit
Note: "PK" is how the Intel SDM refers to this bit, so we also use that nomenclature. This only defines the bit, it does not plumb it anywhere to be handled. Signed-off-by: Dave Hansen <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 5c1d90f commit b3ecd51

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/x86/mm/fault.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
* bit 2 == 0: kernel-mode access 1: user-mode access
3434
* bit 3 == 1: use of reserved bit detected
3535
* bit 4 == 1: fault was an instruction fetch
36+
* bit 5 == 1: protection keys block access
3637
*/
3738
enum x86_pf_error_code {
3839

@@ -41,6 +42,7 @@ enum x86_pf_error_code {
4142
PF_USER = 1 << 2,
4243
PF_RSVD = 1 << 3,
4344
PF_INSTR = 1 << 4,
45+
PF_PK = 1 << 5,
4446
};
4547

4648
/*
@@ -916,6 +918,12 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
916918

917919
if ((error_code & PF_INSTR) && !pte_exec(*pte))
918920
return 0;
921+
/*
922+
* Note: We do not do lazy flushing on protection key
923+
* changes, so no spurious fault will ever set PF_PK.
924+
*/
925+
if ((error_code & PF_PK))
926+
return 1;
919927

920928
return 1;
921929
}

0 commit comments

Comments
 (0)