Skip to contentSkip to conversation

s390x: Cleanup and maintenance

PATCH Superseded Janosch Frank 3 participants 31 messages Aug 13, 2021 – Aug 18, 2021

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover s390x: Cleanup and maintenance

A bit more cleanup and some extensions before I start adding the PV SIE support.

https://gitlab.com/frankja/kvm-unit-tests/-/tree/lib_clean_ext

Janosch Frank (8):
s390x: lib: Extend bitops
lib: s390x: Add 0x3d, 0x3e and 0x3f PGM constants
lib: s390x: Print addressing related exception information
lib: s390x: Start using bitops instead of magic constants
s390x: uv-host: Explain why we set up the home space and remove the
space change
lib: s390x: Add PSW_MASK_64
lib: s390x: Control register constant cleanup
lib: s390x: uv: Add rc 0x100 query error handling

 lib/s390x/asm/arch_def.h |  39 +++++++++------
 lib/s390x/asm/bitops.h   | 102 +++++++++++++++++++++++++++++++++++++++
 lib/s390x/interrupt.c    |  80 +++++++++++++++++++++++++++++-
 lib/s390x/smp.c          |   4 +-
 lib/s390x/uv.c           |   4 +-
 s390x/Makefile           |   1 +
 s390x/mvpg-sie.c         |   2 +-
 s390x/sie.c              |   2 +-
 s390x/skrf.c             |   8 +--
 s390x/uv-host.c          |  11 +++--
 10 files changed, 223 insertions(+), 30 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/8 s390x: lib: Extend bitops

Bit setting and clearing is never bad to have.

---
 lib/s390x/asm/bitops.h | 102 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)
lib/s390x/asm/bitops.h +102 -0
index 792881ec..f5612855 100644
@@ -17,6 +17,78 @@
 
 #define BITS_PER_LONG	64
 
+static inline unsigned long *bitops_word(unsigned long nr,
+					 const volatile unsigned long *ptr)
+{
+	unsigned long addr;
+
+	addr = (unsigned long)ptr + ((nr ^ (nr & (BITS_PER_LONG - 1))) >> 3);
+	return (unsigned long *)addr;
+}
+
+static inline unsigned long bitops_mask(unsigned long nr)
+{
+	return 1UL << (nr & (BITS_PER_LONG - 1));
+}
+
+static inline uint64_t laog(volatile unsigned long *ptr, uint64_t mask)
+{
+	uint64_t old;
+
+	/* load and or 64bit concurrent and interlocked */
+	asm volatile(
+		"	laog	%[old],%[mask],%[ptr]\n"
+		: [old] "=d" (old), [ptr] "+Q" (*ptr)
+		: [mask] "d" (mask)
+		: "memory", "cc" );
+	return old;
+}
+
+static inline uint64_t lang(volatile unsigned long *ptr, uint64_t mask)
+{
+	uint64_t old;
+
+	/* load and and 64bit concurrent and interlocked */
+	asm volatile(
+		"	lang	%[old],%[mask],%[ptr]\n"
+		: [old] "=d" (old), [ptr] "+Q" (*ptr)
+		: [mask] "d" (mask)
+		: "memory", "cc" );
+	return old;
+}
+
+static inline void set_bit(unsigned long nr,
+			   const volatile unsigned long *ptr)
+{
+	uint64_t mask = bitops_mask(nr);
+	uint64_t *addr = bitops_word(nr, ptr);
+
+	laog(addr, mask);
+}
+
+static inline void set_bit_inv(unsigned long nr,
+			       const volatile unsigned long *ptr)
+{
+	return set_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+}
+
+static inline void clear_bit(unsigned long nr,
+			     const volatile unsigned long *ptr)
+{
+	uint64_t mask = bitops_mask(nr);
+	uint64_t *addr = bitops_word(nr, ptr);
+
+	lang(addr, ~mask);
+}
+
+static inline void clear_bit_inv(unsigned long nr,
+				 const volatile unsigned long *ptr)
+{
+	return clear_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+}
+
+/* non-atomic bit manipulation functions */
+
 static inline bool test_bit(unsigned long nr,
 			    const volatile unsigned long *ptr)
 {
@@ -33,4 +105,34 @@ static inline bool test_bit_inv(unsigned long nr,
 	return test_bit(nr ^ (BITS_PER_LONG - 1), ptr);
 }
 
+static inline void __set_bit(unsigned long nr,
+			     const volatile unsigned long *ptr)
+{
+	uint64_t mask = bitops_mask(nr);
+	uint64_t *addr = bitops_word(nr, ptr);
+
+	*addr |= mask;
+}
+
+static inline void __set_bit_inv(unsigned long nr,
+				 const volatile unsigned long *ptr)
+{
+	return __set_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+}
+
+static inline void __clear_bit(unsigned long nr,
+			       const volatile unsigned long *ptr)
+{
+	uint64_t mask = bitops_mask(nr);
+	uint64_t *addr = bitops_word(nr, ptr);
+
+	*addr &= ~mask;
+}
+
+static inline void __clear_bit_inv(unsigned long nr,
+				   const volatile unsigned long *ptr)
+{
+	return __clear_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+}
+
 #endif
Signature · 1 line
2.30.2
#2 lore raw

Re: [kvm-unit-tests PATCH 1/8] s390x: lib: Extend bitops

Quoted 14 lines · On Fri, 13 Aug 2021 07:36:08 +0000 Janosch Frank <[email protected]> wrote:

Bit setting and clearing is never bad to have.

---
 lib/s390x/asm/bitops.h | 102

+++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)

lib/s390x/asm/bitops.h +0 -0
index 792881ec..f5612855 100644
@@ -17,6 +17,78 @@
 

lib/s390x/asm/bitops.h line 27

Quoted 10 lines
lib/s390x/asm/bitops.h +6 -0
 #define BITS_PER_LONG	64
 
+static inline unsigned long *bitops_word(unsigned long nr,
+					 const volatile unsigned
 long *ptr) +{
+	unsigned long addr;
+
+	addr = (unsigned long)ptr + ((nr ^ (nr & (BITS_PER_LONG -
 1))) >> 3);
+	return (unsigned long *)addr;

why not just

return ptr + (nr / BITS_PER_LONG);

Quoted 9 lines
lib/s390x/asm/bitops.h +8 -0
+}
+
+static inline unsigned long bitops_mask(unsigned long nr)
+{
+	return 1UL << (nr & (BITS_PER_LONG - 1));
+}
+
+static inline uint64_t laog(volatile unsigned long *ptr, uint64_t
 mask) +{

lib/s390x/asm/bitops.h line 45

Quoted 10 lines
lib/s390x/asm/bitops.h +10 -0
+	uint64_t old;
+
+	/* load and or 64bit concurrent and interlocked */
+	asm volatile(
+		"	laog	%[old],%[mask],%[ptr]\n"
+		: [old] "=d" (old), [ptr] "+Q" (*ptr)
+		: [mask] "d" (mask)
+		: "memory", "cc" );
+	return old;
+}

do we really need the artillery (asm) here?
is there a reason why we can't do this in C?

lib/s390x/asm/bitops.h line 58

Quoted 12 lines
lib/s390x/asm/bitops.h +1 -0
+static inline uint64_t lang(volatile unsigned long *ptr, uint64_t

mask) +{

lib/s390x/asm/bitops.h +10 -0
+	uint64_t old;
+
+	/* load and and 64bit concurrent and interlocked */
+	asm volatile(
+		"	lang	%[old],%[mask],%[ptr]\n"
+		: [old] "=d" (old), [ptr] "+Q" (*ptr)
+		: [mask] "d" (mask)
+		: "memory", "cc" );
+	return old;
+}

(same here as above)

Quoted 71 lines
lib/s390x/asm/bitops.h +63 -0
+
+static inline void set_bit(unsigned long nr,
+			   const volatile unsigned long *ptr)
+{
+	uint64_t mask = bitops_mask(nr);
+	uint64_t *addr = bitops_word(nr, ptr);
+
+	laog(addr, mask);
+}
+
+static inline void set_bit_inv(unsigned long nr,
+			       const volatile unsigned long *ptr)
+{
+	return set_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+}
+
+static inline void clear_bit(unsigned long nr,
+			     const volatile unsigned long *ptr)
+{
+	uint64_t mask = bitops_mask(nr);
+	uint64_t *addr = bitops_word(nr, ptr);
+
+	lang(addr, ~mask);
+}
+
+static inline void clear_bit_inv(unsigned long nr,
+				 const volatile unsigned long *ptr)
+{
+	return clear_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+}
+
+/* non-atomic bit manipulation functions */
+
 static inline bool test_bit(unsigned long nr,
 			    const volatile unsigned long *ptr)
 {
@@ -33,4 +105,34 @@ static inline bool test_bit_inv(unsigned long nr,
 	return test_bit(nr ^ (BITS_PER_LONG - 1), ptr);
 }
 
+static inline void __set_bit(unsigned long nr,
+			     const volatile unsigned long *ptr)
+{
+	uint64_t mask = bitops_mask(nr);
+	uint64_t *addr = bitops_word(nr, ptr);
+
+	*addr |= mask;
+}
+
+static inline void __set_bit_inv(unsigned long nr,
+				 const volatile unsigned long *ptr)
+{
+	return __set_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+}
+
+static inline void __clear_bit(unsigned long nr,
+			       const volatile unsigned long *ptr)
+{
+	uint64_t mask = bitops_mask(nr);
+	uint64_t *addr = bitops_word(nr, ptr);
+
+	*addr &= ~mask;
+}
+
+static inline void __clear_bit_inv(unsigned long nr,
+				   const volatile unsigned long *ptr)
+{
+	return __clear_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+}
+
 #endif
#3 lore raw

Re: [kvm-unit-tests PATCH 1/8] s390x: lib: Extend bitops

Quoted 46 lines · Claudio Imbrenda
Quoted 14 lines · On Fri, 13 Aug 2021 07:36:08 +0000 Janosch Frank <[email protected]> wrote:

Bit setting and clearing is never bad to have.

---
 lib/s390x/asm/bitops.h | 102

+++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)

lib/s390x/asm/bitops.h +0 -0
index 792881ec..f5612855 100644
@@ -17,6 +17,78 @@
 

lib/s390x/asm/bitops.h line 27

Quoted 10 lines
lib/s390x/asm/bitops.h +6 -0
 #define BITS_PER_LONG	64
 
+static inline unsigned long *bitops_word(unsigned long nr,
+					 const volatile unsigned
 long *ptr) +{
+	unsigned long addr;
+
+	addr = (unsigned long)ptr + ((nr ^ (nr & (BITS_PER_LONG -
 1))) >> 3);
+	return (unsigned long *)addr;

why not just

return ptr + (nr / BITS_PER_LONG);

Quoted 14 lines
lib/s390x/asm/bitops.h +13 -0
+}
+
+static inline unsigned long bitops_mask(unsigned long nr)
+{
+	return 1UL << (nr & (BITS_PER_LONG - 1));
+}
+
+static inline uint64_t laog(volatile unsigned long *ptr, uint64_t
 mask) +{
+	uint64_t old;
+
+	/* load and or 64bit concurrent and interlocked */
+	asm volatile(
+		"	laog	%[old],%[mask],%[ptr]\n"
Quoted 8 lines

lib/s390x/asm/bitops.h line 45

Quoted 5 lines
lib/s390x/asm/bitops.h +5 -0
+		: [old] "=d" (old), [ptr] "+Q" (*ptr)
+		: [mask] "d" (mask)
+		: "memory", "cc" );
+	return old;
+}

do we really need the artillery (asm) here?
is there a reason why we can't do this in C?

Those are the interlocked/atomic instructions and even though we don't exactly need them right now I wanted to add them for completeness. We might be able to achieve the same via compiler functionality but this is not my expertise. Maybe Thomas or David have a few pointers for me?

Quoted 88 lines

lib/s390x/asm/bitops.h line 58

