From patchwork Wed Apr 3 03:43:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 161653 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2514124jan; Tue, 2 Apr 2019 20:50:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwycaSyL6DnE+Q0pA2MN5G6f3PrtyFroCe8JsXS+XaImXq6a3MQy2uOOf5MT8akdSFeS7ok X-Received: by 2002:a0d:c745:: with SMTP id j66mr61431074ywd.258.1554263405381; Tue, 02 Apr 2019 20:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554263405; cv=none; d=google.com; s=arc-20160816; b=hGG8aR2UNwwfTs7bvk7fgCOtQVjHpvuFUPJpK0OgtcpmLFUnVKiw7CwybXOLEwonw3 2sI6fijhAJozZHeCr5QFBV8koITxH3p+NIJaLLSHGg/PHRx+jZcZGNqMCbJbnao1l8YG Wo837r9U0qLMvLy4F6Wpfi4weekK8J7Ksm980kkSoMc+3u6yxCPH1HW3Sz4fWiv6NtVk tfIq1QTFTaFR9GVkOM0fC9tutGSc6a+o8WbRCI/Xq+3AME19vOSrsgaQqQbExeyuuUy3 3X+DLbMPX9yKIbhAi7wiXrjZ+8qyhWd/FnWc8ah3TF2CwxCt7WG2Rba7sImSuEWFKf3J Av/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=T6WPmTFnuwgmwKqzFLAzjRNZe3eRbqRWr6UuIt9sYlM=; b=o5a6N1QudlZVGcF8TLhhmE1ftvP6iCulHu/l64yLhc0c32Sp10ePV5W+xbfT3h48YN +7d1l2MN0+1IWIHkoE8BWDYe2Cq7/TqUhmFtkMm2ew+rP4WqwGR5IrwpgaDOeSwCjM1E YLhATBXNDMrvUvf3VFGbcdwnlD2wkluRg/LzbgWF6DVBbfKLkPXpf6oVX1oV3V5WASj+ 4CaosjhNKVKlWQZyoTZbDQCa3DUm9vYgpMbbudquUmZnMDXqqhR394Zd6M8KWVq9oS3b Nj/BBVxUdU2LSdSzYySpqECyxuOf5Ytps3f5BZDP83h61wUQLFwJ4bGJpjBcTPtQWT4u IBAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xFz3J8Yr; 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 i207si8870908ywa.448.2019.04.02.20.50.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 02 Apr 2019 20:50:05 -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=xFz3J8Yr; 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]:52624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBWua-0007eZ-QJ for patch@linaro.org; Tue, 02 Apr 2019 23:50:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBWou-0002f5-8h for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hBWos-0007zp-VG for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:12 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:36144) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hBWos-0007yC-LP for qemu-devel@nongnu.org; Tue, 02 Apr 2019 23:44:10 -0400 Received: by mail-pl1-x643.google.com with SMTP id ck15so6123252plb.3 for ; Tue, 02 Apr 2019 20:44:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=T6WPmTFnuwgmwKqzFLAzjRNZe3eRbqRWr6UuIt9sYlM=; b=xFz3J8YrLOLm+tcDP5rnM6XDE8qfNRgargi75XIc16Jxmy0YKJlW49n0Ym6Rji7XnF PrNdjmsZsH/NGzAfM1+QVmTq6Md0f2iNoCz00vyccH9Tj+IiyRKFWswT4g5N4NFtgQtm X1YKyK1zNxws/befIXUlwDytyFXeJpHXo5k9g9rHF8vyXvZptOT2qSgr2H2Rmk5Wf1k3 SfHCMVxaxsxFUlaDNpnku9Nm8LleEGQmMKsP56X/mX/gWDAKgHAwixio20lvztMuF/29 +bWiHGBf+L02duOSwsdmn0psXo3TxKYMV9kZ7RQWByx7b/i7zV8T3GVtW2GXSo9dAVye OPwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=T6WPmTFnuwgmwKqzFLAzjRNZe3eRbqRWr6UuIt9sYlM=; b=lcaboa2O28EWzyU35VV1DRvSyCLe+mbUvsqC6NI03ZfQa5rcgYS73xukrho2du57Xb QRB6XhjY8xIyEUU6IG2SKe1pTWKBAzsTKiUl5VN7SF/QG8eV2oYmT9SPgGYc5UjMdjlE bdaiYsdnAwlrZA2XphAJ7HKqBgQ4WNTN+R4Fu42Zr+qo4zH2MNLvKHQOEufBn5PBKy7l Z7dYkOeO3M60JZs+ztZwj9GJd3xWb2OVDKkZ/IH3w0yW/Aj+QQnw0NdmYAlG80hwTDAT OWqUMbz/o/GDPeqJNzF+xhPBQkyNvzf5z1kx+o4ZY5J5xINoqr/m/kgLldaVnVQwRCo8 QrHA== X-Gm-Message-State: APjAAAX04r+EleQLpic6x9ciwnMe8kteWDniwENk6+h8Txax9siEKvpg lnNlUF1UB/WarLnx35XWelnf8OahAf8nQQ== X-Received: by 2002:a17:902:8f92:: with SMTP id z18mr21924479plo.123.1554263047845; Tue, 02 Apr 2019 20:44:07 -0700 (PDT) Received: from cloudburst.imgcgcw.net ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id z6sm26753214pgo.31.2019.04.02.20.44.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Apr 2019 20:44:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 3 Apr 2019 10:43:35 +0700 Message-Id: <20190403034358.21999-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190403034358.21999-1-richard.henderson@linaro.org> References: <20190403034358.21999-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::643 Subject: [Qemu-devel] [PATCH 03/26] target/alpha: 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/alpha/cpu.h | 5 ++-- target/alpha/cpu.c | 5 ++-- target/alpha/helper.c | 50 +++++++++++++++++++++++---------------- target/alpha/mem_helper.c | 16 ------------- 4 files changed, 35 insertions(+), 41 deletions(-) -- 2.17.1 Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h index 7b50be785d..aecf8d75c1 100644 --- a/target/alpha/cpu.h +++ b/target/alpha/cpu.h @@ -476,8 +476,9 @@ void alpha_cpu_list(FILE *f, fprintf_function cpu_fprintf); is returned if the signal was handled by the virtual CPU. */ int cpu_alpha_signal_handler(int host_signum, void *pinfo, void *puc); -int alpha_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw, - int mmu_idx); +bool alpha_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); void QEMU_NORETURN dynamic_excp(CPUAlphaState *, uintptr_t, int, int); void QEMU_NORETURN arith_excp(CPUAlphaState *, uintptr_t, int, uint64_t); diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 1fd95d6c0f..5aa4581b9f 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -230,9 +230,8 @@ static void alpha_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = alpha_cpu_set_pc; cc->gdb_read_register = alpha_cpu_gdb_read_register; cc->gdb_write_register = alpha_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = alpha_cpu_handle_mmu_fault; -#else + cc->tlb_fill = alpha_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->do_transaction_failed = alpha_cpu_do_transaction_failed; cc->do_unaligned_access = alpha_cpu_do_unaligned_access; cc->get_phys_page_debug = alpha_cpu_get_phys_page_debug; diff --git a/target/alpha/helper.c b/target/alpha/helper.c index 57e2c212b3..e54197d5fb 100644 --- a/target/alpha/helper.c +++ b/target/alpha/helper.c @@ -102,17 +102,7 @@ void cpu_alpha_store_gr(CPUAlphaState *env, unsigned reg, uint64_t val) *cpu_alpha_addr_gr(env, reg) = val; } -#if defined(CONFIG_USER_ONLY) -int alpha_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, - int rw, int mmu_idx) -{ - AlphaCPU *cpu = ALPHA_CPU(cs); - - cs->exception_index = EXCP_MMFAULT; - cpu->env.trap_arg0 = address; - return 1; -} -#else +#ifndef CONFIG_USER_ONLY /* Returns the OSF/1 entMM failure indication, or -1 on success. */ static int get_physical_address(CPUAlphaState *env, target_ulong addr, int prot_need, int mmu_idx, @@ -246,29 +236,49 @@ hwaddr alpha_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) fail = get_physical_address(&cpu->env, addr, 0, 0, &phys, &prot); return (fail >= 0 ? -1 : phys); } +#endif /* !USER_ONLY */ -int alpha_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, int size, int rw, - int mmu_idx) +bool alpha_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { AlphaCPU *cpu = ALPHA_CPU(cs); + +#ifdef CONFIG_USER_ONLY + cs->exception_index = EXCP_MMFAULT; + cpu->env.trap_arg0 = address; + cpu_loop_exit_restore(cs, retaddr); +#else CPUAlphaState *env = &cpu->env; target_ulong phys; int prot, fail; - fail = get_physical_address(env, addr, 1 << rw, mmu_idx, &phys, &prot); + fail = get_physical_address(env, address, 1 << access_type, + mmu_idx, &phys, &prot); if (unlikely(fail >= 0)) { + if (probe) { + return false; + } cs->exception_index = EXCP_MMFAULT; - env->trap_arg0 = addr; + env->trap_arg0 = address; env->trap_arg1 = fail; - env->trap_arg2 = (rw == 2 ? -1 : rw); - return 1; + env->trap_arg2 = (access_type == MMU_INST_FETCH ? -1 : access_type); + cpu_loop_exit_restore(cs, retaddr); } - tlb_set_page(cs, addr & TARGET_PAGE_MASK, phys & TARGET_PAGE_MASK, + tlb_set_page(cs, address & TARGET_PAGE_MASK, phys & TARGET_PAGE_MASK, prot, mmu_idx, TARGET_PAGE_SIZE); - return 0; + return true; +#endif } -#endif /* USER_ONLY */ + +#ifndef CONFIG_USER_ONLY +void tlb_fill(CPUState *cs, target_ulong addr, int size, + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) +{ + alpha_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr); +} +#endif void alpha_cpu_do_interrupt(CPUState *cs) { diff --git a/target/alpha/mem_helper.c b/target/alpha/mem_helper.c index 011bc73dca..934faa1d6f 100644 --- a/target/alpha/mem_helper.c +++ b/target/alpha/mem_helper.c @@ -62,20 +62,4 @@ void alpha_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, env->error_code = 0; cpu_loop_exit_restore(cs, retaddr); } - -/* 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) -{ - int ret; - - ret = alpha_cpu_handle_mmu_fault(cs, addr, size, access_type, mmu_idx); - if (unlikely(ret != 0)) { - /* Exception index and error code are already set */ - cpu_loop_exit_restore(cs, retaddr); - } -} #endif /* CONFIG_USER_ONLY */