From patchwork Thu May 9 22:26:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163784 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp1583002ilr; Thu, 9 May 2019 15:47:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzaRdmhtWB+ljrPXJjwqDKvlnVQtXfeG79Uht8JaISah01aXcartfWkLMAy+cwpNQrfbP+8 X-Received: by 2002:a1c:3287:: with SMTP id y129mr4888964wmy.153.1557442023492; Thu, 09 May 2019 15:47:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557442023; cv=none; d=google.com; s=arc-20160816; b=vNA8bqq66NCczes/LnXjNqpOj7+UIXTRkyLdgQkERsNo3T0KmwYZWR2ZrI89CMFcfW rZ0Ic3SYeyqUBWh7NEgoqdwP5phAkDOqBQtRkerwqWmzASvIni0RmaKQs1EbJIpcoJ6O 20kbEtPWLxSHfuuf6ZqJSlHWxF0NWnP42xeD1pPJLxEdfiZZl/n5B6RNHBh0rBBlo1pQ bxEecCM6GaC8nWyjSoFMTIXpmBNiEI+mQSSWqq9BkBc1zkLvxnIbinyhLFIzA4gjl5Ck nFzRImWp8ma5RDq4Gl6x4jbI/wvdkFXq7EcUsQRlTYD013oKZh7GnfMcstN8jBMGhL6J d1Yw== 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=i61mEex2vpahjushkr4y22Y6q9/HL9JKMG8d2fXnTE0=; b=PcBT/o7KRNJuiIt3zvfJ8hsN+wFz+sIbYoFq9cMR3l7yGtcxQzjsH63RdVs2GuYVs5 EHL5QACU6jd1wDhyCIRJkJVKvWCAyylHYDxPLDeDa/lIDWModGBbfjb+0NL/RpyKCkfF V2SX4N+lNrPdN/zGCPN2S9c1iR58RxEWCLxf991WWOSbH2HUBklMGJEUhlEvu376nqzG o+aXbR3E1YZY0KtJEBZ4wyw28s6iY5fod6siQLI/D/ekEJ/GKFGOuHrGRfbqYiT7KiQQ x5+XQPoxMev08MEkWZQeu4KpmWUZnIy+m+G6Azm94j0eXn0+fXkfQ2qvowlr+vnJ1Iem uN4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=nm4DjUfS; 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 y15si2721759wru.14.2019.05.09.15.47.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 May 2019 15:47:03 -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=nm4DjUfS; 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]:33755 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOroc-0008Nm-Fx for patch@linaro.org; Thu, 09 May 2019 18:47:02 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOrVB-0007oQ-6h for qemu-devel@nongnu.org; Thu, 09 May 2019 18:26:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOrVA-0005Xn-0A for qemu-devel@nongnu.org; Thu, 09 May 2019 18:26:57 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:41939) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOrV9-0005XC-Qh for qemu-devel@nongnu.org; Thu, 09 May 2019 18:26:55 -0400 Received: by mail-pf1-x444.google.com with SMTP id l132so2041397pfc.8 for ; Thu, 09 May 2019 15:26:55 -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=i61mEex2vpahjushkr4y22Y6q9/HL9JKMG8d2fXnTE0=; b=nm4DjUfSsSj9UfmRYqY4EAiqgB0VEcXrhjFYdPPYjrlMaGjIY1XNMkvzF0XI5vhSt5 73Eo8mjCsJ5zpnbjgik2+uolkQYlg/LsLuZ18vhkYvQ4ULJmKpdOgBskmVw4V4Tv0wrt DtEjWUOCoUaCnLYRq/Jq6C/cOEuTtsIehLsfAYjhJ3XoZYwmPaxVweYq1rrshrugGMx0 3IlUNEXxIXWOvJlZnc8EOMxKrJTtXsUMFurE8O8sFDAy/aLDO+k3QjkG4M5yuY94Sh8Z HgDq4lessUItxsgIpI5SRPYvXXde1BsymjjmxpzGtKOJV4sAkKv1V9FiGdSiJP8ac67n 4UpA== 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=i61mEex2vpahjushkr4y22Y6q9/HL9JKMG8d2fXnTE0=; b=laPQ7SKYRyYYXRsSfRLxXFvuUY8O9PNQC/VSLUksu4xBRiegeGcp97j0btmi4MpQuv OwLtHq/mwqN9L12SSYvsb1RVsyI4GXkTQNKhr9QI5yYYkh0fhopKpuDLNhbAQcvJcZKg oq/efFuh20W2eZnoH5JitlBKlJCCO0qin+lMdAzSVWy+O8txawECnaGbowQaiuiJTqlM RTrCSp5EVPKSIYv1Zb40UJcrf+93fcWdXr19oGEa8pVhbjXBHOdJ2bgpOqhR5/4ytvrM tRCUCsf1Vg195jhHZu1kHZoSFXzkCi2NUkC3na0UCawEiQ+B2I7jpsB7PyJ5ThQB6ggm GztQ== X-Gm-Message-State: APjAAAUFRILuRwQvaK8ekEDrl/+fWz1oQqsDdx+RXfI4JXp4LwMJT6vy S12pu4o+Z76k4FgFlcGoof1ZI87eLHw= X-Received: by 2002:a63:5c5b:: with SMTP id n27mr9165423pgm.52.1557440814573; Thu, 09 May 2019 15:26:54 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id m2sm4490521pfi.24.2019.05.09.15.26.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 15:26:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 9 May 2019 15:26:20 -0700 Message-Id: <20190509222631.14271-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190509222631.14271-1-richard.henderson@linaro.org> References: <20190509222631.14271-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 v3 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: 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 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 Acked-by: David Gibson 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..3f847de36c 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -10592,9 +10592,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); }