From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3nzf-0005dp-Er for qemu-devel@nongnu.org; Mon, 29 Jul 2013 10:00:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3nzW-00035a-2Y for qemu-devel@nongnu.org; Mon, 29 Jul 2013 10:00:11 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:46726) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3nzV-00034D-Qw for qemu-devel@nongnu.org; Mon, 29 Jul 2013 10:00:02 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 29 Jul 2013 14:51:21 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id C7E721B08074 for ; Mon, 29 Jul 2013 14:59:57 +0100 (BST) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps3074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r6TDxk1Z63439000 for ; Mon, 29 Jul 2013 13:59:46 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r6TDxuIr025578 for ; Mon, 29 Jul 2013 07:59:57 -0600 From: Christian Borntraeger Date: Mon, 29 Jul 2013 16:00:12 +0200 Message-Id: <1375106418-22828-3-git-send-email-borntraeger@de.ibm.com> In-Reply-To: <1375106418-22828-1-git-send-email-borntraeger@de.ibm.com> References: <1375092324-23943-1-git-send-email-agraf@suse.de> <1375106418-22828-1-git-send-email-borntraeger@de.ibm.com> Subject: [Qemu-devel] [PATCH 2/8] s390x/ioinst: Add missing alignment checks for IO instructions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Developers Cc: aliguori@us.ibm.com, Thomas Huth , Alexander Graf , Christian Borntraeger , Jens Freimann , cornelia.huck@de.ibm.com From: Thomas Huth The IO instructions MSCH, SSCH, STSCH, TSCH, STCRW and TPI require that the second operand address must be aligned on a word boundary. Signed-off-by: Thomas Huth Reviewed-by: Cornelia Huck Signed-off-by: Christian Borntraeger --- target-s390x/ioinst.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/target-s390x/ioinst.c b/target-s390x/ioinst.c index 28c508d..91cc41b 100644 --- a/target-s390x/ioinst.c +++ b/target-s390x/ioinst.c @@ -157,6 +157,10 @@ int ioinst_handle_msch(CPUS390XState *env, uint64_t reg1, uint32_t ipb) } trace_ioinst_sch_id("msch", cssid, ssid, schid); addr = decode_basedisp_s(env, ipb); + if (addr & 3) { + program_interrupt(env, PGM_SPECIFICATION, 2); + return -EIO; + } schib = s390_cpu_physical_memory_map(env, addr, &len, 0); if (!schib || len != sizeof(*schib)) { program_interrupt(env, PGM_SPECIFICATION, 2); @@ -228,6 +232,10 @@ int ioinst_handle_ssch(CPUS390XState *env, uint64_t reg1, uint32_t ipb) } trace_ioinst_sch_id("ssch", cssid, ssid, schid); addr = decode_basedisp_s(env, ipb); + if (addr & 3) { + program_interrupt(env, PGM_SPECIFICATION, 2); + return -EIO; + } orig_orb = s390_cpu_physical_memory_map(env, addr, &len, 0); if (!orig_orb || len != sizeof(*orig_orb)) { program_interrupt(env, PGM_SPECIFICATION, 2); @@ -272,6 +280,10 @@ int ioinst_handle_stcrw(CPUS390XState *env, uint32_t ipb) hwaddr len = sizeof(*crw); addr = decode_basedisp_s(env, ipb); + if (addr & 3) { + program_interrupt(env, PGM_SPECIFICATION, 2); + return -EIO; + } crw = s390_cpu_physical_memory_map(env, addr, &len, 1); if (!crw || len != sizeof(*crw)) { program_interrupt(env, PGM_SPECIFICATION, 2); @@ -300,6 +312,10 @@ int ioinst_handle_stsch(CPUS390XState *env, uint64_t reg1, uint32_t ipb) } trace_ioinst_sch_id("stsch", cssid, ssid, schid); addr = decode_basedisp_s(env, ipb); + if (addr & 3) { + program_interrupt(env, PGM_SPECIFICATION, 2); + return -EIO; + } schib = s390_cpu_physical_memory_map(env, addr, &len, 1); if (!schib || len != sizeof(*schib)) { program_interrupt(env, PGM_SPECIFICATION, 2); @@ -345,6 +361,10 @@ int ioinst_handle_tsch(CPUS390XState *env, uint64_t reg1, uint32_t ipb) } trace_ioinst_sch_id("tsch", cssid, ssid, schid); addr = decode_basedisp_s(env, ipb); + if (addr & 3) { + program_interrupt(env, PGM_SPECIFICATION, 2); + return -EIO; + } irb = s390_cpu_physical_memory_map(env, addr, &len, 1); if (!irb || len != sizeof(*irb)) { program_interrupt(env, PGM_SPECIFICATION, 2); @@ -625,6 +645,11 @@ int ioinst_handle_tpi(CPUS390XState *env, uint32_t ipb) trace_ioinst("tpi"); addr = decode_basedisp_s(env, ipb); + if (addr & 3) { + program_interrupt(env, PGM_SPECIFICATION, 2); + return -EIO; + } + lowcore = addr ? 0 : 1; len = lowcore ? 8 /* two words */ : 12 /* three words */; orig_len = len; -- 1.8.3.1