From patchwork Fri May 10 18:54:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163939 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2751733ilr; Fri, 10 May 2019 11:55:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCGvPTEimBrLJCmFhPqrdtQ8IPKZ1hIQVuhJnviqVqKZkRh176e7rEgD2VdkzAvGpRnw+g X-Received: by 2002:a50:b56a:: with SMTP id z39mr13060325edd.91.1557514540849; Fri, 10 May 2019 11:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557514540; cv=none; d=google.com; s=arc-20160816; b=sEdg4hBvJ5aBqrOpMUsoQgOi8owTlXbtNHTPfcvV4tmr9LBH/HSL8XpQzz75WAST1f thcfrjxcML6L6t4+qXSosiHbjFiMkz5TiGDNItog5pKXOODWWBsJddIzAk4NrC0+/eQr tz7tz9s4OWF81CLtC6NtxuoL47uyMIeKCUnt6yYSJscnQZRCmcO9qkbcwi55eiTS3Q8a XXglM/cI50PQbFYKRxwxR/9g6MubAj3g0dJyWn8kRLx6o8fUvoLYKCDW/7sF5aV6s+Jy 4n9AYS4NISbQgS4JDg+NSDwx6DJzdLobDVJn4cId/PuXiHTYka28MSJVVc2rave4rJSf W9kQ== 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=QUvZbCp4hiIu4WKEe9vqsUzs+jUu0CQw3Oh1C09dIOU=; b=MOZQJeVbMNcFAKp+PVrnRsKeuUDsMhP9YI6c+KWnHfhnKz+phNWTaVb+D0j6Kb2jGu 4P5sdmeIzOcGa2I0tIcd1KnYnxGa1k3V4B2szbVe8LSR1PXwJ3F6cwKXiA37Uv6LOBVG Z3dBv83/b3cIVXBYcVJqMosU2swUyo1WbY1IlVXsldgdtO3FBk54FNj3zf+7kcJl3YCg 3Ii228kbBP/en/0RUS36HULEfoZN4US+WtKhjeAj+LOw8ZIOQF59t2oxlktS9+ClFidx Yy3AdniivUDP2rX523eyiYNo4KWAzpNKZM6cFIaUSecdGndWPfcfu7fdrTDQ4GJ6z9oo YnUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IvVEQFyE; 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 a2si2641198ejp.164.2019.05.10.11.55.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 11:55:40 -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=IvVEQFyE; 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]:48525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAgF-0008Fj-PM for patch@linaro.org; Fri, 10 May 2019 14:55:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48521) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAfY-0007vr-Q0 for qemu-devel@nongnu.org; Fri, 10 May 2019 14:55:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPAfQ-0005ro-90 for qemu-devel@nongnu.org; Fri, 10 May 2019 14:54:56 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:45733) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hPAfQ-0005pU-1l for qemu-devel@nongnu.org; Fri, 10 May 2019 14:54:48 -0400 Received: by mail-pl1-x641.google.com with SMTP id a5so3221256pls.12 for ; Fri, 10 May 2019 11:54:47 -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=QUvZbCp4hiIu4WKEe9vqsUzs+jUu0CQw3Oh1C09dIOU=; b=IvVEQFyEWqmQGAZ/cD5Z3fc3cuZFHOKeqBZK37/h0XMWhaJFZMKCUgJ8ja3zn/yJLv RiBBv1X3ImmKK+mIzyts3IUYKKeyEKHmD7MTzE2BFYiEnkbCXAGhGzpwYwR7I7s+LuHD 2s53/z0ElIxP429Z8kQhh8NzdUdoXaKxUEe4TnNOsYkhgZf+2MbTTrdiQLZOIc5VVQpD OXHfVAWMPi/o4eKNV8RtfVTqAfMCh2xnNfuazXZhh86PsIJH/NFGv82Xn1n7ahZHfzzk 86dRerJhw+8xwk1SHwaFhWdYGUPZGI2fTkfZ/Vhz2mVbBYrIK/tcnisIhKefV0ZThrwf SJoQ== 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=QUvZbCp4hiIu4WKEe9vqsUzs+jUu0CQw3Oh1C09dIOU=; b=Aupk4z8FrrXqYSyhzl6pIirDF5vENIxBGxnQkxE/vF90WXP1Zb76N3/r6+7lMxrshQ Y/7hNVdXFtHkA9G4csi0cvS8nBudnZahAn3DUm6BM8shshyo7X/89+sLRv9qporWABmq zRtbTNGOfY3nKyXW7p6APkpfi2uDzbulvBe8uwKL3rpCz56AZOiwH85M4y15BNbdaOKE EmMG6kJVvTzY+c2+XQEemKrlzmx6s2Ho5rSfVPJKbu9Ag4XxGlVHSM6RQU7evhwLCIBA tdZn0+U60TpdkQTbAkWeeRVc79YSgF0m7NThRPowRqwKv0nT0ZwZ2hFq2S329k02HTex hzGA== X-Gm-Message-State: APjAAAVrxxgEM6HYgZ/cdS+Sk9lwg33coGQMetdU5XwquCJAPu0RbfuJ 8Orlm8CsUChNdr6Df1zohfgyr5QbSV8= X-Received: by 2002:a17:902:5995:: with SMTP id p21mr15415797pli.216.1557514486616; Fri, 10 May 2019 11:54:46 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id q20sm12733146pfi.166.2019.05.10.11.54.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 11:54:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 11:54:35 -0700 Message-Id: <20190510185438.29533-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510185438.29533-1-richard.henderson@linaro.org> References: <20190510185438.29533-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::641 Subject: [Qemu-devel] [PULL v2 16/27] 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: peter.maydell@linaro.org, qemu-ppc@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: qemu-ppc@nongnu.org Acked-by: David Gibson Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/ppc/cpu.h | 7 +++---- target/ppc/mmu_helper.c | 22 +++++++++++++--------- target/ppc/translate_init.inc.c | 5 ++--- target/ppc/user_only_helper.c | 14 ++++++++------ 4 files changed, 26 insertions(+), 22 deletions(-) -- 2.17.1 diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 5e7cf54b2f..d7f23ad5e0 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1311,10 +1311,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 1dbc9acb75..afcca50530 100644 --- a/target/ppc/mmu_helper.c +++ b/target/ppc/mmu_helper.c @@ -3057,15 +3057,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); @@ -3078,7 +3072,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 0394a9ddad..ad5e14b16f 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -10592,9 +10592,7 @@ 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 +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; cc->vmsd = &vmstate_ppc_cpu; #endif @@ -10624,6 +10622,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) #endif #ifdef CONFIG_TCG cc->tcg_initialize = ppc_translate_init; + cc->tlb_fill = ppc_cpu_tlb_fill; #endif cc->disas_set_info = ppc_disas_set_info; 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); }