From nobody Tue Feb 10 06:07:25 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 1494353347820959.8167591640384; Tue, 9 May 2017 11:09:07 -0700 (PDT) Received: from localhost ([::1]:38764 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d89ZJ-0002P0-Fl for importer@patchew.org; Tue, 09 May 2017 14:09:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d89Xh-00015o-Vg for qemu-devel@nongnu.org; Tue, 09 May 2017 14:07:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d89Xh-0002kT-07 for qemu-devel@nongnu.org; Tue, 09 May 2017 14:07:25 -0400 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:32862) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d89Xg-0002jX-Sn for qemu-devel@nongnu.org; Tue, 09 May 2017 14:07:24 -0400 Received: by mail-qt0-x242.google.com with SMTP id a46so1002124qte.0 for ; Tue, 09 May 2017 11:07:24 -0700 (PDT) Received: from bigtime.twiddle.net.com ([2602:47:d954:1500:5e51:4fff:fe40:9c64]) by smtp.gmail.com with ESMTPSA id w12sm213102qtc.20.2017.05.09.11.07.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 May 2017 11:07:23 -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=PF3/J1k7RKLbsOuiOCZdszMrp0mbUFlWU7Srw5HAU5c=; b=UQD70dFJf1l/u7oxOrjP01bBwK5HnSGxMNAFVHfVEBL4EXK0rMqUWzEd0xwjtdg20W CN71nw/UIAEsuduVO76xot/i+rod01Bw3n3Li7YLh8gL3he+s0YsexdjCk3UxAmxfjH5 yj79SpqA3LNAC6IxCNKo1SrldS587ukFma9wAOl6xAt743n290uMntrwK76vfqQ7pfkZ OwHQ+c6kbqTybeYPJ833PfeTRQ9Fy4Jp1qlOAiN0u550LqhSnsoolZdHfeqKYB4xbiSN K+956MFPoox6PcUpCn4pTqWyWeMBNOm2jhkvIAUrG3tOaPnFiOVtCZYotU7GHMV/acHB FjaA== 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=PF3/J1k7RKLbsOuiOCZdszMrp0mbUFlWU7Srw5HAU5c=; b=LzcJ5pTeg9+KUxME43hqqZTnlJtyE6ztcagbe5BC1s7tEyxpAb9BlI/tpV9qTa0xjn u+8R4GwAD+gxqmhQVjlGbfhD30GldLyhZa83CLQJQzcMxfO87fpwn3GYdHPs59WOlu7s MSL3STXwMzOt9T8/LaD/EeNAtZxcvBUa9K0N1PIHAHaKP7i8y5/l2V1eNfEozugI3Xhv lcgmPCmzUt+SDK6SSenxmDKOcp3Vqz1/cVspfZcD2fxgRH3q0y8kGIZLdNe4TFv6Mu86 NdRSR8aR2xwCU2tcx/HviCbjokzQ1+dQ/oOp2RGaPtuTRK/222YQmlDzuRuYvh3VrTep cCfA== X-Gm-Message-State: AODbwcCS0LBhE0a0BpRKtMf97ftGZoFR/CuI6mEoW07Uw1K+oyFP7HYE msgzOKhC6d9l/T2zS/8= X-Received: by 10.200.42.199 with SMTP id c7mr1686257qta.102.1494353244102; Tue, 09 May 2017 11:07:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 9 May 2017 11:07:12 -0700 Message-Id: <20170509180715.22910-4-rth@twiddle.net> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170509180715.22910-1-rth@twiddle.net> References: <20170509180715.22910-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::242 Subject: [Qemu-devel] [PATCH v3 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. Reviewed-by: Aurelien Jarno Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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