diff options
author | Peter Zijlstra <peterz@infradead.org> | 2022-10-29 13:19:31 +0200 |
---|---|---|
committer | Dave Hansen <dave.hansen@linux.intel.com> | 2022-12-15 10:37:27 -0800 |
commit | 60463628c9e0a8060ac6bef0457b0505c7532c7c (patch) | |
tree | 7a55e6d4605579ac147d5e41fc3777d1ddcc2cd5 /arch/x86/mm | |
parent | d48567c9a0d1e605639f8a8705a61bbb55fb4e84 (diff) | |
download | linux-stable-60463628c9e0a8060ac6bef0457b0505c7532c7c.tar.gz linux-stable-60463628c9e0a8060ac6bef0457b0505c7532c7c.tar.bz2 linux-stable-60463628c9e0a8060ac6bef0457b0505c7532c7c.zip |
x86/mm: Implement native set_memory_rox()
Provide a native implementation of set_memory_rox(), avoiding the
double set_memory_ro();set_memory_x(); calls.
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Diffstat (limited to 'arch/x86/mm')
-rw-r--r-- | arch/x86/mm/pat/set_memory.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index 97342c42dda8..f275605892df 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -2025,6 +2025,16 @@ int set_memory_ro(unsigned long addr, int numpages) return change_page_attr_clear(&addr, numpages, __pgprot(_PAGE_RW), 0); } +int set_memory_rox(unsigned long addr, int numpages) +{ + pgprot_t clr = __pgprot(_PAGE_RW); + + if (__supported_pte_mask & _PAGE_NX) + clr.pgprot |= _PAGE_NX; + + return change_page_attr_clear(&addr, numpages, clr, 0); +} + int set_memory_rw(unsigned long addr, int numpages) { return change_page_attr_set(&addr, numpages, __pgprot(_PAGE_RW), 0); |