From patchwork Wed Apr 3 03:43:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 161664 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2518136jan; Tue, 2 Apr 2019 20:56:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfg0vsr0F2ddXuUC5GqDs2gInkPNc485nfQYb7yL/9A7s+maLd7bJ+i5JAg7R+497F7UQA X-Received: by 2002:a81:1b52:: with SMTP id b79mr61693949ywb.285.1554263801256; Tue, 02 Apr 2019 20:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554263801; cv=none; d=google.com; s=arc-20160816; b=Sy46TpHFIL2KclLJ/FHBQ6ky4T8vEfolfFJjsjWut6W80UfkeCreq9AzvE1nVcW0My 176XwphC2I5gjWreGDfAwByZ0L9LxsRzrQoYtJINxpwqGwJQ4rDeNOL9JZhr9E3ZLVb9 wtFx4OGruqo0ZVh0tdOZVM46pJWuSdgdBWVNpnOH2c91FtbVhiftB6HKXmgoasDmDtbA QBkbn4M1NVF2WaH5+oHhQb4WlEgdIEYY1eHzpoAG0zU7ZxiZujVUu1grx3Gm0FzK8eVU o31SIrf+cLP85w86WCjSJSDitryrWxoXCsxOSeSVEpReMrZLeUVyJfuL4cg29k4WZjYR 41oA== 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; bh=cqLJBmieT/JY9FOcf60NXGKLtJWacSntKsw5Msw8hSU=; b=nD/Q9Jchqp2f6ClwDd+tTc6HPxfqyHDsO+UNWq1gXA9Svhkp+cMQc7B46hjURIoPlr eAnJM5hRVpprC0JeYrNaqbnETBeWtd7iTGKtGp6tX4wnT1pLDOZ/YyQo8gY6NbBnM9NL 0QihhVihr8f7SZYv4prHKP1qf+oFWe2xVlE2QT0dQaVQot5kNp0evMdNcbuOi9ULGq7G a1kGAXF3jIQfwfBpDMMiWFELouiqpOYgdm7muALN8jGqAaZKCaAMIPbyF76kx/ifX9UD dDzuYGC56hKg9dAUwyd0r5oete5fg7POCBcqIj6o1st1K5zwZRAEUo2h1Fhh3PG9r4jU E07Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TgvOpAzs; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 63si9064319ywb.344.2019.04.02.20.56.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 02 Apr 2019 20:56:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TgvOpAzs; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:54314 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBX0y-0005F6-Pc for patch@linaro.org; Tue, 02 Apr 2019 23:56:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBWp4-0002oz-NJ for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hBWp3-0008Hq-8o for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:22 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:42486) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hBWp2-0008Gx-T1 for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:21 -0400 Received: by mail-pf1-x441.google.com with SMTP id r15so7415176pfn.9 for ; Tue, 02 Apr 2019 20:44:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cqLJBmieT/JY9FOcf60NXGKLtJWacSntKsw5Msw8hSU=; b=TgvOpAzsNZ4c53HmGWSwyFUuOlQoh+cmr5GXpoS7qzA7ZcTwwvLmlcjxb3Ckk6ZU0U 2Hcry2HICt3arfbZw1PsgrIvNoXR7LMZvIUlNnxFdZzXE9zCAU66aiPXLyxdxmPjch5G +SBnt4Ql4Z74KNYgd7w651OhDOeNNaSKrj6qxIFA6t2HDwq/yqtI+4WLNrKa2OLqoDY5 ucWwyhdLizY3QfIxQXD0iO4cnwW6cmT5hzqkGhz1la1+c3gsWnC36KJ4uUDv9jqBnn3L e9StrSBGInH/R3AmP4WeWIaLfpfvx0HieKjUbRlu4a9Lvh3BNEIzHve4idvFQQRxsokw Obxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cqLJBmieT/JY9FOcf60NXGKLtJWacSntKsw5Msw8hSU=; b=H3ReBAObSMFOzSwkHFznLkgO8sFpI7MWasqzHqLGzE5aOQ4yedWtmWPClMCgVd9pkb bY1mrm5m0alr/n8XIPvrr3fmEz59xIpXL/IIWvHMKOmzuLu2BuMW/mNabg+6CwvhLZe2 gQjRWE03ysuJ4kYmlL9Q7TOxroraYYn0YOVvNjrgYMXpb3KYDX8jxNncow1zYMZNrsR5 cpWAxNLBGgwky7ETmCkwsOgY3nQi2sDZmCG6cR7tWmSq7M4rIpoOaMXk51eW3+jNY/pp u53V+rcn8Kw1Qt9um5tycH3o9K8VS7ceUJaNqKncTOeEv5xEffKNA0z2Sw4xKrbAPhoA BX7w== X-Gm-Message-State: APjAAAVX+Y29csro/3LzlJ74ASGDcBOqosxq9GpSbZ5IuMOIfPwpuGsU KGjwCMFbLcezNcWdOUkI3LK+AuAyr/XtZg== X-Received: by 2002:a63:5466:: with SMTP id e38mr42992540pgm.340.1554263059661; Tue, 02 Apr 2019 20:44:19 -0700 (PDT) Received: from cloudburst.imgcgcw.net ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id z6sm26753214pgo.31.2019.04.02.20.44.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 20:44:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Apr 2019 10:43:41 +0700 Message-Id: <20190403034358.21999-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403034358.21999-1-richard.henderson@linaro.org> References: <20190403034358.21999-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH 09/26] target/m68k: Convert to CPUClass::tlb_fill 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: Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: Laurent Vivier Signed-off-by: Richard Henderson --- target/m68k/cpu.h | 5 ++- target/m68k/cpu.c | 2 +- target/m68k/helper.c | 87 ++++++++++++++++++++++------------------- target/m68k/op_helper.c | 15 ------- 4 files changed, 50 insertions(+), 59 deletions(-) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index f154565117..663c4c0307 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -543,8 +543,9 @@ static inline int cpu_mmu_index (CPUM68KState *env, bool ifetch) return (env->sr & SR_S) == 0 ? 1 : 0; } -int m68k_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw, - int mmu_idx); +bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); void m68k_cpu_unassigned_access(CPUState *cs, hwaddr addr, bool is_write, bool is_exec, int is_asi, unsigned size); diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 582e3a73b3..6f441bc973 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -269,7 +269,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data) cc->set_pc = m68k_cpu_set_pc; cc->gdb_read_register = m68k_cpu_gdb_read_register; cc->gdb_write_register = m68k_cpu_gdb_write_register; - cc->handle_mmu_fault = m68k_cpu_handle_mmu_fault; + cc->tlb_fill = m68k_cpu_tlb_fill; #if defined(CONFIG_SOFTMMU) cc->do_unassigned_access = m68k_cpu_unassigned_access; cc->get_phys_page_debug = m68k_cpu_get_phys_page_debug; diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 3e26d337bf..9768b4517f 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -359,20 +359,7 @@ void m68k_switch_sp(CPUM68KState *env) env->current_sp = new_sp; } -#if defined(CONFIG_USER_ONLY) - -int m68k_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, - int mmu_idx) -{ - M68kCPU *cpu = M68K_CPU(cs); - - cs->exception_index = EXCP_ACCESS; - cpu->env.mmu.ar = address; - return 1; -} - -#else - +#if !defined(CONFIG_USER_ONLY) /* MMU: 68040 only */ static void print_address_zone(FILE *f, fprintf_function cpu_fprintf, @@ -804,11 +791,36 @@ hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) return phys_addr; } -int m68k_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, - int mmu_idx) +/* + * Notify CPU of a pending interrupt. Prioritization and vectoring should + * be handled by the interrupt controller. Real hardware only requests + * the vector when the interrupt is acknowledged by the CPU. For + * simplicitly we calculate it when the interrupt is signalled. + */ +void m68k_set_irq_level(M68kCPU *cpu, int level, uint8_t vector) +{ + CPUState *cs = CPU(cpu); + CPUM68KState *env = &cpu->env; + + env->pending_level = level; + env->pending_vector = vector; + if (level) { + cpu_interrupt(cs, CPU_INTERRUPT_HARD); + } else { + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); + } +} + +#endif + +bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType qemu_access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { M68kCPU *cpu = M68K_CPU(cs); CPUM68KState *env = &cpu->env; + +#ifndef CONFIG_USER_ONLY hwaddr physical; int prot; int access_type; @@ -821,32 +833,35 @@ int m68k_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, address & TARGET_PAGE_MASK, PAGE_READ | PAGE_WRITE | PAGE_EXEC, mmu_idx, TARGET_PAGE_SIZE); - return 0; + return true; } - if (rw == 2) { + if (qemu_access_type == MMU_INST_FETCH) { access_type = ACCESS_CODE; - rw = 0; } else { access_type = ACCESS_DATA; - if (rw) { + if (qemu_access_type == MMU_DATA_STORE) { access_type |= ACCESS_STORE; } } - if (mmu_idx != MMU_USER_IDX) { access_type |= ACCESS_SUPER; } ret = get_physical_address(&cpu->env, &physical, &prot, address, access_type, &page_size); - if (ret == 0) { + if (likely(ret == 0)) { address &= TARGET_PAGE_MASK; physical += address & (page_size - 1); tlb_set_page(cs, address, physical, prot, mmu_idx, TARGET_PAGE_SIZE); - return 0; + return true; } + + if (probe) { + return false; + } + /* page fault */ env->mmu.ssw = M68K_ATC_040; switch (size) { @@ -871,29 +886,19 @@ int m68k_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, if (!(access_type & ACCESS_STORE)) { env->mmu.ssw |= M68K_RW_040; } - env->mmu.ar = address; +#endif + cs->exception_index = EXCP_ACCESS; - return 1; + env->mmu.ar = address; + cpu_loop_exit_restore(cs, retaddr); } -/* Notify CPU of a pending interrupt. Prioritization and vectoring should - be handled by the interrupt controller. Real hardware only requests - the vector when the interrupt is acknowledged by the CPU. For - simplicitly we calculate it when the interrupt is signalled. */ -void m68k_set_irq_level(M68kCPU *cpu, int level, uint8_t vector) +#ifndef CONFIG_USER_ONLY +void tlb_fill(CPUState *cs, target_ulong addr, int size, + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - CPUState *cs = CPU(cpu); - CPUM68KState *env = &cpu->env; - - env->pending_level = level; - env->pending_vector = vector; - if (level) { - cpu_interrupt(cs, CPU_INTERRUPT_HARD); - } else { - cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); - } + m68k_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr); } - #endif uint32_t HELPER(bitrev)(uint32_t x) diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index 76f439985a..d421614727 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -36,21 +36,6 @@ static inline void do_interrupt_m68k_hardirq(CPUM68KState *env) #else -/* Try to fill the TLB and return an exception if error. If retaddr is - NULL, it means that the function was called in C code (i.e. not - from generated code or from helper.c) */ -void tlb_fill(CPUState *cs, target_ulong addr, int size, - MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) -{ - int ret; - - ret = m68k_cpu_handle_mmu_fault(cs, addr, size, access_type, mmu_idx); - if (unlikely(ret)) { - /* now we have a real cpu fault */ - cpu_loop_exit_restore(cs, retaddr); - } -} - static void cf_rte(CPUM68KState *env) { uint32_t sp;