From patchwork Thu May 9 06:02:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163661 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp541788ilr; Wed, 8 May 2019 23:05:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwU6DUGg9VR0KPmxj9KQ24gqpAemlbaOpf1c+9FBlT5E2HXq61QbcpiPtNflviB5TM2ik9g X-Received: by 2002:a5d:4f88:: with SMTP id d8mr1437819wru.34.1557381951600; Wed, 08 May 2019 23:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557381951; cv=none; d=google.com; s=arc-20160816; b=p2J87iwE4PaIiF3ocq7rIwco+O2D7eLUG2ONq2NL/6JPv06ZZjzcbRQvJyv27oWNIT HobYZDpHC1ml0adpdI3frvpJCbYwcC0YOxoOY+fJkrrDCPOUIn0QWGOjWmrbrt4diRjL i3IejIUBVwfpJcO65eVp6hf2Na6haT17WeXOgm8QGMEBdcAFVgKGMB5im/mFb1fZyw04 PwZi44C/YKUf8w0okwpudHu+BY149Fu8b/MEXYSDND4NbjDtWhxcXMNIuHrcxUCE5a8E /Rnw0mIhCTZOm+NJLwB9F3/5OwcOoz5ixmyAhVzFa/hYyw7Ydz3CgXDoUTA6sM8YdBPy 6seg== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=nXQKQmWv/YKHXQBl4iXWce1fvy4Q62aar83khsKjymg=; b=jXQa5hFUJyAs6q+Yj87YlQkqdmGv06EckOtpNEohsh/j15xP2vOfQ2TZPAe7uyHoEd 2LFoPTrMAbWgv54WjlxuyIhUBd9j5oBm7sAilyFj981GHV+xf5RLJUVFigBx9tyXQMeU jVoWGtY6dLQo3mRbVH5Fro5qd5GwQkwLxCtTmEaut5YRhjTtOV9k01YHQbMkNn2rl6Jz mohjm+7bBMguboIqd9kUCl56qLat1hbXy7bB9DV2tuetS87JbIFxiUC7jYH8Pc+geBlP nisuUCXHcWPv20Wry1nILVJqGkS1JARPsPO4stEbrQWxoXOE7wFojgM4PVXUBmMIc0Ii 2gzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Gbrikn+V; 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 g6si956222wrq.307.2019.05.08.23.05.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 May 2019 23:05:51 -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=Gbrikn+V; 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]:48609 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOcBi-0008Qi-FM for patch@linaro.org; Thu, 09 May 2019 02:05:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOc8r-0005vA-HD for qemu-devel@nongnu.org; Thu, 09 May 2019 02:02:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOc8q-00070o-BM for qemu-devel@nongnu.org; Thu, 09 May 2019 02:02:53 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34946) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOc8q-00070S-5I for qemu-devel@nongnu.org; Thu, 09 May 2019 02:02:52 -0400 Received: by mail-pf1-x441.google.com with SMTP id t87so730724pfa.2 for ; Wed, 08 May 2019 23:02:52 -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:mime-version :content-transfer-encoding; bh=nXQKQmWv/YKHXQBl4iXWce1fvy4Q62aar83khsKjymg=; b=Gbrikn+Vp37AnJo3jBEL6aMO5QmhCkB1IUb5phruLggUL4W557VUZq7rAwGZnHCUA6 za4LFYWuAdWIJWih/9HMtU6L89xJJwNnQSv5xobp8BuhQ+0x7YXV2j3euZ7zNR0YbRDG gxBCkcXD/iqYQd8E+nwOD1/DVnwOWs2E6vGo1ZtQjVldh7K81FDzRTA0LlDcOWRHc7up YRgqovz97WZkosVrG2udkZ2PZf+ynfW/Z6lAOXSfU4dn+RuLx/WflMxl0hk2mXgOuwyp Vl00iT79kHSF2WiI3hky4twd3pYEDIO/gfvXDrGLNmTUtE1+NMa6OePRiAF2ZLMhOBGv 42xA== 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:mime-version:content-transfer-encoding; bh=nXQKQmWv/YKHXQBl4iXWce1fvy4Q62aar83khsKjymg=; b=ByLnalDKrOz0rWJ3hx199VCEgfM77S2SDgTF9GOIWG/Z9HAeC0fY8QIiJQ0NIHDQjq L1UaGczpTRoB2TlBI5KtKQA0ZptP97ekIxpL98tmSvLNvRYROEiu7FDsKBzWeILcgxyX eAzMLfBZdhTUDhDUNf/JZONs6WDI/9r2VqqQBJ4q82miZLHXdEwjYBs2laHX8n5ppC1O veNRIJ46yVjbPCI3gyQf34Jj/hwTxX6LPoteB2I0UuKqOgkM6OcfWRg0Mqtv2n1GO4t+ eCte7ZrJJWBFJseRygg3jBPKYQmZlyNKTVrSty8QfwF9qy5ftrBdaTHA2m8dp4KovvAW 6B1w== X-Gm-Message-State: APjAAAUFBCxJOFrp9cre+wzlJdVwf+IiMio5xXUd51rSEt57xS+WsrZt jgvYxgdw8pQzSn0y9cOI5A+WQw6GG8M= X-Received: by 2002:a65:4489:: with SMTP id l9mr3084713pgq.1.1557381770916; Wed, 08 May 2019 23:02:50 -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.02.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 23:02:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 8 May 2019 23:02:21 -0700 Message-Id: <20190509060246.4031-3-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> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH v2 02/27] 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" Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- v2: Keep user-only and system tlb_fill separate. --- target/alpha/cpu.h | 5 +++-- target/alpha/cpu.c | 5 ++--- target/alpha/helper.c | 30 +++++++++++++++++++++--------- target/alpha/mem_helper.c | 16 ---------------- 4 files changed, 26 insertions(+), 30 deletions(-) -- 2.17.1 diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h index 63bf3618ff..cf09112b6a 100644 --- a/target/alpha/cpu.h +++ b/target/alpha/cpu.h @@ -475,8 +475,9 @@ void alpha_cpu_list(void); 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 ad3588a44a..7c81be4111 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -225,9 +225,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 7201576aae..929a217455 100644 --- a/target/alpha/helper.c +++ b/target/alpha/helper.c @@ -104,14 +104,15 @@ void cpu_alpha_store_gr(CPUAlphaState *env, unsigned reg, uint64_t val) } #if defined(CONFIG_USER_ONLY) -int alpha_cpu_handle_mmu_fault(CPUState *cs, 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) { AlphaCPU *cpu = ALPHA_CPU(cs); cs->exception_index = EXCP_MMFAULT; cpu->env.trap_arg0 = address; - return 1; + cpu_loop_exit_restore(cs, retaddr); } #else /* Returns the OSF/1 entMM failure indication, or -1 on success. */ @@ -248,26 +249,37 @@ hwaddr alpha_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) return (fail >= 0 ? -1 : phys); } -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 addr, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { AlphaCPU *cpu = ALPHA_CPU(cs); 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, addr, 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_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, prot, mmu_idx, TARGET_PAGE_SIZE); - return 0; + return true; +} + +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 /* USER_ONLY */ 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 */