From patchwork Tue Jul 3 05:57:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 140898 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp767740ljj; Mon, 2 Jul 2018 23:08:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd9t9OkLI/M/OiY8OxcpnSt/0izr1Yz+/3gi2EPEmdLZgfGLLHQIBFNJ8TZ3UcvMYo1+DU/ X-Received: by 2002:a37:4f85:: with SMTP id d127-v6mr24603011qkb.183.1530598089928; Mon, 02 Jul 2018 23:08:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530598089; cv=none; d=google.com; s=arc-20160816; b=gZeA9jZeFQqgml6sSIBYY9WZsE+cCrWKr2XRBODhOEbR3O/6ONmzSxYl6fxzVdn7Q6 KzyJ2vmzHMf15uJObHk6waec7oEFyn+8q1BtAkTc6urlaBsMX64sGM39ck8ZGBy8eHFn QAoafzlhBu6SKzvCTrgKX8096ZQ5Stg14iekT4wsT3lyXKpQGzYZUBtaCvYHcOp8gPqM FVMUCebAN1PO0UKce7qT6KdvnzrWD9Riitu/dtI4WBBQi+67ohkDFoh6Yy+DNN9Bkolj IYmUVeIUX85T3cdSwpE0SUlE6qisCJCQgyY5wBVB15JAs8QLhmjxXCqEAyGecn+fVqRl hd9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=ExyJOnM0+3YIZKqgL5CAjzll9RYluH9gN1Lq+YPckeU=; b=m6FXnueKbUV6h9a+8iIv2/Hm2KKO/gajC7cbqZ0MSJuTtS3SiBk3/Eo272SvqBD949 R1JzzHHLy+yRbin80ZkivxTAG5CqRzBU1zNZKRXvDACzIGyw83wFPwnfyAyFZVBS72nW +gLFAkItUfxJLoJyBlSgqJn6bONsUjjWvzwJPprnA/hRHRMCslGunMQH0WggLWMeBWFS eiTfB+ICmqY72eyZwXR1aj3q7wcVPzbHuxZLDZKuYjhaQpof8tq1HN/+/VvObpaC5SvF PcyG+8baoBtA9wCd26AibtJgtQjBgEAKyrtR+vwBeBEcjJxx8wiDVxrC9dJgqXPgJVCg kDYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gibson.dropbear.id.au header.s=201602 header.b=f8Iran+G; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e1-v6si320876qvo.268.2018.07.02.23.08.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Jul 2018 23:08:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gibson.dropbear.id.au header.s=201602 header.b=f8Iran+G; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:37982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faETx-0001xX-AP for patch@linaro.org; Tue, 03 Jul 2018 02:08:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKQ-0002mO-Fr for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKP-0006uJ-E2 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:18 -0400 Received: from ozlabs.org ([203.11.71.1]:33461) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKP-0006qT-1i; Tue, 03 Jul 2018 01:58:17 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM76lx8z9s8k; Tue, 3 Jul 2018 15:58:10 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597491; bh=uKJtkisTiKinECKXdYDXNin0kYLXxvzpO5mjwqT/BP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f8Iran+GJlRMkaXAmXEUvlBLe9S5dIbC6JD7wUoWqHy1zlw6G5Jy2ghFatq8yxSB9 PwrzKHNvS6RROIf59/Q5w6LR6RbHbAxbS+qxEFBLVpsxCLsam4RrEHjZ2xIow081VG Q6X6Z+7RQXh9jAnq9pxhlaMlANZmKPVscrCyTh1U= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:40 +1000 Message-Id: <20180703055804.13449-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 11/35] target/ppc: Add do_unaligned_access hook 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: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson This allows faults from MO_ALIGN to have the same effect as from gen_check_align. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/excp_helper.c | 18 +++++++++++++++++- target/ppc/internal.h | 5 +++++ target/ppc/translate_init.inc.c | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index c092fbead0..d6e97a90e0 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -22,7 +22,7 @@ #include "exec/helper-proto.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" - +#include "internal.h" #include "helper_regs.h" //#define DEBUG_OP @@ -1198,3 +1198,19 @@ void helper_book3s_msgsnd(target_ulong rb) qemu_mutex_unlock_iothread(); } #endif + +void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, + MMUAccessType access_type, + int mmu_idx, uintptr_t retaddr) +{ + CPUPPCState *env = cs->env_ptr; + uint32_t insn; + + /* Restore state and reload the insn we executed, for filling in DSISR. */ + cpu_restore_state(cs, retaddr, true); + insn = cpu_ldl_code(env, env->nip); + + cs->exception_index = POWERPC_EXCP_ALIGN; + env->error_code = insn & 0x03FF0000; + cpu_loop_exit(cs); +} diff --git a/target/ppc/internal.h b/target/ppc/internal.h index 1f441c6483..a9bcadff42 100644 --- a/target/ppc/internal.h +++ b/target/ppc/internal.h @@ -252,4 +252,9 @@ static inline void putVSR(int n, ppc_vsr_t *vsr, CPUPPCState *env) void helper_compute_fprf_float16(CPUPPCState *env, float16 arg); void helper_compute_fprf_float32(CPUPPCState *env, float32 arg); void helper_compute_fprf_float128(CPUPPCState *env, float128 arg); + +/* Raise a data fault alignment exception for the specified virtual address */ +void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, + MMUAccessType access_type, + int mmu_idx, uintptr_t retaddr); #endif /* PPC_INTERNAL_H */ diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c index 76d6f3fd5e..7813b1b004 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -10457,6 +10457,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = ppc_cpu_set_pc; cc->gdb_read_register = ppc_cpu_gdb_read_register; cc->gdb_write_register = ppc_cpu_gdb_write_register; + cc->do_unaligned_access = ppc_cpu_do_unaligned_access; #ifdef CONFIG_USER_ONLY cc->handle_mmu_fault = ppc_cpu_handle_mmu_fault; #else