From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOB8Z-0001L5-Ub for qemu-devel@nongnu.org; Wed, 18 Feb 2015 15:22:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOB8S-00020Y-9m for qemu-devel@nongnu.org; Wed, 18 Feb 2015 15:22:23 -0500 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:46448) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOB8S-0001yQ-1V for qemu-devel@nongnu.org; Wed, 18 Feb 2015 15:22:16 -0500 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Feb 2015 20:22:15 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id ACF871B08072 for ; Wed, 18 Feb 2015 20:22:24 +0000 (GMT) Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t1IKMClY5308686 for ; Wed, 18 Feb 2015 20:22:12 GMT Received: from d06av07.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t1IKMBht026927 for ; Wed, 18 Feb 2015 15:22:11 -0500 From: Christian Borntraeger Date: Wed, 18 Feb 2015 21:22:20 +0100 Message-Id: <1424290943-22480-27-git-send-email-borntraeger@de.ibm.com> In-Reply-To: <1424290943-22480-1-git-send-email-borntraeger@de.ibm.com> References: <1424290943-22480-1-git-send-email-borntraeger@de.ibm.com> Subject: [Qemu-devel] [PULL 26/29] s390x/ioinst: Rework memory access in CHSC instruction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Thomas Huth , qemu-devel , Alexander Graf , Christian Borntraeger , Jens Freimann , Cornelia Huck , Richard Henderson From: Thomas Huth Change the CHSC handler to correctly use logical addresses, too. Signed-off-by: Thomas Huth Signed-off-by: Jens Freimann Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Signed-off-by: Christian Borntraeger --- target-s390x/ioinst.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/target-s390x/ioinst.c b/target-s390x/ioinst.c index 157972d..7e748c2 100644 --- a/target-s390x/ioinst.c +++ b/target-s390x/ioinst.c @@ -629,8 +629,8 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb) int reg; uint16_t len; uint16_t command; - hwaddr map_size = TARGET_PAGE_SIZE; CPUS390XState *env = &cpu->env; + uint8_t buf[TARGET_PAGE_SIZE]; trace_ioinst("chsc"); reg = (ipb >> 20) & 0x00f; @@ -640,16 +640,20 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb) program_interrupt(env, PGM_SPECIFICATION, 2); return; } - req = s390_cpu_physical_memory_map(env, addr, &map_size, 1); - if (!req || map_size != TARGET_PAGE_SIZE) { - program_interrupt(env, PGM_ADDRESSING, 2); - goto out; + /* + * Reading sizeof(ChscReq) bytes is currently enough for all of our + * present CHSC sub-handlers ... if we ever need more, we should take + * care of req->len here first. + */ + if (s390_cpu_virt_mem_read(cpu, addr, buf, sizeof(ChscReq))) { + return; } + req = (ChscReq *)buf; len = be16_to_cpu(req->len); /* Length field valid? */ if ((len < 16) || (len > 4088) || (len & 7)) { program_interrupt(env, PGM_OPERAND, 2); - goto out; + return; } memset((char *)req + len, 0, TARGET_PAGE_SIZE - len); res = (void *)((char *)req + len); @@ -673,9 +677,9 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb) break; } - setcc(cpu, 0); /* Command execution complete */ -out: - s390_cpu_physical_memory_unmap(env, req, map_size, 1); + if (!s390_cpu_virt_mem_write(cpu, addr + len, res, be16_to_cpu(res->len))) { + setcc(cpu, 0); /* Command execution complete */ + } } int ioinst_handle_tpi(CPUS390XState *env, uint32_t ipb) -- 1.9.3