Skip to contentSkip to conversation

s390x: verify EQBS/SQBS is unavailable

PATCH Superseded Nico Boehr 2 participants 3 messages Aug 2, 2022 – Aug 3, 2022 KVM

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Nico Boehr

author
#0 lore raw

PATCH 1/1 s390x: verify EQBS/SQBS is unavailable

QEMU doesn't provide EQBS/SQBS instructions, so we should check they result in an exception.

---
 s390x/intercept.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
s390x/intercept.c +50 -0
index 9e826b6c79ad..73b06b5fc6e8 100644
@@ -197,6 +197,55 @@ static void test_diag318(void)
 
 }
 
+static inline int sqbs(u64 token)
+{
+	unsigned long _token = token;
+	int cc;
+
+	asm volatile(
+		"	lgr 1,%[token]\n"
+		"	.insn   rsy,0xeb000000008a,0,0,0(0)\n"
+		"	ipm %[cc]\n"
+		"	srl %[cc],28\n"
+		: [cc] "=&d" (cc)
+		: [token] "d" (_token)
+		: "memory", "cc", "1");
+
+	return cc;
+}
+
+static inline int eqbs(u64 token)
+{
+	unsigned long _token = token;
+	int cc;
+
+	asm volatile(
+		"	lgr 1,%[token]\n"
+		"	.insn   rrf,0xb99c0000,0,0,0,0\n"
+		"	ipm %[cc]\n"
+		"	srl %[cc],28\n"
+		: [cc] "=&d" (cc)
+		: [token] "d" (_token)
+		: "memory", "cc", "1");
+
+	return cc;
+}
+
+static void test_qbs(void)
+{
+	report_prefix_push("sqbs");
+	expect_pgm_int();
+	sqbs(0xffffffdeadbeefULL);
+	check_pgm_int_code(PGM_INT_CODE_OPERATION);
+	report_prefix_pop();
+
+	report_prefix_push("eqbs");
+	expect_pgm_int();
+	eqbs(0xffffffdeadbeefULL);
+	check_pgm_int_code(PGM_INT_CODE_OPERATION);
+	report_prefix_pop();
+}
+
 struct {
 	const char *name;
 	void (*func)(void);
@@ -208,6 +257,7 @@ struct {
 	{ "stidp", test_stidp, false },
 	{ "testblock", test_testblock, false },
 	{ "diag318", test_diag318, false },
+	{ "qbs", test_qbs, false },
 	{ NULL, NULL, false }
 };
 
Signature · 1 line
2.36.1
#1 lore raw
Quoted 17 lines · On Tue, 2 Aug 2022 16:51:02 +0200 Nico Boehr <[email protected]> wrote:

QEMU doesn't provide EQBS/SQBS instructions, so we should check they result in an exception.

---
 s390x/intercept.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
s390x/intercept.c +1 -0
index 9e826b6c79ad..73b06b5fc6e8 100644
@@ -197,6 +197,55 @@ static void test_diag318(void)
 
 }
 
+static inline int sqbs(u64 token)

s390x/intercept.c static void test_diag318(void) · line 210