Quoted 13 lines
lib/s390x/asm/bitops.h +1 -0
+static inline uint64_t lang(volatile unsigned long *ptr, uint64_t

mask) +{

lib/s390x/asm/bitops.h +10 -0
+	uint64_t old;
+
+	/* load and and 64bit concurrent and interlocked */
+	asm volatile(
+		"	lang	%[old],%[mask],%[ptr]\n"
+		: [old] "=d" (old), [ptr] "+Q" (*ptr)
+		: [mask] "d" (mask)
+		: "memory", "cc" );
+	return old;
+}

(same here as above)

Quoted 71 lines
lib/s390x/asm/bitops.h +63 -0
+
+static inline void set_bit(unsigned long nr,
+			   const volatile unsigned long *ptr)
+{
+	uint64_t mask = bitops_mask(nr);
+	uint64_t *addr = bitops_word(nr, ptr);
+
+	laog(addr, mask);
+}
+
+static inline void set_bit_inv(unsigned long nr,
+			       const volatile unsigned long *ptr)
+{
+	return set_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+}
+
+static inline void clear_bit(unsigned long nr,
+			     const volatile unsigned long *ptr)
+{
+	uint64_t mask = bitops_mask(nr);
+	uint64_t *addr = bitops_word(nr, ptr);
+
+	lang(addr, ~mask);
+}
+
+static inline void clear_bit_inv(unsigned long nr,
+				 const volatile unsigned long *ptr)
+{
+	return clear_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+}
+
+/* non-atomic bit manipulation functions */
+
 static inline bool test_bit(unsigned long nr,
 			    const volatile unsigned long *ptr)
 {
@@ -33,4 +105,34 @@ static inline bool test_bit_inv(unsigned long nr,
 	return test_bit(nr ^ (BITS_PER_LONG - 1), ptr);
 }
 
+static inline void __set_bit(unsigned long nr,
+			     const volatile unsigned long *ptr)
+{
+	uint64_t mask = bitops_mask(nr);
+	uint64_t *addr = bitops_word(nr, ptr);
+
+	*addr |= mask;
+}
+
+static inline void __set_bit_inv(unsigned long nr,
+				 const volatile unsigned long *ptr)
+{
+	return __set_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+}
+
+static inline void __clear_bit(unsigned long nr,
+			       const volatile unsigned long *ptr)
+{
+	uint64_t mask = bitops_mask(nr);
+	uint64_t *addr = bitops_word(nr, ptr);
+
+	*addr &= ~mask;
+}
+
+static inline void __clear_bit_inv(unsigned long nr,
+				   const volatile unsigned long *ptr)
+{
+	return __clear_bit(nr ^ (BITS_PER_LONG - 1), ptr);
+}
+
 #endif
#4 lore raw

Re: [kvm-unit-tests PATCH 1/8] s390x: lib: Extend bitops

Quoted 56 lines · Janosch Frank
Quoted 46 lines · Claudio Imbrenda
Quoted 14 lines · On Fri, 13 Aug 2021 07:36:08 +0000 Janosch Frank <[email protected]> wrote:

Bit setting and clearing is never bad to have.

---
  lib/s390x/asm/bitops.h | 102

+++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)

lib/s390x/asm/bitops.h +0 -0
index 792881ec..f5612855 100644
@@ -17,6 +17,78 @@
 

lib/s390x/asm/bitops.h line 27

Quoted 10 lines
lib/s390x/asm/bitops.h +6 -0
  #define BITS_PER_LONG	64
 
+static inline unsigned long *bitops_word(unsigned long nr,
+					 const volatile unsigned
 long *ptr) +{
+	unsigned long addr;
+
+	addr = (unsigned long)ptr + ((nr ^ (nr & (BITS_PER_LONG -
 1))) >> 3);
+	return (unsigned long *)addr;

why not just

return ptr + (nr / BITS_PER_LONG);

Quoted 14 lines
lib/s390x/asm/bitops.h +13 -0
+}
+
+static inline unsigned long bitops_mask(unsigned long nr)
+{
+	return 1UL << (nr & (BITS_PER_LONG - 1));
+}
+
+static inline uint64_t laog(volatile unsigned long *ptr, uint64_t
 mask) +{
+	uint64_t old;
+
+	/* load and or 64bit concurrent and interlocked */
+	asm volatile(
+		"	laog	%[old],%[mask],%[ptr]\n"
Quoted 8 lines

lib/s390x/asm/bitops.h line 45

Quoted 5 lines
lib/s390x/asm/bitops.h +5 -0
+		: [old] "=d" (old), [ptr] "+Q" (*ptr)
+		: [mask] "d" (mask)
+		: "memory", "cc" );
+	return old;
+}

do we really need the artillery (asm) here?
is there a reason why we can't do this in C?

Quoted 2 lines

Those are the interlocked/atomic instructions and even though we don't exactly need them right now I wanted to add them for completeness.

I think I agree with Claudio - unless we really need them, we should not clog the sources with arbitrary inline assembly functions.

Quoted 2 lines

We might be able to achieve the same via compiler functionality but this is not my expertise. Maybe Thomas or David have a few pointers for me?

I'm not an expert with atomic builtins either, but what's the point of this at all? Loading a value and OR-ing something into the value in one go? What's that good for?

Thomas

#5 lore raw

Re: [kvm-unit-tests PATCH 1/8] s390x: lib: Extend bitops

Quoted 57 lines · Thomas Huth
Quoted 56 lines · Janosch Frank
Quoted 54 lines · Claudio Imbrenda
Quoted 14 lines · On Fri, 13 Aug 2021 07:36:08 +0000 Janosch Frank <[email protected]> wrote:

Bit setting and clearing is never bad to have.

---
  lib/s390x/asm/bitops.h | 102

+++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)

lib/s390x/asm/bitops.h +0 -0
index 792881ec..f5612855 100644
@@ -17,6 +17,78 @@
 

lib/s390x/asm/bitops.h line 27

Quoted 10 lines
lib/s390x/asm/bitops.h +6 -0
  #define BITS_PER_LONG	64
 
+static inline unsigned long *bitops_word(unsigned long nr,
+					 const volatile unsigned
 long *ptr) +{
+	unsigned long addr;
+
+	addr = (unsigned long)ptr + ((nr ^ (nr & (BITS_PER_LONG -
 1))) >> 3);
+	return (unsigned long *)addr;

why not just

return ptr + (nr / BITS_PER_LONG);

Quoted 9 lines
lib/s390x/asm/bitops.h +8 -0
+}
+
+static inline unsigned long bitops_mask(unsigned long nr)
+{
+	return 1UL << (nr & (BITS_PER_LONG - 1));
+}
+
+static inline uint64_t laog(volatile unsigned long *ptr, uint64_t
 mask) +{

lib/s390x/asm/bitops.h line 45

Quoted 10 lines
lib/s390x/asm/bitops.h +10 -0
+	uint64_t old;
+
+	/* load and or 64bit concurrent and interlocked */
+	asm volatile(
+		"	laog	%[old],%[mask],%[ptr]\n"
+		: [old] "=d" (old), [ptr] "+Q" (*ptr)
+		: [mask] "d" (mask)
+		: "memory", "cc" );
+	return old;
+}

do we really need the artillery (asm) here?
is there a reason why we can't do this in C?

Quoted 5 lines
Quoted 2 lines

Those are the interlocked/atomic instructions and even though we don't exactly need them right now I wanted to add them for completeness.

I think I agree with Claudio - unless we really need them, we should not clog the sources with arbitrary inline assembly functions.

Alright I can trim it down

Quoted 7 lines
Quoted 3 lines

We might be able to achieve the same via compiler functionality but this is not my expertise. Maybe Thomas or David have a few pointers for me?

I'm not an expert with atomic builtins either, but what's the point of this at all? Loading a value and OR-ing something into the value in one go? What's that good for?

Well it's a block-concurrent interlocked-update load, or and store. I.e. it loads the data from the ptr and copies it into [old] then ors the mask and stores it back to the ptr address.

The instruction name "load and or" does not represent the full actions of the instruction.

Quoted 3 lines

Thomas

#6 lore raw

Re: [kvm-unit-tests PATCH 1/8] s390x: lib: Extend bitops

Quoted 74 lines · Janosch Frank
Quoted 57 lines · Thomas Huth
Quoted 56 lines · Janosch Frank
Quoted 54 lines · Claudio Imbrenda
Quoted 14 lines · On Fri, 13 Aug 2021 07:36:08 +0000 Janosch Frank <[email protected]> wrote:

Bit setting and clearing is never bad to have.

---
   lib/s390x/asm/bitops.h | 102

+++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)

lib/s390x/asm/bitops.h +0 -0
index 792881ec..f5612855 100644
@@ -17,6 +17,78 @@
 

lib/s390x/asm/bitops.h line 27

Quoted 10 lines
lib/s390x/asm/bitops.h +6 -0
   #define BITS_PER_LONG	64
 
+static inline unsigned long *bitops_word(unsigned long nr,
+					 const volatile unsigned
 long *ptr) +{
+	unsigned long addr;
+
+	addr = (unsigned long)ptr + ((nr ^ (nr & (BITS_PER_LONG -
 1))) >> 3);
+	return (unsigned long *)addr;

why not just

return ptr + (nr / BITS_PER_LONG);

Quoted 9 lines
lib/s390x/asm/bitops.h +8 -0
+}
+
+static inline unsigned long bitops_mask(unsigned long nr)
+{
+	return 1UL << (nr & (BITS_PER_LONG - 1));
+}
+
+static inline uint64_t laog(volatile unsigned long *ptr, uint64_t
 mask) +{

lib/s390x/asm/bitops.h line 45

Quoted 10 lines
lib/s390x/asm/bitops.h +10 -0
+	uint64_t old;
+
+	/* load and or 64bit concurrent and interlocked */
+	asm volatile(
+		"	laog	%[old],%[mask],%[ptr]\n"
+		: [old] "=d" (old), [ptr] "+Q" (*ptr)
+		: [mask] "d" (mask)
+		: "memory", "cc" );
+	return old;
+}

do we really need the artillery (asm) here?
is there a reason why we can't do this in C?

Quoted 5 lines
Quoted 2 lines

Those are the interlocked/atomic instructions and even though we don't exactly need them right now I wanted to add them for completeness.

I think I agree with Claudio - unless we really need them, we should not clog the sources with arbitrary inline assembly functions.

Alright I can trim it down

Quoted 7 lines
Quoted 3 lines

We might be able to achieve the same via compiler functionality but this is not my expertise. Maybe Thomas or David have a few pointers for me?

I'm not an expert with atomic builtins either, but what's the point of this at all? Loading a value and OR-ing something into the value in one go? What's that good for?

Quoted 6 lines

Well it's a block-concurrent interlocked-update load, or and store. I.e. it loads the data from the ptr and copies it into [old] then ors the mask and stores it back to the ptr address.

The instruction name "load and or" does not represent the full actions of the instruction.

Ok, thanks, that makes more sense now, but you could at least have mentioned this in the comment that you added in front of it :-)

Anyway, I guess it's easier to use the builtin atomic functions like __atomic_or_fetch() for stuff like this in case we ever need it.

Thomas

#7 lore raw

PATCH 2/8 lib: s390x: Add 0x3d, 0x3e and 0x3f PGM constants

In reply to Janosch Frank

For UV and format 4 SIE tests we need to handle the following PGM exceptions:
0x3d Secure Storage Access (non-secure CPU accesses secure storage) 0x3e Non-Secure Storage Access (secure CPU accesses non-secure storage) 0x3f Mapping of secure guest is wrong

---
 lib/s390x/asm/arch_def.h | 3 +++
 lib/s390x/interrupt.c    | 3 +++
 2 files changed, 6 insertions(+)
lib/s390x/asm/arch_def.h +3 -0
index 15cf7d48..4ca02c1d 100644
@@ -177,6 +177,9 @@ _Static_assert(sizeof(struct lowcore) == 0x1900, "Lowcore size");
 #define PGM_INT_CODE_REGION_FIRST_TRANS		0x39
 #define PGM_INT_CODE_REGION_SECOND_TRANS	0x3a
 #define PGM_INT_CODE_REGION_THIRD_TRANS		0x3b
