~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/powerpc/tm/tm-resched-dscr.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /* Test context switching to see if the DSCR SPR is correctly preserved
  3  * when within a transaction.
  4  *
  5  * Note: We assume that the DSCR has been left at the default value (0)
  6  * for all CPUs.
  7  *
  8  * Method:
  9  *
 10  * Set a value into the DSCR.
 11  *
 12  * Start a transaction, and suspend it (*).
 13  *
 14  * Hard loop checking to see if the transaction has become doomed.
 15  *
 16  * Now that we *may* have been preempted, record the DSCR and TEXASR SPRS.
 17  *
 18  * If the abort was because of a context switch, check the DSCR value.
 19  * Otherwise, try again.
 20  *
 21  * (*) If the transaction is not suspended we can't see the problem because
 22  * the transaction abort handler will restore the DSCR to it's checkpointed
 23  * value before we regain control.
 24  */
 25 
 26 #include <inttypes.h>
 27 #include <stdio.h>
 28 #include <stdlib.h>
 29 #include <assert.h>
 30 #include <asm/tm.h>
 31 
 32 #include "utils.h"
 33 #include "tm.h"
 34 #include "../pmu/lib.h"
 35 
 36 #define SPRN_DSCR       0x03
 37 
 38 int test_body(void)
 39 {
 40         uint64_t rv, dscr1 = 1, dscr2, texasr;
 41 
 42         SKIP_IF(!have_htm());
 43         SKIP_IF(htm_is_synthetic());
 44 
 45         printf("Check DSCR TM context switch: ");
 46         fflush(stdout);
 47         for (;;) {
 48                 asm __volatile__ (
 49                         /* set a known value into the DSCR */
 50                         "ld      3, %[dscr1];"
 51                         "mtspr   %[sprn_dscr], 3;"
 52 
 53                         "li      %[rv], 1;"
 54                         /* start and suspend a transaction */
 55                         "tbegin.;"
 56                         "beq     1f;"
 57                         "tsuspend.;"
 58 
 59                         /* hard loop until the transaction becomes doomed */
 60                         "2: ;"
 61                         "tcheck 0;"
 62                         "bc      4, 0, 2b;"
 63 
 64                         /* record DSCR and TEXASR */
 65                         "mfspr   3, %[sprn_dscr];"
 66                         "std     3, %[dscr2];"
 67                         "mfspr   3, %[sprn_texasr];"
 68                         "std     3, %[texasr];"
 69 
 70                         "tresume.;"
 71                         "tend.;"
 72                         "li      %[rv], 0;"
 73                         "1: ;"
 74                         : [rv]"=r"(rv), [dscr2]"=m"(dscr2), [texasr]"=m"(texasr)
 75                         : [dscr1]"m"(dscr1)
 76                         , [sprn_dscr]"i"(SPRN_DSCR), [sprn_texasr]"i"(SPRN_TEXASR)
 77                         : "memory", "r3"
 78                 );
 79                 assert(rv); /* make sure the transaction aborted */
 80                 if ((texasr >> 56) != TM_CAUSE_RESCHED) {
 81                         continue;
 82                 }
 83                 if (dscr2 != dscr1) {
 84                         printf(" FAIL\n");
 85                         return 1;
 86                 } else {
 87                         printf(" OK\n");
 88                         return 0;
 89                 }
 90         }
 91 }
 92 
 93 static int tm_resched_dscr(void)
 94 {
 95         return eat_cpu(test_body);
 96 }
 97 
 98 int main(int argc, const char *argv[])
 99 {
100         return test_harness(tm_resched_dscr, "tm_resched_dscr");
101 }
102 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php