* [PATCH 2/3] selftests/powerpc: Add test for real address error handling
2021-07-30 18:23 [PATCH 1/3] powerpc/pseries: Parse control memory access error Ganesh Goudar
@ 2021-07-30 18:23 ` Ganesh Goudar
2021-08-03 10:53 ` Michael Ellerman
2021-07-30 18:23 ` [PATCH 3/3] powerpc/mce: Modify the real address error logging messages Ganesh Goudar
1 sibling, 1 reply; 4+ messages in thread
From: Ganesh Goudar @ 2021-07-30 18:23 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: mikey, Ganesh Goudar, mahesh, npiggin
Add test for real address or control memory address access
error handling, using NX-GZIP engine.
The error is injected by accessing the control memory address
using illegal instruction, on successful handling the process
attempting to access control memory address using illegal
instruction receives SIGBUS.
Signed-off-by: Ganesh Goudar <ganeshgr@linux.ibm.com>
---
tools/testing/selftests/powerpc/Makefile | 3 +-
tools/testing/selftests/powerpc/mce/Makefile | 6 +++
.../selftests/powerpc/mce/inject-ra-err.c | 42 +++++++++++++++++++
.../selftests/powerpc/mce/inject-ra-err.sh | 19 +++++++++
4 files changed, 69 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/powerpc/mce/Makefile
create mode 100644 tools/testing/selftests/powerpc/mce/inject-ra-err.c
create mode 100755 tools/testing/selftests/powerpc/mce/inject-ra-err.sh
diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile
index 0830e63818c1..4830372d7416 100644
--- a/tools/testing/selftests/powerpc/Makefile
+++ b/tools/testing/selftests/powerpc/Makefile
@@ -31,7 +31,8 @@ SUB_DIRS = alignment \
vphn \
math \
ptrace \
- security
+ security \
+ mce
endif
diff --git a/tools/testing/selftests/powerpc/mce/Makefile b/tools/testing/selftests/powerpc/mce/Makefile
new file mode 100644
index 000000000000..0f537ce86370
--- /dev/null
+++ b/tools/testing/selftests/powerpc/mce/Makefile
@@ -0,0 +1,6 @@
+#SPDX-License-Identifier: GPL-2.0-or-later
+
+TEST_PROGS := inject-ra-err.sh
+TEST_GEN_FILES := inject-ra-err
+
+include ../../lib.mk
diff --git a/tools/testing/selftests/powerpc/mce/inject-ra-err.c b/tools/testing/selftests/powerpc/mce/inject-ra-err.c
new file mode 100644
index 000000000000..58374bc92e90
--- /dev/null
+++ b/tools/testing/selftests/powerpc/mce/inject-ra-err.c
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <asm/vas-api.h>
+
+int main(void)
+{
+ int fd, ret;
+ int *paste_addr;
+ struct vas_tx_win_open_attr attr;
+ char *devname = "/dev/crypto/nx-gzip";
+
+ memset(&attr, 0, sizeof(attr));
+ attr.version = 1;
+ attr.vas_id = 0;
+
+ fd = open(devname, O_RDWR);
+ if (fd < 0) {
+ fprintf(stderr, "Failed to open device %s\n", devname);
+ return -errno;
+ }
+ ret = ioctl(fd, VAS_TX_WIN_OPEN, &attr);
+ if (ret < 0) {
+ fprintf(stderr, "ioctl() n %d, error %d\n", ret, errno);
+ ret = -errno;
+ goto out;
+ }
+ paste_addr = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0ULL);
+ /* The following assignment triggers exception */
+ *paste_addr = 1;
+ ret = 0;
+out:
+ close(fd);
+ return ret;
+}
diff --git a/tools/testing/selftests/powerpc/mce/inject-ra-err.sh b/tools/testing/selftests/powerpc/mce/inject-ra-err.sh
new file mode 100755
index 000000000000..0e9c8ae6ad78
--- /dev/null
+++ b/tools/testing/selftests/powerpc/mce/inject-ra-err.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+if [[ ! -w /dev/crypto/nx-gzip ]]; then
+ echo "WARN: Can't access /dev/crypto/nx-gzip, skipping"
+ exit 0
+fi
+
+# Timeout in 5 seconds, If not handled it may run indefinitely.
+timeout 5 ./inject-ra-err
+
+# 128 + 7 (SIGBUS) = 135, 128 is a exit Code With Special Meaning.
+if [ $? -ne 135 ]; then
+ echo "FAILED: Control memory access error not handled"
+ exit $?
+fi
+
+echo "OK: Control memory access error is handled"
+exit 0
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] powerpc/mce: Modify the real address error logging messages
2021-07-30 18:23 [PATCH 1/3] powerpc/pseries: Parse control memory access error Ganesh Goudar
2021-07-30 18:23 ` [PATCH 2/3] selftests/powerpc: Add test for real address error handling Ganesh Goudar
@ 2021-07-30 18:23 ` Ganesh Goudar
1 sibling, 0 replies; 4+ messages in thread
From: Ganesh Goudar @ 2021-07-30 18:23 UTC (permalink / raw)
To: linuxppc-dev, mpe; +Cc: mikey, Ganesh Goudar, mahesh, npiggin
To avoid ambiguity, modify the strings in real address error
logging messages to "foreign/control memory" from "foreign",
Since the error discriptions in P9 user manual and P10 user
manual are different for same type of errors.
P9 User Manual for MCE:
DSISR:59 Host real address to foreign space during translation.
DSISR:60 Host real address to foreign space on a load or store
access.
P10 User Manual for MCE:
DSISR:59 D-side tablewalk used a host real address in the
control memory address range.
DSISR:60 D-side operand access to control memory address space.
Signed-off-by: Ganesh Goudar <ganeshgr@linux.ibm.com>
---
arch/powerpc/kernel/mce.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c
index 47a683cd00d2..f3ef480bb739 100644
--- a/arch/powerpc/kernel/mce.c
+++ b/arch/powerpc/kernel/mce.c
@@ -388,14 +388,14 @@ void machine_check_print_event_info(struct machine_check_event *evt,
static const char *mc_ra_types[] = {
"Indeterminate",
"Instruction fetch (bad)",
- "Instruction fetch (foreign)",
+ "Instruction fetch (foreign/control memory)",
"Page table walk ifetch (bad)",
- "Page table walk ifetch (foreign)",
+ "Page table walk ifetch (foreign/control memory)",
"Load (bad)",
"Store (bad)",
"Page table walk Load/Store (bad)",
- "Page table walk Load/Store (foreign)",
- "Load/Store (foreign)",
+ "Page table walk Load/Store (foreign/control memory)",
+ "Load/Store (foreign/control memory)",
};
static const char *mc_link_types[] = {
"Indeterminate",
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread