hw/s390x: Remediate legacy API call
cover hw/s390x: Remediate legacy API call
From: Jared Rossi <[email protected]>
Remediate the use of a legacy API call introduced by a recent patch.
Jared Rossi (1):
hw/s390x: Use preferred API call for IPLB chain write
hw/s390x/ipl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
Signature · 1 line
2.49.0
PATCH 1/1 hw/s390x: Use preferred API call for IPLB chain write
From: Jared Rossi <[email protected]>
Replace a recently introduced legacy API call with the preferred API call.
--- hw/s390x/ipl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
hw/s390x/ipl.c +9 -1
@@ -399,8 +399,16 @@ static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain)uint16_t count =be16_to_cpu (ipl->qipl.chain_len);uint64_t len =sizeof (IplParameterBlock) * count;uint64_t chain_addr =find_iplb_chain_addr (ipl->bios_start_addr, count); +MemTxResult ret; + + ret =address_space_write (&address_space_memory, chain_addr, +MEMTXATTRS_UNSPECIFIED , iplb_chain, len); + +if (ret !=MEMTX_OK ) { +error_report ("Failed to map IPLB chain." ); +exit (1 ); + } -cpu_physical_memory_write (chain_addr, iplb_chain, len);return chain_addr; }
Signature · 1 line
2.49.0
Re: [PATCH 1/1] hw/s390x: Use preferred API call for IPLB chain write
Quoted 15 lines · On 6/23/25 4:12 PM, [email protected] wrote:
From: Jared Rossi <[email protected]>
Replace a recently introduced legacy API call with the preferred API call.
Fixes 0927875 (hw/s390x: Build an IPLB for each boot device)Signed-off-by Jared Rossi <[email protected]>--- hw/s390x/ipl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)hw/s390x/ipl.c +0
-0
hw/s390x/ipl.c static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain) · line 405
Quoted 7 lines
hw/s390x/ipl.c +4
-0@@ -399,8 +399,16 @@ static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain)uint16_t count =be16_to_cpu (ipl->qipl.chain_len);uint64_t len =sizeof (IplParameterBlock) * count;uint64_t chain_addr =find_iplb_chain_addr (ipl->bios_start_addr, count); +MemTxResult ret; + + ret =address_space_write (&address_space_memory, chain_addr, +MEMTXATTRS_UNSPECIFIED , iplb_chain, len);
Just a small nit: the indentation seems a bit off.
hw/s390x/ipl.c static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain) · line 414
Quoted 10 lines
hw/s390x/ipl.c +5
-1+ +if (ret !=MEMTX_OK ) { +error_report ("Failed to map IPLB chain." ); +exit (1 ); + } -cpu_physical_memory_write (chain_addr, iplb_chain, len);return chain_addr; }
Regards,
Joy
Re: [PATCH 1/1] hw/s390x: Use preferred API call for IPLB chain write
In reply to [email protected]Quoted 17 lines · On 6/23/25 13:12, [email protected] wrote:
From: Jared Rossi <[email protected]>
Replace a recently introduced legacy API call with the preferred API call.
Fixes 0927875 (hw/s390x: Build an IPLB for each boot device)Signed-off-by Jared Rossi <[email protected]>--- hw/s390x/ipl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)hw/s390x/ipl.c +0
-0@@ -399,8 +399,16 @@ static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain)uint16_t count =be16_to_cpu (ipl->qipl.chain_len);uint64_t len =sizeof (IplParameterBlock) * count;
hw/s390x/ipl.c static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain) · line 410
Quoted 10 lines
hw/s390x/ipl.c +9
-0uint64_t chain_addr =find_iplb_chain_addr (ipl->bios_start_addr, count); +MemTxResult ret; + + ret =address_space_write (&address_space_memory, chain_addr, +MEMTXATTRS_UNSPECIFIED , iplb_chain, len); + +if (ret !=MEMTX_OK ) { +error_report ("Failed to map IPLB chain." ); +exit (1 ); + }
I'm certain you should not exit for a guest error.
r~
Quoted 5 lines
hw/s390x/ipl.c +0
-1-cpu_physical_memory_write (chain_addr, iplb_chain, len);return chain_addr; }
Re: [PATCH 1/1] hw/s390x: Use preferred API call for IPLB chain write
In reply to [email protected]Quoted 19 lines · On 23/06/2025 22.12, [email protected] wrote:
From: Jared Rossi <[email protected]>
Replace a recently introduced legacy API call with the preferred API call.
Fixes 0927875 (hw/s390x: Build an IPLB for each boot device)Signed-off-by Jared Rossi <[email protected]>--- hw/s390x/ipl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)hw/s390x/ipl.c +1
-0@@ -399,8 +399,16 @@ static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain)uint16_t count =be16_to_cpu (ipl->qipl.chain_len);uint64_t len =sizeof (IplParameterBlock) * count;uint64_t chain_addr =find_iplb_chain_addr (ipl->bios_start_addr, count); +MemTxResult ret;
hw/s390x/ipl.c static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain) · line 403
Quoted 10 lines
hw/s390x/ipl.c +8
-1+ + ret =address_space_write (&address_space_memory, chain_addr, +MEMTXATTRS_UNSPECIFIED , iplb_chain, len); + +if (ret !=MEMTX_OK ) { +error_report ("Failed to map IPLB chain." ); +exit (1 ); + } -cpu_physical_memory_write (chain_addr, iplb_chain, len);
By using address_space_memory, you're basically open-coding cpu_physical_memory_write() here. That does not make too much sense. If I got Philippe right in https://lore.kernel.org/qemu-devel/[email protected]/ , he rather asked about a device specific address space instead. However, that ipl device does not have its own address space as far as I can see, so that request does not make much sense here (unless I missed something). Thus I'd suggest to drop this patch here.
Thomas
Re: [PATCH 1/1] hw/s390x: Use preferred API call for IPLB chain write
Quoted 33 lines · Thomas Huth
Quoted 19 lines · On 23/06/2025 22.12, [email protected] wrote:
From: Jared Rossi <[email protected]>
Replace a recently introduced legacy API call with the preferred API call.
Fixes 0927875 (hw/s390x: Build an IPLB for each boot device)Signed-off-by Jared Rossi <[email protected]>---
hw/s390x/ipl.c| 10 +++++++++-1 file changed, 9 insertions(+), 1 deletion(-)hw/s390x/ipl.c +0
-0@@ -399,8 +399,16 @@ static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain) uint16_t count = be16_to_cpu(ipl->qipl.chain_len); uint64_t len = sizeof(IplParameterBlock) * count; uint64_t chain_addr = find_iplb_chain_addr(ipl->bios_start_addr, count);hw/s390x/ipl.c static uint64_t · line 412
Quoted 10 lines
hw/s390x/ipl.c +9
-0+ MemTxResult ret; + + ret = address_space_write(&address_space_memory, chain_addr, + MEMTXATTRS_UNSPECIFIED, iplb_chain, len); + + if (ret != MEMTX_OK) { + error_report("Failed to map IPLB chain."); + exit(1); + } - cpu_physical_memory_write(chain_addr, iplb_chain, len);By using
address_space_memory, you're basically open-codingcpu_physical_memory_write()here. That does not make too much sense. If I got Philippe right in https://lore.kernel.org/qemu-devel/[email protected]/ , he rather asked about a device specific address space instead. However, that ipl device does not have its own address space as far as I can see, so that request does not make much sense here (unless I missed something). Thus I'd suggest to drop this patch here.
Quoted 2 lines
Thomas
Yes, it is basically the same. I interpreted Philippe's request to mean avoid introducing new calls to cpu_physical_memory_* functions as per the documentation in load-stores.rst. If the request was to use a device specific address space, then Thomas is correct and it cannot done be here.
Regards,
Jared Rossi
Re: [PATCH 1/1] hw/s390x: Use preferred API call for IPLB chain write
Hi,
Quoted 22 lines · Jared Rossi
Quoted 21 lines · Thomas Huth
Quoted 20 lines · On 23/06/2025 22.12, [email protected] wrote:
From: Jared Rossi <[email protected]>
Replace a recently introduced legacy API call with the preferred API call.
Fixes 0927875 (hw/s390x: Build an IPLB for each boot device)Signed-off-by Jared Rossi <[email protected]>---
hw/s390x/ipl.c| 10 +++++++++-1 file changed, 9 insertions(+), 1 deletion(-)hw/s390x/ipl.c +0
-0@@ -399,8 +399,16 @@ static uint64_t s390_ipl_map_iplb_chain(IplParameterBlock *iplb_chain) uint16_t count = be16_to_cpu(ipl->qipl.chain_len); uint64_t len = sizeof(IplParameterBlock) * count;
uint64_tchain_addr= find_iplb_chain_addr(ipl-Quoted 1 line
bios_start_addr, count);
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
+ MemTxResult ret;
+
+ ret =address_space_write(&address_space_memory, chain_addr, + MEMTXATTRS_UNSPECIFIED, iplb_chain, len);Quoted 8 lines
Quoted 6 lines
+
+ if (ret !=MEMTX_OK) {
+error_report("Failed to map IPLB chain."); + exit(1);
+ }
-cpu_physical_memory_write(chain_addr, iplb_chain, len);By using
address_space_memory, you're basically open-codingcpu_physical_memory_write()here. That does not make too much sense. If I got Philippe right in https://lore.kernel.org/qemu- devel/[email protected]/ , he rather asked about a device specific address space instead. However, that ipl device does not have its own address space as far as I can see, so that request does not make much sense here (unless I missed something). Thus I'd suggest to drop this patch here.
Generic pattern to remove &address_space_memory singleton is to add a link property to the device, set it in the device Realize handler (here s390_ipl_realize) and use this device address space instead.
Eventually we'd be able to remove the legacy cpu_physical_memory_write() API, not re-using it.
I don't know about the IPL device. IIUC s390x is unlikely interested in heterogeneous emulation, and model design often took API shortcuts, but if we want the whole codebase to move toward the heterogeneous goal, we need to strengthen API uses.
My 2 cents anyhow.
Regards,
Phil.