s390: ipl: fix physical-virtual confusion for diag308
PATCH 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, this is fine since virt_to_phys(0) == 0.
--- arch/s390/kernel/ipl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/kernel/ipl.c +2 -2
@@ -176,7 +176,7 @@ 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,u64 addr) {union register_pair r1;
@@ -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,virt_to_phys (addr)); }EXPORT_SYMBOL_GPL (diag308);
Signature · 1 line
2.39.1
Alexander Gordeev
maintainerQuoted 31 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, this is fine since
virt_to_phys(0)== 0.Suggested-by Marc Hartmayer <[email protected]>Signed-off-by Nico Boehr <[email protected]>--- arch/s390/kernel/ipl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/s390/kernel/ipl.c +1
-1@@ -176,7 +176,7 @@ 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,u64 addr) {union register_pair r1;
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,virt_to_phys (addr)); }EXPORT_SYMBOL_GPL (diag308);
Please note diag308() is called with NULL a lot.
I think a proper fix would be like this:
arch/s390/kernel/ipl.c +3 -3
@@ -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 ; asmvolatile ( " 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);
Alexander Gordeev
maintainerQuoted 2 lines · Alexander Gordeev
Quoted 2 lines
Note that several callers pass NULL as addr, this is fine since
virt_to_phys(0)== 0.
Missed that.
Are you sure? Quickly checked ppc64, x86 and arm64 - they do not seem adhere virt_to_phys(0) == 0, nor the VR kernel (so far).
Quoting Alexander Gordeev (2023-03-10 13:42:47)
Quoted 8 lines · Alexander Gordeev
Quoted 2 lines
Quoted 2 lines
Note that several callers pass NULL as addr, this is fine since
virt_to_phys(0)== 0.Missed that.
Are you sure? Quickly checked ppc64, x86 and arm64 - they do not seem adhere
virt_to_phys(0)== 0, nor the VR kernel (so far).
I think we do, but you are right - it might change in the future, so it's better to be on the safe side. Fixed in v2, thanks.
Christian Borntraeger
reviewerAm 10.03.23 um 13:42 schrieb Alexander Gordeev:
Quoted 8 lines · Alexander Gordeev
Quoted 2 lines
Quoted 2 lines
Note that several callers pass NULL as addr, this is fine since
virt_to_phys(0)== 0.Missed that.
Are you sure? Quickly checked ppc64, x86 and arm64 - they do not seem adhere
virt_to_phys(0)== 0, nor the VR kernel (so far).
Isnt that the prefix page? I think we did say that the prefix page must be 0 in virt and phys otherwise we will have performance issues due to cache synonyms.
Alexander Gordeev
maintainerQuoted 4 lines · Christian Borntraeger
Quoted 2 lines
Are you sure? Quickly checked ppc64, x86 and arm64 - they do not seem adhere
virt_to_phys(0)== 0, nor the VR kernel (so far).Isnt that the prefix page? I think we did say that the prefix page must be 0 in virt and phys otherwise we will have performance issues due to cache synonyms.
As far as I am concerned we should keep virt_to_phys() semantics in sync with other archs and one should not rely on s390 implementation- specifics. Please, see also my other reply to Nico in v2.
Christian Borntraeger
reviewerAm 10.03.23 um 14:31 schrieb Alexander Gordeev:
Quoted 9 lines · Christian Borntraeger
Quoted 4 lines
Quoted 2 lines
Are you sure? Quickly checked ppc64, x86 and arm64 - they do not seem adhere
virt_to_phys(0)== 0, nor the VR kernel (so far).Isnt that the prefix page? I think we did say that the prefix page must be 0 in virt and phys otherwise we will have performance issues due to cache synonyms.
As far as I am concerned we should keep
virt_to_phys()semantics in sync with other archs and one should not rely on s390 implementation- specifics. Please, see also my other reply to Nico in v2.
I agree with that.
I am just saying that we should never have virtual/real for prefix != 0 on current machines.