+#define PGM_INT_CODE_SECURE_STOR_ACCESS		0x3d
+#define PGM_INT_CODE_NON_SECURE_STOR_ACCESS	0x3e
+#define PGM_INT_CODE_SECURE_STOR_VIOLATION	0x3f
 #define PGM_INT_CODE_MONITOR_EVENT		0x40
 #define PGM_INT_CODE_PER			0x80
 #define PGM_INT_CODE_CRYPTO_OPERATION		0x119
lib/s390x/interrupt.c +3 -0
index 785b7355..01ded49d 100644
@@ -115,6 +115,9 @@ static void fixup_pgm_int(struct stack_frame_int *stack)
 	case PGM_INT_CODE_REGION_THIRD_TRANS:
 	case PGM_INT_CODE_PER:
 	case PGM_INT_CODE_CRYPTO_OPERATION:
+	case PGM_INT_CODE_SECURE_STOR_ACCESS:
+	case PGM_INT_CODE_NON_SECURE_STOR_ACCESS:
+	case PGM_INT_CODE_SECURE_STOR_VIOLATION:
 		/* The interrupt was nullified, the old PSW points at the
 		 * responsible instruction. Forward the PSW so we don't loop.
 		 */
Signature · 1 line
2.30.2
Reviewed-by on v1 2/8
#8 lore raw

Re: [kvm-unit-tests PATCH 2/8] lib: s390x: Add 0x3d, 0x3e and 0x3f PGM constants

Quoted 6 lines · On Fri, 13 Aug 2021 07:36:09 +0000 Janosch Frank <[email protected]> wrote:

For UV and format 4 SIE tests we need to handle the following PGM
exceptions: 0x3d Secure Storage Access (non-secure CPU accesses secure storage) 0x3e Non-Secure Storage Access (secure CPU accesses non-secure storage) 0x3f Mapping of secure guest is wrong

Quoted 34 lines
---
 lib/s390x/asm/arch_def.h | 3 +++
 lib/s390x/interrupt.c    | 3 +++
 2 files changed, 6 insertions(+)
lib/s390x/asm/arch_def.h +0 -0
index 15cf7d48..4ca02c1d 100644
@@ -177,6 +177,9 @@ _Static_assert(sizeof(struct lowcore) == 0x1900,

"Lowcore size"); #define PGM_INT_CODE_REGION_FIRST_TRANS

	0x39 #define PGM_INT_CODE_REGION_SECOND_TRANS	0x3a

#define PGM_INT_CODE_REGION_THIRD_TRANS 0x3b

lib/s390x/asm/arch_def.h +3 -0
+#define PGM_INT_CODE_SECURE_STOR_ACCESS		0x3d
+#define PGM_INT_CODE_NON_SECURE_STOR_ACCESS	0x3e
+#define PGM_INT_CODE_SECURE_STOR_VIOLATION	0x3f
 #define PGM_INT_CODE_MONITOR_EVENT		0x40
 #define PGM_INT_CODE_PER			0x80
 #define PGM_INT_CODE_CRYPTO_OPERATION		0x119
lib/s390x/interrupt.c +3 -0
index 785b7355..01ded49d 100644
@@ -115,6 +115,9 @@ static void fixup_pgm_int(struct stack_frame_int
 *stack) case PGM_INT_CODE_REGION_THIRD_TRANS:
 	case PGM_INT_CODE_PER:
 	case PGM_INT_CODE_CRYPTO_OPERATION:
+	case PGM_INT_CODE_SECURE_STOR_ACCESS:
+	case PGM_INT_CODE_NON_SECURE_STOR_ACCESS:
+	case PGM_INT_CODE_SECURE_STOR_VIOLATION:
 		/* The interrupt was nullified, the old PSW points

at the
* responsible instruction. Forward the PSW so we
don't loop. */

#9 lore raw

PATCH 3/8 lib: s390x: Print addressing related exception information

In reply to Janosch Frank

Right now we only get told the kind of program exception as well as the PSW at the point where it happened.

For addressing exceptions the PSW is not always enough so let's print the TEID which contains the failing address and flags that tell us more about the kind of address exception.

---
 lib/s390x/asm/arch_def.h |  4 +++
 lib/s390x/interrupt.c    | 72 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)
lib/s390x/asm/arch_def.h +4 -0
index 4ca02c1d..39c5ba99 100644
@@ -41,6 +41,10 @@ struct psw {
 	uint64_t	addr;
 };
 
+/* Let's ignore spaces we don't expect to use for now. */
+#define AS_PRIM				0
+#define AS_HOME				3
+
 #define PSW_MASK_EXT			0x0100000000000000UL
 #define PSW_MASK_IO			0x0200000000000000UL
 #define PSW_MASK_DAT			0x0400000000000000UL
lib/s390x/interrupt.c +72 -0

90 lines not on this page · raw message

Signature · 1 line
2.30.2
#10 lore raw

Re: [kvm-unit-tests PATCH 3/8] lib: s390x: Print addressing related exception information

Quoted 42 lines · On Fri, 13 Aug 2021 07:36:10 +0000 Janosch Frank <[email protected]> wrote:

Right now we only get told the kind of program exception as well as the PSW at the point where it happened.

For addressing exceptions the PSW is not always enough so let's print the TEID which contains the failing address and flags that tell us more about the kind of address exception.

---
 lib/s390x/asm/arch_def.h |  4 +++
 lib/s390x/interrupt.c    | 72

++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+)

lib/s390x/asm/arch_def.h +4 -0
index 4ca02c1d..39c5ba99 100644
@@ -41,6 +41,10 @@ struct psw {
 	uint64_t	addr;
 };
 
+/* Let's ignore spaces we don't expect to use for now. */
+#define AS_PRIM				0
+#define AS_HOME				3
+
 #define PSW_MASK_EXT			0x0100000000000000UL
 #define PSW_MASK_IO			0x0200000000000000UL
 #define PSW_MASK_DAT			0x0400000000000000UL
lib/s390x/interrupt.c +1 -0
index 01ded49d..1248bceb 100644
@@ -12,6 +12,7 @@
 #include <sclp.h>
 #include <interrupt.h>
 #include <sie.h>
+#include <asm/page.h>
 
 static bool pgm_int_expected;
 static bool ext_int_expected;

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int · line 130

Quoted 4 lines
lib/s390x/interrupt.c +1 -0
@@ -126,6 +127,73 @@ static void fixup_pgm_int(struct stack_frame_int
 *stack) /* suppressed/terminated/completed point already at the next
 address */ }
 
+static void decode_pgm_prot(uint64_t teid)

it is actually more complicated than this.

if you don't want to add all the possibilities because they are unlikely and/or not relevant, maybe add a comment

Quoted 86 lines
lib/s390x/interrupt.c +39 -0
+{
+	/* Low-address protection exception, 100 */
+	if (test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) &&
 !test_bit_inv(61, &teid)) {
+		printf("Type: LAP\n");
+		return;
+	}
+
+	/* Instruction execution prevention, i.e. no-execute, 101 */
+	if (test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) &&
 test_bit_inv(61, &teid)) {
+		printf("Type: IEP\n");
+		return;
+	}
+
+	/* Standard DAT exception, 001 */
+	if (!test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) &&
 test_bit_inv(61, &teid)) {
+		printf("Type: DAT\n");
+		return;
+	}
+}
+
+static void decode_teid(uint64_t teid)
+{
+	int asce_id = lc->trans_exc_id & 3;
+	bool dat = lc->pgm_old_psw.mask & PSW_MASK_DAT;
+
+	printf("Memory exception information:\n");
+	printf("TEID: %lx\n", teid);
+	printf("DAT: %s\n", dat ? "on" : "off");
+	printf("AS: %s\n", asce_id == AS_PRIM ? "Primary" : "Home");
+
+	if (lc->pgm_int_code == PGM_INT_CODE_PROTECTION)
+		decode_pgm_prot(teid);
+
+	/*
+	 * If teid bit 61 is off for these two exception the reported
+	 * address is unpredictable.
+	 */
+	if ((lc->pgm_int_code == PGM_INT_CODE_SECURE_STOR_ACCESS ||
+	     lc->pgm_int_code == PGM_INT_CODE_SECURE_STOR_VIOLATION)

&&

lib/s390x/interrupt.c +2 -0
+	    !test_bit_inv(61, &teid)) {
+		printf("Address: %lx, unpredictable\n ", teid &

PAGE_MASK);

lib/s390x/interrupt.c +27 -0
+		return;
+	}
+	printf("Address: %lx\n\n", teid & PAGE_MASK);
+}
+
+static void print_storage_exception_information(void)
+{
+	switch (lc->pgm_int_code) {
+	case PGM_INT_CODE_PROTECTION:
+	case PGM_INT_CODE_PAGE_TRANSLATION:
+	case PGM_INT_CODE_SEGMENT_TRANSLATION:
+	case PGM_INT_CODE_ASCE_TYPE:
+	case PGM_INT_CODE_REGION_FIRST_TRANS:
+	case PGM_INT_CODE_REGION_SECOND_TRANS:
+	case PGM_INT_CODE_REGION_THIRD_TRANS:
+	case PGM_INT_CODE_SECURE_STOR_ACCESS:
+	case PGM_INT_CODE_NON_SECURE_STOR_ACCESS:
+	case PGM_INT_CODE_SECURE_STOR_VIOLATION:
+		decode_teid(lc->trans_exc_id);
+		break;
+	default:
+		return;
+	}
+}
+
 static void print_int_regs(struct stack_frame_int *stack)
 {
 	printf("\n");
@@ -155,6 +223,10 @@ static void print_pgm_info(struct
 stack_frame_int *stack) lc->pgm_int_code, stap(),
 lc->pgm_old_psw.addr, lc->pgm_int_id); print_int_regs(stack);
 	dump_stack();
+
+	/* Dump stack doesn't end with a \n so we add it here

instead */

lib/s390x/interrupt.c +2 -0
+	printf("\n");
+	print_storage_exception_information();
 	report_summary();
 	abort();
 }
#11 lore raw

Re: [kvm-unit-tests PATCH 3/8] lib: s390x: Print addressing related exception information

Quoted 48 lines · Claudio Imbrenda
Quoted 45 lines · On Fri, 13 Aug 2021 07:36:10 +0000 Janosch Frank <[email protected]> wrote:

Right now we only get told the kind of program exception as well as the PSW at the point where it happened.

For addressing exceptions the PSW is not always enough so let's print the TEID which contains the failing address and flags that tell us more about the kind of address exception.

---
 lib/s390x/asm/arch_def.h |  4 +++
 lib/s390x/interrupt.c    | 72

++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+)

lib/s390x/asm/arch_def.h +4 -0
index 4ca02c1d..39c5ba99 100644
@@ -41,6 +41,10 @@ struct psw {
 	uint64_t	addr;
 };
 
+/* Let's ignore spaces we don't expect to use for now. */
+#define AS_PRIM				0
+#define AS_HOME				3
+
 #define PSW_MASK_EXT			0x0100000000000000UL
 #define PSW_MASK_IO			0x0200000000000000UL
 #define PSW_MASK_DAT			0x0400000000000000UL
lib/s390x/interrupt.c +1 -0
index 01ded49d..1248bceb 100644
@@ -12,6 +12,7 @@
 #include <sclp.h>
 #include <interrupt.h>
 #include <sie.h>
+#include <asm/page.h>
 
 static bool pgm_int_expected;
 static bool ext_int_expected;
@@ -126,6 +127,73 @@ static void fixup_pgm_int(struct stack_frame_int
 *stack) /* suppressed/terminated/completed point already at the next
 address */ }
 
Quoted 3 lines

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 130

Quoted 1 line
lib/s390x/interrupt.c +1 -0
+static void decode_pgm_prot(uint64_t teid)

it is actually more complicated than this.

I know it hurts to look at the spec :)

Quoted 3 lines

if you don't want to add all the possibilities because they are unlikely and/or not relevant, maybe add a comment

Will do!

