From patchwork Fri May 12 23:40:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 761887 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 3wPmk419rHz9s7y for ; Sat, 13 May 2017 09:42:52 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cMD+aLCr"; dkim-atps=neutral Received: from localhost ([::1]:55693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9KCv-0002xk-OS for incoming@patchwork.ozlabs.org; Fri, 12 May 2017 19:42:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9KAV-0001Bv-O6 for qemu-devel@nongnu.org; Fri, 12 May 2017 19:40:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d9KAU-0003zV-Qf for qemu-devel@nongnu.org; Fri, 12 May 2017 19:40:19 -0400 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:34180) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d9KAU-0003zC-N7 for qemu-devel@nongnu.org; Fri, 12 May 2017 19:40:18 -0400 Received: by mail-qk0-x243.google.com with SMTP id u75so9817232qka.1 for ; Fri, 12 May 2017 16:40:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=PF3/J1k7RKLbsOuiOCZdszMrp0mbUFlWU7Srw5HAU5c=; b=cMD+aLCrirjUqKYMl59YrN6+sqnxQazGu2jfHz6Wg0SgQpjNruG16Fc8yLYsrU5kej RVWePBpJwhBK4qWO63WcH/80GVsLgjnyUFExjt2TuYo7hP74v4nqY8eOgQuHYBZxJDWw UijHcvBYqR3pY2fgY59GZ1TGg4pEk8HedUy1fyVUPI8ZD8ApHrLnBDOi5/ILfr0NV17N im4vtOHSSHXttqXbwAj5x/qKY0pd6c5f6/c0C9qy0nPw7o3jsnebd5jHNkS3DBhjI2PW n5YSfYQ0EWslIBPftXymuFwjUgZtxh93gxQjbRLas33UrmW7rV+P5xyaDPQeK36pdPn9 xMcw== 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:cc:subject:date:message-id :in-reply-to:references; bh=PF3/J1k7RKLbsOuiOCZdszMrp0mbUFlWU7Srw5HAU5c=; b=clJHE4JyvPvWDUDpHJXHFxScNQlpMD3Ay46IPFTvYWiUFd9nZ+6RN31V6s7B18Chj3 V6chkX5KmyYVJRLODQA5txsAAcb4WrZH9R0AlyuLZrOdTYJkyQSGq1dBLkfrQAFJDkhN MOs1XJ5U3Dbw+GaHV6J+KgVX/zrHOPqimSAJLVujHLtOB4fwBzVStmKIj+X7cjOEmYch OX2XZX2boZNc41M+GttW0J9wTh9hQzHIkV51pQoAeUCbF4W+ITf1/ULFoTHSAs4ASLZS QnLLoRWGALprpvnE2Q4hM4/tx99mR34UpYkeUtmU8Y5tbNKz3sBYVVVR/8bWZ8jksflz wSyw== X-Gm-Message-State: AODbwcD1SRM/Cix7aKdi2CHHUN/he2K84hM4zQQR/D28mg7wYIe3FZsg WfGHyPRM5kHy1Q== X-Received: by 10.55.24.9 with SMTP id j9mr5680426qkh.25.1494632418257; Fri, 12 May 2017 16:40:18 -0700 (PDT) Received: from bigtime.twiddle.net.com ([2602:47:d954:1500:5e51:4fff:fe40:9c64]) by smtp.gmail.com with ESMTPSA id z65sm3367460qkz.29.2017.05.12.16.40.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 May 2017 16:40:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 12 May 2017 16:40:03 -0700 Message-Id: <20170512234009.32557-4-rth@twiddle.net> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170512234009.32557-1-rth@twiddle.net> References: <20170512234009.32557-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::243 Subject: [Qemu-devel] [PULL 3/9] 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: , Cc: stefanha@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 = s390_cpu_write_elf64_note; cc->cpu_exec_interrupt = s390_cpu_exec_interrupt; cc->debug_excp_handler = s390x_cpu_debug_excp_handler; + cc->do_unaligned_access = s390x_cpu_do_unaligned_access; #endif cc->disas_set_info = s390_cpu_disas_set_info; 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 address, int rw, #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); 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 = S390_CPU(cs); + CPUS390XState *env = &cpu->env; + + if (retaddr) { + cpu_restore_state(cs, retaddr); + } + program_interrupt(env, PGM_SPECIFICATION, ILEN_LATER); +} #endif /* CONFIG_USER_ONLY */