From patchwork Thu May 9 22:26:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163765 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp1569102ilr; Thu, 9 May 2019 15:30:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhlurnN++9AiRDcnKlc4z+u9LQgmRXVMSWz7eEgemb09fJmvY+/6lJ8ua/dUbGcXtuy+XZ X-Received: by 2002:a1c:2104:: with SMTP id h4mr4503035wmh.146.1557441017749; Thu, 09 May 2019 15:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557441017; cv=none; d=google.com; s=arc-20160816; b=iGbVJVZlln14N7cJa7F4PCPeel+i6XUd1fq7riqnHBGGFBz8V+e/27H4QLPSRz1ACS h+hWnMoMGQ5eRUSg4ip6CIzJ0wNsxDjGjS7cJWCyzvs8zhMeoiTjknW9A2kW3x3AE668 dvmpQci+2108db3VMF3za9h4E8XD3XrLkCRCjp+E7G+JNv8+kI5QKegobVyVU8I9BOlD mDyl7aQRYf1HumUEL+WUkG7cuEscQB0cMZh5YzK1saFdXOhulsARgaVF/8V/kzBvfesG BnP4cV3KdH1Xwsc2M3hOEkp6cUuKubUcvsr95n3jz38yJiQnv3AB1sKQOw0GFZiejzDX IVxA== 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=pyOmNQehrxQ+vJN1rBIdXnxr1kqTHPzFsWgERMP7ALs=; b=PifOGDBwlfr1g/bircXw1LJNCfCM73K4F7Tq+HrYfDt3c6ru2hix+G+jaBagxjcKsQ CVeEuaZ+7bPh2AK0Yf4/laOeu/CaAS0ATK3kf+N/MVYzX2zgiMzSaDhIQWrBGzEUdFKL hgEJFltFGnqmSoZUdq99jqm7kzRRA6z1D50yJ13tckWlvjTiMvF5Ffr/OntcIhIf0pd3 Ez27Nahk0FfQL9x5jGSC41fvL8JWlZ89RMpzMVsQTQTK2FqG+kLbaByK/0BMXdjS7RVW KkJv1DImHBWqbf5a4NU7wDAiKDj6B4HCubZCxLsPqbQQRXxBfPHws43Eo/qs5sJUZwJX pWCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="f/cLIwy2"; 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 f201si2423519wme.177.2019.05.09.15.30.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 May 2019 15:30:17 -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="f/cLIwy2"; 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]:33460 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOrYO-0001lP-IH for patch@linaro.org; Thu, 09 May 2019 18:30:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOrV9-0007mg-Fx for qemu-devel@nongnu.org; Thu, 09 May 2019 18:26:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOrV8-0005WZ-CC for qemu-devel@nongnu.org; Thu, 09 May 2019 18:26:55 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:41759) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOrV8-0005WP-6G for qemu-devel@nongnu.org; Thu, 09 May 2019 18:26:54 -0400 Received: by mail-pl1-x641.google.com with SMTP id d9so1800873pls.8 for ; Thu, 09 May 2019 15:26:54 -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=pyOmNQehrxQ+vJN1rBIdXnxr1kqTHPzFsWgERMP7ALs=; b=f/cLIwy2OMjK1HB+Myp61BRRwUEr+BM8LJ3ybmbIFg9F+7iAwj2Fo//gX5ih6O1koc 0hfwPqMytjRS1T/IVyvLRIR47A26Oqq+Sz2+Ybv/8RkbKMcGPZdK92qi2gqZ6SJRS6P3 Vv2iTwqtU7TWQRX0FJOBbD+hq75YuI4B0s3/O0SRCXoroUxDzJq33Bv7uOlIl6bMAoDG j5m8Ow2AIwOqBurt9Hpnf9KQ2o3mivjqZ244Q2bM2FGkgHEUcOsyqxyPaoKBmYkFpnvy aTI5R5GIgWUb81HcivxzHPif+rWKxAGY4AYqtIM7+OM8gVQGlhGUQtI6zZ9agNwms3nx T72g== 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=pyOmNQehrxQ+vJN1rBIdXnxr1kqTHPzFsWgERMP7ALs=; b=IEdhW0JJ3gVT15J5rmDKXNf+rwEXyFOP1Q16sh4wVmtut2wElKl9e9rf0tulOGPhlK iOUXSHLHmRUkD85Dq6KYjGZqSvCzaoVQ47GTvZowT/qmmJkF3bd1pBY23+GwXyWMxDsd kmIAG3dDOwwIY88VicylDeuHaB40tVoCHMRg6cYTrUqJLyxFm4yYnW9rc1rwJ2aoUP/t 4kPELO+j6Vq+8gRKYjtXhZ5VRTdIcjF/1I9lU7Sn2qKP0bPItePQyaXBOuFCu3l3Y4xL vokohWiflKHKirwwUqmX0f+4Xb+J3I50cogzx9KMOlADUnswAf31+nI58Y9pRF5mRNbd jT4A== X-Gm-Message-State: APjAAAUiT+M7yWvW3knLAdbEXNFhWy011lq2zy2z0aV+XRCqdiqrF6ic WZCRHPgUE452Ym6foEcDLQWRFte/EKM= X-Received: by 2002:a17:902:102a:: with SMTP id b39mr8585437pla.188.1557440812996; Thu, 09 May 2019 15:26:52 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 15:26:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 9 May 2019 15:26:19 -0700 Message-Id: <20190509222631.14271-16-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::641 Subject: [Qemu-devel] [PATCH v3 15/27] target/openrisc: 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: Stafford Horne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: Stafford Horne Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/openrisc/cpu.h | 5 ++-- target/openrisc/cpu.c | 5 ++-- target/openrisc/mmu.c | 65 ++++++++++++++++++++++--------------------- 3 files changed, 39 insertions(+), 36 deletions(-) -- 2.17.1 diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 88a8c70092..9473d94d0c 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -344,8 +344,9 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int openrisc_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void openrisc_translate_init(void); -int openrisc_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, - int rw, int mmu_idx); +bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); int cpu_openrisc_signal_handler(int host_signum, void *pinfo, void *puc); int print_insn_or1k(bfd_vma addr, disassemble_info *info); diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index d125236977..3816baee70 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -149,9 +149,8 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = openrisc_cpu_set_pc; cc->gdb_read_register = openrisc_cpu_gdb_read_register; cc->gdb_write_register = openrisc_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = openrisc_cpu_handle_mmu_fault; -#else + cc->tlb_fill = openrisc_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = openrisc_cpu_get_phys_page_debug; dc->vmsd = &vmstate_openrisc_cpu; #endif diff --git a/target/openrisc/mmu.c b/target/openrisc/mmu.c index 5dec68dcff..94c65a25fa 100644 --- a/target/openrisc/mmu.c +++ b/target/openrisc/mmu.c @@ -107,16 +107,42 @@ static void raise_mmu_exception(OpenRISCCPU *cpu, target_ulong address, cpu->env.lock_addr = -1; } -int openrisc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, - int rw, int mmu_idx) +bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { -#ifdef CONFIG_USER_ONLY OpenRISCCPU *cpu = OPENRISC_CPU(cs); - raise_mmu_exception(cpu, address, EXCP_DPF); - return 1; -#else - g_assert_not_reached(); + int excp = EXCP_DPF; + +#ifndef CONFIG_USER_ONLY + int prot; + hwaddr phys_addr; + + if (mmu_idx == MMU_NOMMU_IDX) { + /* The mmu is disabled; lookups never fail. */ + get_phys_nommu(&phys_addr, &prot, addr); + excp = 0; + } else { + bool super = mmu_idx == MMU_SUPERVISOR_IDX; + int need = (access_type == MMU_INST_FETCH ? PAGE_EXEC + : access_type == MMU_DATA_STORE ? PAGE_WRITE + : PAGE_READ); + excp = get_phys_mmu(cpu, &phys_addr, &prot, addr, need, super); + } + + if (likely(excp == 0)) { + tlb_set_page(cs, addr & TARGET_PAGE_MASK, + phys_addr & TARGET_PAGE_MASK, prot, + mmu_idx, TARGET_PAGE_SIZE); + return true; + } + if (probe) { + return false; + } #endif + + raise_mmu_exception(cpu, addr, excp); + cpu_loop_exit_restore(cs, retaddr); } #ifndef CONFIG_USER_ONLY @@ -156,29 +182,6 @@ hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) void tlb_fill(CPUState *cs, target_ulong addr, int size, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - OpenRISCCPU *cpu = OPENRISC_CPU(cs); - int prot, excp; - hwaddr phys_addr; - - if (mmu_idx == MMU_NOMMU_IDX) { - /* The mmu is disabled; lookups never fail. */ - get_phys_nommu(&phys_addr, &prot, addr); - excp = 0; - } else { - bool super = mmu_idx == MMU_SUPERVISOR_IDX; - int need = (access_type == MMU_INST_FETCH ? PAGE_EXEC - : access_type == MMU_DATA_STORE ? PAGE_WRITE - : PAGE_READ); - excp = get_phys_mmu(cpu, &phys_addr, &prot, addr, need, super); - } - - if (unlikely(excp)) { - raise_mmu_exception(cpu, addr, excp); - cpu_loop_exit_restore(cs, retaddr); - } - - tlb_set_page(cs, addr & TARGET_PAGE_MASK, - phys_addr & TARGET_PAGE_MASK, prot, - mmu_idx, TARGET_PAGE_SIZE); + openrisc_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, 0, retaddr); } #endif