From patchwork Wed Apr 3 03:43:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 161667 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2519590jan; Tue, 2 Apr 2019 20:59:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/jgQTfUNEfqb39Omtj5mMMdcO4C/Q9xDwK68ldrbL5AHKPncAG92SDTBIQz2IoYebf7ij X-Received: by 2002:a25:758a:: with SMTP id q132mr18401558ybc.73.1554263958047; Tue, 02 Apr 2019 20:59:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554263958; cv=none; d=google.com; s=arc-20160816; b=o8dvSXMB3EDD7LMdV+gAw+4oDiBMHq+HnP371jqa6iOJ4tLMZ4jhZjBRt7OcH6AGq0 j4YFZsq+y17DzqiAxZQBl0XpIjSCRTxj189CWW4fYd8fYQl8AFJ3+LYu2Lsis8kHhg0Q 6azixxsZXSuOT2la/1pgGDujvs5EKuUNf/dvrGRKrEHADXEywTNO7o1VtfbnrMO+nuRn fy0/+pVDvyxt0wkLpF37aMlj7k7N3+Dwzw4iY447JS6JWZHkYyfK965E2sFV3ivgS3Dt uD17p0FZsOP6A5U1z2nZ3CgkeE6tmHBRUFWoM7xhG3wgAV07FCYa0DxH5AkisgFUz3rY 6DfQ== 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=1va7KWEJPOsYlljyzZctOZk62WDcs6x8O8MJIgG/rEE=; b=DWEhoLbBvrYRWWk1B1mcrdTu49zZ4agR77c/6qHQdHnO64ptyLBEoi9SuP4jXXuwWF 1zTmXSKKAhzp3O+vX9R+O0ozQdN6PI6k0huFQK7a8kAsxTMtbUCFK3LXDSKN1HZxDABq s2dfaXaUoXp0m131J+5dujpq1TqaChsYxf/CKykXfwvpR+xXwB3fZOuwH5wEDhRc1hSb Yn7b5n3QqWJU5EM1eb/LzDly28oXw+97HM2quO38rFxTcYFGUCVpyPYsSFX7M4b+HsM2 JZaQBw1bpEQz/DKuoVqoTCbffarepIFz4L2YWcI0VX39D3hNVuE02l4WvHBamXOI1jal Lw/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=x+JCjURI; 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 a145si9643237ywe.149.2019.04.02.20.59.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 02 Apr 2019 20:59:18 -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=x+JCjURI; 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]:55006 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBX3V-0007MR-JQ for patch@linaro.org; Tue, 02 Apr 2019 23:59:17 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48812) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBWpU-0003Bn-G8 for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hBWpT-0000K7-2X for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:48 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:40395) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hBWpS-0000Iw-Pe for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:47 -0400 Received: by mail-pg1-x531.google.com with SMTP id u9so7575717pgo.7 for ; Tue, 02 Apr 2019 20:44:46 -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=1va7KWEJPOsYlljyzZctOZk62WDcs6x8O8MJIgG/rEE=; b=x+JCjURI1s1jNM3xva8hyKWO4TpYCtG0dWNiBNOqCg5r6wvPJXRX/+tCgRGuw+Lci5 nZEKkuNmhBDWtfIPCACQ2/1Eo+KFsd+b//dMEV2FooeckcqOLVBjeZyOtzSWRlDd/Yks +S8lRn6fB2HP+KNYNEDqzABceyZ8XHRSZPmFNWb92wj4Ub175ZMzrmRyA79kOEzKtxOm 1/XthI46tyBqmVcOPvqkZCzXHZTkho0tusNkAqV3+qFF7DmPsPjlx671nrGBvPTpTD5Y cC71qIRvzKriMuJVhb4bQ/VOwfCcoru5qcpVERXl8fzUD7FoPMExv37utV2lLhWA/iNe eUfQ== 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=1va7KWEJPOsYlljyzZctOZk62WDcs6x8O8MJIgG/rEE=; b=f6rAaSQsr08ZFOdSqIiXapXyH6in/xA2MxTwYckOBKp95QIUcweRda/5ye06roM/fj StaKrJlqrE9SCjO0AgyO2cKrjp64y5+8vwqP5mOOyznG7eBR1jynyLflHqGIGmFslbpU Iq45Yv9lUkxkx4UN7Quc5WgKO7m9+oErElAQyP89lCJBlyY39MooXo8uIOrbiLk93qv8 +GwVEowFOt6beQgtNH3kpdJ95kmrSjWn5afGy6/Jd6C4I8oYzdhjIIW+nnrCGkPJakSv wa9lacS2j8B9SbG8Hbe9uYaIZJ4GxWLrQSNdMLPWTzTPLOybVUm9ybUvKUBWABftdOqU J0BA== X-Gm-Message-State: APjAAAU75TfA0PNEkxGGJgbUWuqpB1+aD1eiUf5Bw7wejdBuiP+cfOYj RG9J0qB37L9SOF1cKY2tsEMR2GPg16Yrbg== X-Received: by 2002:a62:52c3:: with SMTP id g186mr57696452pfb.173.1554263085304; Tue, 02 Apr 2019 20:44:45 -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.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 20:44:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Apr 2019 10:43:53 +0700 Message-Id: <20190403034358.21999-22-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::531 Subject: [Qemu-devel] [PATCH 21/26] target/tricore: 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: Bastian Koppelmann Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: Bastian Koppelmann Signed-off-by: Richard Henderson --- target/tricore/cpu.h | 6 +++--- target/tricore/cpu.c | 1 + target/tricore/helper.c | 27 +++++++++++++++++++-------- target/tricore/op_helper.c | 26 -------------------------- 4 files changed, 23 insertions(+), 37 deletions(-) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h index 00e69dc154..5c0b8cb94c 100644 --- a/target/tricore/cpu.h +++ b/target/tricore/cpu.h @@ -418,8 +418,8 @@ static inline void cpu_get_tb_cpu_state(CPUTriCoreState *env, target_ulong *pc, #define CPU_RESOLVING_TYPE TYPE_TRICORE_CPU /* helpers.c */ -int cpu_tricore_handle_mmu_fault(CPUState *cpu, target_ulong address, - int rw, int mmu_idx); -#define cpu_handle_mmu_fault cpu_tricore_handle_mmu_fault +bool tricore_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); #endif /* TRICORE_CPU_H */ diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index e8d37e4040..ea1199d27e 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -166,6 +166,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data) cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb; cc->get_phys_page_attrs_debug = tricore_cpu_get_phys_page_attrs_debug; cc->tcg_initialize = tricore_tcg_init; + cc->tlb_fill = tricore_cpu_tlb_fill; } #define DEFINE_TRICORE_CPU_TYPE(cpu_model, initfn) \ diff --git a/target/tricore/helper.c b/target/tricore/helper.c index 0769046993..3c99a8c22b 100644 --- a/target/tricore/helper.c +++ b/target/tricore/helper.c @@ -49,8 +49,9 @@ static void raise_mmu_exception(CPUTriCoreState *env, target_ulong address, { } -int cpu_tricore_handle_mmu_fault(CPUState *cs, target_ulong address, - int rw, int mmu_idx) +bool tricore_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType rw, int mmu_idx, + bool probe, uintptr_t retaddr) { TriCoreCPU *cpu = TRICORE_CPU(cs); CPUTriCoreState *env = &cpu->env; @@ -63,20 +64,30 @@ int cpu_tricore_handle_mmu_fault(CPUState *cs, target_ulong address, access_type = ACCESS_INT; ret = get_physical_address(env, &physical, &prot, address, rw, access_type); - qemu_log_mask(CPU_LOG_MMU, "%s address=" TARGET_FMT_lx " ret %d physical " TARGET_FMT_plx - " prot %d\n", __func__, address, ret, physical, prot); + + qemu_log_mask(CPU_LOG_MMU, "%s address=" TARGET_FMT_lx " ret %d physical " + TARGET_FMT_plx " prot %d\n", + __func__, (target_ulong)address, ret, physical, prot); if (ret == TLBRET_MATCH) { tlb_set_page(cs, address & TARGET_PAGE_MASK, physical & TARGET_PAGE_MASK, prot | PAGE_EXEC, mmu_idx, TARGET_PAGE_SIZE); - ret = 0; - } else if (ret < 0) { + return true; + } else { + assert(ret < 0); + if (probe) { + return false; + } raise_mmu_exception(env, address, rw, ret); - ret = 1; + cpu_loop_exit_restore(cs, retaddr); } +} - return ret; +void tlb_fill(CPUState *cs, target_ulong addr, int size, + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) +{ + tricore_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr); } static void tricore_cpu_list_entry(gpointer data, gpointer user_data) diff --git a/target/tricore/op_helper.c b/target/tricore/op_helper.c index ed9dc0c83e..601e92f92a 100644 --- a/target/tricore/op_helper.c +++ b/target/tricore/op_helper.c @@ -2793,29 +2793,3 @@ uint32_t helper_psw_read(CPUTriCoreState *env) { return psw_read(env); } - - -static inline void QEMU_NORETURN do_raise_exception_err(CPUTriCoreState *env, - uint32_t exception, - int error_code, - uintptr_t pc) -{ - CPUState *cs = CPU(tricore_env_get_cpu(env)); - cs->exception_index = exception; - env->error_code = error_code; - /* now we have a real cpu fault */ - cpu_loop_exit_restore(cs, pc); -} - -void tlb_fill(CPUState *cs, target_ulong addr, int size, - MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) -{ - int ret; - ret = cpu_tricore_handle_mmu_fault(cs, addr, access_type, mmu_idx); - if (ret) { - TriCoreCPU *cpu = TRICORE_CPU(cs); - CPUTriCoreState *env = &cpu->env; - do_raise_exception_err(env, cs->exception_index, - env->error_code, retaddr); - } -}