Skip to contentSkip to conversation

powerpc/tm: MSR oops printing and selftests

PATCH Applied Michael Neuling 3 participants 9 messages Nov 20, 2015 – Dec 15, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover powerpc/tm: MSR oops printing and selftests

Here are 3 non-urgent TM patches. These were left off my other post of the urgent fixes.

v2:
- Added invalid stack with signal delievery during tm selftest
- Added selftest binaries to .gitignore
- Improved signal return selftest based on mpe's feedback
- Improved oops message printing based on mpe's feedback
- Dropped get_tm_stackpointer() renaming patch in leui of more extensive rewrite later

Michael Neuling (3):
powerpc: Print MSR TM bits in oops message selftests/powerpc: Add TM signal return test selftests/powerpc: Add TM signal with invalid stack test

 arch/powerpc/kernel/process.c                      | 51 ++++++++++++---
 tools/testing/selftests/powerpc/tm/.gitignore      |  2 +
 tools/testing/selftests/powerpc/tm/Makefile        |  2 +-
 .../selftests/powerpc/tm/tm-signal-msr-resv.c      | 71 +++++++++++++++++++++
 .../testing/selftests/powerpc/tm/tm-signal-stack.c | 73 ++++++++++++++++++++++
 5 files changed, 190 insertions(+), 9 deletions(-)
 create mode 100644 tools/testing/selftests/powerpc/tm/tm-signal-msr-resv.c
 create mode 100644 tools/testing/selftests/powerpc/tm/tm-signal-stack.c
Signature · 1 line
2.5.0
#1 lore raw

PATCH v2 1/3 powerpc: Print MSR TM bits in oops messages

Print MSR TM bits in oops messages. This appends them to the end like this:

    MSR: 8000000502823031 <SF,VEC,VSX,FP,ME,IR,DR,LE,TM[TE]>

You get the TM[] only if at least one TM MSR bit is set. Inside the TM[], E means Enabled (bit 32), S means Suspended (bit 33), and T means Transactional (bit 34)

If no bits are set, you get no TM[] output.

Include rework of printbits() to handle this case.

---
 arch/powerpc/kernel/process.c | 51 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 43 insertions(+), 8 deletions(-)
arch/powerpc/kernel/process.c +43 -8
index 646bf4d..f086e8b 100644
@@ -952,10 +952,12 @@ static void show_instructions(struct pt_regs *regs)
 	printk("\n");
 }
 
