From patchwork Wed Apr 3 03:43:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 161658 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2516156jan; Tue, 2 Apr 2019 20:53:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkrTsdyHNYfo0XefD8m3OLk4PJE6V4OjJso8gOs4jJuQky2F9vYYmPXho0fpy25tTbL3Xt X-Received: by 2002:a25:2455:: with SMTP id k82mr23363699ybk.136.1554263593643; Tue, 02 Apr 2019 20:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554263593; cv=none; d=google.com; s=arc-20160816; b=0ULm8qIYUuW+AO/lCtgoRGWkl/ehA2ku7NVMc3r/RYV57yYHxxDTE58EGvdXP5M5cr OY1wasQ0JNKIFVGCrnjRNbIM+3lW0DDobbbc40BMtUl2fhc5ocHNm79NF3E9mqW/wYeH /tWr/WUwLk3bopPjjp6qyr0AijGmGvT0j3iJrhuaeskXqyBTgmDpLNQS4BDBLCl2SiJQ XKj/JA29v/T2pSRmrxScihD3HoMcqCMDygItbfWOlZgeQ0UZP2AgvLfptzqGFA13Qa/P 5i76shC15MP4ftywUA6TQrhl4FnTl6xAgSl+9B3RI/z5+TjCWw5JLQS6XN4eC1hlzs+W +23w== 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=8354UYz0iHV/MgtSpeIFFn3yOLwg087OrnDM/sW0KHw=; b=QDzekmOiuRHCM/2xJ70AOQaFANYH9uiulVGofDjhB4wyUmDVl8YuK8epypCXPAo3i5 +I3RL9R1BK3ZY/ZPSL0Dnonefy1BS7EoJeeCliBO7t76uFotsNUHc4Ocm1GqSHIgZGKw KegQIBEiTC2CQW3cu1Y7hlgAjjIgBpOhCqWt0T/FHbWTOjL1KpUru9+mJCPB1FwxrhJh 0t8Gj/IZvdjmQ3vPadULNE4/pk5i9e2TjjoUfnM/u3pAfxJNsZ5ucl/2/2YnyBPlRXjy /DIdhtRf7uzpm2Q1axv7zRup8CELjAypVSiXDs3Un1cGrCk3cRyvKC7+6R+aFg12h2Ly uZhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ulmO5mac; 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 v124si6885132ybb.156.2019.04.02.20.53.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 02 Apr 2019 20:53:13 -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=ulmO5mac; 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]:53407 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBWxd-00024P-3f for patch@linaro.org; Tue, 02 Apr 2019 23:53:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBWpA-0002t9-Sf for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hBWp9-0008OA-FR for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:28 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:44533) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hBWp9-0008NQ-5m for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:27 -0400 Received: by mail-pf1-x444.google.com with SMTP id y13so7421325pfm.11 for ; Tue, 02 Apr 2019 20:44:27 -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=8354UYz0iHV/MgtSpeIFFn3yOLwg087OrnDM/sW0KHw=; b=ulmO5macMl5fpxloReDiaAokII2eaH5qQ/dVKZpoP/AIz7fjQYJ4NUfgSGVU26+D9V JEQNcsvm3I7HnDVRSpjwzfgdocCNTBmKPVClDpLH7XRtaW5GsBbNFv+ZWr0QhC6t0qS+ y8RUrZXR+bTchpOqvDPT7jmSAJHZ3X7vxKPfJxN/g/1Ybt0KsaNGGawJ68R6NDcjxcPj SJ67DplIKHZh5b4JG0E/hMSpnBhSIyMkFc/4SD+/uEy4SJttcMd/pqJSvnTYgqhPl+Qt 3KDSKehYHhNgM3OqJ0PRT6JgTu5AjTGPQB63mVUtvhWlR27b0ELlUTMjIyYhfFUGZY7E +Nfw== 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=8354UYz0iHV/MgtSpeIFFn3yOLwg087OrnDM/sW0KHw=; b=WEkD+UYBRf34iy1TMiNHbffigaR+9M+Zalsh4Tw++CnNlQ+wrZ+ByRRaTpAxSMUcNL gDjh5cw09U/hY2WOsLeu5Ki1gCiLP7LUNn3wqKIlgnFT0rsPApVaT1qusyd+wVyOA+ea jJPZV6cKCy7fuDoG3Lq2kLHbYM1DwtURKx1cAKd0+Zk++rPMUmFho2hVJ+80yDizSdHI lwwfrVlCB4IGf+3xcqDy4hOhub4IedqDbfhBH1oDFK1/u3iLlwCck9Fuj82qQh2wtvS4 ss6bA1djVza5GGvFmyQEBsfyMIeTsZhEJcAMvj8kACaxO5fN456WE+5RSt3yBn+auPeo k2YA== X-Gm-Message-State: APjAAAW1/L8byDGKUobAdkOCP1erQq6QeAM2m408ThRLpmsreuaUUIc3 XiNGH9eXCI49sXsN0W6NcheoTk8BoB2kYA== X-Received: by 2002:a63:4241:: with SMTP id p62mr53310008pga.379.1554263065947; Tue, 02 Apr 2019 20:44:25 -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.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 20:44:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Apr 2019 10:43:44 +0700 Message-Id: <20190403034358.21999-13-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::444 Subject: [Qemu-devel] [PATCH 12/26] target/moxie: 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: Anthony Green Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: Anthony Green Signed-off-by: Richard Henderson --- target/moxie/cpu.h | 5 ++-- target/moxie/cpu.c | 5 ++-- target/moxie/helper.c | 61 ++++++++++--------------------------------- 3 files changed, 19 insertions(+), 52 deletions(-) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/target/moxie/cpu.h b/target/moxie/cpu.h index 080df4ee6f..a82c2caf30 100644 --- a/target/moxie/cpu.h +++ b/target/moxie/cpu.h @@ -140,7 +140,8 @@ static inline void cpu_get_tb_cpu_state(CPUMoxieState *env, target_ulong *pc, *flags = 0; } -int moxie_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, - int rw, int mmu_idx); +bool moxie_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); #endif /* MOXIE_CPU_H */ diff --git a/target/moxie/cpu.c b/target/moxie/cpu.c index 46434e65ba..02b2b47574 100644 --- a/target/moxie/cpu.c +++ b/target/moxie/cpu.c @@ -112,9 +112,8 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = moxie_cpu_do_interrupt; cc->dump_state = moxie_cpu_dump_state; cc->set_pc = moxie_cpu_set_pc; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = moxie_cpu_handle_mmu_fault; -#else + cc->tlb_fill = moxie_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug; cc->vmsd = &vmstate_moxie_cpu; #endif diff --git a/target/moxie/helper.c b/target/moxie/helper.c index f3d8ee7d6b..216cef057e 100644 --- a/target/moxie/helper.c +++ b/target/moxie/helper.c @@ -26,18 +26,10 @@ #include "qemu/host-utils.h" #include "exec/helper-proto.h" -/* 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 = moxie_cpu_handle_mmu_fault(cs, addr, size, access_type, mmu_idx); - if (unlikely(ret)) { - cpu_loop_exit_restore(cs, retaddr); - } + moxie_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr); } void helper_raise_exception(CPUMoxieState *env, int ex) @@ -85,53 +77,29 @@ void helper_debug(CPUMoxieState *env) cpu_loop_exit(cs); } -#if defined(CONFIG_USER_ONLY) - -void moxie_cpu_do_interrupt(CPUState *cs) -{ - CPUState *cs = CPU(moxie_env_get_cpu(env)); - - cs->exception_index = -1; -} - -int moxie_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, - int rw, int mmu_idx) -{ - MoxieCPU *cpu = MOXIE_CPU(cs); - - cs->exception_index = 0xaa; - cpu->env.debug1 = address; - cpu_dump_state(cs, stderr, fprintf, 0); - return 1; -} - -#else /* !CONFIG_USER_ONLY */ - -int moxie_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, - int rw, int mmu_idx) +bool moxie_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { MoxieCPU *cpu = MOXIE_CPU(cs); CPUMoxieState *env = &cpu->env; MoxieMMUResult res; int prot, miss; - target_ulong phy; - int r = 1; address &= TARGET_PAGE_MASK; prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; - miss = moxie_mmu_translate(&res, env, address, rw, mmu_idx); - if (miss) { - /* handle the miss. */ - phy = 0; - cs->exception_index = MOXIE_EX_MMU_MISS; - } else { - phy = res.phy; - r = 0; + miss = moxie_mmu_translate(&res, env, address, access_type, mmu_idx); + if (likely(!miss)) { + tlb_set_page(cs, address, res.phy, prot, mmu_idx, TARGET_PAGE_SIZE); + return true; + } + if (probe) { + return false; } - tlb_set_page(cs, address, phy, prot, mmu_idx, TARGET_PAGE_SIZE); - return r; -} + cs->exception_index = MOXIE_EX_MMU_MISS; + cpu_loop_exit_restore(cs, retaddr); +} void moxie_cpu_do_interrupt(CPUState *cs) { @@ -156,4 +124,3 @@ hwaddr moxie_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) } return phy; } -#endif