From patchwork Thu May 9 06:02: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: 163670 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp547586ilr; Wed, 8 May 2019 23:11:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzyl9LdiMskvQeFmqiZQ8Istll97RQXStdlepx6XOhNaKwCM9P56BysM1Ppw5bLXJ/pvcdN X-Received: by 2002:a1c:80d7:: with SMTP id b206mr1323726wmd.48.1557382312676; Wed, 08 May 2019 23:11:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557382312; cv=none; d=google.com; s=arc-20160816; b=y2hLeMW3nHsRjjrKXWMiHUwPcznGAlM8xXtmwA8/C9TEXhBVqF1rDwxuzDGZkvC7Jp 3+CyWKPveNEs6f2k3skjILTmFkwzw51qK5jZPRJaXXhxFehCNbFvSfnaZo35FVYmyfKh GhhCd/YYdCV3SBf3wLewBtOApdKC8bxEZFCf3eizMfa1LZa/vucoEQmBb9mdykBVhg4x BB07jPy0TNo8nlAYMOy6I40WqI3jL2P7C0d+aAtTbnM+JfZnh7cnRcDe1oMvGyEzH8A+ dDnahOgUjYaen3P1bQyZn5LiRtSego3zi4648xTndc7urwksz+NLu/HKTr2cC7qLAwjo DjQQ== 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=SbdgfaYjW8ILfhiu0/mJqWKm/tBVnd5f44zvoNG8J24=; b=RqIA9jGQC9qwmpIHHg9FWqNWtS+CGewlbsjoU5L7g2SfPCp5fXEqoKsEdl3FqB3Ox+ 0URO5PHu6rsm6eeFL9RNJd/tQze/5/QdnDKS7OgoenpoYoOQp0pHYz+/VNqAwWwwqZ4p KDERh5P/oi5VnCQQEf6mH/nGiFwQtaSmo43WWSCevE/XFGhTkuj+uCDNlUOZtIo3GV44 3IhUtVqUqvBSnr72LUnP4HP3nNECLdJl9VfKeSCgjNa5YKM9DIVIKBal2+TyO/Mj7saf VMmNkaKDwsGgOPUC2MAnXlkobUTt2zT7ZNwuvJnA3p4r6giA5dAgDBMDnLki7ZdwpU1k AT2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jDwQO+o4; 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 h3si963336wrh.415.2019.05.08.23.11.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 May 2019 23:11:52 -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=jDwQO+o4; 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]:48694 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOcHX-0005sl-HC for patch@linaro.org; Thu, 09 May 2019 02:11:51 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOc95-00064N-Kz for qemu-devel@nongnu.org; Thu, 09 May 2019 02:03:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOc94-00078i-GQ for qemu-devel@nongnu.org; Thu, 09 May 2019 02:03:07 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:44025) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOc94-00078I-AW for qemu-devel@nongnu.org; Thu, 09 May 2019 02:03:06 -0400 Received: by mail-pg1-x544.google.com with SMTP id t22so619389pgi.10 for ; Wed, 08 May 2019 23:03: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=SbdgfaYjW8ILfhiu0/mJqWKm/tBVnd5f44zvoNG8J24=; b=jDwQO+o4P71Y4cY4cnQJeEsM1kiC9c3aZ+io9ORyRcq/WdPUtcEXUzJAYv2s4lGujG fMQSrDFlbvxjOMr9pz5esRYICstDy7yr97zTTHoBoHilP/fq8JUreeW/m/7XX0Cu6YRR meHzUNKLIbY1n4ATASKb5HAOMdks+u4OoNXdWH5KGtgqqUERny9aGNdjsGnY3keP0p01 Ni3jlhOEjxcRkk36wwaZM+rchm3JOg3g6MBeFAhV9c6jLtSd/SJQWBv6596fGxbJVfmw Tb3SB6S6+0XWpMVEMKX+Fp6B5VVn01+wtcI0GCvmMoimI+fKG11C3raqPWZKp09OXoIV 6ZlA== 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=SbdgfaYjW8ILfhiu0/mJqWKm/tBVnd5f44zvoNG8J24=; b=QZ3VU8KI3T/Hb0nvuRZ4IRtj5/t15OXYAKvGeiBO1/K+uaNprXmyVP8b8dTHq7uTTC PZ3qF3r+dc5EIcPoZhv+z3a7CjWMglhqi5w/zV5+MsUw+0gC01k3hjU8SZ1c85fuL+J2 t8G8OFhCXZ07uG+rNhTY1Aj5mza9Pgd0grVvAJIG0iZE7ZeyljS5us00eDWaXCUNRyde qbO/B7XPviDWYaEc44SqeRioiOLmiKy6wq8Icrg0zgzgh+pQNHlpW4ceyX9Eo8iXm0gp 6/bzaEi1IunG0P4c+XvAZc9sKD8g8v9xz1skocrfY/n1Z98f3XiNpeTg5ffjWaz+6UqA qY4g== X-Gm-Message-State: APjAAAUqkzUzPtdO3DYxVKzG4jZru1jEiLcPleanJb/VAzd1LEKdywSz WAll8fN76sWLrEsxg6jGBKydbxp/Zg4= X-Received: by 2002:aa7:81d0:: with SMTP id c16mr2567292pfn.132.1557381785073; Wed, 08 May 2019 23:03:05 -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.03.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 23:03:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 8 May 2019 23:02:32 -0700 Message-Id: <20190509060246.4031-14-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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH v2 13/27] target/moxie: 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: Anthony Green Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Remove the user-only functions, as we don't have a user-only config. Fix the unconditional call to tlb_set_page, even if the translation failed. Cc: Anthony Green Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/moxie/cpu.h | 5 ++-- target/moxie/cpu.c | 5 ++-- target/moxie/helper.c | 61 ++++++++++--------------------------------- 3 files changed, 19 insertions(+), 52 deletions(-) -- 2.17.1 diff --git a/target/moxie/cpu.h b/target/moxie/cpu.h index f3b6d83ae7..a63a96bc05 100644 --- a/target/moxie/cpu.h +++ b/target/moxie/cpu.h @@ -139,7 +139,8 @@ static inline void cpu_get_tb_cpu_state(CPUMoxieState *env, target_ulong *pc, *flags = 0; } -int moxie_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, - int rw, int mmu_idx); +bool moxie_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); #endif /* MOXIE_CPU_H */ diff --git a/target/moxie/cpu.c b/target/moxie/cpu.c index 46434e65ba..02b2b47574 100644 --- a/target/moxie/cpu.c +++ b/target/moxie/cpu.c @@ -112,9 +112,8 @@ static void moxie_cpu_class_init(ObjectClass *oc, void *data) cc->do_interrupt = moxie_cpu_do_interrupt; cc->dump_state = moxie_cpu_dump_state; cc->set_pc = moxie_cpu_set_pc; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = moxie_cpu_handle_mmu_fault; -#else + cc->tlb_fill = moxie_cpu_tlb_fill; +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = moxie_cpu_get_phys_page_debug; cc->vmsd = &vmstate_moxie_cpu; #endif diff --git a/target/moxie/helper.c b/target/moxie/helper.c index 287a45232c..216cef057e 100644 --- a/target/moxie/helper.c +++ b/target/moxie/helper.c @@ -26,18 +26,10 @@ #include "qemu/host-utils.h" #include "exec/helper-proto.h" -/* 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) */ void tlb_fill(CPUState *cs, target_ulong addr, int size, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - int ret; - - ret = moxie_cpu_handle_mmu_fault(cs, addr, size, access_type, mmu_idx); - if (unlikely(ret)) { - cpu_loop_exit_restore(cs, retaddr); - } + moxie_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr); } void helper_raise_exception(CPUMoxieState *env, int ex) @@ -85,53 +77,29 @@ void helper_debug(CPUMoxieState *env) cpu_loop_exit(cs); } -#if defined(CONFIG_USER_ONLY) - -void moxie_cpu_do_interrupt(CPUState *cs) -{ - CPUState *cs = CPU(moxie_env_get_cpu(env)); - - cs->exception_index = -1; -} - -int moxie_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, - int rw, int mmu_idx) -{ - MoxieCPU *cpu = MOXIE_CPU(cs); - - cs->exception_index = 0xaa; - cpu->env.debug1 = address; - cpu_dump_state(cs, stderr, 0); - return 1; -} - -#else /* !CONFIG_USER_ONLY */ - -int moxie_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, - int rw, int mmu_idx) +bool moxie_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { MoxieCPU *cpu = MOXIE_CPU(cs); CPUMoxieState *env = &cpu->env; MoxieMMUResult res; int prot, miss; - target_ulong phy; - int r = 1; address &= TARGET_PAGE_MASK; prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; - miss = moxie_mmu_translate(&res, env, address, rw, mmu_idx); - if (miss) { - /* handle the miss. */ - phy = 0; - cs->exception_index = MOXIE_EX_MMU_MISS; - } else { - phy = res.phy; - r = 0; + miss = moxie_mmu_translate(&res, env, address, access_type, mmu_idx); + if (likely(!miss)) { + tlb_set_page(cs, address, res.phy, prot, mmu_idx, TARGET_PAGE_SIZE); + return true; + } + if (probe) { + return false; } - tlb_set_page(cs, address, phy, prot, mmu_idx, TARGET_PAGE_SIZE); - return r; -} + cs->exception_index = MOXIE_EX_MMU_MISS; + cpu_loop_exit_restore(cs, retaddr); +} void moxie_cpu_do_interrupt(CPUState *cs) { @@ -156,4 +124,3 @@ hwaddr moxie_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) } return phy; } -#endif