From nobody Mon Feb 9 09:16:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14884227200401007.2996992222295; Wed, 1 Mar 2017 18:45:20 -0800 (PST) Received: from localhost ([::1]:49882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjGk2-0001KU-Un for importer@patchew.org; Wed, 01 Mar 2017 21:45:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjGgZ-0006y0-3v for qemu-devel@nongnu.org; Wed, 01 Mar 2017 21:41:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjGgY-0006i6-4Q for qemu-devel@nongnu.org; Wed, 01 Mar 2017 21:41:43 -0500 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:36766) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cjGgX-0006i2-WB for qemu-devel@nongnu.org; Wed, 01 Mar 2017 21:41:42 -0500 Received: by mail-qk0-x241.google.com with SMTP id u188so15709130qkc.3 for ; Wed, 01 Mar 2017 18:41:41 -0800 (PST) Received: from bigtime.twiddle.net.com (mail.taphouse.com.au. [180.214.90.195]) by smtp.gmail.com with ESMTPSA id s3sm4459321qte.57.2017.03.01.18.41.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2017 18:41:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=C5tipqk3N641rB+ePkDb8IskEOEU9agwRqcUVfz55UE=; b=g5rI59vTNkNejncLojNMie2LY9TtJaDS/oRholqMWHj3sLvijIXRNytVwI5qNa7hAZ 8dO98w8QSWtBwmaQfaWR6aXsaU2y6PWarEDeT79yxCKF2MR5v7QqIcYmsy8MnBWoBXIj lR7wXZ+ErGuHkZOV5yHBMiltGQSaAoeH8eRoqiuFCXWX/BsEfaHpNCP53BzDzSDvEdkU t9erFBtRHCwmWwVmFjdFeg/BEwHgG6GBQLMwguepw2KDc1axf0IHKTKi3B7MfLQgBFio ebGWlXmHuoy7gkjZtSZaegiRWFDGPwtqZMrKicEFWvtnY2bAstoaUUwWmmxuUaQgAYg4 aLmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=C5tipqk3N641rB+ePkDb8IskEOEU9agwRqcUVfz55UE=; b=SuMI2mQ0Lnvh0s9SgyHZTIjgbJBOD8/0YgGwsR83W37ubspw33AAesotVbs9hb6gdj qTwvkdjMnUsIEOahLItTldy1MHmH1fcQbdoqVwlv4sSJ31U2oOAQf7El+HpfQc3oRt5d 8YiSUhrFGzTGSLpHiK62lFGRDq7FI850CquPB89SvNAHq/ZTlop3VE9QaoMRe0zmpcI2 r8whu5AOAM1V1iEmVrR6TV9An4/IEFSLkNrLPQSkWOtHv9Efs3pTECxNBK9HbbM16vjD lqrk5auXsYtYpohEmDCJYQBzxTDpX2uRAUNzVxbR00ln0z/Zyn7YrqYnXkLPjUbVX7vo 6/TQ== X-Gm-Message-State: AMke39kuwBUpxtZ2o4XXcmo6F067LiK9BKP4EK8zh6BWzmFUVLpnJLDW2m56GUxO0YvjXQ== X-Received: by 10.55.6.150 with SMTP id 144mr13539556qkg.46.1488422501284; Wed, 01 Mar 2017 18:41:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 2 Mar 2017 13:41:07 +1100 Message-Id: <20170302024110.3978-4-rth@twiddle.net> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170302024110.3978-1-rth@twiddle.net> References: <20170302024110.3978-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [PATCH 3/6] target/s390x: Diagnose specification exception for atomics X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" All of the interlocked access facility instructions raise a specification exception for unaligned accesses. Do this by using the (previously unused) unaligned_access hook. Signed-off-by: Richard Henderson --- target/s390x/cpu.c | 1 + target/s390x/cpu.h | 3 +++ target/s390x/helper.c | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 066dcd1..a1bf2ba 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -430,6 +430,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) cc->write_elf64_note =3D s390_cpu_write_elf64_note; cc->cpu_exec_interrupt =3D s390_cpu_exec_interrupt; cc->debug_excp_handler =3D s390x_cpu_debug_excp_handler; + cc->do_unaligned_access =3D s390x_cpu_do_unaligned_access; #endif cc->disas_set_info =3D s390_cpu_disas_set_info; =20 diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 058ddad..bbed320 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -480,6 +480,9 @@ int s390_cpu_handle_mmu_fault(CPUState *cpu, vaddr addr= ess, int rw, =20 #ifndef CONFIG_USER_ONLY void do_restart_interrupt(CPUS390XState *env); +void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr, + MMUAccessType access_type, + int mmu_idx, uintptr_t retaddr); =20 static inline hwaddr decode_basedisp_s(CPUS390XState *env, uint32_t ipb, uint8_t *ar) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 68bd2f9..9978490 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -718,4 +718,20 @@ void s390x_cpu_debug_excp_handler(CPUState *cs) cpu_loop_exit_noexc(cs); } } + +/* Unaligned accesses are only diagnosed with MO_ALIGN. At the moment, + this is only for the atomic operations, for which we want to raise a + specification exception. */ +void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr, + MMUAccessType access_type, + int mmu_idx, uintptr_t retaddr) +{ + S390CPU *cpu =3D S390_CPU(cs); + CPUS390XState *env =3D &cpu->env; + + if (retaddr) { + cpu_restore_state(cs, retaddr); + } + program_interrupt(env, PGM_SPECIFICATION, ILEN_LATER); +} #endif /* CONFIG_USER_ONLY */ --=20 2.9.3