From patchwork Fri May 10 15:19:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163891 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2542076ilr; Fri, 10 May 2019 08:45:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8DKemmwTKR1rMZEoJPoJtDMo3mj5CDeZnah4UDw7nSy6miAeernaT1CEQmkWYNDHNxD5y X-Received: by 2002:a17:906:50e:: with SMTP id j14mr9162805eja.248.1557503123052; Fri, 10 May 2019 08:45:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557503123; cv=none; d=google.com; s=arc-20160816; b=oyMD413EhUw9OSE4ibhEjoYoNkhbHdJ2qZ9nBCjLHTNeU9+5yvAc1FoLcyj52Nl1No VEzLfRuoa+4V8MHoG+DDJlJiE/uMR4eR3GVnOGtUXL7kmd71jjH7dyrLTFxEZGloUtAd DDdv8BpebAoRzd2Cx8pELocYDVsOgqFbx4n6oUiNG5YuwKIqcZJQq6CBm/cF5tu/kHgt Z9ufvO9fe+8KPUfd0yUf9HoU/prepVZ6Ah+VEiIKzbqfjuwpxnCMQhZvr/2rqIzwy51S miyu8RyOSlNLRekvbXKyAPBOq7Zs8+1MLVvVoGTAZ3hKqWP7wGFTAI/tBzReb1nw4Tej Id5g== 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=bWfPEK+qkU+H+gRl4yZYfGof/Snf7uW20Ba+qkEL858=; b=UvtqIOxPyiL1Nrpo2newKyFSI/DFdpEPPbvM17oi2hjaU8LhPvzeKKtlUUYndh0izn MSztcFhvpur3ENfEvKgvwLpWl3iP+D/AxGXwgEuxS2VS3etmA9SkOfNIg2pieub8bJ/z xsL10Tla0Icatby8qGwKnrD+HgRttRCgckjcA6RLNWdkgz9QLVf6qH451VMp+N5ckFFU 3f4Ty+zmvhLAoNSEZMHS9eDjel6Yx373D6oBKocfHledn5xOqyEGzGPMeLxka/ziJix4 DUZo3HOEguWDVgKO7GH+NseEf7d65ut2ujHJ7dPEnso7eheP+LhMco7r+5jByHfQWDF2 Y4mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UoWgTuLQ; 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 a12si3206490ejp.19.2019.05.10.08.45.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 08:45:23 -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=UoWgTuLQ; 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]:45353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP7i5-0006FC-Vd for patch@linaro.org; Fri, 10 May 2019 11:45:22 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP7Jr-0007sm-HU for qemu-devel@nongnu.org; Fri, 10 May 2019 11:20:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hP7Jq-0000K7-6Z for qemu-devel@nongnu.org; Fri, 10 May 2019 11:20:19 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:32819) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hP7Jp-0000JY-WC for qemu-devel@nongnu.org; Fri, 10 May 2019 11:20:18 -0400 Received: by mail-pf1-x42c.google.com with SMTP id z28so3419549pfk.0 for ; Fri, 10 May 2019 08:20:17 -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=bWfPEK+qkU+H+gRl4yZYfGof/Snf7uW20Ba+qkEL858=; b=UoWgTuLQZR1/s5vdZUOVe5/548PhR4bjgDwviQ5/ypWDXRVGNHotq52am3pdItJ7/V krQ2CZyHn6DsbECkPiFiJpq9EbKKi3ZCQBQCqSpTXOGJ/jnA3+vtgUty0V+6b9pCOQID ZpfS5PHY92BR018U3FcQEUHulqSjdIEspu5krE+E4jSep3RYh44SsdSfOvTXdknHVdjN RSahWcHRAqPGbcQ0gU8y66f8FPDHnZpy7Q4nSv89pvM4FHUw5ByV+HQmurc5uHF+BxZ5 FGAitO8SxCArx9N1OPby0+r9UumgEa6+QCyvzj4kvf4Va2dx2wdZF7W1Orb0InOT9jFQ pivQ== 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=bWfPEK+qkU+H+gRl4yZYfGof/Snf7uW20Ba+qkEL858=; b=cTQyXY9Hrpqv7OFdPsg0MX5l8DqEKG5EiXhZLTeNaABB58BQsoCBl2eM+6+xJ7TAsB OLUgI8Y+SdnCNlQ5KdnHTWyjZDoB4b60kQqTKb15xlv6OXl+hRl2S98JyrQmubnljgih yg/E22nblSiYcYXDzbxbxIvD8RPQNoz+IEwLto90RVjkI90nTSk5brAlylTNwqFqWNw7 RBnTDX9NSxn1msDpQ6fFyVG6MeEkxiwMoM+KHZgW8ZEl3VBrGXzmpCuqUi1HYxcLbyTg kO/liENz6ArwgbnSP4sP0YZsy28zg3wfzqT8jqMwU4ixDg60MnjI6zf0XsKv+Vyxg52k RxtA== X-Gm-Message-State: APjAAAW7JGr/cgRjNszq2K/KFY2uQN0OUGigP2YNOuQ2IKTls9ViEARt hYULQMsbxutRSZrW7p7is52EM7DkxYA= X-Received: by 2002:a62:3381:: with SMTP id z123mr15461144pfz.42.1557501616646; Fri, 10 May 2019 08:20:16 -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.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 08:20:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 08:19:41 -0700 Message-Id: <20190510151944.22981-25-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::42c Subject: [Qemu-devel] [PULL 24/27] target/xtensa: 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, Max Filippov Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: Max Filippov Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/xtensa/cpu.h | 5 +++-- target/xtensa/cpu.c | 5 ++--- target/xtensa/helper.c | 39 ++++++++++++++++++++++++++------------- 3 files changed, 31 insertions(+), 18 deletions(-) -- 2.17.1 diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 5d23e1345b..68d89f8faf 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -552,8 +552,9 @@ static inline XtensaCPU *xtensa_env_get_cpu(const CPUXtensaState *env) #define ENV_OFFSET offsetof(XtensaCPU, env) -int xtensa_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int rw, int size, - int mmu_idx); +bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); void xtensa_cpu_do_interrupt(CPUState *cpu); bool xtensa_cpu_exec_interrupt(CPUState *cpu, int interrupt_request); void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index a54dbe4260..da1236377e 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -181,9 +181,8 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = xtensa_cpu_gdb_read_register; cc->gdb_write_register = xtensa_cpu_gdb_write_register; cc->gdb_stop_before_watchpoint = true; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = xtensa_cpu_handle_mmu_fault; -#else + cc->tlb_fill = xtensa_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->do_unaligned_access = xtensa_cpu_do_unaligned_access; cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug; cc->do_transaction_failed = xtensa_cpu_do_transaction_failed; diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index 5f37f378a3..5c94f934dd 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -240,19 +240,21 @@ void xtensa_cpu_list(void) #ifdef CONFIG_USER_ONLY -int xtensa_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, - int mmu_idx) +bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { XtensaCPU *cpu = XTENSA_CPU(cs); CPUXtensaState *env = &cpu->env; qemu_log_mask(CPU_LOG_INT, "%s: rw = %d, address = 0x%08" VADDR_PRIx ", size = %d\n", - __func__, rw, address, size); + __func__, access_type, address, size); env->sregs[EXCVADDR] = address; - env->sregs[EXCCAUSE] = rw ? STORE_PROHIBITED_CAUSE : LOAD_PROHIBITED_CAUSE; + env->sregs[EXCCAUSE] = (access_type == MMU_DATA_STORE ? + STORE_PROHIBITED_CAUSE : LOAD_PROHIBITED_CAUSE); cs->exception_index = EXC_USER; - return 1; + cpu_loop_exit_restore(cs, retaddr); } #else @@ -273,31 +275,42 @@ void xtensa_cpu_do_unaligned_access(CPUState *cs, } } -void tlb_fill(CPUState *cs, target_ulong vaddr, int size, - MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) +bool xtensa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { XtensaCPU *cpu = XTENSA_CPU(cs); CPUXtensaState *env = &cpu->env; uint32_t paddr; uint32_t page_size; unsigned access; - int ret = xtensa_get_physical_addr(env, true, vaddr, access_type, mmu_idx, - &paddr, &page_size, &access); + int ret = xtensa_get_physical_addr(env, true, address, access_type, + mmu_idx, &paddr, &page_size, &access); - qemu_log_mask(CPU_LOG_MMU, "%s(%08x, %d, %d) -> %08x, ret = %d\n", - __func__, vaddr, access_type, mmu_idx, paddr, ret); + qemu_log_mask(CPU_LOG_MMU, "%s(%08" VADDR_PRIx + ", %d, %d) -> %08x, ret = %d\n", + __func__, address, access_type, mmu_idx, paddr, ret); if (ret == 0) { tlb_set_page(cs, - vaddr & TARGET_PAGE_MASK, + address & TARGET_PAGE_MASK, paddr & TARGET_PAGE_MASK, access, mmu_idx, page_size); + return true; + } else if (probe) { + return false; } else { cpu_restore_state(cs, retaddr, true); - HELPER(exception_cause_vaddr)(env, env->pc, ret, vaddr); + HELPER(exception_cause_vaddr)(env, env->pc, ret, address); } } +void tlb_fill(CPUState *cs, target_ulong vaddr, int size, + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) +{ + xtensa_cpu_tlb_fill(cs, vaddr, size, access_type, mmu_idx, false, retaddr); +} + void xtensa_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr, unsigned size, MMUAccessType access_type, int mmu_idx, MemTxAttrs attrs,