diff options
author | Borislav Petkov <bp@suse.de> | 2019-02-02 10:45:17 +0100 |
---|---|---|
committer | Borislav Petkov <bp@suse.de> | 2019-02-02 10:45:17 +0100 |
commit | 84ba10d633f1e8886e62bfd88e1b04ea28310483 (patch) | |
tree | cdea4b31d0e59393cccdfb31aa283d00d1836012 /tools | |
parent | 912ebd99edfa1d1695083fa6d34ac878346ac66b (diff) | |
parent | e6d429313ea5c776d2e76b4494df69102e6b7115 (diff) |
Merge remote-tracking branch 'tip/x86/urgent' into edac-for-5.1
... to pick up dependent change:
00ae831dfe44 ("x86/cpu: Add Atom Tremont (Jacobsville)")
introducing the model number define which will be needed by the new
i10nm_edac driver for 10nm Intel Atoms.
Signed-off-by: Borislav Petkov <bp@suse.de>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/x86/protection_keys.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c index 460b4bdf4c1ed..5d546dcdbc805 100644 --- a/tools/testing/selftests/x86/protection_keys.c +++ b/tools/testing/selftests/x86/protection_keys.c @@ -1133,6 +1133,21 @@ void test_pkey_syscalls_bad_args(int *ptr, u16 pkey) pkey_assert(err); } +void become_child(void) +{ + pid_t forkret; + + forkret = fork(); + pkey_assert(forkret >= 0); + dprintf3("[%d] fork() ret: %d\n", getpid(), forkret); + + if (!forkret) { + /* in the child */ + return; + } + exit(0); +} + /* Assumes that all pkeys other than 'pkey' are unallocated */ void test_pkey_alloc_exhaust(int *ptr, u16 pkey) { @@ -1141,7 +1156,7 @@ void test_pkey_alloc_exhaust(int *ptr, u16 pkey) int nr_allocated_pkeys = 0; int i; - for (i = 0; i < NR_PKEYS*2; i++) { + for (i = 0; i < NR_PKEYS*3; i++) { int new_pkey; dprintf1("%s() alloc loop: %d\n", __func__, i); new_pkey = alloc_pkey(); @@ -1152,21 +1167,27 @@ void test_pkey_alloc_exhaust(int *ptr, u16 pkey) if ((new_pkey == -1) && (errno == ENOSPC)) { dprintf2("%s() failed to allocate pkey after %d tries\n", __func__, nr_allocated_pkeys); - break; + } else { + /* + * Ensure the number of successes never + * exceeds the number of keys supported + * in the hardware. + */ + pkey_assert(nr_allocated_pkeys < NR_PKEYS); + allocated_pkeys[nr_allocated_pkeys++] = new_pkey; } - pkey_assert(nr_allocated_pkeys < NR_PKEYS); - allocated_pkeys[nr_allocated_pkeys++] = new_pkey; + + /* + * Make sure that allocation state is properly + * preserved across fork(). + */ + if (i == NR_PKEYS*2) + become_child(); } dprintf3("%s()::%d\n", __func__, __LINE__); /* - * ensure it did not reach the end of the loop without - * failure: - */ - pkey_assert(i < NR_PKEYS*2); - - /* * There are 16 pkeys supported in hardware. Three are * allocated by the time we get here: * 1. The default key (0) |