Quoted 88 lines
Quoted 87 lines
lib/s390x/interrupt.c +39 -0
+{
+	/* Low-address protection exception, 100 */
+	if (test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) &&
 !test_bit_inv(61, &teid)) {
+		printf("Type: LAP\n");
+		return;
+	}
+
+	/* Instruction execution prevention, i.e. no-execute, 101 */
+	if (test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) &&
 test_bit_inv(61, &teid)) {
+		printf("Type: IEP\n");
+		return;
+	}
+
+	/* Standard DAT exception, 001 */
+	if (!test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) &&
 test_bit_inv(61, &teid)) {
+		printf("Type: DAT\n");
+		return;
+	}
+}
+
+static void decode_teid(uint64_t teid)
+{
+	int asce_id = lc->trans_exc_id & 3;
+	bool dat = lc->pgm_old_psw.mask & PSW_MASK_DAT;
+
+	printf("Memory exception information:\n");
+	printf("TEID: %lx\n", teid);
+	printf("DAT: %s\n", dat ? "on" : "off");
+	printf("AS: %s\n", asce_id == AS_PRIM ? "Primary" : "Home");
+
+	if (lc->pgm_int_code == PGM_INT_CODE_PROTECTION)
+		decode_pgm_prot(teid);
+
+	/*
+	 * If teid bit 61 is off for these two exception the reported
+	 * address is unpredictable.
+	 */
+	if ((lc->pgm_int_code == PGM_INT_CODE_SECURE_STOR_ACCESS ||
+	     lc->pgm_int_code == PGM_INT_CODE_SECURE_STOR_VIOLATION)

&&

lib/s390x/interrupt.c +2 -0
+	    !test_bit_inv(61, &teid)) {
+		printf("Address: %lx, unpredictable\n ", teid &

PAGE_MASK);

lib/s390x/interrupt.c +27 -0
+		return;
+	}
+	printf("Address: %lx\n\n", teid & PAGE_MASK);
+}
+
+static void print_storage_exception_information(void)
+{
+	switch (lc->pgm_int_code) {
+	case PGM_INT_CODE_PROTECTION:
+	case PGM_INT_CODE_PAGE_TRANSLATION:
+	case PGM_INT_CODE_SEGMENT_TRANSLATION:
+	case PGM_INT_CODE_ASCE_TYPE:
+	case PGM_INT_CODE_REGION_FIRST_TRANS:
+	case PGM_INT_CODE_REGION_SECOND_TRANS:
+	case PGM_INT_CODE_REGION_THIRD_TRANS:
+	case PGM_INT_CODE_SECURE_STOR_ACCESS:
+	case PGM_INT_CODE_NON_SECURE_STOR_ACCESS:
+	case PGM_INT_CODE_SECURE_STOR_VIOLATION:
+		decode_teid(lc->trans_exc_id);
+		break;
+	default:
+		return;
+	}
+}
+
 static void print_int_regs(struct stack_frame_int *stack)
 {
 	printf("\n");
@@ -155,6 +223,10 @@ static void print_pgm_info(struct
 stack_frame_int *stack) lc->pgm_int_code, stap(),
 lc->pgm_old_psw.addr, lc->pgm_int_id); print_int_regs(stack);
 	dump_stack();
+
+	/* Dump stack doesn't end with a \n so we add it here

instead */

lib/s390x/interrupt.c +2 -0
+	printf("\n");
+	print_storage_exception_information();
 	report_summary();
 	abort();
 }
#12 lore raw

Re: [kvm-unit-tests PATCH 3/8] lib: s390x: Print addressing related exception information

In reply to Janosch Frank
Quoted 41 lines · Janosch Frank

Right now we only get told the kind of program exception as well as the PSW at the point where it happened.

For addressing exceptions the PSW is not always enough so let's print the TEID which contains the failing address and flags that tell us more about the kind of address exception.

---
  lib/s390x/asm/arch_def.h |  4 +++
  lib/s390x/interrupt.c    | 72 ++++++++++++++++++++++++++++++++++++++++
  2 files changed, 76 insertions(+)
lib/s390x/asm/arch_def.h +4 -0
index 4ca02c1d..39c5ba99 100644
@@ -41,6 +41,10 @@ struct psw {
  	uint64_t	addr;
  };
 
+/* Let's ignore spaces we don't expect to use for now. */
+#define AS_PRIM				0
+#define AS_HOME				3
+
  #define PSW_MASK_EXT			0x0100000000000000UL
  #define PSW_MASK_IO			0x0200000000000000UL
  #define PSW_MASK_DAT			0x0400000000000000UL
lib/s390x/interrupt.c +1 -0
index 01ded49d..1248bceb 100644
@@ -12,6 +12,7 @@
  #include <sclp.h>
  #include <interrupt.h>
  #include <sie.h>
+#include <asm/page.h>
 
  static bool pgm_int_expected;
  static bool ext_int_expected;

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 133

Quoted 7 lines
lib/s390x/interrupt.c +4 -0
@@ -126,6 +127,73 @@ static void fixup_pgm_int(struct stack_frame_int *stack)
  	/* suppressed/terminated/completed point already at the next address */
  }
 
+static void decode_pgm_prot(uint64_t teid)
+{
+	/* Low-address protection exception, 100 */
+	if (test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) && !test_bit_inv(61, &teid)) {

Likely just a matter of taste, but I'd prefer something like:

	if ((teid & 0x8c) == 0x80) {
Quoted 5 lines
lib/s390x/interrupt.c +5 -0
+		printf("Type: LAP\n");
+		return;
+	}
+
+	/* Instruction execution prevention, i.e. no-execute, 101 */

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 148

Quoted 10 lines
lib/s390x/interrupt.c +10 -0
+	if (test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) && test_bit_inv(61, &teid)) {
+		printf("Type: IEP\n");
+		return;
+	}
+
+	/* Standard DAT exception, 001 */
+	if (!test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) && test_bit_inv(61, &teid)) {
+		printf("Type: DAT\n");
+		return;
+	}

What about 010 (key controlled protection) and 011 (access-list controlled protection)? Even if we do not trigger those yet, it might make sense to add them right from the start, too?

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 153

Quoted 5 lines
lib/s390x/interrupt.c +5 -0
+}
+
+static void decode_teid(uint64_t teid)
+{
+	int asce_id = lc->trans_exc_id & 3;

Why are you referencing the lc->trans_exc_id here again? It's already passed as "teid" parameter.

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 159

Quoted 6 lines
lib/s390x/interrupt.c +6 -0
+	bool dat = lc->pgm_old_psw.mask & PSW_MASK_DAT;
+
+	printf("Memory exception information:\n");
+	printf("TEID: %lx\n", teid);
+	printf("DAT: %s\n", dat ? "on" : "off");
+	printf("AS: %s\n", asce_id == AS_PRIM ? "Primary" : "Home");

Could "secondary" or "AR" mode really never happen here? I'd rather like to see a switch-case statement here that is able to print all four modes, just to avoid confusion.

Quoted 23 lines
lib/s390x/interrupt.c +23 -0
+	if (lc->pgm_int_code == PGM_INT_CODE_PROTECTION)
+		decode_pgm_prot(teid);
+
+	/*
+	 * If teid bit 61 is off for these two exception the reported
+	 * address is unpredictable.
+	 */
+	if ((lc->pgm_int_code == PGM_INT_CODE_SECURE_STOR_ACCESS ||
+	     lc->pgm_int_code == PGM_INT_CODE_SECURE_STOR_VIOLATION) &&
+	    !test_bit_inv(61, &teid)) {
+		printf("Address: %lx, unpredictable\n ", teid & PAGE_MASK);
+		return;
+	}
+	printf("Address: %lx\n\n", teid & PAGE_MASK);
+}
+
+static void print_storage_exception_information(void)
+{
+	switch (lc->pgm_int_code) {
+	case PGM_INT_CODE_PROTECTION:
+	case PGM_INT_CODE_PAGE_TRANSLATION:
+	case PGM_INT_CODE_SEGMENT_TRANSLATION:
+	case PGM_INT_CODE_ASCE_TYPE:

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 193

Quoted 10 lines
lib/s390x/interrupt.c +10 -0
+	case PGM_INT_CODE_REGION_FIRST_TRANS:
+	case PGM_INT_CODE_REGION_SECOND_TRANS:
+	case PGM_INT_CODE_REGION_THIRD_TRANS:
+	case PGM_INT_CODE_SECURE_STOR_ACCESS:
+	case PGM_INT_CODE_NON_SECURE_STOR_ACCESS:
+	case PGM_INT_CODE_SECURE_STOR_VIOLATION:
+		decode_teid(lc->trans_exc_id);
+		break;
+	default:
+		return;

I think you could drop that default case.

Quoted 18 lines
lib/s390x/interrupt.c +7 -0
+	}
+}
+
  static void print_int_regs(struct stack_frame_int *stack)
  {
  	printf("\n");
@@ -155,6 +223,10 @@ static void print_pgm_info(struct stack_frame_int *stack)
  	       lc->pgm_int_code, stap(), lc->pgm_old_psw.addr, lc->pgm_int_id);
  	print_int_regs(stack);
  	dump_stack();
+
+	/* Dump stack doesn't end with a \n so we add it here instead */
+	printf("\n");
+	print_storage_exception_information();
  	report_summary();
  	abort();
  }
#13 lore raw

Re: [kvm-unit-tests PATCH 3/8] lib: s390x: Print addressing related exception information

Quoted 54 lines · On Wed, 18 Aug 2021 11:12:57 +0200 Thomas Huth <[email protected]> wrote:
Quoted 49 lines · Janosch Frank

Right now we only get told the kind of program exception as well as the PSW at the point where it happened.

For addressing exceptions the PSW is not always enough so let's print the TEID which contains the failing address and flags that tell us more about the kind of address exception.

---
  lib/s390x/asm/arch_def.h |  4 +++
  lib/s390x/interrupt.c    | 72

++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+)

lib/s390x/asm/arch_def.h +4 -0
index 4ca02c1d..39c5ba99 100644
@@ -41,6 +41,10 @@ struct psw {
  	uint64_t	addr;
  };
 
+/* Let's ignore spaces we don't expect to use for now. */
+#define AS_PRIM				0
+#define AS_HOME				3
+
  #define PSW_MASK_EXT			0x0100000000000000UL
  #define PSW_MASK_IO			0x0200000000000000UL
  #define PSW_MASK_DAT			0x0400000000000000UL
lib/s390x/interrupt.c +1 -0
index 01ded49d..1248bceb 100644
@@ -12,6 +12,7 @@
  #include <sclp.h>
  #include <interrupt.h>
  #include <sie.h>
+#include <asm/page.h>
 
  static bool pgm_int_expected;
  static bool ext_int_expected;
@@ -126,6 +127,73 @@ static void fixup_pgm_int(struct

stack_frame_int *stack) /* suppressed/terminated/completed point already at the next address */ }

