From patchwork Wed Apr 3 03:43:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 161659 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2516184jan; Tue, 2 Apr 2019 20:53:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqybGJvdwlmt3hgGTy6Zb6P1hvkHeXfFtR0v6Q7ARzgGdIQDRlEF1NngM0gIJvObYTEoJR46 X-Received: by 2002:a25:10c3:: with SMTP id 186mr60554657ybq.375.1554263595814; Tue, 02 Apr 2019 20:53:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554263595; cv=none; d=google.com; s=arc-20160816; b=IweZf5YZIKuSDZoHi73ZpZJSl8gzNJj35EdAnnqeZlJjhED0eP9lxH1jYKGkrMkT/G LiaNqlWrnoy1IsGFtmGx621lhNOij0c4nH07oIFa7Nhq2MmaJysNHrx9dkJHo57WrURl ihabBhjcQMR8bJ8OJzYO4N0ythBBBCLQmha6MM5nkNpu83JW5jE3PWcKO6/6/QU4AOmI QvWXKDimW4Qmn4Zx3JVwAcDryj5ZYP/c6tqYJUjxNcF6KmGxvHT7xuqFOXynAMYNURo8 Ha8UFQ8LctKHXdAzKPrxKiVzsHDHc1A9xwkG+0+6T2nWQXMgOVbjFVnAV/ccOrtjeT6x Xrgw== 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=INYoMOC2BML1R/tNbeYBbum+91nSf0ZPyhXaQqqzn14=; b=cf5Xw83itPDlm4B6S9oDFgbJxAXVMdSmzSoBfFZQWmanFfVampqfayon623LxUlZnp LIKiyca5EzGaCUA0OH1yMM86OxzzHfi0vwsZkn2hkZemaJrgsi9JzhyR/5XgqM48KVVR 37/WjBr0qq/1gNG3qMP0sBAkai6iqvCVBFLMybo7RJfwEZsHhjZ/3HTHzjXQIMEruxqg 1bUuo2Zh6kG9IVZ5ucQpUsni/ONCfnVPlaIkkim/1VUotittfxjrqjQs50nzzWfd7wLE /mgw3r2AuvM+RcPlsFpQqsIP1TGGAJx80xaVkyACL2ye8Te+Gv8PTVx5fyykMGME9IVx Q/kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i0hOnnr0; 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 81si8856905yby.420.2019.04.02.20.53.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 02 Apr 2019 20:53: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=i0hOnnr0; 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]:53418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBWxf-00026O-7F for patch@linaro.org; Tue, 02 Apr 2019 23:53:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBWpH-0002zQ-EB for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hBWpG-0008Tp-39 for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:35 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:33992) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hBWpF-0008TG-SU for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:34 -0400 Received: by mail-pl1-x644.google.com with SMTP id y6so7330692plt.1 for ; Tue, 02 Apr 2019 20:44:33 -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=INYoMOC2BML1R/tNbeYBbum+91nSf0ZPyhXaQqqzn14=; b=i0hOnnr0XD1kPsdUHaDbtodSvsCiGNwpsAkSw4OqQbkQhDQtCHkT0fk7jbIZ12SrEC KbF9kHZnAL6S1db8w9VW5spGvSeuY1FxY3Z9s33VQZZGTd2oHRrwaO2J2giBwvYWqG1Z KVO6bHUtIky4he8KPNJnv5kBPvmfRyGJdnOygDaGBBY2EKFyt1hbIOoGtZGIo0drjqYM pQ08B4COyaEJah2ksvwLD9iBCOnlkTfafh4JwTIN2DkdViJZoAUGlNrlPkWLuZNqGbmE MvlOBGF02OOI4gDaAqoOCWItvy2OJqbjTquDRlHVJLXkI2P3Lh8+mUeRbKwbw6/qj01L n+UQ== 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=INYoMOC2BML1R/tNbeYBbum+91nSf0ZPyhXaQqqzn14=; b=I+9u/LU5DBH/cWNA1lKtK9mC4nNWyZ4uvxCQmqRjpmdCtfhFQXzzmSABs2Pzu7GgBI crgG2/rtYT+gi79u9dPmhm60btwaQ7+rUsbGWnbaQu6aU/1gFvGU+IkG5jwLdsU0EQJZ QWRdvg+LZyQ+L6QEznDg3cL2s6M+f+wePES5KAQUrPUste/8cy/74Pwjie7VrIZcl2fQ /qypTlbfEBuvMGCRGMHTbJMh+7s2LikT1F46u3Lsd/278/H5OMcbLMU9H/bx0kPHXfht 381fopGmIlxAiFVVqMltBTUMd81df/02LLee8Qb7IbTDL/9FfrN6/RonodFtjmOksxk1 Ug/w== X-Gm-Message-State: APjAAAV0EK9LxwlKGGsYnOjsKSJL1Y1WpQv0t8WBm7718lAuYK6A9/K2 7Gng+xfDlmEhp4zCu8Ckme7u3iZU1yO+Lw== X-Received: by 2002:a17:902:be04:: with SMTP id r4mr60799618pls.218.1554263072609; Tue, 02 Apr 2019 20:44:32 -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.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 20:44:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Apr 2019 10:43:47 +0700 Message-Id: <20190403034358.21999-16-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::644 Subject: [Qemu-devel] [PATCH 15/26] target/ppc: 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: qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: qemu-ppc@nongnu.org Cc: David Gibson Signed-off-by: Richard Henderson --- target/ppc/cpu.h | 7 +++---- target/ppc/mmu_helper.c | 19 +++++++++++++------ target/ppc/translate_init.inc.c | 5 ++--- target/ppc/user_only_helper.c | 14 ++++++++------ 4 files changed, 26 insertions(+), 19 deletions(-) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 0707177584..da73d3ee5b 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1297,10 +1297,9 @@ void ppc_translate_init(void); is returned if the signal was handled by the virtual CPU. */ int cpu_ppc_signal_handler (int host_signum, void *pinfo, void *puc); -#if defined(CONFIG_USER_ONLY) -int ppc_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw, - int mmu_idx); -#endif +bool ppc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); #if !defined(CONFIG_USER_ONLY) void ppc_store_sdr1 (CPUPPCState *env, target_ulong value); diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c index 4a6be4d63b..6865c0ca37 100644 --- a/target/ppc/mmu_helper.c +++ b/target/ppc/mmu_helper.c @@ -3026,12 +3026,9 @@ void helper_check_tlb_flush_global(CPUPPCState *env) /*****************************************************************************/ -/* 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) */ -/* XXX: fix it to restore all registers */ -void tlb_fill(CPUState *cs, target_ulong addr, int size, - MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) +bool ppc_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { PowerPCCPU *cpu = POWERPC_CPU(cs); PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); @@ -3044,7 +3041,17 @@ void tlb_fill(CPUState *cs, target_ulong addr, int size, ret = cpu_ppc_handle_mmu_fault(env, addr, access_type, mmu_idx); } if (unlikely(ret != 0)) { + if (probe) { + return false; + } raise_exception_err_ra(env, cs->exception_index, env->error_code, retaddr); } + return true; +} + +void tlb_fill(CPUState *cs, target_ulong addr, int size, + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) +{ + ppc_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr); } diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c index 0bd555eb19..39f37bba5b 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -10545,9 +10545,8 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = ppc_cpu_gdb_read_register; cc->gdb_write_register = ppc_cpu_gdb_write_register; cc->do_unaligned_access = ppc_cpu_do_unaligned_access; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = ppc_cpu_handle_mmu_fault; -#else + cc->tlb_fill = ppc_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; cc->vmsd = &vmstate_ppc_cpu; #endif diff --git a/target/ppc/user_only_helper.c b/target/ppc/user_only_helper.c index 2f1477f102..683c03390d 100644 --- a/target/ppc/user_only_helper.c +++ b/target/ppc/user_only_helper.c @@ -20,21 +20,24 @@ #include "qemu/osdep.h" #include "cpu.h" +#include "exec/exec-all.h" -int ppc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, - int mmu_idx) + +bool ppc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; int exception, error_code; - if (rw == 2) { + if (access_type == MMU_INST_FETCH) { exception = POWERPC_EXCP_ISI; error_code = 0x40000000; } else { exception = POWERPC_EXCP_DSI; error_code = 0x40000000; - if (rw) { + if (access_type == MMU_DATA_STORE) { error_code |= 0x02000000; } env->spr[SPR_DAR] = address; @@ -42,6 +45,5 @@ int ppc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, } cs->exception_index = exception; env->error_code = error_code; - - return 1; + cpu_loop_exit_restore(cs, retaddr); }