From patchwork Thu Feb 12 17:09:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Freimann X-Patchwork-Id: 439264 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 37F1C1400DD for ; Fri, 13 Feb 2015 04:13:15 +1100 (AEDT) Received: from localhost ([::1]:51311 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLxKC-0007DD-EL for incoming@patchwork.ozlabs.org; Thu, 12 Feb 2015 12:13:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLxH3-0002Na-2x for qemu-devel@nongnu.org; Thu, 12 Feb 2015 12:09:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLxGw-0007pq-HP for qemu-devel@nongnu.org; Thu, 12 Feb 2015 12:09:56 -0500 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:58744) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLxGw-0007pK-9e for qemu-devel@nongnu.org; Thu, 12 Feb 2015 12:09:50 -0500 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Feb 2015 17:09:49 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 12 Feb 2015 17:09:47 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 50CF0219006C for ; Thu, 12 Feb 2015 17:09:42 +0000 (GMT) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t1CH9lm327852890 for ; Thu, 12 Feb 2015 17:09:47 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t1CH9kYv003353 for ; Thu, 12 Feb 2015 10:09:46 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t1CH9kWb003342; Thu, 12 Feb 2015 10:09:46 -0700 Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 1122) id AF9481224469; 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:35 +0100 Message-Id: <1423760982-8474-19-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-0041-0000-0000-0000033C522E X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.106 Cc: Jens Freimann , qemu-devel@nongnu.org, Thomas Huth Subject: [Qemu-devel] [PATCH 18/25] s390x/ioinst: Rework memory access in STSCH 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 handler for STSCH to use the new logical memory access functions. Signed-off-by: Thomas Huth Signed-off-by: Jens Freimann Reviewed-by: Cornelia Huck --- target-s390x/ioinst.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/target-s390x/ioinst.c b/target-s390x/ioinst.c index 0ef7a93..23c2faf 100644 --- a/target-s390x/ioinst.c +++ b/target-s390x/ioinst.c @@ -284,8 +284,7 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb) SubchDev *sch; uint64_t addr; int cc; - SCHIB *schib; - hwaddr len = sizeof(*schib); + SCHIB schib; CPUS390XState *env = &cpu->env; addr = decode_basedisp_s(env, ipb); @@ -293,21 +292,23 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb) program_interrupt(env, PGM_SPECIFICATION, 2); return; } - schib = s390_cpu_physical_memory_map(env, addr, &len, 1); - if (!schib || len != sizeof(*schib)) { - program_interrupt(env, PGM_ADDRESSING, 2); - goto out; - } if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { - program_interrupt(env, PGM_OPERAND, 2); - goto out; + /* + * As operand exceptions have a lower priority than access exceptions, + * we check whether the memory area is writeable (injecting the + * access execption if it is not) first. + */ + if (!s390_cpu_virt_mem_check_write(cpu, addr, sizeof(schib))) { + program_interrupt(env, PGM_OPERAND, 2); + } + return; } trace_ioinst_sch_id("stsch", cssid, ssid, schid); sch = css_find_subch(m, cssid, ssid, schid); if (sch) { if (css_subch_visible(sch)) { - css_do_stsch(sch, schib); + css_do_stsch(sch, &schib); cc = 0; } else { /* Indicate no more subchannels in this css/ss */ @@ -318,14 +319,21 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb) cc = 3; /* No more subchannels in this css/ss */ } else { /* Store an empty schib. */ - memset(schib, 0, sizeof(*schib)); + memset(&schib, 0, sizeof(schib)); cc = 0; } } + if (cc != 3) { + if (s390_cpu_virt_mem_write(cpu, addr, &schib, sizeof(schib)) != 0) { + return; + } + } else { + /* Access exceptions have a higher priority than cc3 */ + if (s390_cpu_virt_mem_check_write(cpu, addr, sizeof(schib)) != 0) { + return; + } + } setcc(cpu, cc); - -out: - s390_cpu_physical_memory_unmap(env, schib, len, 1); } int ioinst_handle_tsch(CPUS390XState *env, uint64_t reg1, uint32_t ipb)