lib/s390x/interrupt.c +4 -0
+static void decode_pgm_prot(uint64_t teid)
+{
+	/* Low-address protection exception, 100 */
+	if (test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) &&
Quoted 1 line

!test_bit_inv(61, &teid)) {

Likely just a matter of taste, but I'd prefer something like:

Quoted 1 line
	if ((teid & 0x8c) == 0x80) {

or even better:

	switch (teid & TEID_MASK) {
Quoted 104 lines
Quoted 16 lines
lib/s390x/interrupt.c +5 -0
+		printf("Type: LAP\n");
+		return;
+	}
+
+	/* Instruction execution prevention, i.e. no-execute, 101

*/

lib/s390x/interrupt.c +1 -0
+	if (test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) &&

test_bit_inv(61, &teid)) {

lib/s390x/interrupt.c +6 -0
+		printf("Type: IEP\n");
+		return;
+	}
+
+	/* Standard DAT exception, 001 */
+	if (!test_bit_inv(56, &teid) && !test_bit_inv(60, &teid)

&& test_bit_inv(61, &teid)) {

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 148

Quoted 3 lines
lib/s390x/interrupt.c +3 -0
+		printf("Type: DAT\n");
+		return;
+	}  

What about 010 (key controlled protection) and 011 (access-list controlled protection)? Even if we do not trigger those yet, it might make sense to add them right from the start, too?

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 153

Quoted 5 lines
lib/s390x/interrupt.c +5 -0
+}
+
+static void decode_teid(uint64_t teid)
+{
+	int asce_id = lc->trans_exc_id & 3;  

Why are you referencing the lc->trans_exc_id here again? It's already passed as "teid" parameter.

Quoted 7 lines
lib/s390x/interrupt.c +6 -0
+	bool dat = lc->pgm_old_psw.mask & PSW_MASK_DAT;
+
+	printf("Memory exception information:\n");
+	printf("TEID: %lx\n", teid);
+	printf("DAT: %s\n", dat ? "on" : "off");
+	printf("AS: %s\n", asce_id == AS_PRIM ? "Primary" :

"Home");

Could "secondary" or "AR" mode really never happen here? I'd rather like to see a switch-case statement here that is able to print all four modes, just to avoid confusion.

Quoted 26 lines
lib/s390x/interrupt.c +5 -0
+	if (lc->pgm_int_code == PGM_INT_CODE_PROTECTION)
+		decode_pgm_prot(teid);
+
+	/*
+	 * If teid bit 61 is off for these two exception the

reported

lib/s390x/interrupt.c +4 -0
+	 * address is unpredictable.
+	 */
+	if ((lc->pgm_int_code == PGM_INT_CODE_SECURE_STOR_ACCESS ||
+	     lc->pgm_int_code ==

PGM_INT_CODE_SECURE_STOR_VIOLATION) &&

lib/s390x/interrupt.c +2 -0
+	    !test_bit_inv(61, &teid)) {
+		printf("Address: %lx, unpredictable\n ", teid &

PAGE_MASK);

lib/s390x/interrupt.c +12 -0
+		return;
+	}
+	printf("Address: %lx\n\n", teid & PAGE_MASK);
+}
+
+static void print_storage_exception_information(void)
+{
+	switch (lc->pgm_int_code) {
+	case PGM_INT_CODE_PROTECTION:
+	case PGM_INT_CODE_PAGE_TRANSLATION:
+	case PGM_INT_CODE_SEGMENT_TRANSLATION:
+	case PGM_INT_CODE_ASCE_TYPE:

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 193

Quoted 10 lines
lib/s390x/interrupt.c +10 -0
+	case PGM_INT_CODE_REGION_FIRST_TRANS:
+	case PGM_INT_CODE_REGION_SECOND_TRANS:
+	case PGM_INT_CODE_REGION_THIRD_TRANS:
+	case PGM_INT_CODE_SECURE_STOR_ACCESS:
+	case PGM_INT_CODE_NON_SECURE_STOR_ACCESS:
+	case PGM_INT_CODE_SECURE_STOR_VIOLATION:
+		decode_teid(lc->trans_exc_id);
+		break;
+	default:
+		return;  

I think you could drop that default case.

Quoted 19 lines
lib/s390x/interrupt.c +5 -0
+	}
+}
+
  static void print_int_regs(struct stack_frame_int *stack)
  {
  	printf("\n");
@@ -155,6 +223,10 @@ static void print_pgm_info(struct
 stack_frame_int *stack) lc->pgm_int_code, stap(),
 lc->pgm_old_psw.addr, lc->pgm_int_id); print_int_regs(stack);
  	dump_stack();
+
+	/* Dump stack doesn't end with a \n so we add it here

instead */

lib/s390x/interrupt.c +2 -0
+	printf("\n");
+	print_storage_exception_information();
  	report_summary();
  	abort();
  }
#14 lore raw

Re: [kvm-unit-tests PATCH 3/8] lib: s390x: Print addressing related exception information

In reply to Thomas Huth
Quoted 45 lines · Thomas Huth
Quoted 44 lines · Janosch Frank

Right now we only get told the kind of program exception as well as the PSW at the point where it happened.

For addressing exceptions the PSW is not always enough so let's print the TEID which contains the failing address and flags that tell us more about the kind of address exception.

---
  lib/s390x/asm/arch_def.h |  4 +++
  lib/s390x/interrupt.c    | 72 ++++++++++++++++++++++++++++++++++++++++
  2 files changed, 76 insertions(+)
lib/s390x/asm/arch_def.h +4 -0
index 4ca02c1d..39c5ba99 100644
@@ -41,6 +41,10 @@ struct psw {
  	uint64_t	addr;
  };
 
+/* Let's ignore spaces we don't expect to use for now. */
+#define AS_PRIM				0
+#define AS_HOME				3
+
  #define PSW_MASK_EXT			0x0100000000000000UL
  #define PSW_MASK_IO			0x0200000000000000UL
  #define PSW_MASK_DAT			0x0400000000000000UL
lib/s390x/interrupt.c +1 -0
index 01ded49d..1248bceb 100644
@@ -12,6 +12,7 @@
  #include <sclp.h>
  #include <interrupt.h>
  #include <sie.h>
+#include <asm/page.h>
 
  static bool pgm_int_expected;
  static bool ext_int_expected;
@@ -126,6 +127,73 @@ static void fixup_pgm_int(struct stack_frame_int *stack)
  	/* suppressed/terminated/completed point already at the next address */
  }
 
Quoted 8 lines

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 133

Quoted 4 lines
lib/s390x/interrupt.c +4 -0
+static void decode_pgm_prot(uint64_t teid)
+{
+	/* Low-address protection exception, 100 */
+	if (test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) && !test_bit_inv(61, &teid)) {

Likely just a matter of taste, but I'd prefer something like:

	if ((teid & 0x8c) == 0x80) {

The POP states these as bits when you have a look at the ESOP section and I'd like to keep it the same here for easier comparison.

The test_bits() are as explicit as it gets and I value that.

Quoted 12 lines
Quoted 12 lines
lib/s390x/interrupt.c +11 -0
+		printf("Type: LAP\n");
+		return;
+	}
+
+	/* Instruction execution prevention, i.e. no-execute, 101 */
+	if (test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) && test_bit_inv(61, &teid)) {
+		printf("Type: IEP\n");
+		return;
+	}
+
+	/* Standard DAT exception, 001 */
Quoted 8 lines

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 148

Quoted 4 lines
lib/s390x/interrupt.c +4 -0
+	if (!test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) && test_bit_inv(61, &teid)) {
+		printf("Type: DAT\n");
+		return;
+	}

What about 010 (key controlled protection) and 011 (access-list controlled protection)? Even if we do not trigger those yet, it might make sense to add them right from the start, too?

If I do that then I can start a whole new file "fault.c" and move these changes there (which I'll do now anyway). My intentions were a small change that covers 90% of our current exceptions (especially PV exceptions) to make my life easier in LPAR.

If people add skey/ar code they can also add the decoding here, no? :-)

Quoted 9 lines

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 153

Quoted 6 lines
lib/s390x/interrupt.c +5 -0
+}
+
+static void decode_teid(uint64_t teid)
+{
+	int asce_id = lc->trans_exc_id & 3;

Why are you referencing the lc->trans_exc_id here again? It's already passed as "teid" parameter.

Forgot to remove that

Quoted 11 lines

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 159

Quoted 7 lines
lib/s390x/interrupt.c +6 -0
+	bool dat = lc->pgm_old_psw.mask & PSW_MASK_DAT;
+
+	printf("Memory exception information:\n");
+	printf("TEID: %lx\n", teid);
+	printf("DAT: %s\n", dat ? "on" : "off");
+	printf("AS: %s\n", asce_id == AS_PRIM ? "Primary" : "Home");

Could "secondary" or "AR" mode really never happen here? I'd rather like to see a switch-case statement here that is able to print all four modes, just to avoid confusion.

Right now we ONLY use primary space.

Quoted 28 lines
Quoted 28 lines
lib/s390x/interrupt.c +27 -0
+	if (lc->pgm_int_code == PGM_INT_CODE_PROTECTION)
+		decode_pgm_prot(teid);
+
+	/*
+	 * If teid bit 61 is off for these two exception the reported
+	 * address is unpredictable.
+	 */
+	if ((lc->pgm_int_code == PGM_INT_CODE_SECURE_STOR_ACCESS ||
+	     lc->pgm_int_code == PGM_INT_CODE_SECURE_STOR_VIOLATION) &&
+	    !test_bit_inv(61, &teid)) {
+		printf("Address: %lx, unpredictable\n ", teid & PAGE_MASK);
+		return;
+	}
+	printf("Address: %lx\n\n", teid & PAGE_MASK);
+}
+
+static void print_storage_exception_information(void)
+{
+	switch (lc->pgm_int_code) {
+	case PGM_INT_CODE_PROTECTION:
+	case PGM_INT_CODE_PAGE_TRANSLATION:
+	case PGM_INT_CODE_SEGMENT_TRANSLATION:
+	case PGM_INT_CODE_ASCE_TYPE:
+	case PGM_INT_CODE_REGION_FIRST_TRANS:
+	case PGM_INT_CODE_REGION_SECOND_TRANS:
+	case PGM_INT_CODE_REGION_THIRD_TRANS:
+	case PGM_INT_CODE_SECURE_STOR_ACCESS:
Quoted 8 lines

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 193

Quoted 6 lines
lib/s390x/interrupt.c +6 -0
+	case PGM_INT_CODE_NON_SECURE_STOR_ACCESS:
+	case PGM_INT_CODE_SECURE_STOR_VIOLATION:
+		decode_teid(lc->trans_exc_id);
+		break;
+	default:
+		return;

I think you could drop that default case.

Yes

Quoted 20 lines
Quoted 19 lines
lib/s390x/interrupt.c +7 -0
+	}
+}
+
  static void print_int_regs(struct stack_frame_int *stack)
  {
  	printf("\n");
@@ -155,6 +223,10 @@ static void print_pgm_info(struct stack_frame_int *stack)
  	       lc->pgm_int_code, stap(), lc->pgm_old_psw.addr, lc->pgm_int_id);
  	print_int_regs(stack);
  	dump_stack();
+
+	/* Dump stack doesn't end with a \n so we add it here instead */
+	printf("\n");
+	print_storage_exception_information();
  	report_summary();
  	abort();
  }
#15 lore raw

PATCH 4/8 lib: s390x: Start using bitops instead of magic constants

In reply to Janosch Frank

TEID data is specified in the Principles of Operation as bits so it makes more sens to test the bits instead of anding the mask.

We need to set -Wno-address-of-packed-member since for test bit we take an address of a struct lowcore member.

---
 lib/s390x/interrupt.c | 5 +++--
 s390x/Makefile        | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)
lib/s390x/interrupt.c +3 -2
index 1248bceb..e05c212e 100644
@@ -8,6 +8,7 @@
  *  David Hildenbrand <[email protected]>
  */
 #include <libcflat.h>
+#include <bitops.h>
 #include <asm/barrier.h>
 #include <sclp.h>
 #include <interrupt.h>
@@ -77,8 +78,8 @@ static void fixup_pgm_int(struct stack_frame_int *stack)
 		break;
 	case PGM_INT_CODE_PROTECTION:
 		/* Handling for iep.c test case. */
-		if (lc->trans_exc_id & 0x80UL && lc->trans_exc_id & 0x04UL &&
-		    !(lc->trans_exc_id & 0x08UL))
+		if (test_bit_inv(56, &lc->trans_exc_id) && test_bit_inv(61, &lc->trans_exc_id) &&
+		    !test_bit_inv(60, &lc->trans_exc_id))
 			/*
 			 * We branched to the instruction that caused
 			 * the exception so we can use the return
s390x/Makefile +1 -0
index ef8041a6..d260b336 100644
@@ -45,6 +45,7 @@ CFLAGS += -O2
 CFLAGS += -march=zEC12
 CFLAGS += -mbackchain
 CFLAGS += -fno-delete-null-pointer-checks
+CFLAGS += -Wno-address-of-packed-member
 LDFLAGS += -nostdlib -Wl,--build-id=none
 
 # We want to keep intermediate files
Signature · 1 line
2.30.2
Reviewed-by on v1 4/8
#16 lore raw

Re: [kvm-unit-tests PATCH 4/8] lib: s390x: Start using bitops instead of magic constants

Quoted 5 lines · On Fri, 13 Aug 2021 07:36:11 +0000 Janosch Frank <[email protected]> wrote:

TEID data is specified in the Principles of Operation as bits so it makes more sens to test the bits instead of anding the mask.

We need to set -Wno-address-of-packed-member since for test bit we take an address of a struct lowcore member.

and s390x has no alignment requirements

Quoted 1 line
Quoted 42 lines
---
 lib/s390x/interrupt.c | 5 +++--
 s390x/Makefile        | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)
lib/s390x/interrupt.c +1 -1
index 1248bceb..e05c212e 100644
@@ -8,6 +8,7 @@
  *  David Hildenbrand <[email protected]>
  */
 #include <libcflat.h>
