Skip to contentSkip to conversation

s390x: cmm: test no-translate bit after reset

PATCH Superseded Nico Boehr 2 participants 2 messages Nov 15, 2023

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Nico Boehr

author
#0 lore raw

PATCH 1/1 s390x: cmm: test no-translate bit after reset

KVM did not properly reset the no-translate bit after reset, see
https://lore.kernel.org/kvm/[email protected]/

Add a test which performs a load normal reset (includes a subsystem reset) and verify that this clears the no-translate bit.

---
 s390x/cmm.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
s390x/cmm.c +24 -0
index af852838851e..8f10c107d81b 100644
@@ -9,6 +9,7 @@
  */
 
 #include <libcflat.h>
+#include <bitops.h>
 #include <asm/asm-offsets.h>
 #include <asm/interrupt.h>
 #include <asm/page.h>
@@ -16,6 +17,8 @@
 
 static uint8_t pagebuf[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
 
+extern int diag308_load_reset(u64);
+
 static void test_params(void)
 {
 	report_prefix_push("invalid ORC 8");
@@ -35,6 +38,26 @@ static void test_priv(void)
 	report_prefix_pop();
 }
 
+static void test_reset_no_translate(void)
+{
+	unsigned long state;
+	const uint64_t mask_no_translate = BIT(63 - 58);
+
+	report_prefix_push("reset no-translate");
+	essa(ESSA_SET_STABLE_NODAT, (unsigned long)pagebuf);
+
+	state = essa(ESSA_GET_STATE, (unsigned long)pagebuf);
+	report(state & mask_no_translate, "no-translate bit set before reset");
+
+	/* Load normal reset - includes subsystem reset */
+	diag308_load_reset(1);
+
+	state = essa(ESSA_GET_STATE, (unsigned long)pagebuf);
+	report(!(state & mask_no_translate), "no-translate bit unset after reset");
+
+	report_prefix_pop();
+}
+
 int main(void)
 {
 	bool has_essa = check_essa_available();
@@ -47,6 +70,7 @@ int main(void)
 
 	test_priv();
 	test_params();
+	test_reset_no_translate();
 done:
 	report_prefix_pop();
 	return report_summary();
Signature · 1 line
2.41.0
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 33 lines · On Wed, 15 Nov 2023 09:38:32 +0100 Nico Boehr <[email protected]> wrote:

KVM did not properly reset the no-translate bit after reset, see
https://lore.kernel.org/kvm/[email protected]/

Add a test which performs a load normal reset (includes a subsystem reset) and verify that this clears the no-translate bit.

---
 s390x/cmm.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
s390x/cmm.c +3 -0
index af852838851e..8f10c107d81b 100644
@@ -9,6 +9,7 @@
  */
 
 #include <libcflat.h>
+#include <bitops.h>
 #include <asm/asm-offsets.h>
 #include <asm/interrupt.h>
 #include <asm/page.h>
@@ -16,6 +17,8 @@
 
 static uint8_t pagebuf[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
 
+extern int diag308_load_reset(u64);
+
 static void test_params(void)
 {
 	report_prefix_push("invalid ORC 8");

s390x/cmm.c static void test_priv(void) · line 44

Quoted 7 lines
s390x/cmm.c +4 -0
@@ -35,6 +38,26 @@ static void test_priv(void)
 	report_prefix_pop();
 }
 
+static void test_reset_no_translate(void)
+{
+	unsigned long state;
+	const uint64_t mask_no_translate = BIT(63 - 58);

reverse Christmas tree, please :)

also, maybe it's easier to read with just a numeric constant? i.e. 0x20

with the Christmas tree fixed (with or without numeric constant):

Quoted 27 lines
s390x/cmm.c +17 -0
+
+	report_prefix_push("reset no-translate");
+	essa(ESSA_SET_STABLE_NODAT, (unsigned long)pagebuf);
+
+	state = essa(ESSA_GET_STATE, (unsigned long)pagebuf);
+	report(state & mask_no_translate, "no-translate bit set before reset");
+
+	/* Load normal reset - includes subsystem reset */
+	diag308_load_reset(1);
+
+	state = essa(ESSA_GET_STATE, (unsigned long)pagebuf);
+	report(!(state & mask_no_translate), "no-translate bit unset after reset");
+
+	report_prefix_pop();
+}
+
 int main(void)
 {
 	bool has_essa = check_essa_available();
@@ -47,6 +70,7 @@ int main(void)
 
 	test_priv();
 	test_params();
+	test_reset_no_translate();
 done:
 	report_prefix_pop();
 	return report_summary();