Quoted 10 lines
s390x/intercept.c +10 -0
+{
+	unsigned long _token = token;
+	int cc;
+
+	asm volatile(
+		"	lgr 1,%[token]\n"
+		"	.insn   rsy,0xeb000000008a,0,0,0(0)\n"
+		"	ipm %[cc]\n"
+		"	srl %[cc],28\n"
+		: [cc] "=&d" (cc)

do you really need all those extra things?

can't you just reduce this whole function to:

asm volatile(" .insn rsy,0xeb000000008a,0,0,0(0)\n");

in the end we don't care what happens, we only want it to fail with an operation exception

(ok maybe you need to add some clobbers to make sure things work as they should in case the instruction is actually executed)

Quoted 4 lines
s390x/intercept.c +4 -0
+		: [token] "d" (_token)
+		: "memory", "cc", "1");
+
+	return cc;

s390x/intercept.c static void test_diag318(void) · line 224

Quoted 10 lines
s390x/intercept.c +10 -0
+}
+
+static inline int eqbs(u64 token)
+{
+	unsigned long _token = token;
+	int cc;
+
+	asm volatile(
+		"	lgr 1,%[token]\n"
+		"	.insn   rrf,0xb99c0000,0,0,0,0\n"

same here

Quoted 13 lines
s390x/intercept.c +13 -0
+		"	ipm %[cc]\n"
+		"	srl %[cc],28\n"
+		: [cc] "=&d" (cc)
+		: [token] "d" (_token)
+		: "memory", "cc", "1");
+
+	return cc;
+}
+
+static void test_qbs(void)
+{
+	report_prefix_push("sqbs");
+	expect_pgm_int();

s390x/intercept.c static void test_diag318(void) · line 247

Quoted 10 lines
s390x/intercept.c +10 -0
+	sqbs(0xffffffdeadbeefULL);
+	check_pgm_int_code(PGM_INT_CODE_OPERATION);
+	report_prefix_pop();
+
+	report_prefix_push("eqbs");
+	expect_pgm_int();
+	eqbs(0xffffffdeadbeefULL);
+	check_pgm_int_code(PGM_INT_CODE_OPERATION);
+	report_prefix_pop();
+}

we expect those to fail only in qemu, right?
maybe this should be fenced and skip the tests when running in other environments

Quoted 12 lines
s390x/intercept.c +2 -0
+
 struct {
 	const char *name;
 	void (*func)(void);
@@ -208,6 +257,7 @@ struct {
 	{ "stidp", test_stidp, false },
 	{ "testblock", test_testblock, false },
 	{ "diag318", test_diag318, false },
+	{ "qbs", test_qbs, false },
 	{ NULL, NULL, false }
 };
 
author
#2 lore raw

Quoting Claudio Imbrenda (2022-08-02 18:14:20)
[...]

Quoted 24 lines
Quoted 9 lines
s390x/intercept.c +1 -0
index 9e826b6c79ad..73b06b5fc6e8 100644
@@ -197,6 +197,55 @@ static void test_diag318(void)
 
 }
 
+static inline int sqbs(u64 token)

s390x/intercept.c static void test_diag318(void) · line 210

Quoted 10 lines
s390x/intercept.c +10 -0
+{
+     unsigned long _token = token;
+     int cc;
+
+     asm volatile(
+             "       lgr 1,%[token]\n"
+             "       .insn   rsy,0xeb000000008a,0,0,0(0)\n"
+             "       ipm %[cc]\n"
+             "       srl %[cc],28\n"
+             : [cc] "=&d" (cc)

do you really need all those extra things?

can't you just reduce this whole function to:

Quoted 7 lines

asm volatile(" .insn rsy,0xeb000000008a,0,0,0(0)\n");

in the end we don't care what happens, we only want it to fail with an operation exception

(ok maybe you need to add some clobbers to make sure things work as they should in case the instruction is actually executed)

I don't mind changing that, will do.

[...]

Quoted 10 lines
Quoted 10 lines
s390x/intercept.c +10 -0
+static void test_qbs(void)
+{
+     report_prefix_push("sqbs");
+     expect_pgm_int();
+     sqbs(0xffffffdeadbeefULL);
+     check_pgm_int_code(PGM_INT_CODE_OPERATION);
+     report_prefix_pop();
+
+     report_prefix_push("eqbs");
+     expect_pgm_int();
Quoted 8 lines

s390x/intercept.c static void test_diag318(void) · line 247

Quoted 4 lines
s390x/intercept.c +4 -0
+     eqbs(0xffffffdeadbeefULL);
+     check_pgm_int_code(PGM_INT_CODE_OPERATION);
+     report_prefix_pop();
+}

we expect those to fail only in qemu, right?
maybe this should be fenced and skip the tests when running in other environments

OK will do.