From patchwork Thu Feb 12 17:09:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Freimann X-Patchwork-Id: 439283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id AB50D140182 for ; Fri, 13 Feb 2015 04:24:25 +1100 (AEDT) Received: from localhost ([::1]:51429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLxV1-0001j7-SE for incoming@patchwork.ozlabs.org; Thu, 12 Feb 2015 12:24:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLxHo-0003rL-B9 for qemu-devel@nongnu.org; Thu, 12 Feb 2015 12:10:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLxHf-0008H2-H0 for qemu-devel@nongnu.org; Thu, 12 Feb 2015 12:10:44 -0500 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:34095) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLxHf-0008GO-65 for qemu-devel@nongnu.org; Thu, 12 Feb 2015 12:10:35 -0500 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Feb 2015 17:10:34 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp16.uk.ibm.com (192.168.101.146) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 12 Feb 2015 17:10:33 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id C814B17D8071 for ; Thu, 12 Feb 2015 17:10:43 +0000 (GMT) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t1CH9l7e3342756 for ; Thu, 12 Feb 2015 17:09:47 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t1CH9kCa025372 for ; Thu, 12 Feb 2015 10:09:47 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t1CH9kDg025357; Thu, 12 Feb 2015 10:09:46 -0700 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 1122) id B7B03122446D; Thu, 12 Feb 2015 18:09:45 +0100 (CET) From: Jens Freimann To: Christian Borntraeger , Alexander Graf , Cornelia Huck Date: Thu, 12 Feb 2015 18:09:39 +0100 Message-Id: <1423760982-8474-23-git-send-email-jfrei@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1423760982-8474-1-git-send-email-jfrei@linux.vnet.ibm.com> References: <1423760982-8474-1-git-send-email-jfrei@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15021217-0025-0000-0000-000003DA881E X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.112 Cc: Jens Freimann , qemu-devel@nongnu.org, Thomas Huth Subject: [Qemu-devel] [PATCH 22/25] s390x/ioinst: Rework memory access in CHSC instruction X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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)