+#include <bitops.h>
 #include <asm/barrier.h>
 #include <sclp.h>
 #include <interrupt.h>
@@ -77,8 +78,8 @@ static void fixup_pgm_int(struct stack_frame_int
 *stack) break;
 	case PGM_INT_CODE_PROTECTION:
 		/* Handling for iep.c test case. */
-		if (lc->trans_exc_id & 0x80UL && lc->trans_exc_id &

0x04UL &&

lib/s390x/interrupt.c +1 -1
-		    !(lc->trans_exc_id & 0x08UL))
+		if (test_bit_inv(56, &lc->trans_exc_id) &&

test_bit_inv(61, &lc->trans_exc_id) &&

lib/s390x/interrupt.c +1 -0
+		    !test_bit_inv(60, &lc->trans_exc_id))
 			/*
 			 * We branched to the instruction that caused
 			 * the exception so we can use the return
s390x/Makefile +1 -0
index ef8041a6..d260b336 100644
@@ -45,6 +45,7 @@ CFLAGS += -O2
 CFLAGS += -march=zEC12
 CFLAGS += -mbackchain
 CFLAGS += -fno-delete-null-pointer-checks
+CFLAGS += -Wno-address-of-packed-member
 LDFLAGS += -nostdlib -Wl,--build-id=none
 
 # We want to keep intermediate files
#17 lore raw

Re: [kvm-unit-tests PATCH 4/8] lib: s390x: Start using bitops instead of magic constants

In reply to Janosch Frank
Quoted 25 lines · Janosch Frank

TEID data is specified in the Principles of Operation as bits so it makes more sens to test the bits instead of anding the mask.

We need to set -Wno-address-of-packed-member since for test bit we take an address of a struct lowcore member.

---
  lib/s390x/interrupt.c | 5 +++--
  s390x/Makefile        | 1 +
  2 files changed, 4 insertions(+), 2 deletions(-)
lib/s390x/interrupt.c +1 -0
index 1248bceb..e05c212e 100644
@@ -8,6 +8,7 @@
   *  David Hildenbrand <[email protected]>
   */
  #include <libcflat.h>
+#include <bitops.h>
  #include <asm/barrier.h>
  #include <sclp.h>
  #include <interrupt.h>

lib/s390x/interrupt.c static void fixup_pgm_int(struct stack_frame_int *stack) · line 82

Quoted 7 lines
lib/s390x/interrupt.c +2 -2
@@ -77,8 +78,8 @@ static void fixup_pgm_int(struct stack_frame_int *stack)
  		break;
  	case PGM_INT_CODE_PROTECTION:
  		/* Handling for iep.c test case. */
-		if (lc->trans_exc_id & 0x80UL && lc->trans_exc_id & 0x04UL &&
-		    !(lc->trans_exc_id & 0x08UL))
+		if (test_bit_inv(56, &lc->trans_exc_id) && test_bit_inv(61, &lc->trans_exc_id) &&
+		    !test_bit_inv(60, &lc->trans_exc_id))

I'd rather prefer:

	if ((lc->trans_exc_id & 0x8c) == 0x84)

... or maybe you could add a helper function for these checks a la:

bool check_teid_prot_cause(uint64_t teid, bool bit56, bool bit60,

                           bool bit61)

then you could replace the if statement with:

	if (check_teid_prot_cause(lc->trans_exc_id, 1, 0, 1))

which would be way more readable, IMHO.

s390x/Makefile CFLAGS += -O2 · line 48

Quoted 12 lines
lib/s390x/interrupt.c +0 -0
  			/*
  			 * We branched to the instruction that caused
  			 * the exception so we can use the return
s390x/Makefile +1 -0
index ef8041a6..d260b336 100644
@@ -45,6 +45,7 @@ CFLAGS += -O2
  CFLAGS += -march=zEC12
  CFLAGS += -mbackchain
  CFLAGS += -fno-delete-null-pointer-checks
+CFLAGS += -Wno-address-of-packed-member

I think we should avoid this since this also affects the common code, doesn't it? And in common code, we might need to deal with this.

Thomas

#18 lore raw

PATCH 5/8 s390x: uv-host: Explain why we set up the home space and remove the space change

In reply to Janosch Frank

UV home addresses don't require us to be in home space but we need to have it set up so hw/fw can use the home asce to translate home virtual addresses.

Hence we add a comment why we're setting up the home asce and remove the address space since it's unneeded.

---
 s390x/uv-host.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
s390x/uv-host.c +8 -3
index 426a67f6..28035707 100644
@@ -444,13 +444,18 @@ static void test_clear(void)
 
 static void setup_vmem(void)
 {
-	uint64_t asce, mask;
+	uint64_t asce;
 
 	setup_mmu(get_max_ram_size(), NULL);
+	/*
+	 * setup_mmu() will enable DAT and set the primary address
+	 * space but we need to have a valid home space since UV calls
+	 * take home space virtual addresses.
+	 *
+	 * Hence we just copy the primary asce into the home space.
+	 */
 	asce = stctg(1);
 	lctlg(13, asce);
-	mask = extract_psw_mask() | 0x0000C00000000000UL;
-	load_psw_mask(mask);
 }
 
 int main(void)
Signature · 1 line
2.30.2
Reviewed-by on v1 5/8
#19 lore raw

Re: [kvm-unit-tests PATCH 5/8] s390x: uv-host: Explain why we set up the home space and remove the space change

Quoted 6 lines · On Fri, 13 Aug 2021 07:36:12 +0000 Janosch Frank <[email protected]> wrote:

UV home addresses don't require us to be in home space but we need to have it set up so hw/fw can use the home asce to translate home virtual addresses.

Hence we add a comment why we're setting up the home asce and remove the address space since it's unneeded.

oh, we actually never use it?

Quoted 1 line
Quoted 31 lines
---
 s390x/uv-host.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
s390x/uv-host.c +4 -1
index 426a67f6..28035707 100644
@@ -444,13 +444,18 @@ static void test_clear(void)
 
 static void setup_vmem(void)
 {
-	uint64_t asce, mask;
+	uint64_t asce;
 
 	setup_mmu(get_max_ram_size(), NULL);
+	/*
+	 * setup_mmu() will enable DAT and set the primary address
+	 * space but we need to have a valid home space since UV

calls

s390x/uv-host.c +4 -2
+	 * take home space virtual addresses.
+	 *
+	 * Hence we just copy the primary asce into the home space.
+	 */
 	asce = stctg(1);
 	lctlg(13, asce);
-	mask = extract_psw_mask() | 0x0000C00000000000UL;
-	load_psw_mask(mask);
 }
 
 int main(void)
#20 lore raw

Re: [kvm-unit-tests PATCH 5/8] s390x: uv-host: Explain why we set up the home space and remove the space change

Quoted 11 lines · Claudio Imbrenda
Quoted 6 lines · On Fri, 13 Aug 2021 07:36:12 +0000 Janosch Frank <[email protected]> wrote:

UV home addresses don't require us to be in home space but we need to have it set up so hw/fw can use the home asce to translate home virtual addresses.

Hence we add a comment why we're setting up the home asce and remove the address space since it's unneeded.

oh, we actually never use it?

Yes, as I said, those addresses are not relative to your PSW DAT settings, they are defined to be home space addresses.

Quoted 3 lines
Quoted 1 line

Thanks!

Quoted 33 lines
Quoted 32 lines
---
 s390x/uv-host.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
s390x/uv-host.c +4 -1
index 426a67f6..28035707 100644
@@ -444,13 +444,18 @@ static void test_clear(void)
 
 static void setup_vmem(void)
 {
-	uint64_t asce, mask;
+	uint64_t asce;
 
 	setup_mmu(get_max_ram_size(), NULL);
+	/*
+	 * setup_mmu() will enable DAT and set the primary address
+	 * space but we need to have a valid home space since UV

calls

s390x/uv-host.c +4 -2
+	 * take home space virtual addresses.
+	 *
+	 * Hence we just copy the primary asce into the home space.
+	 */
 	asce = stctg(1);
 	lctlg(13, asce);
-	mask = extract_psw_mask() | 0x0000C00000000000UL;
-	load_psw_mask(mask);
 }
 
 int main(void)
#21 lore raw

PATCH 6/8 lib: s390x: Add PSW_MASK_64

In reply to Janosch Frank

Let's replace the magic 0x0000000180000000ULL numeric constants with PSW_MASK_64 as it's used more often since the introduction of smp and sie.

---
 lib/s390x/asm/arch_def.h | 3 +++
 lib/s390x/smp.c          | 2 +-
 s390x/mvpg-sie.c         | 2 +-
 s390x/sie.c              | 2 +-
 s390x/skrf.c             | 6 +++---
 5 files changed, 9 insertions(+), 6 deletions(-)
