From: Andrew Morton <akpm@linux-foundation.org> To: akpm@linux-foundation.org, aneesh.kumar@linux.ibm.com, bauerman@linux.ibm.com, dave.hansen@intel.com, desnesn@linux.vnet.ibm.com, fweimer@redhat.com, linux-mm@kvack.org, linuxram@us.ibm.com, mhocko@kernel.org, mingo@kernel.org, mm-commits@vger.kernel.org, mpe@ellerman.id.au, msuchanek@suse.de, sandipan@linux.ibm.com, shuah@kernel.org, torvalds@linux-foundation.org Subject: [patch 105/127] selftests/vm/pkeys: move some definitions to arch-specific header Date: Thu, 04 Jun 2020 16:51:44 -0700 [thread overview] Message-ID: <20200604235144.hi-isoxfB%akpm@linux-foundation.org> (raw) In-Reply-To: <20200604164523.e15f3177f4b69dcb4f2534a1@linux-foundation.org> From: Thiago Jung Bauermann <bauerman@linux.ibm.com> Subject: selftests/vm/pkeys: move some definitions to arch-specific header In preparation for multi-arch support, move definitions which have arch-specific values to x86-specific header. Link: http://lkml.kernel.org/r/d58eba2930059c8b209eefd6d5b48fe922a5b010.1585646528.git.sandipan@linux.ibm.com Acked-by: Dave Hansen <dave.hansen@intel.com> Signed-off-by: Ram Pai <linuxram@us.ibm.com> Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com> Signed-off-by: Sandipan Das <sandipan@linux.ibm.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Florian Weimer <fweimer@redhat.com> Cc: "Desnes A. Nunes do Rosario" <desnesn@linux.vnet.ibm.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Hocko <mhocko@kernel.org> Cc: Michal Suchanek <msuchanek@suse.de> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- tools/testing/selftests/vm/pkey-helpers.h | 111 ------------ tools/testing/selftests/vm/pkey-x86.h | 156 +++++++++++++++++ tools/testing/selftests/vm/protection_keys.c | 47 ----- 3 files changed, 162 insertions(+), 152 deletions(-) --- a/tools/testing/selftests/vm/pkey-helpers.h~selftests-vm-pkeys-move-some-definitions-to-arch-specific-header +++ a/tools/testing/selftests/vm/pkey-helpers.h @@ -21,9 +21,6 @@ #define PTR_ERR_ENOTSUP ((void *)-ENOTSUP) -#define NR_PKEYS 16 -#define PKEY_BITS_PER_PKEY 2 - #ifndef DEBUG_LEVEL #define DEBUG_LEVEL 0 #endif @@ -73,19 +70,13 @@ extern void abort_hooks(void); } \ } while (0) +#if defined(__i386__) || defined(__x86_64__) /* arch */ +#include "pkey-x86.h" +#else /* arch */ +#error Architecture not supported +#endif /* arch */ + extern unsigned int shadow_pkey_reg; -static inline unsigned int __read_pkey_reg(void) -{ - unsigned int eax, edx; - unsigned int ecx = 0; - unsigned int pkey_reg; - - asm volatile(".byte 0x0f,0x01,0xee\n\t" - : "=a" (eax), "=d" (edx) - : "c" (ecx)); - pkey_reg = eax; - return pkey_reg; -} static inline unsigned int _read_pkey_reg(int line) { @@ -100,19 +91,6 @@ static inline unsigned int _read_pkey_re #define read_pkey_reg() _read_pkey_reg(__LINE__) -static inline void __write_pkey_reg(unsigned int pkey_reg) -{ - unsigned int eax = pkey_reg; - unsigned int ecx = 0; - unsigned int edx = 0; - - dprintf4("%s() changing %08x to %08x\n", __func__, - __read_pkey_reg(), pkey_reg); - asm volatile(".byte 0x0f,0x01,0xef\n\t" - : : "a" (eax), "c" (ecx), "d" (edx)); - assert(pkey_reg == __read_pkey_reg()); -} - static inline void write_pkey_reg(unsigned int pkey_reg) { dprintf4("%s() changing %08x to %08x\n", __func__, @@ -157,83 +135,6 @@ static inline void __pkey_write_allow(in dprintf4("pkey_reg now: %08x\n", read_pkey_reg()); } -#define PAGE_SIZE 4096 -#define MB (1<<20) - -static inline void __cpuid(unsigned int *eax, unsigned int *ebx, - unsigned int *ecx, unsigned int *edx) -{ - /* ecx is often an input as well as an output. */ - asm volatile( - "cpuid;" - : "=a" (*eax), - "=b" (*ebx), - "=c" (*ecx), - "=d" (*edx) - : "0" (*eax), "2" (*ecx)); -} - -/* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx) */ -#define X86_FEATURE_PKU (1<<3) /* Protection Keys for Userspace */ -#define X86_FEATURE_OSPKE (1<<4) /* OS Protection Keys Enable */ - -static inline int cpu_has_pku(void) -{ - unsigned int eax; - unsigned int ebx; - unsigned int ecx; - unsigned int edx; - - eax = 0x7; - ecx = 0x0; - __cpuid(&eax, &ebx, &ecx, &edx); - - if (!(ecx & X86_FEATURE_PKU)) { - dprintf2("cpu does not have PKU\n"); - return 0; - } - if (!(ecx & X86_FEATURE_OSPKE)) { - dprintf2("cpu does not have OSPKE\n"); - return 0; - } - return 1; -} - -#define XSTATE_PKEY_BIT (9) -#define XSTATE_PKEY 0x200 - -int pkey_reg_xstate_offset(void) -{ - unsigned int eax; - unsigned int ebx; - unsigned int ecx; - unsigned int edx; - int xstate_offset; - int xstate_size; - unsigned long XSTATE_CPUID = 0xd; - int leaf; - - /* assume that XSTATE_PKEY is set in XCR0 */ - leaf = XSTATE_PKEY_BIT; - { - eax = XSTATE_CPUID; - ecx = leaf; - __cpuid(&eax, &ebx, &ecx, &edx); - - if (leaf == XSTATE_PKEY_BIT) { - xstate_offset = ebx; - xstate_size = eax; - } - } - - if (xstate_size == 0) { - printf("could not find size/offset of PKEY in xsave state\n"); - return 0; - } - - return xstate_offset; -} - #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) #define ALIGN_UP(x, align_to) (((x) + ((align_to)-1)) & ~((align_to)-1)) #define ALIGN_DOWN(x, align_to) ((x) & ~((align_to)-1)) --- /dev/null +++ a/tools/testing/selftests/vm/pkey-x86.h @@ -0,0 +1,156 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _PKEYS_X86_H +#define _PKEYS_X86_H + +#ifdef __i386__ + +#ifndef SYS_mprotect_key +# define SYS_mprotect_key 380 +#endif + +#ifndef SYS_pkey_alloc +# define SYS_pkey_alloc 381 +# define SYS_pkey_free 382 +#endif + +#define REG_IP_IDX REG_EIP +#define si_pkey_offset 0x14 + +#else + +#ifndef SYS_mprotect_key +# define SYS_mprotect_key 329 +#endif + +#ifndef SYS_pkey_alloc +# define SYS_pkey_alloc 330 +# define SYS_pkey_free 331 +#endif + +#define REG_IP_IDX REG_RIP +#define si_pkey_offset 0x20 + +#endif + +#ifndef PKEY_DISABLE_ACCESS +# define PKEY_DISABLE_ACCESS 0x1 +#endif + +#ifndef PKEY_DISABLE_WRITE +# define PKEY_DISABLE_WRITE 0x2 +#endif + +#define NR_PKEYS 16 +#define PKEY_BITS_PER_PKEY 2 +#define HPAGE_SIZE (1UL<<21) +#define PAGE_SIZE 4096 +#define MB (1<<20) + +static inline void __page_o_noops(void) +{ + /* 8-bytes of instruction * 512 bytes = 1 page */ + asm(".rept 512 ; nopl 0x7eeeeeee(%eax) ; .endr"); +} + +static inline unsigned int __read_pkey_reg(void) +{ + unsigned int eax, edx; + unsigned int ecx = 0; + unsigned int pkey_reg; + + asm volatile(".byte 0x0f,0x01,0xee\n\t" + : "=a" (eax), "=d" (edx) + : "c" (ecx)); + pkey_reg = eax; + return pkey_reg; +} + +static inline void __write_pkey_reg(unsigned int pkey_reg) +{ + unsigned int eax = pkey_reg; + unsigned int ecx = 0; + unsigned int edx = 0; + + dprintf4("%s() changing %08x to %08x\n", __func__, + __read_pkey_reg(), pkey_reg); + asm volatile(".byte 0x0f,0x01,0xef\n\t" + : : "a" (eax), "c" (ecx), "d" (edx)); + assert(pkey_reg == __read_pkey_reg()); +} + +static inline void __cpuid(unsigned int *eax, unsigned int *ebx, + unsigned int *ecx, unsigned int *edx) +{ + /* ecx is often an input as well as an output. */ + asm volatile( + "cpuid;" + : "=a" (*eax), + "=b" (*ebx), + "=c" (*ecx), + "=d" (*edx) + : "0" (*eax), "2" (*ecx)); +} + +/* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx) */ +#define X86_FEATURE_PKU (1<<3) /* Protection Keys for Userspace */ +#define X86_FEATURE_OSPKE (1<<4) /* OS Protection Keys Enable */ + +static inline int cpu_has_pku(void) +{ + unsigned int eax; + unsigned int ebx; + unsigned int ecx; + unsigned int edx; + + eax = 0x7; + ecx = 0x0; + __cpuid(&eax, &ebx, &ecx, &edx); + + if (!(ecx & X86_FEATURE_PKU)) { + dprintf2("cpu does not have PKU\n"); + return 0; + } + if (!(ecx & X86_FEATURE_OSPKE)) { + dprintf2("cpu does not have OSPKE\n"); + return 0; + } + return 1; +} + +#define XSTATE_PKEY_BIT (9) +#define XSTATE_PKEY 0x200 + +int pkey_reg_xstate_offset(void) +{ + unsigned int eax; + unsigned int ebx; + unsigned int ecx; + unsigned int edx; + int xstate_offset; + int xstate_size; + unsigned long XSTATE_CPUID = 0xd; + int leaf; + + /* assume that XSTATE_PKEY is set in XCR0 */ + leaf = XSTATE_PKEY_BIT; + { + eax = XSTATE_CPUID; + ecx = leaf; + __cpuid(&eax, &ebx, &ecx, &edx); + + if (leaf == XSTATE_PKEY_BIT) { + xstate_offset = ebx; + xstate_size = eax; + } + } + + if (xstate_size == 0) { + printf("could not find size/offset of PKEY in xsave state\n"); + return 0; + } + + return xstate_offset; +} + +#endif /* _PKEYS_X86_H */ --- a/tools/testing/selftests/vm/protection_keys.c~selftests-vm-pkeys-move-some-definitions-to-arch-specific-header +++ a/tools/testing/selftests/vm/protection_keys.c @@ -49,9 +49,6 @@ int iteration_nr = 1; int test_nr; unsigned int shadow_pkey_reg; - -#define HPAGE_SIZE (1UL<<21) - int dprint_in_signal; char dprint_in_signal_buffer[DPRINT_IN_SIGNAL_BUF_SIZE]; @@ -137,12 +134,6 @@ void abort_hooks(void) #endif } -static inline void __page_o_noops(void) -{ - /* 8-bytes of instruction * 512 bytes = 1 page */ - asm(".rept 512 ; nopl 0x7eeeeeee(%eax) ; .endr"); -} - /* * This attempts to have roughly a page of instructions followed by a few * instructions that do a write, and another page of instructions. That @@ -165,36 +156,6 @@ void lots_o_noops_around_write(int *writ dprintf3("%s() done\n", __func__); } -#ifdef __i386__ - -#ifndef SYS_mprotect_key -# define SYS_mprotect_key 380 -#endif - -#ifndef SYS_pkey_alloc -# define SYS_pkey_alloc 381 -# define SYS_pkey_free 382 -#endif - -#define REG_IP_IDX REG_EIP -#define si_pkey_offset 0x14 - -#else - -#ifndef SYS_mprotect_key -# define SYS_mprotect_key 329 -#endif - -#ifndef SYS_pkey_alloc -# define SYS_pkey_alloc 330 -# define SYS_pkey_free 331 -#endif - -#define REG_IP_IDX REG_RIP -#define si_pkey_offset 0x20 - -#endif - void dump_mem(void *dumpme, int len_bytes) { char *c = (void *)dumpme; @@ -367,14 +328,6 @@ pid_t fork_lazy_child(void) return forkret; } -#ifndef PKEY_DISABLE_ACCESS -# define PKEY_DISABLE_ACCESS 0x1 -#endif - -#ifndef PKEY_DISABLE_WRITE -# define PKEY_DISABLE_WRITE 0x2 -#endif
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org> To: akpm@linux-foundation.org, aneesh.kumar@linux.ibm.com, bauerman@linux.ibm.com, dave.hansen@intel.com, desnesn@linux.vnet.ibm.com, fweimer@redhat.com, linux-mm@kvack.org, linuxram@us.ibm.com, mhocko@kernel.org, mingo@kernel.org, mm-commits@vger.kernel.org, mpe@ellerman.id.au, msuchanek@suse.de, sandipan@linux.ibm.com, shuah@kernel.org, torvalds@linux-foundation.org Subject: [patch 105/127] selftests/vm/pkeys: move some definitions to arch-specific header Date: Thu, 04 Jun 2020 16:51:44 -0700 [thread overview] Message-ID: <20200604235144.hi-isoxfB%akpm@linux-foundation.org> (raw) In-Reply-To: <20200604164523.e15f3177f4b69dcb4f2534a1@linux-foundation.org> From: Thiago Jung Bauermann <bauerman@linux.ibm.com> Subject: selftests/vm/pkeys: move some definitions to arch-specific header In preparation for multi-arch support, move definitions which have arch-specific values to x86-specific header. Link: http://lkml.kernel.org/r/d58eba2930059c8b209eefd6d5b48fe922a5b010.1585646528.git.sandipan@linux.ibm.com Acked-by: Dave Hansen <dave.hansen@intel.com> Signed-off-by: Ram Pai <linuxram@us.ibm.com> Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com> Signed-off-by: Sandipan Das <sandipan@linux.ibm.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Florian Weimer <fweimer@redhat.com> Cc: "Desnes A. Nunes do Rosario" <desnesn@linux.vnet.ibm.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Hocko <mhocko@kernel.org> Cc: Michal Suchanek <msuchanek@suse.de> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- tools/testing/selftests/vm/pkey-helpers.h | 111 ------------ tools/testing/selftests/vm/pkey-x86.h | 156 +++++++++++++++++ tools/testing/selftests/vm/protection_keys.c | 47 ----- 3 files changed, 162 insertions(+), 152 deletions(-) --- a/tools/testing/selftests/vm/pkey-helpers.h~selftests-vm-pkeys-move-some-definitions-to-arch-specific-header +++ a/tools/testing/selftests/vm/pkey-helpers.h @@ -21,9 +21,6 @@ #define PTR_ERR_ENOTSUP ((void *)-ENOTSUP) -#define NR_PKEYS 16 -#define PKEY_BITS_PER_PKEY 2 - #ifndef DEBUG_LEVEL #define DEBUG_LEVEL 0 #endif @@ -73,19 +70,13 @@ extern void abort_hooks(void); } \ } while (0) +#if defined(__i386__) || defined(__x86_64__) /* arch */ +#include "pkey-x86.h" +#else /* arch */ +#error Architecture not supported +#endif /* arch */ + extern unsigned int shadow_pkey_reg; -static inline unsigned int __read_pkey_reg(void) -{ - unsigned int eax, edx; - unsigned int ecx = 0; - unsigned int pkey_reg; - - asm volatile(".byte 0x0f,0x01,0xee\n\t" - : "=a" (eax), "=d" (edx) - : "c" (ecx)); - pkey_reg = eax; - return pkey_reg; -} static inline unsigned int _read_pkey_reg(int line) { @@ -100,19 +91,6 @@ static inline unsigned int _read_pkey_re #define read_pkey_reg() _read_pkey_reg(__LINE__) -static inline void __write_pkey_reg(unsigned int pkey_reg) -{ - unsigned int eax = pkey_reg; - unsigned int ecx = 0; - unsigned int edx = 0; - - dprintf4("%s() changing %08x to %08x\n", __func__, - __read_pkey_reg(), pkey_reg); - asm volatile(".byte 0x0f,0x01,0xef\n\t" - : : "a" (eax), "c" (ecx), "d" (edx)); - assert(pkey_reg == __read_pkey_reg()); -} - static inline void write_pkey_reg(unsigned int pkey_reg) { dprintf4("%s() changing %08x to %08x\n", __func__, @@ -157,83 +135,6 @@ static inline void __pkey_write_allow(in dprintf4("pkey_reg now: %08x\n", read_pkey_reg()); } -#define PAGE_SIZE 4096 -#define MB (1<<20) - -static inline void __cpuid(unsigned int *eax, unsigned int *ebx, - unsigned int *ecx, unsigned int *edx) -{ - /* ecx is often an input as well as an output. */ - asm volatile( - "cpuid;" - : "=a" (*eax), - "=b" (*ebx), - "=c" (*ecx), - "=d" (*edx) - : "0" (*eax), "2" (*ecx)); -} - -/* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx) */ -#define X86_FEATURE_PKU (1<<3) /* Protection Keys for Userspace */ -#define X86_FEATURE_OSPKE (1<<4) /* OS Protection Keys Enable */ - -static inline int cpu_has_pku(void) -{ - unsigned int eax; - unsigned int ebx; - unsigned int ecx; - unsigned int edx; - - eax = 0x7; - ecx = 0x0; - __cpuid(&eax, &ebx, &ecx, &edx); - - if (!(ecx & X86_FEATURE_PKU)) { - dprintf2("cpu does not have PKU\n"); - return 0; - } - if (!(ecx & X86_FEATURE_OSPKE)) { - dprintf2("cpu does not have OSPKE\n"); - return 0; - } - return 1; -} - -#define XSTATE_PKEY_BIT (9) -#define XSTATE_PKEY 0x200 - -int pkey_reg_xstate_offset(void) -{ - unsigned int eax; - unsigned int ebx; - unsigned int ecx; - unsigned int edx; - int xstate_offset; - int xstate_size; - unsigned long XSTATE_CPUID = 0xd; - int leaf; - - /* assume that XSTATE_PKEY is set in XCR0 */ - leaf = XSTATE_PKEY_BIT; - { - eax = XSTATE_CPUID; - ecx = leaf; - __cpuid(&eax, &ebx, &ecx, &edx); - - if (leaf == XSTATE_PKEY_BIT) { - xstate_offset = ebx; - xstate_size = eax; - } - } - - if (xstate_size == 0) { - printf("could not find size/offset of PKEY in xsave state\n"); - return 0; - } - - return xstate_offset; -} - #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) #define ALIGN_UP(x, align_to) (((x) + ((align_to)-1)) & ~((align_to)-1)) #define ALIGN_DOWN(x, align_to) ((x) & ~((align_to)-1)) --- /dev/null +++ a/tools/testing/selftests/vm/pkey-x86.h @@ -0,0 +1,156 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _PKEYS_X86_H +#define _PKEYS_X86_H + +#ifdef __i386__ + +#ifndef SYS_mprotect_key +# define SYS_mprotect_key 380 +#endif + +#ifndef SYS_pkey_alloc +# define SYS_pkey_alloc 381 +# define SYS_pkey_free 382 +#endif + +#define REG_IP_IDX REG_EIP +#define si_pkey_offset 0x14 + +#else + +#ifndef SYS_mprotect_key +# define SYS_mprotect_key 329 +#endif + +#ifndef SYS_pkey_alloc +# define SYS_pkey_alloc 330 +# define SYS_pkey_free 331 +#endif + +#define REG_IP_IDX REG_RIP +#define si_pkey_offset 0x20 + +#endif + +#ifndef PKEY_DISABLE_ACCESS +# define PKEY_DISABLE_ACCESS 0x1 +#endif + +#ifndef PKEY_DISABLE_WRITE +# define PKEY_DISABLE_WRITE 0x2 +#endif + +#define NR_PKEYS 16 +#define PKEY_BITS_PER_PKEY 2 +#define HPAGE_SIZE (1UL<<21) +#define PAGE_SIZE 4096 +#define MB (1<<20) + +static inline void __page_o_noops(void) +{ + /* 8-bytes of instruction * 512 bytes = 1 page */ + asm(".rept 512 ; nopl 0x7eeeeeee(%eax) ; .endr"); +} + +static inline unsigned int __read_pkey_reg(void) +{ + unsigned int eax, edx; + unsigned int ecx = 0; + unsigned int pkey_reg; + + asm volatile(".byte 0x0f,0x01,0xee\n\t" + : "=a" (eax), "=d" (edx) + : "c" (ecx)); + pkey_reg = eax; + return pkey_reg; +} + +static inline void __write_pkey_reg(unsigned int pkey_reg) +{ + unsigned int eax = pkey_reg; + unsigned int ecx = 0; + unsigned int edx = 0; + + dprintf4("%s() changing %08x to %08x\n", __func__, + __read_pkey_reg(), pkey_reg); + asm volatile(".byte 0x0f,0x01,0xef\n\t" + : : "a" (eax), "c" (ecx), "d" (edx)); + assert(pkey_reg == __read_pkey_reg()); +} + +static inline void __cpuid(unsigned int *eax, unsigned int *ebx, + unsigned int *ecx, unsigned int *edx) +{ + /* ecx is often an input as well as an output. */ + asm volatile( + "cpuid;" + : "=a" (*eax), + "=b" (*ebx), + "=c" (*ecx), + "=d" (*edx) + : "0" (*eax), "2" (*ecx)); +} + +/* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx) */ +#define X86_FEATURE_PKU (1<<3) /* Protection Keys for Userspace */ +#define X86_FEATURE_OSPKE (1<<4) /* OS Protection Keys Enable */ + +static inline int cpu_has_pku(void) +{ + unsigned int eax; + unsigned int ebx; + unsigned int ecx; + unsigned int edx; + + eax = 0x7; + ecx = 0x0; + __cpuid(&eax, &ebx, &ecx, &edx); + + if (!(ecx & X86_FEATURE_PKU)) { + dprintf2("cpu does not have PKU\n"); + return 0; + } + if (!(ecx & X86_FEATURE_OSPKE)) { + dprintf2("cpu does not have OSPKE\n"); + return 0; + } + return 1; +} + +#define XSTATE_PKEY_BIT (9) +#define XSTATE_PKEY 0x200 + +int pkey_reg_xstate_offset(void) +{ + unsigned int eax; + unsigned int ebx; + unsigned int ecx; + unsigned int edx; + int xstate_offset; + int xstate_size; + unsigned long XSTATE_CPUID = 0xd; + int leaf; + + /* assume that XSTATE_PKEY is set in XCR0 */ + leaf = XSTATE_PKEY_BIT; + { + eax = XSTATE_CPUID; + ecx = leaf; + __cpuid(&eax, &ebx, &ecx, &edx); + + if (leaf == XSTATE_PKEY_BIT) { + xstate_offset = ebx; + xstate_size = eax; + } + } + + if (xstate_size == 0) { + printf("could not find size/offset of PKEY in xsave state\n"); + return 0; + } + + return xstate_offset; +} + +#endif /* _PKEYS_X86_H */ --- a/tools/testing/selftests/vm/protection_keys.c~selftests-vm-pkeys-move-some-definitions-to-arch-specific-header +++ a/tools/testing/selftests/vm/protection_keys.c @@ -49,9 +49,6 @@ int iteration_nr = 1; int test_nr; unsigned int shadow_pkey_reg; - -#define HPAGE_SIZE (1UL<<21) - int dprint_in_signal; char dprint_in_signal_buffer[DPRINT_IN_SIGNAL_BUF_SIZE]; @@ -137,12 +134,6 @@ void abort_hooks(void) #endif } -static inline void __page_o_noops(void) -{ - /* 8-bytes of instruction * 512 bytes = 1 page */ - asm(".rept 512 ; nopl 0x7eeeeeee(%eax) ; .endr"); -} - /* * This attempts to have roughly a page of instructions followed by a few * instructions that do a write, and another page of instructions. That @@ -165,36 +156,6 @@ void lots_o_noops_around_write(int *writ dprintf3("%s() done\n", __func__); } -#ifdef __i386__ - -#ifndef SYS_mprotect_key -# define SYS_mprotect_key 380 -#endif - -#ifndef SYS_pkey_alloc -# define SYS_pkey_alloc 381 -# define SYS_pkey_free 382 -#endif - -#define REG_IP_IDX REG_EIP -#define si_pkey_offset 0x14 - -#else - -#ifndef SYS_mprotect_key -# define SYS_mprotect_key 329 -#endif - -#ifndef SYS_pkey_alloc -# define SYS_pkey_alloc 330 -# define SYS_pkey_free 331 -#endif - -#define REG_IP_IDX REG_RIP -#define si_pkey_offset 0x20 - -#endif - void dump_mem(void *dumpme, int len_bytes) { char *c = (void *)dumpme; @@ -367,14 +328,6 @@ pid_t fork_lazy_child(void) return forkret; } -#ifndef PKEY_DISABLE_ACCESS -# define PKEY_DISABLE_ACCESS 0x1 -#endif - -#ifndef PKEY_DISABLE_WRITE -# define PKEY_DISABLE_WRITE 0x2 -#endif - static u32 hw_pkey_get(int pkey, unsigned long flags) { u32 mask = (PKEY_DISABLE_ACCESS|PKEY_DISABLE_WRITE); _
next prev parent reply other threads:[~2020-06-04 23:51 UTC|newest] Thread overview: 166+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-06-04 23:45 incoming Andrew Morton 2020-06-04 23:45 ` [patch 001/127] kcov: cleanup debug messages Andrew Morton 2020-06-04 23:45 ` Andrew Morton 2020-06-04 23:45 ` [patch 002/127] kcov: fix potential use-after-free in kcov_remote_start Andrew Morton 2020-06-04 23:45 ` [patch 003/127] kcov: move t->kcov assignments into kcov_start/stop Andrew Morton 2020-06-04 23:45 ` [patch 004/127] kcov: move t->kcov_sequence assignment Andrew Morton 2020-06-04 23:46 ` [patch 005/127] kcov: use t->kcov_mode as enabled indicator Andrew Morton 2020-06-04 23:46 ` [patch 006/127] kcov: collect coverage from interrupts Andrew Morton 2020-06-04 23:46 ` [patch 007/127] usb: core: kcov: collect coverage from usb complete callback Andrew Morton 2020-06-04 23:46 ` [patch 008/127] mm/util.c: remove the VM_WARN_ONCE for vm_committed_as underflow check Andrew Morton 2020-06-04 23:46 ` Andrew Morton 2020-06-04 23:46 ` [patch 009/127] h8300: remove usage of __ARCH_USE_5LEVEL_HACK Andrew Morton 2020-06-04 23:46 ` [patch 010/127] arm: add support for folded p4d page tables Andrew Morton 2020-06-04 23:46 ` [patch 011/127] arm64: " Andrew Morton 2020-06-04 23:46 ` [patch 012/127] hexagon: remove __ARCH_USE_5LEVEL_HACK Andrew Morton 2020-06-04 23:46 ` [patch 013/127] ia64: add support for folded p4d page tables Andrew Morton 2020-06-04 23:46 ` [patch 014/127] nios2: " Andrew Morton 2020-06-04 23:46 ` [patch 015/127] openrisc: " Andrew Morton 2020-06-04 23:46 ` [patch 016/127] powerpc: " Andrew Morton 2020-06-04 23:46 ` Andrew Morton 2020-06-04 23:46 ` [patch 017/127] sh: fault: modernize printing of kernel messages Andrew Morton 2020-06-04 23:46 ` Andrew Morton 2020-06-04 23:46 ` [patch 018/127] sh: drop __pXd_offset() macros that duplicate pXd_index() ones Andrew Morton 2020-06-04 23:46 ` [patch 019/127] sh: add support for folded p4d page tables Andrew Morton 2020-06-04 23:47 ` [patch 020/127] unicore32: remove __ARCH_USE_5LEVEL_HACK Andrew Morton 2020-06-04 23:47 ` [patch 021/127] asm-generic: remove pgtable-nop4d-hack.h Andrew Morton 2020-06-04 23:47 ` Andrew Morton 2020-06-04 23:47 ` [patch 022/127] mm: remove __ARCH_HAS_5LEVEL_HACK and include/asm-generic/5level-fixup.h Andrew Morton 2020-06-04 23:47 ` [patch 023/127] x86/mm: define mm_p4d_folded() Andrew Morton 2020-06-04 23:47 ` [patch 024/127] mm/debug: add tests validating architecture page table helpers Andrew Morton 2020-06-04 23:47 ` [patch 025/127] mm/vmalloc: fix a typo in comment Andrew Morton 2020-06-04 23:47 ` [patch 026/127] arch/kmap: remove BUG_ON() Andrew Morton 2020-06-04 23:47 ` [patch 027/127] arch/xtensa: move kmap build bug out of the way Andrew Morton 2020-06-04 23:47 ` [patch 028/127] arch/kmap: remove redundant arch specific kmaps Andrew Morton 2020-06-04 23:47 ` [patch 029/127] arch/kunmap: remove duplicate kunmap implementations Andrew Morton 2020-06-04 23:47 ` [patch 030/127] {x86,powerpc,microblaze}/kmap: move preempt disable Andrew Morton 2020-06-04 23:47 ` Andrew Morton 2020-06-04 23:47 ` [patch 031/127] arch/kmap_atomic: consolidate duplicate code Andrew Morton 2020-06-04 23:47 ` [patch 032/127] arch/kunmap_atomic: " Andrew Morton 2020-06-04 23:47 ` [patch 033/127] arch/kmap: ensure kmap_prot visibility Andrew Morton 2020-06-04 23:47 ` [patch 034/127] arch/kmap: don't hard code kmap_prot values Andrew Morton 2020-06-04 23:47 ` [patch 035/127] arch/kmap: define kmap_atomic_prot() for all arch's Andrew Morton 2020-06-04 23:48 ` [patch 036/127] drm: remove drm specific kmap_atomic code Andrew Morton 2020-06-04 23:48 ` Andrew Morton 2020-06-04 23:48 ` [patch 037/127] kmap: remove kmap_atomic_to_page() Andrew Morton 2020-06-04 23:48 ` Andrew Morton 2020-06-04 23:48 ` [patch 038/127] parisc/kmap: remove duplicate kmap code Andrew Morton 2020-06-04 23:48 ` [patch 039/127] sparc: remove unnecessary includes Andrew Morton 2020-06-04 23:48 ` [patch 040/127] kmap: consolidate kmap_prot definitions Andrew Morton 2020-06-04 23:48 ` [patch 041/127] mm: add kvfree_sensitive() for freeing sensitive data objects Andrew Morton 2020-06-16 20:59 ` Jarkko Sakkinen 2020-06-04 23:48 ` [patch 042/127] mm/memory_hotplug: refrain from adding memory into an impossible node Andrew Morton 2020-06-04 23:48 ` [patch 043/127] powerpc/pseries/hotplug-memory: stop checking is_mem_section_removable() Andrew Morton 2020-06-04 23:48 ` Andrew Morton 2020-06-04 23:48 ` [patch 044/127] mm/memory_hotplug: remove is_mem_section_removable() Andrew Morton 2020-06-04 23:48 ` Andrew Morton 2020-06-04 23:48 ` [patch 045/127] mm/memory_hotplug: set node_start_pfn of hotadded pgdat to 0 Andrew Morton 2020-06-04 23:48 ` [patch 046/127] mm/memory_hotplug: handle memblocks only with CONFIG_ARCH_KEEP_MEMBLOCK Andrew Morton 2020-06-04 23:48 ` [patch 047/127] mm/memory_hotplug: introduce add_memory_driver_managed() Andrew Morton 2020-06-04 23:48 ` [patch 048/127] kexec_file: don't place kexec images on IORESOURCE_MEM_DRIVER_MANAGED Andrew Morton 2020-06-04 23:48 ` [patch 049/127] device-dax: add memory via add_memory_driver_managed() Andrew Morton 2020-06-04 23:48 ` [patch 050/127] mm/memory_hotplug: disable the functionality for 32b Andrew Morton 2020-06-04 23:48 ` [patch 051/127] mm: replace zero-length array with flexible-array member Andrew Morton 2020-06-04 23:48 ` [patch 052/127] mm/memory_hotplug: fix a typo in comment "recoreded"->"recorded" Andrew Morton 2020-06-04 23:49 ` [patch 053/127] mm: ksm: fix a typo in comment "alreaady"->"already" Andrew Morton 2020-06-04 23:49 ` [patch 054/127] mm: mmap: fix a typo in comment "compatbility"->"compatibility" Andrew Morton 2020-06-04 23:49 ` [patch 055/127] mm/hugetlb: fix a typos in comments Andrew Morton 2020-06-04 23:49 ` [patch 056/127] mm/vmsan: fix some typos in comment Andrew Morton 2020-06-04 23:49 ` [patch 057/127] mm/compaction: fix a typo in comment "pessemistic"->"pessimistic" Andrew Morton 2020-06-04 23:49 ` [patch 058/127] mm/memblock: fix a typo in comment "implict"->"implicit" Andrew Morton 2020-06-04 23:49 ` [patch 059/127] mm/list_lru: fix a typo in comment "numbesr"->"numbers" Andrew Morton 2020-06-04 23:49 ` [patch 060/127] mm/filemap: fix a typo in comment "unneccssary"->"unnecessary" Andrew Morton 2020-06-04 23:49 ` [patch 061/127] mm/frontswap: fix some typos in frontswap.c Andrew Morton 2020-06-04 23:49 ` [patch 062/127] mm, memcg: fix some typos in memcontrol.c Andrew Morton 2020-06-04 23:49 ` [patch 063/127] mm: fix a typo in comment "strucure"->"structure" Andrew Morton 2020-06-04 23:49 ` [patch 064/127] mm/slub: fix a typo in comment "disambiguiation"->"disambiguation" Andrew Morton 2020-06-04 23:49 ` [patch 065/127] mm/sparse: fix a typo in comment "convienence"->"convenience" Andrew Morton 2020-06-04 23:49 ` [patch 066/127] mm/page-writeback: fix a typo in comment "effictive"->"effective" Andrew Morton 2020-06-04 23:49 ` [patch 067/127] mm/memory: fix a typo in comment "attampt"->"attempt" Andrew Morton 2020-06-04 23:49 ` [patch 068/127] mm: use false for bool variable Andrew Morton 2020-06-04 23:49 ` [patch 069/127] include/linux/mm.h: return true in cpupid_pid_unset() Andrew Morton 2020-06-04 23:49 ` [patch 070/127] zcomp: Use ARRAY_SIZE() for backends list Andrew Morton 2020-06-04 23:49 ` [patch 071/127] proc: rename "catch" function argument Andrew Morton 2020-06-04 23:49 ` [patch 072/127] user.c: make uidhash_table static Andrew Morton 2020-06-04 23:50 ` [patch 073/127] get_maintainer: add email addresses from .yaml files Andrew Morton 2020-06-04 23:50 ` [patch 074/127] get_maintainer: fix unexpected behavior for path/to//file (double slashes) Andrew Morton 2020-06-04 23:50 ` [patch 075/127] lib/math: avoid trailing newline hidden in pr_fmt() Andrew Morton 2020-06-04 23:50 ` [patch 076/127] lib: Add might_fault() to strncpy_from_user Andrew Morton 2020-06-04 23:50 ` [patch 077/127] lib/test_lockup.c: make test_inode static Andrew Morton 2020-06-04 23:50 ` [patch 078/127] lib/zlib: remove outdated and incorrect pre-increment optimization Andrew Morton 2020-06-04 23:50 ` [patch 079/127] lib/percpu-refcount.c: use a more common logging style Andrew Morton 2020-06-04 23:50 ` [patch 080/127] lib/flex_proportions.c: cleanup __fprop_inc_percpu_max Andrew Morton 2020-06-04 23:50 ` [patch 081/127] lib: make a test module with set/clear bit Andrew Morton 2020-06-04 23:50 ` [patch 082/127] include/linux/bitops.h: avoid clang shift-count-overflow warnings Andrew Morton 2020-06-04 23:50 ` [patch 083/127] checkpatch: additional MAINTAINER section entry ordering checks Andrew Morton 2020-06-04 23:50 ` [patch 084/127] checkpatch: look for c99 comments in ctx_locate_comment Andrew Morton 2020-06-04 23:50 ` [patch 085/127] checkpatch: disallow --git and --file/--fix Andrew Morton 2020-06-04 23:50 ` [patch 086/127] checkpatch: use patch subject when reading from stdin Andrew Morton 2020-06-04 23:50 ` [patch 087/127] fs/binfmt_elf: remove redundant elf_map ifndef Andrew Morton 2020-06-04 23:50 ` Andrew Morton 2020-06-04 23:50 ` [patch 088/127] elfnote: mark all .note sections SHF_ALLOC Andrew Morton 2020-06-04 23:50 ` [patch 089/127] init: allow distribution configuration of default init Andrew Morton 2020-06-04 23:50 ` [patch 090/127] fat: don't allow to mount if the FAT length == 0 Andrew Morton 2020-06-04 23:50 ` [patch 091/127] fat: improve the readahead for FAT entries Andrew Morton 2020-06-04 23:50 ` Andrew Morton 2020-06-04 23:51 ` [patch 092/127] fs/seq_file.c: seq_read: Update pr_info_ratelimited Andrew Morton 2020-06-04 23:51 ` [patch 093/127] include/linux/seq_file.h: introduce DEFINE_SEQ_ATTRIBUTE() helper macro Andrew Morton 2020-06-04 23:51 ` [patch 094/127] mm/vmstat.c: convert to use DEFINE_SEQ_ATTRIBUTE macro Andrew Morton 2020-06-04 23:51 ` Andrew Morton 2020-06-04 23:51 ` [patch 095/127] kernel/kprobes.c: " Andrew Morton 2020-06-04 23:51 ` Andrew Morton 2020-06-04 23:51 ` [patch 096/127] exec: simplify the copy_strings_kernel calling convention Andrew Morton 2020-06-04 23:51 ` [patch 097/127] exec: open code copy_string_kernel Andrew Morton 2020-06-04 23:51 ` [patch 098/127] rapidio: avoid data race between file operation callbacks and mport_cdev_add() Andrew Morton 2020-06-04 23:51 ` Andrew Morton 2020-06-04 23:51 ` [patch 099/127] rapidio: convert get_user_pages() --> pin_user_pages() Andrew Morton 2020-06-04 23:51 ` [patch 100/127] kernel/relay.c: handle alloc_percpu returning NULL in relay_open Andrew Morton 2020-06-04 23:51 ` [patch 101/127] kernel/relay.c: fix read_pos error when multiple readers Andrew Morton 2020-06-04 23:51 ` [patch 102/127] selftests/x86/pkeys: move selftests to arch-neutral directory Andrew Morton 2020-06-04 23:51 ` Andrew Morton 2020-06-04 23:51 ` [patch 103/127] selftests/vm/pkeys: rename all references to pkru to a generic name Andrew Morton 2020-06-04 23:51 ` [patch 104/127] selftests/vm/pkeys: move generic definitions to header file Andrew Morton 2020-06-04 23:51 ` Andrew Morton 2020-06-04 23:51 ` Andrew Morton [this message] 2020-06-04 23:51 ` [patch 105/127] selftests/vm/pkeys: move some definitions to arch-specific header Andrew Morton 2020-06-04 23:51 ` [patch 106/127] selftests/vm/pkeys: make gcc check arguments of sigsafe_printf() Andrew Morton 2020-06-04 23:51 ` [patch 107/127] selftests: vm: pkeys: Use sane types for pkey register Andrew Morton 2020-06-04 23:51 ` [patch 108/127] selftests: vm: pkeys: add helpers for pkey bits Andrew Morton 2020-06-04 23:51 ` [patch 109/127] selftests/vm/pkeys: fix pkey_disable_clear() Andrew Morton 2020-06-04 23:52 ` [patch 110/127] selftests/vm/pkeys: fix assertion in pkey_disable_set/clear() Andrew Morton 2020-06-04 23:52 ` [patch 111/127] selftests/vm/pkeys: fix alloc_random_pkey() to make it really random Andrew Morton 2020-06-04 23:52 ` [patch 112/127] selftests: vm: pkeys: use the correct huge page size Andrew Morton 2020-06-04 23:52 ` [patch 113/127] selftests/vm/pkeys: introduce generic pkey abstractions Andrew Morton 2020-06-04 23:52 ` [patch 114/127] selftests/vm/pkeys: introduce powerpc support Andrew Morton 2020-06-04 23:52 ` Andrew Morton 2020-06-04 23:52 ` [patch 115/127] selftests/vm/pkeys: fix number of reserved powerpc pkeys Andrew Morton 2020-06-04 23:52 ` [patch 116/127] selftests/vm/pkeys: fix assertion in test_pkey_alloc_exhaust() Andrew Morton 2020-06-04 23:52 ` [patch 117/127] selftests/vm/pkeys: improve checks to determine pkey support Andrew Morton 2020-06-04 23:52 ` [patch 118/127] selftests/vm/pkeys: associate key on a mapped page and detect access violation Andrew Morton 2020-06-04 23:52 ` [patch 119/127] selftests/vm/pkeys: associate key on a mapped page and detect write violation Andrew Morton 2020-06-04 23:52 ` [patch 120/127] selftests/vm/pkeys: detect write violation on a mapped access-denied-key page Andrew Morton 2020-06-04 23:52 ` [patch 121/127] selftests/vm/pkeys: introduce a sub-page allocator Andrew Morton 2020-06-04 23:52 ` [patch 122/127] selftests/vm/pkeys: test correct behaviour of pkey-0 Andrew Morton 2020-06-04 23:52 ` [patch 123/127] selftests/vm/pkeys: override access right definitions on powerpc Andrew Morton 2020-06-04 23:52 ` [patch 124/127] selftests: vm: pkeys: use the correct page size " Andrew Morton 2020-06-04 23:52 ` [patch 125/127] selftests: vm: pkeys: fix multilib builds for x86 Andrew Morton 2020-06-04 23:52 ` [patch 126/127] tools/testing/selftests/vm: remove duplicate headers Andrew Morton 2020-06-04 23:53 ` [patch 127/127] lib/ubsan.c: fix gcc-10 warnings Andrew Morton 2020-06-06 0:18 ` + lib-test-get_count_order-long-in-test_bitopsc-fix.patch added to -mm tree Andrew Morton 2020-06-06 0:28 ` + checkpatch-add-test-for-possible-misuse-of-is_enabled-without-config_.patch " Andrew Morton 2020-06-06 0:35 ` [to-be-updated] exec-change-uselib2-is_sreg-failure-to-eacces.patch removed from " Andrew Morton 2020-06-06 0:35 ` [to-be-updated] exec-relocate-s_isreg-check.patch " Andrew Morton 2020-06-06 0:35 ` [to-be-updated] exec-relocate-path_noexec-check.patch " Andrew Morton 2020-06-06 0:35 ` [to-be-updated] fs-include-fmode_exec-when-converting-flags-to-f_mode.patch " Andrew Morton 2020-06-06 0:39 ` + exec-change-uselib2-is_sreg-failure-to-eacces.patch added to " Andrew Morton 2020-06-06 0:40 ` + exec-move-s_isreg-check-earlier.patch " Andrew Morton 2020-06-06 0:40 ` + exec-move-path_noexec-check-earlier.patch " Andrew Morton 2020-06-06 0:53 ` + khugepaged-selftests-fix-timeout-condition-in-wait_for_scan.patch " Andrew Morton 2020-06-06 1:04 ` + scripts-spelling-add-a-few-more-typos.patch " Andrew Morton 2020-06-06 1:06 ` + mm-page_idlec-skip-offline-pages.patch " Andrew Morton 2020-06-07 23:41 ` + nilfs2-fix-null-pointer-dereference-at-nilfs_segctor_do_construct.patch " Andrew Morton 2020-06-07 23:53 ` + mm-consolidate-pgd_index-and-pgd_offset_k-definitions-fix-3.patch " Andrew Morton 2020-06-08 0:21 ` + tracing-kprobes-handle-mixed-kernel-userspace-probes-better-fix.patch " Andrew Morton 2020-06-08 0:50 ` + docs-mm-gup-pin_user_pagesrst-add-a-case-5-v2.patch " Andrew Morton 2020-06-08 0:57 ` + kcov-check-kcov_softirq-in-kcov_remote_stop.patch " Andrew Morton 2020-06-08 1:24 ` + lib-lz4-lz4_decompressc-document-deliberate-use-of.patch " Andrew Morton
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200604235144.hi-isoxfB%akpm@linux-foundation.org \ --to=akpm@linux-foundation.org \ --cc=aneesh.kumar@linux.ibm.com \ --cc=bauerman@linux.ibm.com \ --cc=dave.hansen@intel.com \ --cc=desnesn@linux.vnet.ibm.com \ --cc=fweimer@redhat.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=linuxram@us.ibm.com \ --cc=mhocko@kernel.org \ --cc=mingo@kernel.org \ --cc=mm-commits@vger.kernel.org \ --cc=mpe@ellerman.id.au \ --cc=msuchanek@suse.de \ --cc=sandipan@linux.ibm.com \ --cc=shuah@kernel.org \ --cc=torvalds@linux-foundation.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.