On Mon, Dec 08, 2025 at 04:32:23PM -0500, Zhuoying Cai wrote:
> 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>
> ---
> target/s390x/diag.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/target/s390x/diag.c b/target/s390x/diag.c
> index a35d808fd7..a347be7633 100644
> --- a/target/s390x/diag.c
> +++ b/target/s390x/diag.c
> @@ -26,6 +26,12 @@
> #include "qemu/error-report.h"
>
>
> +static inline bool diag_parm_addr_valid(uint64_t addr, size_t size, bool write)
> +{
> + return address_space_access_valid(&address_space_memory, addr,
> + size, write, MEMTXATTRS_UNSPECIFIED);
> +}
> +
> int handle_diag_288(CPUS390XState *env, uint64_t r1, uint64_t r3)
> {
> uint64_t func = env->regs[r1];
> @@ -65,9 +71,7 @@ static int diag308_parm_check(CPUS390XState *env, uint64_t r1, uint64_t addr,
> s390_program_interrupt(env, PGM_SPECIFICATION, ra);
> return -1;
> }
> - if (!address_space_access_valid(&address_space_memory, addr,
> - sizeof(IplParameterBlock), write,
> - MEMTXATTRS_UNSPECIFIED)) {
> + if (!diag_parm_addr_valid(addr, sizeof(IplParameterBlock), write)) {
> s390_program_interrupt(env, PGM_ADDRESSING, ra);
> return -1;
> }
Reviewed-by: Hendrik Brueckner <brueckner@linux.ibm.com>