-static struct regbit {
+struct regbit {
 	unsigned long bit;
 	const char *name;
-} msr_bits[] = {
+};
+
+static struct regbit msr_bits[] = {
 #if defined(CONFIG_PPC64) && !defined(CONFIG_BOOKE)
 	{MSR_SF,	"SF"},
 	{MSR_HV,	"HV"},
@@ -985,16 +987,49 @@ static struct regbit {
 	{0,		NULL}
 };
 
-static void printbits(unsigned long val, struct regbit *bits)
+static void print_bits(unsigned long val, struct regbit *bits, const char *sep)
 {
-	const char *sep = "";
+	const char *s = "";
 
-	printk("<");
 	for (; bits->bit; ++bits)
 		if (val & bits->bit) {
-			printk("%s%s", sep, bits->name);
-			sep = ",";
+			printk("%s%s", s, bits->name);
+			s = sep;
 		}
+}
+
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+static struct regbit msr_tm_bits[] = {
+	{MSR_TS_T,	"T"},
+	{MSR_TS_S,	"S"},
+	{MSR_TM,	"E"},
+	{0,		NULL}
+};
+
+static void print_tm_bits(unsigned long val)
+{
+/*
+ * This only prints something if at least one of the TM bit is set.
+ * Inside the TM[], the output means:
+ *   E: Enabled		(bit 32)
+ *   S: Suspended	(bit 33)
+ *   T: Transactional	(bit 34)
+ */
+	if (val & (MSR_TM | MSR_TS_S | MSR_TS_T)) {
+		printk(",TM[");
+		print_bits(val, msr_tm_bits, "");
+		printk("]");
+	}
+}
+#else
+static void print_tm_bits(unsigned long val) {}
+#endif
+
+static void print_msr_bits(unsigned long val)
+{
+	printk("<");
+	print_bits(val, msr_bits, ",");
+	print_tm_bits(val);
 	printk(">");
 }
 
@@ -1019,7 +1054,7 @@ void show_regs(struct pt_regs * regs)
 	printk("REGS: %p TRAP: %04lx   %s  (%s)\n",
 	       regs, regs->trap, print_tainted(), init_utsname()->release);
 	printk("MSR: "REG" ", regs->msr);
-	printbits(regs->msr, msr_bits);
+	print_msr_bits(regs->msr);
 	printk("  CR: %08lx  XER: %08lx\n", regs->ccr, regs->xer);
 	trap = TRAP(regs);
 	if ((regs->trap != 0xc00) && cpu_has_feature(CPU_FTR_CFAR))
Signature · 1 line
2.5.0
reviewer Applied
#2 lore raw

Re: [v2,1/3] powerpc: Print MSR TM bits in oops messages

Quoted 9 lines · Michael Neuling

Print MSR TM bits in oops messages. This appends them to the end like this:

    MSR: 8000000502823031 <SF,VEC,VSX,FP,ME,IR,DR,LE,TM[TE]>

You get the TM[] only if at least one TM MSR bit is set. Inside the TM[], E means Enabled (bit 32), S means Suspended (bit 33), and T means Transactional (bit 34)

Quoted 5 lines

If no bits are set, you get no TM[] output.

Include rework of printbits() to handle this case.

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/801c0b2c4db3a33d56b3e192

cheers

#3 lore raw

PATCH v2 2/3 selftests/powerpc: Add TM signal return test

In reply to Michael Neuling

Test the kernel's signal return code to ensure that it doesn't crash when both the transactional and suspend MSR bits are set in the signal context.

---
 tools/testing/selftests/powerpc/tm/.gitignore      |  1 +
 tools/testing/selftests/powerpc/tm/Makefile        |  2 +-
 .../selftests/powerpc/tm/tm-signal-msr-resv.c      | 71 ++++++++++++++++++++++
 3 files changed, 73 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/powerpc/tm/tm-signal-msr-resv.c
tools/testing/selftests/powerpc/tm/.gitignore +1 -0
index 2699635d..61c318f 100644
@@ -1,2 +1,3 @@
 tm-resched-dscr
 tm-syscall
+tm-signal-msr-resv
tools/testing/selftests/powerpc/tm/Makefile +1 -1
index 4bea62a..0c28db7 100644
@@ -1,4 +1,4 @@
-TEST_PROGS := tm-resched-dscr tm-syscall
+TEST_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv
 
 all: $(TEST_PROGS)
 
tools/testing/selftests/powerpc/tm/tm-signal-msr-resv.c new file +71 -0

71 lines not on this page · raw message

Signature · 1 line
2.5.0
reviewer Applied
#5 lore raw

Re: [v2,2/3] selftests/powerpc: Add TM signal return test

In reply to Michael Neuling
Quoted 6 lines · Michael Neuling

Test the kernel's signal return code to ensure that it doesn't crash when both the transactional and suspend MSR bits are set in the signal context.

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/25007a69e852389985ee9823

cheers

#6 lore raw

PATCH v2 3/3 selftests/powerpc: Add TM signal with invalid stack test

In reply to Michael Neuling

Test the kernels signal generation code to ensure it can handle an invalid stack pointer when transactional.

---
 tools/testing/selftests/powerpc/tm/.gitignore      |  1 +
 tools/testing/selftests/powerpc/tm/Makefile        |  2 +-
 .../testing/selftests/powerpc/tm/tm-signal-stack.c | 73 ++++++++++++++++++++++
 3 files changed, 75 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/powerpc/tm/tm-signal-stack.c
tools/testing/selftests/powerpc/tm/.gitignore +1 -0
index 61c318f..e666821 100644
@@ -1,3 +1,4 @@
 tm-resched-dscr
 tm-syscall
 tm-signal-msr-resv
+tm-signal-stack
tools/testing/selftests/powerpc/tm/Makefile +1 -1
index 0c28db7..0e45c7e 100644
@@ -1,4 +1,4 @@
-TEST_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv
+TEST_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack
 
 all: $(TEST_PROGS)
 
tools/testing/selftests/powerpc/tm/tm-signal-stack.c new file +73 -0

73 lines not on this page · raw message

Signature · 1 line
2.5.0
reviewer Applied
#8 lore raw

Re: [v2, 3/3] selftests/powerpc: Add TM signal with invalid stack test

In reply to Michael Neuling
Quoted 5 lines · Michael Neuling

Test the kernels signal generation code to ensure it can handle an invalid stack pointer when transactional.

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/a26f415bf71640f0141e5e94

cheers