From patchwork Thu May 9 06:02:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163677 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp552630ilr; Wed, 8 May 2019 23:17:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxycprZ+diRU1Dk61UTQqS8FjOsxQPkRxJ8hNLX93CBMUEiHd+fgZAT7kxFikW3DVAQyT9X X-Received: by 2002:adf:da51:: with SMTP id r17mr1470892wrl.118.1557382657797; Wed, 08 May 2019 23:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557382657; cv=none; d=google.com; s=arc-20160816; b=aonDnqodytJpEUB+Z2Bz9zP45XCp/O4qXqgF/OxeYMUTINrhoRNgLrkvcnUB2L6sVg K0QZrPpEfa+OMtucAX4LfYpbwwuhTwY7A0lJkDEQ7ZXJxtboM6UMkKov/S0X3mXaGv9y E9SZvMhphI1PZyg4UjZejDg0xGRO5cOUWSCrJI9nl6HiCXng8BCWl8MSm87REQZaLyLV 9UQvSMnvjKiUqIIx3VQjgkEK7kUavYiSu2GKD68zUneW33aP7eNaJF1HlO9NADehyi/f mojGK8ynoHLIjRLyW+r8erVDEK6EoF4G+V+HrloGR21AsDWdpF6bf5OO7ATSPM8Ut8D/ CTPQ== 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=Po065qxrjk3XsW6DqLkqX6sS5n4nQgII0U5vHcIO+W8=; b=QzAyRyBbPk/9vRoDHEeHV0plinoLmkswSXsoYONxXmYhHnL8CRt3OPcqOLB3j5hiDu dTpMylp0HKGJ7QTR2z4QtOZv/N4vfnjjwFqESQ1Vd2UgMf9KJwfL7mdpK1ywZpOG36ut e+8qqN6HON3LRBQtg5p+O0XBjuCQpwU0LMHSwRfgo2CcTbehG/B4snDSVC5MzAQf36os 2LNJBnzWM8Tt9fNn5qya8DcslBQOrfy4Pu4SKbtNSBPJuS5DF11TqgMlLFJmoxhcIcd4 OLRcqP4jOW3VRym4mqi9IrVQNXXMHdDIqKYAmcO2IXDtOUKuYii7CcmL4s9AIJEJk0kq qIug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZA1JPYJH; 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 e3si996424wrw.242.2019.05.08.23.17.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 May 2019 23:17:37 -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=ZA1JPYJH; 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]:48785 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOcN6-0003XT-K6 for patch@linaro.org; Thu, 09 May 2019 02:17:36 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOc98-00066M-1x for qemu-devel@nongnu.org; Thu, 09 May 2019 02:03:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOc96-0007A5-RS for qemu-devel@nongnu.org; Thu, 09 May 2019 02:03:10 -0400 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:32782) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOc96-00079e-L9 for qemu-devel@nongnu.org; Thu, 09 May 2019 02:03:08 -0400 Received: by mail-pf1-x444.google.com with SMTP id z28so733749pfk.0 for ; Wed, 08 May 2019 23:03:08 -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=Po065qxrjk3XsW6DqLkqX6sS5n4nQgII0U5vHcIO+W8=; b=ZA1JPYJHsS8cLBlNDoL7OcZzzfYHKYIz5i4eP+RN21EJNZT0L9VXaKb/Eer3dn/wO6 eDHaYXI0pXHMIF9Optzey+AXayrkZa/TZjlsgwNg2R8N/t8ClCDyR0oUXOhLn+HkF/i/ fCA1bqIx4qGvtxRxV4wa+WbL+S3sJsB2cftI00JG6DiaZ0tW0K7v5VZGNA68t3ZWlEQj f3ATNDz7uJ0tEULL1DianRcxm6R5eEt0eIDzqTXjZ7XrCx72rjcK3FZtRB4zYIU4BIaV GGedQgBDLp3/jioxrFMFzOk5/yJpyB44WKb/arI3pBAMV3AwE/l6gnd2nnZwMvXP14Lv Cz2Q== 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=Po065qxrjk3XsW6DqLkqX6sS5n4nQgII0U5vHcIO+W8=; b=c6e7VSII3H2Xcd8XNAFXm56l4WhBl409pXILDf3XiXStYkVXh9XHu55cBOk7SLPPAE wf5FbLfAimR+kB+mrySfnGnXmhRLADIfv1RDAg73wYPEDtt1wQYryvXa/K1SmE5Atg3V OjV308BCXiQXoHJxxWFw0J3ILPvjprFcubVwLYtQciBlj8umRPFnmoayYxrWkm9XV5aT wE/La7VOcnyBAGfp5ITyky1UKlEG0PwSHcsLa4Eo8MNG7ikKXqFPzTx9Tl/V9nGcHjzJ 8lTKCXK1fV3fByLLQePLBnt+jWqao44OB1lp2DPIxxpv7cAFzg6r6V8ctbPtk8srQpWN SYmQ== X-Gm-Message-State: APjAAAWLC1bMP5ytPLdATqo1dhxBcLhVJCOUGMA6YRuxQuR/Y37IrOeh rIkWs+hSVxRG3LIhaGoSgybSYsU5iOM= X-Received: by 2002:aa7:980e:: with SMTP id e14mr2609706pfl.142.1557381787349; Wed, 08 May 2019 23:03:07 -0700 (PDT) Received: from localhost.localdomain (97-113-27-95.tukw.qwest.net. [97.113.27.95]) by smtp.gmail.com with ESMTPSA id n7sm1496109pff.45.2019.05.08.23.03.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 23:03:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 8 May 2019 23:02:34 -0700 Message-Id: <20190509060246.4031-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190509060246.4031-1-richard.henderson@linaro.org> References: <20190509060246.4031-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 v2 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 a50861955a..5b1ae803a1 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 e7d5219e11..991f3fafe8 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