Skip to contentSkip to conversation

s390: ipl: fix physical-virtual confusion for diag308

PATCH In review Nico Boehr 2 participants 7 messages Mar 10, 2023 – Apr 4, 2023 s390

lore
Share & tools
lore

Nico Boehr

author
#0 lore raw

v3 cover s390: ipl: fix physical-virtual confusion for diag308

v3:
---
* u64 -> unsigned long (thanks Alexander)
* improve commit description a bit (thanks Alexander)

v2:
---
* add special handling for addr NULL (thanks Alexander)

Nico Boehr (1):
s390: ipl: fix physical-virtual confusion for diag308

 arch/s390/kernel/ipl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.39.1
author
#1 lore raw

PATCH v3 1/1 s390: ipl: fix physical-virtual confusion for diag308

Diag 308 subcodes expect a physical address as their parameter.

This currently is not a bug, but in the future physical and virtual addresses might differ.

Fix the confusion by doing a virtual-to-physical conversion in the exported diag308() and leave the assembly wrapper __diag308() alone.

Note that several callers pass NULL as addr, so check for the case when NULL is passed and pass 0 to hardware since virt_to_phys(0) might be nonzero.

---
 arch/s390/kernel/ipl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/kernel/ipl.c +3 -3
index 5f0f5c86963a..afac9970ce42 100644
@@ -176,11 +176,11 @@ static bool reipl_fcp_clear;
 static bool reipl_ccw_clear;
 static bool reipl_eckd_clear;
 
-static inline int __diag308(unsigned long subcode, void *addr)
+static inline int __diag308(unsigned long subcode, unsigned long addr)
 {
 	union register_pair r1;
 
-	r1.even = (unsigned long) addr;
+	r1.even = addr;
 	r1.odd	= 0;
 	asm volatile(
 		"	diag	%[r1],%[subcode],0x308\n"
@@ -195,7 +195,7 @@ static inline int __diag308(unsigned long subcode, void *addr)
 int diag308(unsigned long subcode, void *addr)
 {
 	diag_stat_inc(DIAG_STAT_X308);
-	return __diag308(subcode, addr);
+	return __diag308(subcode, addr ? virt_to_phys(addr) : 0);
 }
 EXPORT_SYMBOL_GPL(diag308);
 
Signature · 1 line
2.39.1
maintainer Reviewed-by on v3 1/1
#2 lore raw
Quoted 37 lines · Nico Boehr

Diag 308 subcodes expect a physical address as their parameter.

This currently is not a bug, but in the future physical and virtual addresses might differ.

Fix the confusion by doing a virtual-to-physical conversion in the exported diag308() and leave the assembly wrapper __diag308() alone.

Note that several callers pass NULL as addr, so check for the case when NULL is passed and pass 0 to hardware since virt_to_phys(0) might be nonzero.

---
 arch/s390/kernel/ipl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/kernel/ipl.c +2 -2
index 5f0f5c86963a..afac9970ce42 100644
@@ -176,11 +176,11 @@ static bool reipl_fcp_clear;
 static bool reipl_ccw_clear;
 static bool reipl_eckd_clear;
 
-static inline int __diag308(unsigned long subcode, void *addr)
+static inline int __diag308(unsigned long subcode, unsigned long addr)
 {
 	union register_pair r1;
 
-	r1.even = (unsigned long) addr;
+	r1.even = addr;
 	r1.odd	= 0;
 	asm volatile(
 		"	diag	%[r1],%[subcode],0x308\n"

arch/s390/kernel/ipl.c static inline int __diag308(unsigned long subcode, void *addr) · line 200

Quoted 7 lines
arch/s390/kernel/ipl.c +1 -1
@@ -195,7 +195,7 @@ static inline int __diag308(unsigned long subcode, void *addr)
 int diag308(unsigned long subcode, void *addr)
 {
 	diag_stat_inc(DIAG_STAT_X308);
-	return __diag308(subcode, addr);
+	return __diag308(subcode, addr ? virt_to_phys(addr) : 0);
 }
 EXPORT_SYMBOL_GPL(diag308);
author
#4 lore raw

Quoting Alexander Gordeev (2023-03-31 08:48:37)

Quoted 3 lines

Hi Nico,

Anything prevents this one from pushing?

No, can be pushed.

#5 lore raw
Quoted 2 lines · Nico Boehr
Quoted 1 line

Anything prevents this one from pushing?

No, can be pushed.

Could you push it then, please?

author
#6 lore raw

Quoting Alexander Gordeev (2023-04-04 08:39:12)

Quoted 5 lines · Nico Boehr
Quoted 2 lines
Quoted 1 line

Anything prevents this one from pushing?

No, can be pushed.

Could you push it then, please?

Done.