lib/s390x/asm/arch_def.h +3 -0
index 39c5ba99..245453c3 100644
@@ -50,6 +50,9 @@ struct psw {
 #define PSW_MASK_DAT			0x0400000000000000UL
 #define PSW_MASK_WAIT			0x0002000000000000UL
 #define PSW_MASK_PSTATE			0x0001000000000000UL
+#define PSW_MASK_EA			0x0000000100000000UL
+#define PSW_MASK_BA			0x0000000080000000UL
+#define PSW_MASK_64			PSW_MASK_BA | PSW_MASK_EA;
 
 #define CR0_EXTM_SCLP			0x0000000000000200UL
 #define CR0_EXTM_EXTC			0x0000000000002000UL
lib/s390x/smp.c +1 -1
index ee68d676..228fe667 100644
@@ -202,7 +202,7 @@ int smp_cpu_setup(uint16_t addr, struct psw psw)
 	cpu->lowcore->sw_int_psw.addr = psw.addr;
 	cpu->lowcore->sw_int_grs[14] = psw.addr;
 	cpu->lowcore->sw_int_grs[15] = (uint64_t)cpu->stack + (PAGE_SIZE * 4);
-	lc->restart_new_psw.mask = 0x0000000180000000UL;
+	lc->restart_new_psw.mask = PSW_MASK_64;
 	lc->restart_new_psw.addr = (uint64_t)smp_cpu_setup_state;
 	lc->sw_int_crs[0] = 0x0000000000040000UL;
 
s390x/mvpg-sie.c +1 -1
index 70d2fcfa..ccc273b4 100644
@@ -100,7 +100,7 @@ static void setup_guest(void)
 	sie_guest_create(&vm, (uint64_t)guest, HPAGE_SIZE);
 
 	vm.sblk->gpsw.addr = PAGE_SIZE * 4;
-	vm.sblk->gpsw.mask = 0x0000000180000000ULL;
+	vm.sblk->gpsw.mask = PSW_MASK_64;
 	vm.sblk->ictl = ICTL_OPEREXC | ICTL_PINT;
 	/* Enable MVPG interpretation as we want to test KVM and not ourselves */
 	vm.sblk->eca = ECA_MVPGI;
s390x/sie.c +1 -1
index ed2c3263..87575b29 100644
@@ -27,7 +27,7 @@ static struct vm vm;
 static void test_diag(u32 instr)
 {
 	vm.sblk->gpsw.addr = PAGE_SIZE * 2;
-	vm.sblk->gpsw.mask = 0x0000000180000000ULL;
+	vm.sblk->gpsw.mask = PSW_MASK_64;
 
 	memset(guest_instr, 0, PAGE_SIZE);
 	memcpy(guest_instr, &instr, 4);
s390x/skrf.c +3 -3
index 94e906a6..9488c32b 100644
@@ -125,15 +125,15 @@ static void ecall_cleanup(void)
 {
 	struct lowcore *lc = (void *)0x0;
 
-	lc->ext_new_psw.mask = 0x0000000180000000UL;
 	lc->sw_int_crs[0] = 0x0000000000040000;
+	lc->ext_new_psw.mask = PSW_MASK_64;
 
 	/*
 	 * PGM old contains the ext new PSW, we need to clean it up,
 	 * so we don't get a special operation exception on the lpswe
 	 * of pgm old.
 	 */
-	lc->pgm_old_psw.mask = 0x0000000180000000UL;
+	lc->pgm_old_psw.mask = PSW_MASK_64;
 
 	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
 	set_flag(1);
@@ -148,7 +148,7 @@ static void ecall_setup(void)
 	register_pgm_cleanup_func(ecall_cleanup);
 	expect_pgm_int();
 	/* Put a skey into the ext new psw */
-	lc->ext_new_psw.mask = 0x00F0000180000000UL;
+	lc->ext_new_psw.mask = 0x00F0000000000000UL | PSW_MASK_64;
 	/* Open up ext masks */
 	ctl_set_bit(0, CTL0_EXTERNAL_CALL);
 	mask = extract_psw_mask();
Signature · 1 line
2.30.2
Reviewed-by on v1 6/8
#22 lore raw

Re: [kvm-unit-tests PATCH 6/8] lib: s390x: Add PSW_MASK_64

Quoted 5 lines · On Fri, 13 Aug 2021 07:36:13 +0000 Janosch Frank <[email protected]> wrote:

Let's replace the magic 0x0000000180000000ULL numeric constants with PSW_MASK_64 as it's used more often since the introduction of smp and sie.

Quoted 93 lines
---
 lib/s390x/asm/arch_def.h | 3 +++
 lib/s390x/smp.c          | 2 +-
 s390x/mvpg-sie.c         | 2 +-
 s390x/sie.c              | 2 +-
 s390x/skrf.c             | 6 +++---
 5 files changed, 9 insertions(+), 6 deletions(-)
lib/s390x/asm/arch_def.h +3 -0
index 39c5ba99..245453c3 100644
@@ -50,6 +50,9 @@ struct psw {
 #define PSW_MASK_DAT			0x0400000000000000UL
 #define PSW_MASK_WAIT			0x0002000000000000UL
 #define PSW_MASK_PSTATE			0x0001000000000000UL
+#define PSW_MASK_EA			0x0000000100000000UL
+#define PSW_MASK_BA			0x0000000080000000UL
+#define PSW_MASK_64			PSW_MASK_BA | PSW_MASK_EA;
 
 #define CR0_EXTM_SCLP			0x0000000000000200UL
 #define CR0_EXTM_EXTC			0x0000000000002000UL
lib/s390x/smp.c +1 -1
index ee68d676..228fe667 100644
@@ -202,7 +202,7 @@ int smp_cpu_setup(uint16_t addr, struct psw psw)
 	cpu->lowcore->sw_int_psw.addr = psw.addr;
 	cpu->lowcore->sw_int_grs[14] = psw.addr;
 	cpu->lowcore->sw_int_grs[15] = (uint64_t)cpu->stack +
 (PAGE_SIZE * 4);
-	lc->restart_new_psw.mask = 0x0000000180000000UL;
+	lc->restart_new_psw.mask = PSW_MASK_64;
 	lc->restart_new_psw.addr = (uint64_t)smp_cpu_setup_state;
 	lc->sw_int_crs[0] = 0x0000000000040000UL;
s390x/mvpg-sie.c +1 -1
index 70d2fcfa..ccc273b4 100644
@@ -100,7 +100,7 @@ static void setup_guest(void)
 	sie_guest_create(&vm, (uint64_t)guest, HPAGE_SIZE);
 
 	vm.sblk->gpsw.addr = PAGE_SIZE * 4;
-	vm.sblk->gpsw.mask = 0x0000000180000000ULL;
+	vm.sblk->gpsw.mask = PSW_MASK_64;
 	vm.sblk->ictl = ICTL_OPEREXC | ICTL_PINT;
 	/* Enable MVPG interpretation as we want to test KVM and not
 ourselves */ vm.sblk->eca = ECA_MVPGI;
s390x/sie.c +1 -1
index ed2c3263..87575b29 100644
@@ -27,7 +27,7 @@ static struct vm vm;
 static void test_diag(u32 instr)
 {
 	vm.sblk->gpsw.addr = PAGE_SIZE * 2;
-	vm.sblk->gpsw.mask = 0x0000000180000000ULL;
+	vm.sblk->gpsw.mask = PSW_MASK_64;
 
 	memset(guest_instr, 0, PAGE_SIZE);
 	memcpy(guest_instr, &instr, 4);
s390x/skrf.c +3 -3
index 94e906a6..9488c32b 100644
@@ -125,15 +125,15 @@ static void ecall_cleanup(void)
 {
 	struct lowcore *lc = (void *)0x0;
 
-	lc->ext_new_psw.mask = 0x0000000180000000UL;
 	lc->sw_int_crs[0] = 0x0000000000040000;
+	lc->ext_new_psw.mask = PSW_MASK_64;
 
 	/*
 	 * PGM old contains the ext new PSW, we need to clean it up,
 	 * so we don't get a special operation exception on the lpswe
 	 * of pgm old.
 	 */
-	lc->pgm_old_psw.mask = 0x0000000180000000UL;
+	lc->pgm_old_psw.mask = PSW_MASK_64;
 
 	check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
 	set_flag(1);
@@ -148,7 +148,7 @@ static void ecall_setup(void)
 	register_pgm_cleanup_func(ecall_cleanup);
 	expect_pgm_int();
 	/* Put a skey into the ext new psw */
-	lc->ext_new_psw.mask = 0x00F0000180000000UL;
+	lc->ext_new_psw.mask = 0x00F0000000000000UL | PSW_MASK_64;
 	/* Open up ext masks */
 	ctl_set_bit(0, CTL0_EXTERNAL_CALL);
 	mask = extract_psw_mask();
#23 lore raw

Re: [kvm-unit-tests PATCH 6/8] lib: s390x: Add PSW_MASK_64

In reply to Janosch Frank
Quoted 18 lines · Janosch Frank

Let's replace the magic 0x0000000180000000ULL numeric constants with PSW_MASK_64 as it's used more often since the introduction of smp and sie.

---
  lib/s390x/asm/arch_def.h | 3 +++
  lib/s390x/smp.c          | 2 +-
  s390x/mvpg-sie.c         | 2 +-
  s390x/sie.c              | 2 +-
  s390x/skrf.c             | 6 +++---
  5 files changed, 9 insertions(+), 6 deletions(-)
lib/s390x/asm/arch_def.h +0 -0
index 39c5ba99..245453c3 100644

lib/s390x/asm/arch_def.h struct psw { · line 55

Quoted 6 lines
lib/s390x/asm/arch_def.h +3 -0
@@ -50,6 +50,9 @@ struct psw {
  #define PSW_MASK_DAT			0x0400000000000000UL
  #define PSW_MASK_WAIT			0x0002000000000000UL
  #define PSW_MASK_PSTATE			0x0001000000000000UL
+#define PSW_MASK_EA			0x0000000100000000UL
+#define PSW_MASK_BA			0x0000000080000000UL
+#define PSW_MASK_64			PSW_MASK_BA | PSW_MASK_EA;

Please put some parentheses around PSW_MASK_BA | PSW_MASK_EA and remove the semicolon at the end.

Thomas

#24 lore raw

PATCH 7/8 lib: s390x: Control register constant cleanup

In reply to Janosch Frank

We had bits and masks defined and don't necessarily need both.

---
 lib/s390x/asm/arch_def.h | 29 +++++++++++++----------------
 lib/s390x/smp.c          |  2 +-
 s390x/skrf.c             |  2 +-
 3 files changed, 15 insertions(+), 18 deletions(-)
lib/s390x/asm/arch_def.h +13 -16
index 245453c3..4574a166 100644
@@ -54,10 +54,19 @@ struct psw {
 #define PSW_MASK_BA			0x0000000080000000UL
 #define PSW_MASK_64			PSW_MASK_BA | PSW_MASK_EA;
 
-#define CR0_EXTM_SCLP			0x0000000000000200UL
-#define CR0_EXTM_EXTC			0x0000000000002000UL
-#define CR0_EXTM_EMGC			0x0000000000004000UL
-#define CR0_EXTM_MASK			0x0000000000006200UL
+#define CTL0_LOW_ADDR_PROT		(63 - 35)
+#define CTL0_EDAT			(63 - 40)
+#define CTL0_IEP			(63 - 43)
+#define CTL0_AFP			(63 - 45)
+#define CTL0_VECTOR			(63 - 46)
+#define CTL0_EMERGENCY_SIGNAL		(63 - 49)
+#define CTL0_EXTERNAL_CALL		(63 - 50)
+#define CTL0_CLOCK_COMPARATOR		(63 - 52)
+#define CTL0_SERVICE_SIGNAL		(63 - 54)
+#define CR0_EXTM_MASK			0x0000000000006200UL /* Combined external masks */
+#define BIT_TO_MASK64(x)		1UL << x
+
+#define CTL2_GUARDED_STORAGE		(63 - 59)
 
 struct lowcore {
 	uint8_t		pad_0x0000[0x0080 - 0x0000];	/* 0x0000 */
@@ -239,18 +248,6 @@ static inline uint64_t stctg(int cr)
 	return value;
 }
 
-#define CTL0_LOW_ADDR_PROT	(63 - 35)
-#define CTL0_EDAT		(63 - 40)
-#define CTL0_IEP		(63 - 43)
-#define CTL0_AFP		(63 - 45)
-#define CTL0_VECTOR		(63 - 46)
-#define CTL0_EMERGENCY_SIGNAL	(63 - 49)
-#define CTL0_EXTERNAL_CALL	(63 - 50)
-#define CTL0_CLOCK_COMPARATOR	(63 - 52)
-#define CTL0_SERVICE_SIGNAL	(63 - 54)
-
-#define CTL2_GUARDED_STORAGE	(63 - 59)
-
 static inline void ctl_set_bit(int cr, unsigned int bit)
 {
         uint64_t reg;
lib/s390x/smp.c +1 -1
index 228fe667..c2c6ffec 100644
@@ -204,7 +204,7 @@ int smp_cpu_setup(uint16_t addr, struct psw psw)
 	cpu->lowcore->sw_int_grs[15] = (uint64_t)cpu->stack + (PAGE_SIZE * 4);
 	lc->restart_new_psw.mask = PSW_MASK_64;
 	lc->restart_new_psw.addr = (uint64_t)smp_cpu_setup_state;
-	lc->sw_int_crs[0] = 0x0000000000040000UL;
+	lc->sw_int_crs[0] = BIT_TO_MASK64(CTL0_AFP);
 
 	/* Start processing */
 	smp_cpu_restart_nolock(addr, NULL);
s390x/skrf.c +1 -1
index 9488c32b..a350ada6 100644
@@ -125,8 +125,8 @@ static void ecall_cleanup(void)
 {
 	struct lowcore *lc = (void *)0x0;
 
-	lc->sw_int_crs[0] = 0x0000000000040000;
 	lc->ext_new_psw.mask = PSW_MASK_64;
+	lc->sw_int_crs[0] = BIT_TO_MASK64(CTL0_AFP);
 
 	/*
 	 * PGM old contains the ext new PSW, we need to clean it up,
Signature · 1 line
2.30.2
#25 lore raw

Re: [kvm-unit-tests PATCH 7/8] lib: s390x: Control register constant cleanup

Quoted 31 lines · On Fri, 13 Aug 2021 07:36:14 +0000 Janosch Frank <[email protected]> wrote:

We had bits and masks defined and don't necessarily need both.

---
 lib/s390x/asm/arch_def.h | 29 +++++++++++++----------------
 lib/s390x/smp.c          |  2 +-
 s390x/skrf.c             |  2 +-
 3 files changed, 15 insertions(+), 18 deletions(-)
lib/s390x/asm/arch_def.h +10 -4
index 245453c3..4574a166 100644
@@ -54,10 +54,19 @@ struct psw {
 #define PSW_MASK_BA			0x0000000080000000UL
 #define PSW_MASK_64			PSW_MASK_BA | PSW_MASK_EA;
 
-#define CR0_EXTM_SCLP			0x0000000000000200UL
-#define CR0_EXTM_EXTC			0x0000000000002000UL
-#define CR0_EXTM_EMGC			0x0000000000004000UL
-#define CR0_EXTM_MASK			0x0000000000006200UL
+#define CTL0_LOW_ADDR_PROT		(63 - 35)
+#define CTL0_EDAT			(63 - 40)
+#define CTL0_IEP			(63 - 43)
+#define CTL0_AFP			(63 - 45)
+#define CTL0_VECTOR			(63 - 46)
+#define CTL0_EMERGENCY_SIGNAL		(63 - 49)
+#define CTL0_EXTERNAL_CALL		(63 - 50)
+#define CTL0_CLOCK_COMPARATOR		(63 - 52)
+#define CTL0_SERVICE_SIGNAL		(63 - 54)
+#define CR0_EXTM_MASK			0x0000000000006200UL /*
Quoted 2 lines

Combined external masks */
+#define BIT_TO_MASK64(x) 1UL << x

don't we already have BIT and BIT_ULL?

Quoted 50 lines
lib/s390x/asm/arch_def.h +1 -0
+#define CTL2_GUARDED_STORAGE		(63 - 59)
 
 struct lowcore {
 	uint8_t		pad_0x0000[0x0080 - 0x0000];

/* 0x0000 */ @@ -239,18 +248,6 @@ static inline uint64_t stctg(int cr)

lib/s390x/asm/arch_def.h +0 -12
 	return value;
 }
 
-#define CTL0_LOW_ADDR_PROT	(63 - 35)
-#define CTL0_EDAT		(63 - 40)
-#define CTL0_IEP		(63 - 43)
-#define CTL0_AFP		(63 - 45)
-#define CTL0_VECTOR		(63 - 46)
-#define CTL0_EMERGENCY_SIGNAL	(63 - 49)
-#define CTL0_EXTERNAL_CALL	(63 - 50)
-#define CTL0_CLOCK_COMPARATOR	(63 - 52)
-#define CTL0_SERVICE_SIGNAL	(63 - 54)
-
-#define CTL2_GUARDED_STORAGE	(63 - 59)
-
 static inline void ctl_set_bit(int cr, unsigned int bit)
 {
         uint64_t reg;
lib/s390x/smp.c +1 -1
index 228fe667..c2c6ffec 100644
@@ -204,7 +204,7 @@ int smp_cpu_setup(uint16_t addr, struct psw psw)
 	cpu->lowcore->sw_int_grs[15] = (uint64_t)cpu->stack +
 (PAGE_SIZE * 4); lc->restart_new_psw.mask = PSW_MASK_64;
 	lc->restart_new_psw.addr = (uint64_t)smp_cpu_setup_state;
-	lc->sw_int_crs[0] = 0x0000000000040000UL;
+	lc->sw_int_crs[0] = BIT_TO_MASK64(CTL0_AFP);
 
 	/* Start processing */
 	smp_cpu_restart_nolock(addr, NULL);
s390x/skrf.c +1 -1
index 9488c32b..a350ada6 100644
@@ -125,8 +125,8 @@ static void ecall_cleanup(void)
 {
 	struct lowcore *lc = (void *)0x0;
 
-	lc->sw_int_crs[0] = 0x0000000000040000;
 	lc->ext_new_psw.mask = PSW_MASK_64;
+	lc->sw_int_crs[0] = BIT_TO_MASK64(CTL0_AFP);
 
 	/*
 	 * PGM old contains the ext new PSW, we need to clean it up,
#26 lore raw

Re: [kvm-unit-tests PATCH 7/8] lib: s390x: Control register constant cleanup

Quoted 30 lines · Claudio Imbrenda
Quoted 27 lines · On Fri, 13 Aug 2021 07:36:14 +0000 Janosch Frank <[email protected]> wrote:

We had bits and masks defined and don't necessarily need both.

---
 lib/s390x/asm/arch_def.h | 29 +++++++++++++----------------
 lib/s390x/smp.c          |  2 +-
 s390x/skrf.c             |  2 +-
 3 files changed, 15 insertions(+), 18 deletions(-)
lib/s390x/asm/arch_def.h +6 -4
index 245453c3..4574a166 100644
@@ -54,10 +54,19 @@ struct psw {
 #define PSW_MASK_BA			0x0000000080000000UL
 #define PSW_MASK_64			PSW_MASK_BA | PSW_MASK_EA;
 
-#define CR0_EXTM_SCLP			0x0000000000000200UL
-#define CR0_EXTM_EXTC			0x0000000000002000UL
-#define CR0_EXTM_EMGC			0x0000000000004000UL
-#define CR0_EXTM_MASK			0x0000000000006200UL
+#define CTL0_LOW_ADDR_PROT		(63 - 35)
+#define CTL0_EDAT			(63 - 40)
+#define CTL0_IEP			(63 - 43)
+#define CTL0_AFP			(63 - 45)
+#define CTL0_VECTOR			(63 - 46)
+#define CTL0_EMERGENCY_SIGNAL		(63 - 49)
Quoted 8 lines
Quoted 6 lines
lib/s390x/asm/arch_def.h +4 -0
+#define CTL0_EXTERNAL_CALL		(63 - 50)
+#define CTL0_CLOCK_COMPARATOR		(63 - 52)
+#define CTL0_SERVICE_SIGNAL		(63 - 54)
+#define CR0_EXTM_MASK			0x0000000000006200UL /*

Combined external masks */
+#define BIT_TO_MASK64(x) 1UL << x

don't we already have BIT and BIT_ULL?

Right, I should have looked first...
Will fix!

Quoted 52 lines
Quoted 51 lines
lib/s390x/asm/arch_def.h +1 -0
+#define CTL2_GUARDED_STORAGE		(63 - 59)
 
 struct lowcore {
 	uint8_t		pad_0x0000[0x0080 - 0x0000];

/* 0x0000 */ @@ -239,18 +248,6 @@ static inline uint64_t stctg(int cr)

lib/s390x/asm/arch_def.h +0 -12
 	return value;
 }
 
-#define CTL0_LOW_ADDR_PROT	(63 - 35)
-#define CTL0_EDAT		(63 - 40)
-#define CTL0_IEP		(63 - 43)
-#define CTL0_AFP		(63 - 45)
-#define CTL0_VECTOR		(63 - 46)
-#define CTL0_EMERGENCY_SIGNAL	(63 - 49)
-#define CTL0_EXTERNAL_CALL	(63 - 50)
-#define CTL0_CLOCK_COMPARATOR	(63 - 52)
-#define CTL0_SERVICE_SIGNAL	(63 - 54)
-
-#define CTL2_GUARDED_STORAGE	(63 - 59)
-
 static inline void ctl_set_bit(int cr, unsigned int bit)
 {
         uint64_t reg;
lib/s390x/smp.c +1 -1
index 228fe667..c2c6ffec 100644
@@ -204,7 +204,7 @@ int smp_cpu_setup(uint16_t addr, struct psw psw)
 	cpu->lowcore->sw_int_grs[15] = (uint64_t)cpu->stack +
 (PAGE_SIZE * 4); lc->restart_new_psw.mask = PSW_MASK_64;
 	lc->restart_new_psw.addr = (uint64_t)smp_cpu_setup_state;
-	lc->sw_int_crs[0] = 0x0000000000040000UL;
+	lc->sw_int_crs[0] = BIT_TO_MASK64(CTL0_AFP);
 
 	/* Start processing */
 	smp_cpu_restart_nolock(addr, NULL);
s390x/skrf.c +1 -1
index 9488c32b..a350ada6 100644
@@ -125,8 +125,8 @@ static void ecall_cleanup(void)
 {
 	struct lowcore *lc = (void *)0x0;
 
-	lc->sw_int_crs[0] = 0x0000000000040000;
 	lc->ext_new_psw.mask = PSW_MASK_64;
+	lc->sw_int_crs[0] = BIT_TO_MASK64(CTL0_AFP);
 
 	/*
 	 * PGM old contains the ext new PSW, we need to clean it up,
#27 lore raw

PATCH 8/8 lib: s390x: uv: Add rc 0x100 query error handling

In reply to Janosch Frank

Let's not get bitten by an extension of the query struct and handle the rc 0x100 error properly which does indicate that the UV has more data for us.

---
 lib/s390x/uv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/s390x/uv.c +3 -1
index fd9de944..c5c69c47 100644
@@ -49,6 +49,8 @@ int uv_setup(void)
 	if (!test_facility(158))
 		return 0;
 
-	assert(!uv_call(0, (u64)&uvcb_qui));
+	uv_call(0, (u64)&uvcb_qui);
+
+	assert(uvcb_qui.header.rc == 1 || uvcb_qui.header.rc == 0x100);
 	return 1;
 }
Signature · 1 line
2.30.2
Reviewed-by on v1 8/8
#28 lore raw

Re: [kvm-unit-tests PATCH 8/8] lib: s390x: uv: Add rc 0x100 query error handling

Quoted 5 lines · On Fri, 13 Aug 2021 07:36:15 +0000 Janosch Frank <[email protected]> wrote:

Let's not get bitten by an extension of the query struct and handle the rc 0x100 error properly which does indicate that the UV has more data for us.

Quoted 18 lines
---
 lib/s390x/uv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/s390x/uv.c +3 -1
index fd9de944..c5c69c47 100644
@@ -49,6 +49,8 @@ int uv_setup(void)
 	if (!test_facility(158))
 		return 0;
 
-	assert(!uv_call(0, (u64)&uvcb_qui));
+	uv_call(0, (u64)&uvcb_qui);
+
+	assert(uvcb_qui.header.rc == 1 || uvcb_qui.header.rc ==
 0x100); return 1;
 }
#29 lore raw

Re: [kvm-unit-tests PATCH 8/8] lib: s390x: uv: Add rc 0x100 query error handling

In reply to Janosch Frank
Quoted 14 lines · Janosch Frank

Let's not get bitten by an extension of the query struct and handle the rc 0x100 error properly which does indicate that the UV has more data for us.

---
  lib/s390x/uv.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
lib/s390x/uv.c +0 -0
index fd9de944..c5c69c47 100644

lib/s390x/uv.c int uv_setup(void) · line 54

Quoted 7 lines
lib/s390x/uv.c +3 -1
@@ -49,6 +49,8 @@ int uv_setup(void)
  	if (!test_facility(158))
  		return 0;
 
-	assert(!uv_call(0, (u64)&uvcb_qui));
+	uv_call(0, (u64)&uvcb_qui);
+
+	assert(uvcb_qui.header.rc == 1 || uvcb_qui.header.rc == 0x100);

Don't you want to continue to check the return code of the uv_call() function?

Thomas

#30 lore raw

Re: [kvm-unit-tests PATCH 8/8] lib: s390x: uv: Add rc 0x100 query error handling

Quoted 18 lines · Thomas Huth
Quoted 17 lines · Janosch Frank

Let's not get bitten by an extension of the query struct and handle the rc 0x100 error properly which does indicate that the UV has more data for us.

---
  lib/s390x/uv.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
lib/s390x/uv.c +0 -0
index fd9de944..c5c69c47 100644
@@ -49,6 +49,8 @@ int uv_setup(void)
  	if (!test_facility(158))
  		return 0;
 
Quoted 9 lines

lib/s390x/uv.c int uv_setup(void) · line 54

Quoted 4 lines
lib/s390x/uv.c +3 -1
-	assert(!uv_call(0, (u64)&uvcb_qui));
+	uv_call(0, (u64)&uvcb_qui);
+
+	assert(uvcb_qui.header.rc == 1 || uvcb_qui.header.rc == 0x100);

Don't you want to continue to check the return code of the uv_call() function?

Thomas

The rc==0x100 case is a cc==1 and the rc==1 is a cc==0 so I had to delete the check.

Those smaller patches are already upstream btw.