From nobody Mon Feb 9 07:05:56 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; dkim=fail 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 1494256745394644.3879468435908; Mon, 8 May 2017 08:19:05 -0700 (PDT) Received: from localhost ([::1]:59993 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7kRD-0006g7-Vd for importer@patchew.org; Mon, 08 May 2017 11:19:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7kPV-0005X2-3Z for qemu-devel@nongnu.org; Mon, 08 May 2017 11:17:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d7kPU-0001Ca-7Y for qemu-devel@nongnu.org; Mon, 08 May 2017 11:17:17 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:36480) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d7kPU-0001CP-3i for qemu-devel@nongnu.org; Mon, 08 May 2017 11:17:16 -0400 Received: by mail-qt0-x244.google.com with SMTP id j13so9958739qta.3 for ; Mon, 08 May 2017 08:17:16 -0700 (PDT) Received: from bigtime.twiddle.net.com ([2602:47:d954:1500:5e51:4fff:fe40:9c64]) by smtp.gmail.com with ESMTPSA id r55sm7864331qte.22.2017.05.08.08.17.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 May 2017 08:17:14 -0700 (PDT) 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=VLyA2+UCrrN3WB30E2p/uO/6UGSAT9NhuXnrgBuA+nFHitxHumJOzFiCr3n0pmcMjT fznVEdh3uYB2CUL092CbJT8N8QM5SctSBDzAzF8AjM2RbihX5AvVd9MXn57dfWNT5Pcl rD5swSwbm5Cy39jDtOMwFV6Kng0A9CKG6EBsPx4sRcmHrjl69WBNp1qyEvv2AOMDDgBz 1L4+XBPNsDm6jdMiWPB2vqNW55tIT2gQmMfBRVx/sR853WX1XT/SzF1jQld53Or4x2IQ Aia4TCX2P7C/xLhPXYAH5yd+f4PKLKf0h+k5H/aggtNouggSrf2tIx3SYlVBDU+rXxdD OzdA== 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=m+UnbztfT1xHmJCp6TO4p/1bfNs7IzNSD4aJeDCqNCAZhiLcAcW4PXE0YVDQs5xfMA WJPRRGxnh+7Y+jZCAW9vfvVRVTiHOI3DRO6ecdINECs8H63ujUeCBExN3jUiH1f/yJ1A /acEPH6nD+cQTdBhDLYGdlEucAJ7oMnot0YLSTPE2raBcKdcQ+1d53yAyhR2Wjo7v2J0 pqtuSKazYodFzAUOINkjmOux7L5QASgTsEbkARjO00e9SM/Pgsz0a9SjXflK/SA/eb81 p3NzlsyC+l6a3ZCp+Xryo0M9thqwMVVWOpgA9A3LpGsq+kxNi3tL9ig2ADyDqf3X4Etm UBKQ== X-Gm-Message-State: AN3rC/6tk96Iefu/aXxAKPQk4ub3yo3zTJ89A43GuIXnm7hJRlVqmdsV 1X4KLA3E5hpYLslTcLI= X-Received: by 10.200.38.132 with SMTP id 4mr51973318qto.99.1494256635441; Mon, 08 May 2017 08:17:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 8 May 2017 08:17:04 -0700 Message-Id: <20170508151707.5434-4-rth@twiddle.net> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170508151707.5434-1-rth@twiddle.net> References: <20170508151707.5434-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::244 Subject: [Qemu-devel] [PATCH v2 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-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 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 Reviewed-by: Aurelien Jarno --- 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