From patchwork Fri May 29 13:10:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 49201 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 74113218E7 for ; Fri, 29 May 2015 13:25:13 +0000 (UTC) Received: by wgme6 with SMTP id e6sf18292568wgm.3 for ; Fri, 29 May 2015 06:25:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=I9tUEOzlcWBsmKI9mw9/AMmnNbdjIPF7k/FmNpHLawQ=; b=EdDj10IPtRe+KKzH9FKveptXHm1IKsFEnVyzjsLkEkZxRhxvzLcnNIohoUaxXym0vM qbIKRg3STxekoWCpoPzabwhWNHmnAqwPK9ao+pYCzHcrpEU53B4nQA/Y5fq2AXhvBZca fv8hnV3N9EJfxdkFw0UDf5A36pa8Q3GAZ7WOp8z93fDCVN0hORTlIJluw0sNedMSV+x8 FJp2HQ8BuW/Fat8zHJikCNtuv+neabSPEu27UPfdAJ+yUP2nOUQdknqPKUTW9D/zSAvj i8VSYV+erYXRvE50wFUvOEYpIhFsXIZejkhrvSy+Bi2S5BhjvPhMlnjTAwjbOSOgsOBD 27Xg== X-Gm-Message-State: ALoCoQmz5v4lU8jllmgP6n8uBRVOrja+MWybCifr81KaxieChVbdMXTra8zEE3TNUcSWlyE32gy5 X-Received: by 10.112.166.137 with SMTP id zg9mr7381296lbb.11.1432905912666; Fri, 29 May 2015 06:25:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.162 with SMTP id n2ls359697laf.82.gmail; Fri, 29 May 2015 06:25:12 -0700 (PDT) X-Received: by 10.152.9.201 with SMTP id c9mr8048079lab.104.1432905912517; Fri, 29 May 2015 06:25:12 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id aa12si4703976lbd.30.2015.05.29.06.25.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 May 2015 06:25:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by labpy14 with SMTP id py14so43956362lab.0 for ; Fri, 29 May 2015 06:25:12 -0700 (PDT) X-Received: by 10.152.21.136 with SMTP id v8mr7955016lae.19.1432905912282; Fri, 29 May 2015 06:25:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp331703lbb; Fri, 29 May 2015 06:25:11 -0700 (PDT) X-Received: by 10.140.92.132 with SMTP id b4mr9366746qge.93.1432905910667; Fri, 29 May 2015 06:25:10 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 23si5582936qhy.21.2015.05.29.06.25.09 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 29 May 2015 06:25:10 -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; Received: from localhost ([::1]:35880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyKHd-0004wC-Gz for patch@linaro.org; Fri, 29 May 2015 09:25:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyK43-00043M-3x for qemu-devel@nongnu.org; Fri, 29 May 2015 09:11:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YyK40-0003dE-6k for qemu-devel@nongnu.org; Fri, 29 May 2015 09:11:07 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:34304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YyK3z-0003US-NR for qemu-devel@nongnu.org; Fri, 29 May 2015 09:11:04 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1YyK3h-0005ln-9Q for qemu-devel@nongnu.org; Fri, 29 May 2015 14:10:45 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 29 May 2015 14:10:10 +0100 Message-Id: <1432905045-22138-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1432905045-22138-1-git-send-email-peter.maydell@linaro.org> References: <1432905045-22138-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 04/39] target-arm: Move setting of exception info into tlb_fill X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Move the code which sets exception information out of arm_cpu_handle_mmu_fault and into tlb_fill. tlb_fill is the only caller which wants to raise_exception() so it makes more sense for it to handle the whole of the exception setup. As part of this cleanup, move the user-mode-only implementation function for the handle_mmu_fault CPU method into cpu.c so we don't need to make it globally visible, and rename the softmmu-only utility function arm_cpu_handle_mmu_fault to arm_tlb_fill so it's clear that it's not the same thing. Signed-off-by: Peter Maydell Reviewed-by: Edgar E. Iglesias --- target-arm/cpu.c | 17 +++++++++++++++++ target-arm/cpu.h | 2 -- target-arm/helper.c | 47 +++++++---------------------------------------- target-arm/internals.h | 3 +++ target-arm/op_helper.c | 27 +++++++++++++++++++++++++-- 5 files changed, 52 insertions(+), 44 deletions(-) diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 3ca3fa8..798c689 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -1197,6 +1197,23 @@ static Property arm_cpu_properties[] = { DEFINE_PROP_END_OF_LIST() }; +#ifdef CONFIG_USER_ONLY +static int arm_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw, + int mmu_idx) +{ + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + + env->exception.vaddress = address; + if (rw == 2) { + cs->exception_index = EXCP_PREFETCH_ABORT; + } else { + cs->exception_index = EXCP_DATA_ABORT; + } + return 1; +} +#endif + static void arm_cpu_class_init(ObjectClass *oc, void *data) { ARMCPUClass *acc = ARM_CPU_CLASS(oc); diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 75d6c4c..6845666 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -504,8 +504,6 @@ static inline bool is_a64(CPUARMState *env) is returned if the signal was handled by the virtual CPU. */ int cpu_arm_signal_handler(int host_signum, void *pinfo, void *puc); -int arm_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw, - int mmu_idx); /** * pmccntr_sync diff --git a/target-arm/helper.c b/target-arm/helper.c index 5d0f011..a9e85b9 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -4047,21 +4047,6 @@ uint32_t HELPER(rbit)(uint32_t x) #if defined(CONFIG_USER_ONLY) -int arm_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw, - int mmu_idx) -{ - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - - env->exception.vaddress = address; - if (rw == 2) { - cs->exception_index = EXCP_PREFETCH_ABORT; - } else { - cs->exception_index = EXCP_DATA_ABORT; - } - return 1; -} - /* These should probably raise undefined insn exceptions. */ void HELPER(v7m_msr)(CPUARMState *env, uint32_t reg, uint32_t val) { @@ -5826,8 +5811,12 @@ static inline int get_phys_addr(CPUARMState *env, target_ulong address, } } -int arm_cpu_handle_mmu_fault(CPUState *cs, vaddr address, - int access_type, int mmu_idx) +/* Walk the page table and (if the mapping exists) add the page + * to the TLB. Return 0 on success, or an ARM DFSR/IFSR fault + * register format value on failure. + */ +int arm_tlb_fill(CPUState *cs, vaddr address, + int access_type, int mmu_idx) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; @@ -5835,8 +5824,6 @@ int arm_cpu_handle_mmu_fault(CPUState *cs, vaddr address, target_ulong page_size; int prot; int ret; - uint32_t syn; - bool same_el = (arm_current_el(env) != 0); MemTxAttrs attrs = {}; ret = get_phys_addr(env, address, access_type, mmu_idx, &phys_addr, @@ -5850,27 +5837,7 @@ int arm_cpu_handle_mmu_fault(CPUState *cs, vaddr address, return 0; } - /* AArch64 syndrome does not have an LPAE bit */ - syn = ret & ~(1 << 9); - - /* For insn and data aborts we assume there is no instruction syndrome - * information; this is always true for exceptions reported to EL1. - */ - if (access_type == 2) { - syn = syn_insn_abort(same_el, 0, 0, syn); - cs->exception_index = EXCP_PREFETCH_ABORT; - } else { - syn = syn_data_abort(same_el, 0, 0, 0, access_type == 1, syn); - if (access_type == 1 && arm_feature(env, ARM_FEATURE_V6)) { - ret |= (1 << 11); - } - cs->exception_index = EXCP_DATA_ABORT; - } - - env->exception.syndrome = syn; - env->exception.vaddress = address; - env->exception.fsr = ret; - return 1; + return ret; } hwaddr arm_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) diff --git a/target-arm/internals.h b/target-arm/internals.h index de0a9c1..1e5071e 100644 --- a/target-arm/internals.h +++ b/target-arm/internals.h @@ -387,4 +387,7 @@ bool arm_is_psci_call(ARMCPU *cpu, int excp_type); void arm_handle_psci_call(ARMCPU *cpu); #endif +/* Do a page table walk and add page to TLB if possible */ +int arm_tlb_fill(CPUState *cpu, vaddr address, int rw, int mmu_idx); + #endif diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index 906b39f..c9f5821 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -80,16 +80,39 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx, { int ret; - ret = arm_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx); + ret = arm_tlb_fill(cs, addr, is_write, mmu_idx); if (unlikely(ret)) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; + uint32_t syn, exc; + bool same_el = (arm_current_el(env) != 0); if (retaddr) { /* now we have a real cpu fault */ cpu_restore_state(cs, retaddr); } - raise_exception(env, cs->exception_index); + + /* AArch64 syndrome does not have an LPAE bit */ + syn = ret & ~(1 << 9); + + /* For insn and data aborts we assume there is no instruction syndrome + * information; this is always true for exceptions reported to EL1. + */ + if (is_write == 2) { + syn = syn_insn_abort(same_el, 0, 0, syn); + exc = EXCP_PREFETCH_ABORT; + } else { + syn = syn_data_abort(same_el, 0, 0, 0, is_write == 1, syn); + if (is_write == 1 && arm_feature(env, ARM_FEATURE_V6)) { + ret |= (1 << 11); + } + exc = EXCP_DATA_ABORT; + } + + env->exception.syndrome = syn; + env->exception.vaddress = addr; + env->exception.fsr = ret; + raise_exception(env, exc); } } #endif