@samitouri / QOSamiQemu / commits / cf6d9c6d9e

s390x/diag: Refactor address validation check from diag308_parm_check

Create a function to validate the address parameter of DIAGNOSE. Refactor the function for reuse in the next patch, which allows address validation in read or write operation of DIAGNOSE. Signed-off-by: Zhuoying Cai <zycai@linux.ibm.com> Reviewed-by: Farhan Ali <alifm@linux.ibm.com> Reviewed-by: Collin Walling <walling@linux.ibm.com> Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Link: https://lore.kernel.org/qemu-devel/20260730214624.2328883-7-zycai@linux.ibm.com Signed-off-by: Eric Farman <farman@linux.ibm.com>

Zhuoying Cai committed Jul 30, 2026 at 17:45 UTC cf6d9c6d9ed659d99c6bcfd479f4bda68c5f75c2
1 file changed +7 -3
target/s390x/diag.c
+7 -3
@@ -26,6 +26,12 @@
26 #include "qemu/error-report.h"
27
28
29 +static inline bool diag_parm_addr_valid(uint64_t addr, size_t size, bool write)
30 +{
31 + return address_space_access_valid(&address_space_memory, addr,
32 + size, write, MEMTXATTRS_UNSPECIFIED);
33 +}
34 +
35 int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3)
36 {
37 uint64_t func = env->regs[r1];
@@ -65,9 +71,7 @@ static int diag308_parm_check(CPUS390XState *env, uint64_t r1, uint64_t addr,
71 s390_program_interrupt(env, PGM_SPECIFICATION, ra);
72 return -1;
73 }
68 - if (!address_space_access_valid(&address_space_memory, addr,
69 - sizeof(IplParameterBlock), write,
70 - MEMTXATTRS_UNSPECIFIED)) {
74 + if (!diag_parm_addr_valid(addr, sizeof(IplParameterBlock), write)) {
75 s390_program_interrupt(env, PGM_ADDRESSING, ra);
76 return -1;
77 }