From patchwork Fri May 10 15:19:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163889 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2539898ilr; Fri, 10 May 2019 08:43:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZE/uidnVrygKa7DFLE5QqtLIrLoi+lTw6FlpEDb+L3L2DI4ZfXf/qrqjKQyRIbkVyr+h1 X-Received: by 2002:a17:906:69b:: with SMTP id u27mr9096341ejb.256.1557503020102; Fri, 10 May 2019 08:43:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557503020; cv=none; d=google.com; s=arc-20160816; b=xV7Xm9UlP31Rj95ymDFoCtEgC3adhGohNwyVNPlWPsF/OZEyGi5dFjgCyvSwCKW30i +sUeUWiEB1+vzvSZvsv8DAoNnc9HhZmpJSz8o7n/Oqt9YWIbF+YsXZPyBkzJKsgn8BQw mykxom7Irnzzm0/KWNDG2UdWRAK9VAWkmrGUKHSGp+RsP/EV3vIek5Ev0y20eHR/80km zZhVTtqqC66oByD9v4wJ4Rb4uI+5X9CXH53KYUFR6znhgtSgmTr3THhVeBDsKsJtq+S5 /TVRHx/KCHu3xf+nLFxMx8AWvQIjdRYY9y+dPmQm2BJjHI0fpczwOUZYb3PpVtINkpFl MwjA== 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=mEhoN52lBLUres1/QwY1daoL00Fs8r4TbvtBiYUyesd4+q3YgYlsyeI8ug38qRnhKf IomeF2owL537K9Ec4/dZgJX6HWySLJP7cVmfeZM77YoXtoKhD61kImowxpXAL44yGHfK suDZz6/YQilDmkISjsJ3yUpDNamteSIaHkpW8diMFzzI1hXOxPkZJCO5cnFVmWzUcDyZ H6sMc26Iq3ch4a8ZHvsGZ3JT156MDXOh9zXFf2iHShlkQ39sH/w62T0XqhjXRm1QD1an uv8ALKMqjDskBI5oFmrKptJXzswxupjpvpZTdfx7qB+T8LP+bfk4GRazoB7x3+DDiEhB Dorw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ofUkvA8D; 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 a15si3323690ejv.330.2019.05.10.08.43.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 08:43: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=ofUkvA8D; 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]:45323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP7gR-0004t6-1G for patch@linaro.org; Fri, 10 May 2019 11:43:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP7Jg-0007ea-Be for qemu-devel@nongnu.org; Fri, 10 May 2019 11:20:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hP7Jf-00005B-57 for qemu-devel@nongnu.org; Fri, 10 May 2019 11:20:08 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:42390) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hP7Je-0008WP-VF for qemu-devel@nongnu.org; Fri, 10 May 2019 11:20:07 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 145so3174133pgg.9 for ; Fri, 10 May 2019 08:20:06 -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=ofUkvA8DKRJRBhSyTfuTP4CJrRpdtlPCRQ9u7qkB5GMg7qmgw5oSq3PloxFex8kwbZ kMDWQIjHFpstu6XI/zrz+mBSvb2DGowu4QXP4kbz9pFoqM/4xFTZ7JYnVadKJ6TkGxXP tL86OhSpxXTBYben9oI7QllprBrC9kEOBm/861TKqNbT+knqXCmWr5uaBZEyEof/mYI1 WD5KZyrg7NzCaZ+13njqy4mNnTOaSoPZlvBQlp9OWd93nHx+ru1+eBd9TZOZf95SknAb ZKGwjaVh/0oMavUez1jmQicq7xBvhJ78aGA2Rxn4hsss9Jtzm140IS4c+Mty7pupyfOY Ek5g== 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=kqBg2nSytpgFV9k0J+HtpqygaKVzWFXJOtfAFkVgoLNPgCK3N4ed0pBtF+TLCsnyZB qlPa5eosyzbKfC7B/3LnV8YAzjrfWXlyLUeS9N9f0/uobDQR8HhS904fJUkl+8y//wCc 9MRcH6IIEOv0Tx4kw8t0qv4LBM/sFC0Hg6fi/eEjW+4Q9XHG7dNWeGlsbXMKtZa0FMbW wisuBApvBsDe3TdS99azvIPnDKiHjMzHuMJpuks31xg9+4C/93wJ+/pMWryeoPjxLpHg uTOcjbyZFTaIbDsbbNWYvc1HPdV+9uRVEFVYWc3XPGXvssPMXxC4kdOXe1X1vSe9aPQL +Png== X-Gm-Message-State: APjAAAU8dOMG1cOTVThTinjBs4F1tj9Q4gterLwVjXNz6RYpX0S85AYO w70IRACCuFRTLss1WfywR0fxanJrcjY= X-Received: by 2002:aa7:8554:: with SMTP id y20mr14945470pfn.258.1557501605638; Fri, 10 May 2019 08:20:05 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id 19sm5920517pgz.24.2019.05.10.08.20.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 08:20:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 08:19:32 -0700 Message-Id: <20190510151944.22981-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510151944.22981-1-richard.henderson@linaro.org> References: <20190510151944.22981-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::52f Subject: [Qemu-devel] [PULL 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: peter.maydell@linaro.org, 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