-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mm/core, x86/mm/pkeys: Add arch_validate_pkey()
The syscall-level code is passed a protection key and need to return an appropriate error code if the protection key is bogus. We will be using this in subsequent patches. Note that this also begins a series of arch-specific calls that we need to expose in otherwise arch-independent code. We create a linux/pkeys.h header where we will put *all* the stubs for these functions. 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]>
- Loading branch information
Showing
4 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef _ASM_X86_PKEYS_H | ||
#define _ASM_X86_PKEYS_H | ||
|
||
#define arch_max_pkey() (boot_cpu_has(X86_FEATURE_OSPKE) ? 16 : 1) | ||
|
||
#endif /*_ASM_X86_PKEYS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef _LINUX_PKEYS_H | ||
#define _LINUX_PKEYS_H | ||
|
||
#include <linux/mm_types.h> | ||
#include <asm/mmu_context.h> | ||
|
||
#ifdef CONFIG_ARCH_HAS_PKEYS | ||
#include <asm/pkeys.h> | ||
#else /* ! CONFIG_ARCH_HAS_PKEYS */ | ||
#define arch_max_pkey() (1) | ||
#endif /* ! CONFIG_ARCH_HAS_PKEYS */ | ||
|
||
/* | ||
* This is called from mprotect_pkey(). | ||
* | ||
* Returns true if the protection keys is valid. | ||
*/ | ||
static inline bool validate_pkey(int pkey) | ||
{ | ||
if (pkey < 0) | ||
return false; | ||
return (pkey < arch_max_pkey()); | ||
} | ||
|
||
#endif /* _LINUX_PKEYS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -672,3 +672,5 @@ config FRAME_VECTOR | |
|
||
config ARCH_USES_HIGH_VMA_FLAGS | ||
bool | ||
config ARCH_HAS_PKEYS | ||
bool |