From patchwork Fri May 10 15:19:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163890 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2541913ilr; Fri, 10 May 2019 08:45:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqx099fiz+ZFJBFWE8tHyRlP/kdaWFePZU7dbHgyhs6fiuK3DJvinBV8s77SHWr/3QnwWXWC X-Received: by 2002:a50:bdcc:: with SMTP id z12mr11396587edh.138.1557503115194; Fri, 10 May 2019 08:45:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557503115; cv=none; d=google.com; s=arc-20160816; b=d2H9gWXuMvTqYR25DpPKVcixTClnZ1D/wGOvwbnqRVgWj0KaOeSjT+Czql8hV2DoB2 WYr9JLoPaRMu4yIwc3XbUCW4c+Dq5TfBQeSlaRqKx7Zt3TrbLzY/UQ1VkkUa3+zQAH1z UAt+jZ7OQP+8+L/9I8uHhL7AHJsa23/gPHWfemLGs4ZE5uDarErgLSE2eYGPaRxw0SHh aiyRDlitk/74NID922xT8P8FaPoreCNCo+Ck0R3Rh/F5KqqHOQ/vjWMmFheTSto/tYJU Ox8PUS/WkZKbHDp7HO9qntXw3yGvu/8ZR1fDfAGLaEsbfaEggy5WLQ6hP4ZQfEKpmxR3 aDOQ== 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=m8b1TfwrtSp/bIRpBWvKs+DLGDtPKUANT8NhwLlWDyg=; b=AAy0sC8Jm7X9IcgLHKM6LI4hCUiNj2xmP9ofc9VeYWL7QyOnBnjJBa0Ai22gK5x+mC aryg7R9XtPcPsERXbJo94UlLLCJKAYBixQlyIrTxkqqq2kGzU4b5T2hiEEPrQenj04F7 HIc0kEqbpI/+HrqGQjsXZLVsdqWvVOqf1x2DOQOOWWPmkEx9gFXNyPx99rOaGKh1+btt dBlKKq95j/SzGpRZGzG6qCtMr+AM7B3z+X6tLo4dEsgqUpXs8pIWQyYK6LVfzS7VWYTo kOfIzqXqrRrkeTQCJR5iFteFugD3L0tqN7jBj0zvNDtX1Q384rf/5sHZT4zE6g8/s1H3 V1iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gF0ARZK4; 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 f49si4504905eda.354.2019.05.10.08.45.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 08:45:15 -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=gF0ARZK4; 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]:45365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP7hx-0006JC-Mu for patch@linaro.org; Fri, 10 May 2019 11:45:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP7Jo-0007pq-SG for qemu-devel@nongnu.org; Fri, 10 May 2019 11:20:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hP7Jn-0000GT-LK for qemu-devel@nongnu.org; Fri, 10 May 2019 11:20:16 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:33187) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hP7Jn-0000Fq-F3 for qemu-devel@nongnu.org; Fri, 10 May 2019 11:20:15 -0400 Received: by mail-pg1-x535.google.com with SMTP id h17so3194448pgv.0 for ; Fri, 10 May 2019 08:20:15 -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=m8b1TfwrtSp/bIRpBWvKs+DLGDtPKUANT8NhwLlWDyg=; b=gF0ARZK4cj+gkEGp7aUCbIQDNiAp18oKWD7gfsU78opsuT47nUJZtOmJYr7nPxfJX9 Ul0yMY5hebWanfg0/i0OF0L6vgDPi9ZnqHyH8NfovNd7SWUOVRt8tDxGTiQIi5EvCKKR K+ZFJOf9idlQlpApCVHa8HjlWXUtqsiLH9Xc7e88JLUSeSrbDT+4TamjhbUrTHsxqxSm 2lNvLl2+ePXsSfwYUfIzR0XSva94DsBhKTt/MP8jf+Z1uQBB98T4bD1xsp9m/iuU6Cq0 p1jNz44mcNCZqV6Ug12oVVaPKtj2zH+t25LQRGwsEqksyajqb4115OLHH66HiGT/hMAg Q4cg== 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=m8b1TfwrtSp/bIRpBWvKs+DLGDtPKUANT8NhwLlWDyg=; b=JLZOsbikiDdk0w/ZLgo+wGH6Qoy1H8x9bo0wqOVkvv+ygUHzZDd5c+zi+ydWwy45WQ OuMYKkx0Hv7l1ZSJUqcfgCMJ8y4BeQqd8sOHjyHdVOARIxftm/oHXQnQ1q4Xo/kCvZkQ RgKzSSRn7njouscLt0mw0S9x+pSKX4kyRxf4u5XzcTo1LKlQPrAb8Gc9+bRFoUnAprjR sN7YoFWbxcQI4Lf1nOpVj/faTKcNaCgeZcaM+jC3oEfp/C5d66NEhYlljocttROB5lNb 9I4pBFjDpUyYAStovSmkHBjshP7vKe5BON1m4Saq7C4PREXl0C0+FL4bcHR++svLQnm/ oL3g== X-Gm-Message-State: APjAAAWB6Mthdq5G5JUuGYv5BmAv0HM3ki+ruJC1JSC1e3OcKNhtynBH x0UlHp2rqNwBEijhqmpE9n7W8WIFAfY= X-Received: by 2002:aa7:9116:: with SMTP id 22mr14842707pfh.165.1557501614042; Fri, 10 May 2019 08:20:14 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id 19sm5920517pgz.24.2019.05.10.08.20.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 08:20:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 08:19:39 -0700 Message-Id: <20190510151944.22981-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510151944.22981-1-richard.henderson@linaro.org> References: <20190510151944.22981-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::535 Subject: [Qemu-devel] [PULL 22/27] 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Acked-by: Bastian Koppelmann Reviewed-by: Peter Maydell 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 diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h index 64d1a9c75e..287f4328a3 100644 --- a/target/tricore/cpu.h +++ b/target/tricore/cpu.h @@ -417,8 +417,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 78ee87c9ea..ed184fee3a 100644 --- a/target/tricore/helper.c +++ b/target/tricore/helper.c @@ -50,8 +50,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; @@ -64,20 +65,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); - } -}