From patchwork Fri May 10 18:54:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163940 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2753485ilr; Fri, 10 May 2019 11:57:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJ8J7hrMZo2sJDWtQLPXFyOYp/OAa6RlLSyi6d27+O5CeoC3LwCzygasBlSBqlOhEcLbcN X-Received: by 2002:a17:906:5252:: with SMTP id y18mr10245980ejm.186.1557514674169; Fri, 10 May 2019 11:57:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557514674; cv=none; d=google.com; s=arc-20160816; b=VmU4Kb+XsOBUh9rSbiaLGpRNc5z3xMOTD08BpxaYEljcPUgNFrJkVvEBziBe7EA4j7 N5U6/IuTYJ/4lvWRVoiQ+MtczUFfuQWBX0Slsjrukz7R0wg8RR0mXewczCp8t/H0dyVd ihXfncLlBJ/7Rjhq64j6xBfJAnqe2RaKkPFHsuiydH2WWdCYxkVTuU5VwQ5ujdoppY5U gGuNvdMWsfckwBNMnI59FvGavGQZGFypSfeqx5n2ffI7ZGEIkkLSKtUThqY91Zsg2zU+ MDakviUisj5C9qFIUT/kxDhkxYR2nn7L3tEDdjvqq2STc4UAreOn0MLmdi+N6Atqbxds MDbg== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=tebtMZETlIDQdWSOMLyAJVULNNmJQHM2vL+aKJmhU6U=; b=dq4RUul64QFKRuQ/5TT8uVM7qTJK3jzcc6MzKW/0TDowD8U8gUp707BkfNXLye2Cy2 GJepOaFqI07nW9ixQaJs3AwkjEGl/cNWUno7eis1MnogGFmcxxoHVcX/BtjGhQ/TqW+X Nf6Qdia969xMOXORHDgNFvziuI9qjhGfvU3KDXiKYrNqmDU0z4G2b1A+xVTKDevKeJgb j7KC62Nhl8iYXHMOG2nnB9nLFEVGha44F1RLu+nHImvVkTVuGHw/CrbYsjB3V+XmOw1W TheRrNuxDdzUQZ9dUqiZSM73l9tYTM6CcHiR07smBzfo0Jhz4kw34CLBxIKYf/cmVuA8 ELYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UlZvUQIZ; 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 t19si3667538ejz.189.2019.05.10.11.57.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 11:57:54 -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=UlZvUQIZ; 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]:48542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAiP-00029X-0k for patch@linaro.org; Fri, 10 May 2019 14:57:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAfW-0007v3-Vw for qemu-devel@nongnu.org; Fri, 10 May 2019 14:55:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPAfO-0005oF-T5 for qemu-devel@nongnu.org; Fri, 10 May 2019 14:54:54 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:38360) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hPAfO-0005lw-J5 for qemu-devel@nongnu.org; Fri, 10 May 2019 14:54:46 -0400 Received: by mail-pl1-x644.google.com with SMTP id a59so3238470pla.5 for ; Fri, 10 May 2019 11:54:46 -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 :mime-version:content-transfer-encoding; bh=tebtMZETlIDQdWSOMLyAJVULNNmJQHM2vL+aKJmhU6U=; b=UlZvUQIZmKs0PDQlZyEQT2qkFIOsAWV7VSVR6jf+ZocudYEJrp3U2quaWCOCqk0g6h 331BgKq2C9Ojv7OulTxVmO8ezCe11ByyMEJtmhcbcaAFaqmUf+f7ZhQOHXFRRNXxFf9X 2/QdmvVwTbGwVLG2sJqg7Ol52cctevusYuFus6aI8yJt7cBKC1u88LUstRDg6hnoZnbu VoC7aZ5HYgsP6cH5I2ZquxjrRI1vcx350pwHTEqPU/yaMjHwd3ZVUA1dwE6Oxd4h7NPe oYTnWE0EdTgKTPApUkyY/W7s5rHb2cylAxHZ3VBAESEnqXj1MD2PZcV2OolMK+0ytIAM +Lcw== 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:mime-version:content-transfer-encoding; bh=tebtMZETlIDQdWSOMLyAJVULNNmJQHM2vL+aKJmhU6U=; b=tVb3fWFy9sIj6vByKxEeZ/tUbJ8usTMl1bD04kunIfOIIVVNL7DUOgBgr85fQkX1oN dZKOI95s+6xLjp9zwFnmeUAB8lHTqa4dd5wbFClauUzvldj+vAXUPjDxYIfDeVnqwlYl xZqx0ayIKSX+tUcfwSyCwfmCuW3tv5K1omLDXqffoYmQqCW49izWD+mgQlDRafpDQ0ua dbnMvhdCD6AVEEHtCMbs+vlP4pKnng3MlEROcW1jcPZjZJ+HvezzfFfw+qjDg1YLimH5 QVUFN7KadDv+k/myZrmKxHBTrK9eN8u/ImNwhDb1uQ1yWIQ5zVXMYj4zcbXTGggJIXE/ bfGA== X-Gm-Message-State: APjAAAWL+UbrRxf1mvIHQaWwSrVCRs+rrzBuFNBKVuKRUoHWJ/F5YGKl O8sUW/sZMR7MOK7jDkUNDRXb5rQ01VA= X-Received: by 2002:a17:902:84:: with SMTP id a4mr15342052pla.210.1557514485101; Fri, 10 May 2019 11:54:45 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id q20sm12733146pfi.166.2019.05.10.11.54.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 11:54:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 11:54:34 -0700 Message-Id: <20190510185438.29533-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510185438.29533-1-richard.henderson@linaro.org> References: <20190510185438.29533-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::644 Subject: [Qemu-devel] [PULL v2 12/27] target/mips: 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: Aleksandar Rikalo , peter.maydell@linaro.org, Aleksandar Markovic Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that env->active_tc.PC is removed from the qemu_log as that value is garbage. The PC isn't recovered until cpu_restore_state, called from cpu_loop_exit_restore, called from do_raise_exception_err. Cc: Aleksandar Markovic Cc: Aleksandar Rikalo Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/mips/internal.h | 5 +++-- target/mips/cpu.c | 5 ++--- target/mips/helper.c | 45 ++++++++++++++++++++++------------------- target/mips/op_helper.c | 15 -------------- 4 files changed, 29 insertions(+), 41 deletions(-) -- 2.17.1 diff --git a/target/mips/internal.h b/target/mips/internal.h index 286e3888ab..b2b41a51ab 100644 --- a/target/mips/internal.h +++ b/target/mips/internal.h @@ -202,8 +202,9 @@ void cpu_mips_start_count(CPUMIPSState *env); void cpu_mips_stop_count(CPUMIPSState *env); /* helper.c */ -int mips_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw, - int mmu_idx); +bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); /* op_helper.c */ uint32_t float_class_s(uint32_t arg, float_status *fst); diff --git a/target/mips/cpu.c b/target/mips/cpu.c index e217fb3e36..a33058609a 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -197,9 +197,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->synchronize_from_tb = mips_cpu_synchronize_from_tb; cc->gdb_read_register = mips_cpu_gdb_read_register; cc->gdb_write_register = mips_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = mips_cpu_handle_mmu_fault; -#else +#ifndef CONFIG_USER_ONLY cc->do_unassigned_access = mips_cpu_unassigned_access; cc->do_unaligned_access = mips_cpu_do_unaligned_access; cc->get_phys_page_debug = mips_cpu_get_phys_page_debug; @@ -208,6 +206,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data) cc->disas_set_info = mips_cpu_disas_set_info; #ifdef CONFIG_TCG cc->tcg_initialize = mips_tcg_init; + cc->tlb_fill = mips_cpu_tlb_fill; #endif cc->gdb_num_core_regs = 73; diff --git a/target/mips/helper.c b/target/mips/helper.c index 86e622efb8..3a4917ce7b 100644 --- a/target/mips/helper.c +++ b/target/mips/helper.c @@ -874,31 +874,25 @@ refill: #endif #endif -int mips_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, - int mmu_idx) +bool mips_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { MIPSCPU *cpu = MIPS_CPU(cs); CPUMIPSState *env = &cpu->env; #if !defined(CONFIG_USER_ONLY) hwaddr physical; int prot; - int access_type; + int mips_access_type; #endif int ret = TLBRET_BADADDR; -#if 0 - log_cpu_state(cs, 0); -#endif - qemu_log_mask(CPU_LOG_MMU, - "%s pc " TARGET_FMT_lx " ad %" VADDR_PRIx " rw %d mmu_idx %d\n", - __func__, env->active_tc.PC, address, rw, mmu_idx); - /* data access */ #if !defined(CONFIG_USER_ONLY) /* XXX: put correct access by using cpu_restore_state() correctly */ - access_type = ACCESS_INT; - ret = get_physical_address(env, &physical, &prot, - address, rw, access_type, mmu_idx); + mips_access_type = ACCESS_INT; + ret = get_physical_address(env, &physical, &prot, address, + access_type, mips_access_type, mmu_idx); switch (ret) { case TLBRET_MATCH: qemu_log_mask(CPU_LOG_MMU, @@ -915,7 +909,7 @@ int mips_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, tlb_set_page(cs, address & TARGET_PAGE_MASK, physical & TARGET_PAGE_MASK, prot | PAGE_EXEC, mmu_idx, TARGET_PAGE_SIZE); - return 0; + return true; } #if !defined(TARGET_MIPS64) if ((ret == TLBRET_NOMATCH) && (env->tlb->nb_tlb > 1)) { @@ -926,27 +920,36 @@ int mips_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, int mode = (env->hflags & MIPS_HFLAG_KSU); bool ret_walker; env->hflags &= ~MIPS_HFLAG_KSU; - ret_walker = page_table_walk_refill(env, address, rw, mmu_idx); + ret_walker = page_table_walk_refill(env, address, access_type, mmu_idx); env->hflags |= mode; if (ret_walker) { - ret = get_physical_address(env, &physical, &prot, - address, rw, access_type, mmu_idx); + ret = get_physical_address(env, &physical, &prot, address, + access_type, mips_access_type, mmu_idx); if (ret == TLBRET_MATCH) { tlb_set_page(cs, address & TARGET_PAGE_MASK, physical & TARGET_PAGE_MASK, prot | PAGE_EXEC, mmu_idx, TARGET_PAGE_SIZE); - return 0; + return true; } } } #endif + if (probe) { + return false; + } #endif - raise_mmu_exception(env, address, rw, ret); - return 1; + raise_mmu_exception(env, address, access_type, ret); + do_raise_exception_err(env, cs->exception_index, env->error_code, retaddr); +} + +#ifndef CONFIG_USER_ONLY +void tlb_fill(CPUState *cs, target_ulong addr, int size, + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) +{ + mips_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr); } -#if !defined(CONFIG_USER_ONLY) hwaddr cpu_mips_translate_address(CPUMIPSState *env, target_ulong address, int rw) { hwaddr physical; diff --git a/target/mips/op_helper.c b/target/mips/op_helper.c index 0f272a5b93..6d86912958 100644 --- a/target/mips/op_helper.c +++ b/target/mips/op_helper.c @@ -2669,21 +2669,6 @@ void mips_cpu_do_unaligned_access(CPUState *cs, vaddr addr, do_raise_exception_err(env, excp, error_code, retaddr); } -void tlb_fill(CPUState *cs, target_ulong addr, int size, - MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) -{ - int ret; - - ret = mips_cpu_handle_mmu_fault(cs, addr, size, access_type, mmu_idx); - if (ret) { - MIPSCPU *cpu = MIPS_CPU(cs); - CPUMIPSState *env = &cpu->env; - - do_raise_exception_err(env, cs->exception_index, - env->error_code, retaddr); - } -} - void mips_cpu_unassigned_access(CPUState *cs, hwaddr addr, bool is_write, bool is_exec, int unused, unsigned size)