mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-06 14:31:46 +00:00
powerpc fixes for 4.12 #3
The headline is a fix for FP/VMX register corruption when using transactional memory, and a new selftest to go with it. Then there's the virt_addr_valid() fix, currently HARDENDED_USERCOPY is tripping on that causing some machines to crash. A few other fairly minor fixes for long tail things, and a couple of fixes for code we just merged. Thanks to: Breno Leitao, Gautham R. Shenoy, Michael Neuling, Naveen N. Rao. Nicholas Piggin, Paul Mackerras. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJZHrn+AAoJEFHr6jzI4aWAgAIQAKv7pthWNkQV+prW9rJqgADN 11V/2Ldjy6oZ0871GDn1bElzkaKMTNLlTYsm2+RAHS1p53+SVlLHig5FdoxqBptj X6N5kUONgYA+jBBXriT/UC91tAJNR+xHmB8QEoFUtUpUBaZ66NVGYeGwlgnP1/Qm rRmViKuLgXPzvJ2Is6R/SbDypyU5W6Rb7n3fAd1pPQN7DlJoF6WDgALblvz2akwg mQaW8PtIbUQGrXqQqQJ2R3o8D+n9M4xh58NEmHjTYiEHBKBOz8G2RCOrnb1PtSyh kDLBZqAaQF7OW089wwzB2fq6kC+z8iENk3iWFk+X64lH0KOnZxZPY2NGcFqEUjLs 3BoO07fksw9waysDFRRDIcj7ECYNET+Zt3kOZoZcWXdIJc+8aNo7CHXSC1DRC/ar GU0zRoH9dvBFfWyvjJnuOspbgHi/R+ODDgxFwqTMmCKUSGpBMkQAxSJqPh6qnyH6 HoLEVjFrsT7qfvSi6OWuENfKMb8j3kPuBVeZammCWu2V8DIL+l+WPusOwmOXkCo7 i/2i3lNuo8k5uuUqRUNMJk8t1+kUIKt7HJHwFGROv1H7173C2HxLTohxl0ZhSlf8 Xe2epWAI4eL0/SPvB8Pi8FwAzb2+FP+DiC6a+cI8YoIz2+UjwiZBUQgEeQR6ETXc aI5uk3lnSFd62839Cezs =KtM/ -----END PGP SIGNATURE----- Merge tag 'powerpc-4.12-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux Pull powerpc fixes from Michael Ellerman: "The headliner is a fix for FP/VMX register corruption when using transactional memory, and a new selftest to go with it. Then there's the virt_addr_valid() fix, currently HARDENDED_USERCOPY is tripping on that causing some machines to crash. A few other fairly minor fixes for long tail things, and a couple of fixes for code we just merged. Thanks to: Breno Leitao, Gautham Shenoy, Michael Neuling, Naveen Rao. Nicholas Piggin, Paul Mackerras" * tag 'powerpc-4.12-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/mm: Fix virt_addr_valid() etc. on 64-bit hash powerpc/mm: Fix crash in page table dump with huge pages powerpc/kprobes: Fix handling of instruction emulation on probe re-entry powerpc/powernv: Set NAPSTATELOST after recovering paca on P9 DD1 selftests/powerpc: Test TM and VMX register state powerpc/tm: Fix FP and VMX register corruption powerpc/modules: If mprofile-kernel is enabled add it to vermagic
This commit is contained in:
commit
e5a489abcf
9 changed files with 164 additions and 6 deletions
|
@ -11,3 +11,4 @@ tm-signal-context-chk-fpu
|
|||
tm-signal-context-chk-gpr
|
||||
tm-signal-context-chk-vmx
|
||||
tm-signal-context-chk-vsx
|
||||
tm-vmx-unavail
|
||||
|
|
|
@ -2,7 +2,8 @@ SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu
|
|||
tm-signal-context-chk-vmx tm-signal-context-chk-vsx
|
||||
|
||||
TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
|
||||
tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS)
|
||||
tm-vmxcopy tm-fork tm-tar tm-tmspr tm-vmx-unavail \
|
||||
$(SIGNAL_CONTEXT_CHK_TESTS)
|
||||
|
||||
include ../../lib.mk
|
||||
|
||||
|
@ -13,6 +14,7 @@ CFLAGS += -mhtm
|
|||
$(OUTPUT)/tm-syscall: tm-syscall-asm.S
|
||||
$(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include
|
||||
$(OUTPUT)/tm-tmspr: CFLAGS += -pthread
|
||||
$(OUTPUT)/tm-vmx-unavail: CFLAGS += -pthread -m64
|
||||
|
||||
SIGNAL_CONTEXT_CHK_TESTS := $(patsubst %,$(OUTPUT)/%,$(SIGNAL_CONTEXT_CHK_TESTS))
|
||||
$(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S
|
||||
|
|
118
tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c
Normal file
118
tools/testing/selftests/powerpc/tm/tm-vmx-unavail.c
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* Copyright 2017, Michael Neuling, IBM Corp.
|
||||
* Licensed under GPLv2.
|
||||
* Original: Breno Leitao <brenohl@br.ibm.com> &
|
||||
* Gustavo Bueno Romero <gromero@br.ibm.com>
|
||||
* Edited: Michael Neuling
|
||||
*
|
||||
* Force VMX unavailable during a transaction and see if it corrupts
|
||||
* the checkpointed VMX register state after the abort.
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <htmintrin.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "tm.h"
|
||||
#include "utils.h"
|
||||
|
||||
int passed;
|
||||
|
||||
void *worker(void *unused)
|
||||
{
|
||||
__int128 vmx0;
|
||||
uint64_t texasr;
|
||||
|
||||
asm goto (
|
||||
"li 3, 1;" /* Stick non-zero value in VMX0 */
|
||||
"std 3, 0(%[vmx0_ptr]);"
|
||||
"lvx 0, 0, %[vmx0_ptr];"
|
||||
|
||||
/* Wait here a bit so we get scheduled out 255 times */
|
||||
"lis 3, 0x3fff;"
|
||||
"1: ;"
|
||||
"addi 3, 3, -1;"
|
||||
"cmpdi 3, 0;"
|
||||
"bne 1b;"
|
||||
|
||||
/* Kernel will hopefully turn VMX off now */
|
||||
|
||||
"tbegin. ;"
|
||||
"beq failure;"
|
||||
|
||||
/* Cause VMX unavail. Any VMX instruction */
|
||||
"vaddcuw 0,0,0;"
|
||||
|
||||
"tend. ;"
|
||||
"b %l[success];"
|
||||
|
||||
/* Check VMX0 sanity after abort */
|
||||
"failure: ;"
|
||||
"lvx 1, 0, %[vmx0_ptr];"
|
||||
"vcmpequb. 2, 0, 1;"
|
||||
"bc 4, 24, %l[value_mismatch];"
|
||||
"b %l[value_match];"
|
||||
:
|
||||
: [vmx0_ptr] "r"(&vmx0)
|
||||
: "r3"
|
||||
: success, value_match, value_mismatch
|
||||
);
|
||||
|
||||
/* HTM aborted and VMX0 is corrupted */
|
||||
value_mismatch:
|
||||
texasr = __builtin_get_texasr();
|
||||
|
||||
printf("\n\n==============\n\n");
|
||||
printf("Failure with error: %lx\n", _TEXASR_FAILURE_CODE(texasr));
|
||||
printf("Summary error : %lx\n", _TEXASR_FAILURE_SUMMARY(texasr));
|
||||
printf("TFIAR exact : %lx\n\n", _TEXASR_TFIAR_EXACT(texasr));
|
||||
|
||||
passed = 0;
|
||||
return NULL;
|
||||
|
||||
/* HTM aborted but VMX0 is correct */
|
||||
value_match:
|
||||
// printf("!");
|
||||
return NULL;
|
||||
|
||||
success:
|
||||
// printf(".");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int tm_vmx_unavail_test()
|
||||
{
|
||||
int threads;
|
||||
pthread_t *thread;
|
||||
|
||||
SKIP_IF(!have_htm());
|
||||
|
||||
passed = 1;
|
||||
|
||||
threads = sysconf(_SC_NPROCESSORS_ONLN) * 4;
|
||||
thread = malloc(sizeof(pthread_t)*threads);
|
||||
if (!thread)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
for (uint64_t i = 0; i < threads; i++)
|
||||
pthread_create(&thread[i], NULL, &worker, NULL);
|
||||
|
||||
for (uint64_t i = 0; i < threads; i++)
|
||||
pthread_join(thread[i], NULL);
|
||||
|
||||
free(thread);
|
||||
|
||||
return passed ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
return test_harness(tm_vmx_unavail_test, "tm_vmx_unavail_test");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue