From nobody Tue Feb 10 03:56:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1557441841; cv=none; d=zoho.com; s=zohoarc; b=agj4ThipAVRY3VLHn55DU+qhaGB4EWfocl6pwkpOv1ShWN311ICG4NZaHJ/mAWj6HJM6ec27zfS95eSK23tQqHYIysMiRnW2XdNy1JBvcRBR6GpRMvVoUXkSdncd+SQSLi5p89mjedbP+X9FxHPd5lei5jRByrwwxSzInCxlscs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557441841; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=epdYlBTiLaV9VQx6jCDpGmNhfjLLlYzffabxUVX4RgQ=; b=QISdZ9tKtVuCsmX/cZFARxLJg2mcCpZhUj+pwpTYwvtvxiSowXplefg01zSA4uXJuk0Km8cnVXSALMnQ0Ac4PagllLdYZAuLy7aQqK3r+ch88herOcyP2pJ1BiAnYuXTFExrf4jDT+FIeBnXrtIMmCWSBtItUCNPlimTMqExpLU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 155744184193992.3311427546854; Thu, 9 May 2019 15:44:01 -0700 (PDT) Received: from localhost ([127.0.0.1]:33684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOrlY-0005ZP-Rc for importer@patchew.org; Thu, 09 May 2019 18:43:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:32928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOrV0-0007di-RT for qemu-devel@nongnu.org; Thu, 09 May 2019 18:26:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOrUz-0005SX-IY for qemu-devel@nongnu.org; Thu, 09 May 2019 18:26:46 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:41937) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOrUz-0005SJ-BJ for qemu-devel@nongnu.org; Thu, 09 May 2019 18:26:45 -0400 Received: by mail-pf1-x442.google.com with SMTP id l132so2041176pfc.8 for ; Thu, 09 May 2019 15:26: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 m2sm4490521pfi.24.2019.05.09.15.26.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 15:26:43 -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=epdYlBTiLaV9VQx6jCDpGmNhfjLLlYzffabxUVX4RgQ=; b=cAhr9Lg+v2BVuh68BTLHS1TLe8IlJdh1TBMtrxB985BXS4VUn0TVAs/Pwp/8YL9izK r1J/YFSmdIDMlOUuWoqIJyBRaLitMtarkNDiBce5Ld+lhI7XxZJmb5G3E45oAVw6K+dG 4oyIvNntKg67qxQg3kVutyyPrGbWawtgI9li22NNyA4A+73q1UrX8ztdxj2wkEP2/Ilc 9ZVB9IXRptq1xyGHUn4XwEQJ0ddmKtNrpUfsvkePxAvMcPazEqQ1yCH83ivEsj8g7mrZ oos0/hAPvVbNR0/wp0/n2ObV5byRcKPTTidK4O1aY8JkY/HQ0iX2ZS04iP52D5rByVQ+ euvQ== 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=epdYlBTiLaV9VQx6jCDpGmNhfjLLlYzffabxUVX4RgQ=; b=QsrjpbEbLFrt+Rm78cQFvLTQz74VV1qCTqWzhvUOnDoblzrT8piUCun+QNRniBLLoQ iD8faomEDMfSUIkojcfHZ/Wuuj5ECssIRjbsTCiHIZpIX3j8O5iUqfiirtFRSz72Yzu0 0hx4XVqQCwTxmpSqzfOHuriCUqo2VeiqzSeMvzUly2+1WTJ3ABipsbh9gglnpgqdebhq qOD5NWWGH/ppZHF7AUOqNqgyY8w7cOi9rdMmwBuOkiHIUdY2wTnBNSHwJOLCm0L3dDB0 Anz9JGEzFJ2i3gtHlnA0d2DNECiZfLaGy5oxMNcsolvnKKCSEvstziKZM4Izc+kX8fyI pt3w== X-Gm-Message-State: APjAAAXuw9qGDGcKtS9bQ0SRiWR0kku3Y3sz/Ce0L2tSFfnaEq6ejlxF UO+4O0tsI4u/Hb3Wm/fDg7+GHZyY63g= X-Google-Smtp-Source: APXvYqz6Zyw/vsikI8lE53+BFSZ2evJ1mHfQefuFFm7KK8GpyECv3xKCar/jx97AxZ+zzAhulF9x9w== X-Received: by 2002:a62:ee05:: with SMTP id e5mr7210282pfi.117.1557440804035; Thu, 09 May 2019 15:26:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 9 May 2019 15:26:12 -0700 Message-Id: <20190509222631.14271-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190509222631.14271-1-richard.henderson@linaro.org> References: <20190509222631.14271-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::442 Subject: [Qemu-devel] [PATCH v3 08/27] target/m68k: 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: Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Cc: Laurent Vivier Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/m68k/cpu.h | 5 ++- target/m68k/cpu.c | 2 +- target/m68k/helper.c | 87 ++++++++++++++++++++++------------------- target/m68k/op_helper.c | 15 ------- 4 files changed, 50 insertions(+), 59 deletions(-) diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index ad41608341..683d3e2f79 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -542,8 +542,9 @@ static inline int cpu_mmu_index (CPUM68KState *env, boo= l ifetch) return (env->sr & SR_S) =3D=3D 0 ? 1 : 0; } =20 -int m68k_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int = rw, - int mmu_idx); +bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); void m68k_cpu_unassigned_access(CPUState *cs, hwaddr addr, bool is_write, bool is_exec, int is_asi, unsigned size); diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 582e3a73b3..6f441bc973 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -269,7 +269,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *d= ata) cc->set_pc =3D m68k_cpu_set_pc; cc->gdb_read_register =3D m68k_cpu_gdb_read_register; cc->gdb_write_register =3D m68k_cpu_gdb_write_register; - cc->handle_mmu_fault =3D m68k_cpu_handle_mmu_fault; + cc->tlb_fill =3D m68k_cpu_tlb_fill; #if defined(CONFIG_SOFTMMU) cc->do_unassigned_access =3D m68k_cpu_unassigned_access; cc->get_phys_page_debug =3D m68k_cpu_get_phys_page_debug; diff --git a/target/m68k/helper.c b/target/m68k/helper.c index d958a34959..862f955f7b 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -353,20 +353,7 @@ void m68k_switch_sp(CPUM68KState *env) env->current_sp =3D new_sp; } =20 -#if defined(CONFIG_USER_ONLY) - -int m68k_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int r= w, - int mmu_idx) -{ - M68kCPU *cpu =3D M68K_CPU(cs); - - cs->exception_index =3D EXCP_ACCESS; - cpu->env.mmu.ar =3D address; - return 1; -} - -#else - +#if !defined(CONFIG_USER_ONLY) /* MMU: 68040 only */ =20 static void print_address_zone(uint32_t logical, uint32_t physical, @@ -795,11 +782,36 @@ hwaddr m68k_cpu_get_phys_page_debug(CPUState *cs, vad= dr addr) return phys_addr; } =20 -int m68k_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int r= w, - int mmu_idx) +/* + * Notify CPU of a pending interrupt. Prioritization and vectoring should + * be handled by the interrupt controller. Real hardware only requests + * the vector when the interrupt is acknowledged by the CPU. For + * simplicity we calculate it when the interrupt is signalled. + */ +void m68k_set_irq_level(M68kCPU *cpu, int level, uint8_t vector) +{ + CPUState *cs =3D CPU(cpu); + CPUM68KState *env =3D &cpu->env; + + env->pending_level =3D level; + env->pending_vector =3D vector; + if (level) { + cpu_interrupt(cs, CPU_INTERRUPT_HARD); + } else { + cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); + } +} + +#endif + +bool m68k_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType qemu_access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { M68kCPU *cpu =3D M68K_CPU(cs); CPUM68KState *env =3D &cpu->env; + +#ifndef CONFIG_USER_ONLY hwaddr physical; int prot; int access_type; @@ -812,32 +824,35 @@ int m68k_cpu_handle_mmu_fault(CPUState *cs, vaddr add= ress, int size, int rw, address & TARGET_PAGE_MASK, PAGE_READ | PAGE_WRITE | PAGE_EXEC, mmu_idx, TARGET_PAGE_SIZE); - return 0; + return true; } =20 - if (rw =3D=3D 2) { + if (qemu_access_type =3D=3D MMU_INST_FETCH) { access_type =3D ACCESS_CODE; - rw =3D 0; } else { access_type =3D ACCESS_DATA; - if (rw) { + if (qemu_access_type =3D=3D MMU_DATA_STORE) { access_type |=3D ACCESS_STORE; } } - if (mmu_idx !=3D MMU_USER_IDX) { access_type |=3D ACCESS_SUPER; } =20 ret =3D get_physical_address(&cpu->env, &physical, &prot, address, access_type, &page_size); - if (ret =3D=3D 0) { + if (likely(ret =3D=3D 0)) { address &=3D TARGET_PAGE_MASK; physical +=3D address & (page_size - 1); tlb_set_page(cs, address, physical, prot, mmu_idx, TARGET_PAGE_SIZE); - return 0; + return true; } + + if (probe) { + return false; + } + /* page fault */ env->mmu.ssw =3D M68K_ATC_040; switch (size) { @@ -862,29 +877,19 @@ int m68k_cpu_handle_mmu_fault(CPUState *cs, vaddr add= ress, int size, int rw, if (!(access_type & ACCESS_STORE)) { env->mmu.ssw |=3D M68K_RW_040; } - env->mmu.ar =3D address; +#endif + cs->exception_index =3D EXCP_ACCESS; - return 1; + env->mmu.ar =3D address; + cpu_loop_exit_restore(cs, retaddr); } =20 -/* Notify CPU of a pending interrupt. Prioritization and vectoring should - be handled by the interrupt controller. Real hardware only requests - the vector when the interrupt is acknowledged by the CPU. For - simplicitly we calculate it when the interrupt is signalled. */ -void m68k_set_irq_level(M68kCPU *cpu, int level, uint8_t vector) +#ifndef CONFIG_USER_ONLY +void tlb_fill(CPUState *cs, target_ulong addr, int size, + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - CPUState *cs =3D CPU(cpu); - CPUM68KState *env =3D &cpu->env; - - env->pending_level =3D level; - env->pending_vector =3D vector; - if (level) { - cpu_interrupt(cs, CPU_INTERRUPT_HARD); - } else { - cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); - } + m68k_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr= ); } - #endif =20 uint32_t HELPER(bitrev)(uint32_t x) diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index 76f439985a..d421614727 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -36,21 +36,6 @@ static inline void do_interrupt_m68k_hardirq(CPUM68KStat= e *env) =20 #else =20 -/* 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 =3D m68k_cpu_handle_mmu_fault(cs, addr, size, access_type, mmu_idx= ); - if (unlikely(ret)) { - /* now we have a real cpu fault */ - cpu_loop_exit_restore(cs, retaddr); - } -} - static void cf_rte(CPUM68KState *env) { uint32_t sp; --=20 2.17.1