2 * Copyright 2015, Michael Neuling, IBM Corp.
3 * Licensed under GPLv2.
5 * Original: Michael Neuling 4/12/2013
6 * Edited: Rashmica Gupta 4/12/2015
8 * See if the altivec state is leaked out of an aborted transaction due to
9 * kernel vmx copy loops.
11 * When the transaction aborts, VSR values should rollback to the values
12 * they held before the transaction commenced. Using VSRs while transaction
13 * is suspended should not affect the checkpointed values.
15 * (1) write A to a VSR
16 * (2) start transaction
17 * (3) suspend transaction
18 * (4) change the VSR to B
19 * (5) trigger kernel vmx copy loop
20 * (6) abort transaction
21 * (7) check that the VSR value is A
37 long double vecin = 1.3;
39 unsigned long pgsize = getpagesize();
43 char tmpfile[] = "/tmp/page_faultXXXXXX";
49 SKIP_IF(!is_ppc64le());
51 fd = mkstemp(tmpfile);
54 memset(buf, 0, pgsize);
55 for (i = 0; i < size; i += pgsize)
56 assert(write(fd, buf, pgsize) == pgsize);
60 a = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
61 assert(a != MAP_FAILED);
64 "lxvd2x 40,0,%[vecinptr];" /* set 40 to initial value*/
68 "xxlxor 40,40,40;" /* set 40 to 0 */
69 "std 5, 0(%[map]);" /* cause kernel vmx copy page */
81 "stxvd2x 40,0,%[vecoutptr];"
83 : [vecinptr]"r"(&vecin),
84 [vecoutptr]"r"(&vecout),
86 : "memory", "r0", "r3", "r4", "r5", "r6", "r7");
88 if (aborted && (vecin != vecout)){
89 printf("FAILED: vector state leaked on abort %f != %f\n",
90 (double)vecin, (double)vecout);
103 return test_harness(test_vmxcopy, "tm_vmxcopy");