From patchwork Fri May 10 18:54: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: 163942 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2753723ilr; Fri, 10 May 2019 11:58:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUcGudDY8So6L9KXTZIaMeXWi5c5TOqI33zUcy4v4iAS9orGbqcJ5vhgNcEbLL/Pr1wfwZ X-Received: by 2002:a17:906:69d6:: with SMTP id g22mr10293511ejs.124.1557514690526; Fri, 10 May 2019 11:58:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557514690; cv=none; d=google.com; s=arc-20160816; b=lAladN4WIRscnF1GoVYhLGFjXtoWjsguvn+aMq5UwJFyByffguPMBCQe01O9CkSw60 5VtnXemvSfnByWSivA15SCDrfhQ3xIb/8xpbEHk268w0C8zGmBUSLFv+rYaa9BMfWDMJ dzSTYfZanEi3wbqw7NNJlcX6EQJPiDX8FDgDUQl1KWEhlfnwDLgPjm4hoHJQk0CewhCP R/CQfAzSoUEXqjmc2wUkNkjaIrTdllWN+lgfwfuYqp1cN36xZL1CVc7ONnyc5ism+Gkw 9xcqtz7KG06D4FswQMJyAobhOspLIoS1b4YxYHpgSMvwNQXtmMBy+y9LbgfOFox7qH53 DLcA== 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=kIP0+bD2TyEk2xdUzlyahVOJ4L+pRPnpI72gFvuwbRA=; b=NN6fXQqm6kZIudoXyvwjSlFiSzSPo3r+ARWSnRq+7Uv+NaWbxFXUh4BkDyF/o/3Yme njxBt5seVIZoEAzgec8ZPWa5Y6DSbtKXOMe6xz1j0TFGr7FcJ//jtraLjJaFte0I8LXo OmTHM1k0RCNM7/RipzXS6UmO+Dl1TShNEpPpcoUzbAgmTrpYtVPlcmdzb9fHY8/vseE0 WgoHLpTPvs1dTvEogRkgz15gXO8W4mYhnla2f+An9k0IUhb02adhDfUl+lPsNJfEx1Dk nhtuDr13BYVr1jZMRPG9qmePlDt+FBlq9Vnh3N17rqj1nN+s4j+ByjciLOUKGW23Cw5Y PQKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mw+PYPGi; 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 x47si4484776edb.353.2019.05.10.11.58.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 11:58:10 -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=mw+PYPGi; 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]:48548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAif-0002QV-Es for patch@linaro.org; Fri, 10 May 2019 14:58:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48214) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAfT-0007u0-JJ for qemu-devel@nongnu.org; Fri, 10 May 2019 14:55:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPAfM-0005i4-I6 for qemu-devel@nongnu.org; Fri, 10 May 2019 14:54:51 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:39584) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hPAfM-0005eR-6N for qemu-devel@nongnu.org; Fri, 10 May 2019 14:54:44 -0400 Received: by mail-pg1-x541.google.com with SMTP id w22so3431263pgi.6 for ; Fri, 10 May 2019 11:54:44 -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=kIP0+bD2TyEk2xdUzlyahVOJ4L+pRPnpI72gFvuwbRA=; b=mw+PYPGiEtM5fnbmPVxbWryQ6otCh/D7zbvkm3SMJHW0Ve08Db9c39Tlm2+9a4XdJB U18iVDkJZYHvol1aWrtyTuKPhrpt8wM4PAVtdL86pTToPJ7jVfVjChbxGQam66QvmGam 23tMWAvuc4Dk/XX3fnV/PUiFqzACbTeOOOnrU2D0ckMYr3HTA1v6P4vmCkxVyFOG0z+6 VJ61T6lNo/rbFAuNAPnEJd7Kb984af+DRIptgFNPl1icT0+mzLlDEwulxA1XvikS2hFT 8tQfOiZ20NYT46Tw7baAqWndcnaw3Y9sfxLtdwEdQ7xyTlM45Wm/vfpBnnuuqXvxDvNH Hkmg== 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=kIP0+bD2TyEk2xdUzlyahVOJ4L+pRPnpI72gFvuwbRA=; b=hkHFQqfXMcc7UvYiitMbbC59iZVFLXHZLJ1oUBynXBoUq3bz9wR5Y3H3301mhivp6H FBDIlccV01UM0ZecQFUvTDudeQz5BbcnT4twpVz25LsorXQF2P1ifdrkt9TZujiwCh0J uezKZHwKmwOmNYeqgm6nlZeam1xHWwGYF8MgByYfQXobFFVjxGN+lWPt/RFYG5DfN9RJ mTsHa82zTKzYiiS1jfY/hDSoKRpaSvZwZI+dztm+a+CPgb1TMMoULlEdW+UGYEnS2ht9 +2aGL+Nomzj1qgHV+cJemqgEIcGr8MnGZhe6I2rEycpv2LdOwCedTOTQssnou4oX6IB/ QUjw== X-Gm-Message-State: APjAAAXtUd5/vScEV0hkEDgyCe6Pxzlt0/qBTZaIWKPesUXZJN2SGTpP MUj413x1kG+i5XStHLqiC3zMWIrRalw= X-Received: by 2002:a63:5c5b:: with SMTP id n27mr16053073pgm.52.1557514482716; Fri, 10 May 2019 11:54:42 -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.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 11:54:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 11:54:32 -0700 Message-Id: <20190510185438.29533-2-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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PULL v2 03/27] target/arm: 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, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: qemu-arm@nongnu.org Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/internals.h | 10 +++-- target/arm/cpu.c | 22 +--------- target/arm/helper.c | 98 ++++++++++++++++++++++++++---------------- target/arm/op_helper.c | 29 ++----------- 4 files changed, 73 insertions(+), 86 deletions(-) -- 2.17.1 diff --git a/target/arm/internals.h b/target/arm/internals.h index 587a1ddf58..5a02f458f3 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -761,10 +761,12 @@ static inline bool arm_extabort_type(MemTxResult result) return result != MEMTX_DECODE_ERROR; } -/* Do a page table walk and add page to TLB if possible */ -bool arm_tlb_fill(CPUState *cpu, vaddr address, - MMUAccessType access_type, int mmu_idx, - ARMMMUFaultInfo *fi); +bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); + +void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, + int mmu_idx, ARMMMUFaultInfo *fi) QEMU_NORETURN; /* Return true if the stage 1 translation regime is using LPAE format page * tables */ diff --git a/target/arm/cpu.c b/target/arm/cpu.c index a181fa8dc1..8eee1d8c59 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2133,23 +2133,6 @@ static Property arm_cpu_properties[] = { DEFINE_PROP_END_OF_LIST() }; -#ifdef CONFIG_USER_ONLY -static int arm_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, - int rw, int mmu_idx) -{ - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - - env->exception.vaddress = address; - if (rw == 2) { - cs->exception_index = EXCP_PREFETCH_ABORT; - } else { - cs->exception_index = EXCP_DATA_ABORT; - } - return 1; -} -#endif - static gchar *arm_gdb_arch_name(CPUState *cs) { ARMCPU *cpu = ARM_CPU(cs); @@ -2182,9 +2165,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->synchronize_from_tb = arm_cpu_synchronize_from_tb; cc->gdb_read_register = arm_cpu_gdb_read_register; cc->gdb_write_register = arm_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = arm_cpu_handle_mmu_fault; -#else +#ifndef CONFIG_USER_ONLY cc->do_interrupt = arm_cpu_do_interrupt; cc->do_unaligned_access = arm_cpu_do_unaligned_access; cc->do_transaction_failed = arm_cpu_do_transaction_failed; @@ -2209,6 +2190,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->disas_set_info = arm_disas_set_info; #ifdef CONFIG_TCG cc->tcg_initialize = arm_translate_init; + cc->tlb_fill = arm_cpu_tlb_fill; #endif } diff --git a/target/arm/helper.c b/target/arm/helper.c index 1e6eb0d0f3..f1a2b94ddb 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -12596,43 +12596,6 @@ static bool get_phys_addr(CPUARMState *env, target_ulong address, } } -/* Walk the page table and (if the mapping exists) add the page - * to the TLB. Return false on success, or true on failure. Populate - * fsr with ARM DFSR/IFSR fault register format value on failure. - */ -bool arm_tlb_fill(CPUState *cs, vaddr address, - MMUAccessType access_type, int mmu_idx, - ARMMMUFaultInfo *fi) -{ - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - hwaddr phys_addr; - target_ulong page_size; - int prot; - int ret; - MemTxAttrs attrs = {}; - - ret = get_phys_addr(env, address, access_type, - core_to_arm_mmu_idx(env, mmu_idx), &phys_addr, - &attrs, &prot, &page_size, fi, NULL); - if (!ret) { - /* - * Map a single [sub]page. Regions smaller than our declared - * target page size are handled specially, so for those we - * pass in the exact addresses. - */ - if (page_size >= TARGET_PAGE_SIZE) { - phys_addr &= TARGET_PAGE_MASK; - address &= TARGET_PAGE_MASK; - } - tlb_set_page_with_attrs(cs, address, phys_addr, attrs, - prot, mmu_idx, page_size); - return 0; - } - - return ret; -} - hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, MemTxAttrs *attrs) { @@ -13111,6 +13074,67 @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) #endif +bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) +{ + ARMCPU *cpu = ARM_CPU(cs); + +#ifdef CONFIG_USER_ONLY + cpu->env.exception.vaddress = address; + if (access_type == MMU_INST_FETCH) { + cs->exception_index = EXCP_PREFETCH_ABORT; + } else { + cs->exception_index = EXCP_DATA_ABORT; + } + cpu_loop_exit_restore(cs, retaddr); +#else + hwaddr phys_addr; + target_ulong page_size; + int prot, ret; + MemTxAttrs attrs = {}; + ARMMMUFaultInfo fi = {}; + + /* + * Walk the page table and (if the mapping exists) add the page + * to the TLB. On success, return true. Otherwise, if probing, + * return false. Otherwise populate fsr with ARM DFSR/IFSR fault + * register format, and signal the fault. + */ + ret = get_phys_addr(&cpu->env, address, access_type, + core_to_arm_mmu_idx(&cpu->env, mmu_idx), + &phys_addr, &attrs, &prot, &page_size, &fi, NULL); + if (likely(!ret)) { + /* + * Map a single [sub]page. Regions smaller than our declared + * target page size are handled specially, so for those we + * pass in the exact addresses. + */ + if (page_size >= TARGET_PAGE_SIZE) { + phys_addr &= TARGET_PAGE_MASK; + address &= TARGET_PAGE_MASK; + } + tlb_set_page_with_attrs(cs, address, phys_addr, attrs, + prot, mmu_idx, page_size); + return true; + } else if (probe) { + return false; + } else { + /* now we have a real cpu fault */ + cpu_restore_state(cs, retaddr, true); + arm_deliver_fault(cpu, address, access_type, mmu_idx, &fi); + } +#endif +} + +#ifndef CONFIG_USER_ONLY +void tlb_fill(CPUState *cs, target_ulong addr, int size, + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) +{ + arm_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr); +} +#endif + void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) { /* Implement DC ZVA, which zeroes a fixed-length block of memory. diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index 8698b4dc83..8ee15a4bd4 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -126,8 +126,8 @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn, return syn; } -static void deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, - int mmu_idx, ARMMMUFaultInfo *fi) +void arm_deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, + int mmu_idx, ARMMMUFaultInfo *fi) { CPUARMState *env = &cpu->env; int target_el; @@ -179,27 +179,6 @@ static void deliver_fault(ARMCPU *cpu, vaddr addr, MMUAccessType access_type, raise_exception(env, exc, syn, target_el); } -/* 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) -{ - bool ret; - ARMMMUFaultInfo fi = {}; - - ret = arm_tlb_fill(cs, addr, access_type, mmu_idx, &fi); - if (unlikely(ret)) { - ARMCPU *cpu = ARM_CPU(cs); - - /* now we have a real cpu fault */ - cpu_restore_state(cs, retaddr, true); - - deliver_fault(cpu, addr, access_type, mmu_idx, &fi); - } -} - /* Raise a data fault alignment exception for the specified virtual address */ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, MMUAccessType access_type, @@ -212,7 +191,7 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, cpu_restore_state(cs, retaddr, true); fi.type = ARMFault_Alignment; - deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi); + arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi); } /* arm_cpu_do_transaction_failed: handle a memory system error response @@ -233,7 +212,7 @@ void arm_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, fi.ea = arm_extabort_type(response); fi.type = ARMFault_SyncExternal; - deliver_fault(cpu, addr, access_type, mmu_idx, &fi); + arm_deliver_fault(cpu, addr, access_type, mmu_idx, &fi); } #endif /* !defined(CONFIG_USER_ONLY) */ From patchwork Fri May 10 18:54:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163937 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2751485ilr; Fri, 10 May 2019 11:55:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxM8QgmWT1eoF0GUrnQEe3qbhfFJUT+2JqhgoufsBVbO0+aoHIc4PyfDruHsV6uqL85+hx2 X-Received: by 2002:a05:6402:28f:: with SMTP id l15mr13073164edv.242.1557514524725; Fri, 10 May 2019 11:55:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557514524; cv=none; d=google.com; s=arc-20160816; b=QexcDaE06zdGRzYjUP9tyKgpq8Pmnth8LVghbi3CeKsnMRz2lOoq2q5FA8cuDFsxOE 6HE0/8R4DTljjMuv09YtTML+I/X2/ZwG3Ya50pW7z44ewbu0d6Lohib7jPCkD0RSUAiZ IIvY6UOKfZdDpL2fkgZbj3Pk50maUjmYSAK8Cni1riCOV+qnxPGyE4qgj/ghpHI92cEf p5saZ/oQRUEgO7DVk1tBIzW99VNrqM8PK9Zm++ifGifWiYk6uSw5Kx+5kEYzRvaJo3NM NCw5hDCKsamjrhqRxg1r+vrC3thg960LOIpemELYEQbTgCifkHh1+Bvt9TPbUHZXAGfe vVgw== 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=7sj9GIEuhTArqwILM67FCe/uDj2RVB+d9OsVw0TMgJw=; b=Pp3/4lgaEEc/oA4QU6Cqbpb3yqzxSCwD6gfAR+5XwkQJ4uCqLP3tzNVA7bKSrFmB/4 IR1E1M34fklqYgVqx9+HV7n3MzkX7qrpmVji2EYCZrynoAvXfVzthtxy+PxVZujcUB29 OUD/RdHboQmvLA9drSkxc+VILpT3YVos6GVbw4mpGQKQh4deAAfUApD7BXQrC9+VXeqR VhDctHhfp/WrKlqt8U5ERhNOcT/weASh+nveDOUqvHMWj75/KcBkfpsfp/zjyezidA2Y cY0KLGy48aKp3nBZANPUsz6cTCySejmxYsv4557Y1EXSmQCR+rdncPAnjrupbhpQ91ws arng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ceN6wPQ5; 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 l3si3987714edl.135.2019.05.10.11.55.24 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 11:55:24 -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=ceN6wPQ5; 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]:48499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAfz-000813-Jj for patch@linaro.org; Fri, 10 May 2019 14:55:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAfU-0007uh-Te for qemu-devel@nongnu.org; Fri, 10 May 2019 14:55:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPAfN-0005lf-SU for qemu-devel@nongnu.org; Fri, 10 May 2019 14:54:52 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]:34041) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hPAfN-0005jA-I3 for qemu-devel@nongnu.org; Fri, 10 May 2019 14:54:45 -0400 Received: by mail-pl1-x634.google.com with SMTP id w7so3253047plz.1 for ; Fri, 10 May 2019 11:54:45 -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=7sj9GIEuhTArqwILM67FCe/uDj2RVB+d9OsVw0TMgJw=; b=ceN6wPQ5RHOwrXdQvckRBkr28MdbNAPX5fRmDKtjmkVnKI4D1Xj9+NPsxIag/FF86K /jaH9c6aILlykXxI8tTH5UuVBKewsWQHSPsEjy9ofvO/pID1QQ7Ak9vJv1rtY+BgcvmF j4Rck6ZgW8UHE0pvJqEYn6wOVx3oSVetiKcgvGgls3I8SusVH4JhbAcVLyY6E5W3tPK5 YrtcowkbXub28/UBunMmyymEmIDd6DwoZcySfUfGQbiXphxiDK61GHWLKa1bgFDcz/A7 /ZNFHijmQux30qTxdoyFAuyVGW8PxYMZpPuELyVWDnNxO7oQepxXrDG48IMBsDEs5zEs AenQ== 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=7sj9GIEuhTArqwILM67FCe/uDj2RVB+d9OsVw0TMgJw=; b=bM86HeLYkyOngKeYAEX4rKdVor1QX+OdMnHh2I/IJuvspIPN6Z1JCbyU92q/CyB2NY WmpsmMCWBchAQt5n3cdBb/LKE9L2xi7HOgN3g971sZJNxozfO+Z8Vy2jK6bpJMEzVl6v mQ95SYNsjvlsHkq0Z70f5TVpERdwdV76QFbAkbFBlBx53QX+WZgPx+pbxxxw87QfEwTF ouFChMVSq81E/g/xVujT2HRVqxIB3KLFjdwONNLFgOdkWFcgYWM99OwSI4GmlgZLzOMX D0fv5RlIXXFoSIEYm6U5sxJLCTnAum+eRz8gSOa2wrf0skCY1wXAK+zGUqo07AMzhYsc t2Yg== X-Gm-Message-State: APjAAAVlUJyj2kQjrLsdfAsvlvh6C/SHQeYGgR1GPHSwuLKPT0b3Skgo YYsC1/7e7bgreHXv5OazGLcBxLX4vVQ= X-Received: by 2002:a17:902:e583:: with SMTP id cl3mr15237805plb.35.1557514483948; Fri, 10 May 2019 11:54:43 -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.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 11:54:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 11:54:33 -0700 Message-Id: <20190510185438.29533-3-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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::634 Subject: [Qemu-devel] [PULL v2 06/27] target/i386: 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, Eduardo Habkost , Paolo Bonzini Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We do not support probing, but we do not need it yet either. Cc: Paolo Bonzini Cc: Eduardo Habkost Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/i386/cpu.h | 5 ++-- target/i386/cpu.c | 5 ++-- target/i386/excp_helper.c | 61 +++++++++++++++++++++++++-------------- target/i386/mem_helper.c | 21 -------------- 4 files changed, 44 insertions(+), 48 deletions(-) -- 2.17.1 diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 0128910661..fce6660bac 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1656,8 +1656,9 @@ void host_cpuid(uint32_t function, uint32_t count, void host_vendor_fms(char *vendor, int *family, int *model, int *stepping); /* helper.c */ -int x86_cpu_handle_mmu_fault(CPUState *cpu, vaddr addr, int size, - int is_write, int mmu_idx); +bool x86_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); void x86_cpu_set_a20(X86CPU *cpu, int a20_state); #ifndef CONFIG_USER_ONLY diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 722c5514d4..2df56fa977 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5915,9 +5915,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->gdb_write_register = x86_cpu_gdb_write_register; cc->get_arch_id = x86_cpu_get_arch_id; cc->get_paging_enabled = x86_cpu_get_paging_enabled; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = x86_cpu_handle_mmu_fault; -#else +#ifndef CONFIG_USER_ONLY cc->asidx_from_attrs = x86_asidx_from_attrs; cc->get_memory_mapping = x86_cpu_get_memory_mapping; cc->get_phys_page_debug = x86_cpu_get_phys_page_debug; @@ -5942,6 +5940,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->cpu_exec_exit = x86_cpu_exec_exit; #ifdef CONFIG_TCG cc->tcg_initialize = tcg_x86_init; + cc->tlb_fill = x86_cpu_tlb_fill; #endif cc->disas_set_info = x86_disas_set_info; diff --git a/target/i386/excp_helper.c b/target/i386/excp_helper.c index 49231f6b69..68bf8e3f7c 100644 --- a/target/i386/excp_helper.c +++ b/target/i386/excp_helper.c @@ -137,26 +137,7 @@ void raise_exception_ra(CPUX86State *env, int exception_index, uintptr_t retaddr raise_interrupt2(env, exception_index, 0, 0, 0, retaddr); } -#if defined(CONFIG_USER_ONLY) -int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, int size, - int is_write, int mmu_idx) -{ - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; - - /* user mode only emulation */ - is_write &= 1; - env->cr[2] = addr; - env->error_code = (is_write << PG_ERROR_W_BIT); - env->error_code |= PG_ERROR_U_MASK; - cs->exception_index = EXCP0E_PAGE; - env->exception_is_int = 0; - env->exception_next_eip = -1; - return 1; -} - -#else - +#if !defined(CONFIG_USER_ONLY) static hwaddr get_hphys(CPUState *cs, hwaddr gphys, MMUAccessType access_type, int *prot) { @@ -365,8 +346,8 @@ static hwaddr get_hphys(CPUState *cs, hwaddr gphys, MMUAccessType access_type, * 0 = nothing more to do * 1 = generate PF fault */ -int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, int size, - int is_write1, int mmu_idx) +static int handle_mmu_fault(CPUState *cs, vaddr addr, int size, + int is_write1, int mmu_idx) { X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; @@ -691,3 +672,39 @@ do_check_protect_pse36: return 1; } #endif + +bool x86_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) +{ + X86CPU *cpu = X86_CPU(cs); + CPUX86State *env = &cpu->env; + +#ifdef CONFIG_USER_ONLY + /* user mode only emulation */ + env->cr[2] = addr; + env->error_code = (access_type == MMU_DATA_STORE) << PG_ERROR_W_BIT; + env->error_code |= PG_ERROR_U_MASK; + cs->exception_index = EXCP0E_PAGE; + env->exception_is_int = 0; + env->exception_next_eip = -1; + cpu_loop_exit_restore(cs, retaddr); +#else + env->retaddr = retaddr; + if (handle_mmu_fault(cs, addr, size, access_type, mmu_idx)) { + /* FIXME: On error in get_hphys we have already jumped out. */ + g_assert(!probe); + raise_exception_err_ra(env, cs->exception_index, + env->error_code, retaddr); + } + return true; +#endif +} + +#if !defined(CONFIG_USER_ONLY) +void tlb_fill(CPUState *cs, target_ulong addr, int size, + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) +{ + x86_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr); +} +#endif diff --git a/target/i386/mem_helper.c b/target/i386/mem_helper.c index 6cc53bcb40..1885df29d2 100644 --- a/target/i386/mem_helper.c +++ b/target/i386/mem_helper.c @@ -191,24 +191,3 @@ void helper_boundl(CPUX86State *env, target_ulong a0, int v) raise_exception_ra(env, EXCP05_BOUND, GETPC()); } } - -#if !defined(CONFIG_USER_ONLY) -/* 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) -{ - X86CPU *cpu = X86_CPU(cs); - CPUX86State *env = &cpu->env; - int ret; - - env->retaddr = retaddr; - ret = x86_cpu_handle_mmu_fault(cs, addr, size, access_type, mmu_idx); - if (ret) { - raise_exception_err_ra(env, cs->exception_index, env->error_code, retaddr); - } -} -#endif 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) From patchwork Fri May 10 18:54:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163939 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2751733ilr; Fri, 10 May 2019 11:55:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCGvPTEimBrLJCmFhPqrdtQ8IPKZ1hIQVuhJnviqVqKZkRh176e7rEgD2VdkzAvGpRnw+g X-Received: by 2002:a50:b56a:: with SMTP id z39mr13060325edd.91.1557514540849; Fri, 10 May 2019 11:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557514540; cv=none; d=google.com; s=arc-20160816; b=sEdg4hBvJ5aBqrOpMUsoQgOi8owTlXbtNHTPfcvV4tmr9LBH/HSL8XpQzz75WAST1f thcfrjxcML6L6t4+qXSosiHbjFiMkz5TiGDNItog5pKXOODWWBsJddIzAk4NrC0+/eQr tz7tz9s4OWF81CLtC6NtxuoL47uyMIeKCUnt6yYSJscnQZRCmcO9qkbcwi55eiTS3Q8a XXglM/cI50PQbFYKRxwxR/9g6MubAj3g0dJyWn8kRLx6o8fUvoLYKCDW/7sF5aV6s+Jy 4n9AYS4NISbQgS4JDg+NSDwx6DJzdLobDVJn4cId/PuXiHTYka28MSJVVc2rave4rJSf W9kQ== 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=QUvZbCp4hiIu4WKEe9vqsUzs+jUu0CQw3Oh1C09dIOU=; b=MOZQJeVbMNcFAKp+PVrnRsKeuUDsMhP9YI6c+KWnHfhnKz+phNWTaVb+D0j6Kb2jGu 4P5sdmeIzOcGa2I0tIcd1KnYnxGa1k3V4B2szbVe8LSR1PXwJ3F6cwKXiA37Uv6LOBVG Z3dBv83/b3cIVXBYcVJqMosU2swUyo1WbY1IlVXsldgdtO3FBk54FNj3zf+7kcJl3YCg 3Ii228kbBP/en/0RUS36HULEfoZN4US+WtKhjeAj+LOw8ZIOQF59t2oxlktS9+ClFidx Yy3AdniivUDP2rX523eyiYNo4KWAzpNKZM6cFIaUSecdGndWPfcfu7fdrTDQ4GJ6z9oo YnUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IvVEQFyE; 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 a2si2641198ejp.164.2019.05.10.11.55.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 11:55:40 -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=IvVEQFyE; 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]:48525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAgF-0008Fj-PM for patch@linaro.org; Fri, 10 May 2019 14:55:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48521) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAfY-0007vr-Q0 for qemu-devel@nongnu.org; Fri, 10 May 2019 14:55:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPAfQ-0005ro-90 for qemu-devel@nongnu.org; Fri, 10 May 2019 14:54:56 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:45733) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hPAfQ-0005pU-1l for qemu-devel@nongnu.org; Fri, 10 May 2019 14:54:48 -0400 Received: by mail-pl1-x641.google.com with SMTP id a5so3221256pls.12 for ; Fri, 10 May 2019 11:54:47 -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=QUvZbCp4hiIu4WKEe9vqsUzs+jUu0CQw3Oh1C09dIOU=; b=IvVEQFyEWqmQGAZ/cD5Z3fc3cuZFHOKeqBZK37/h0XMWhaJFZMKCUgJ8ja3zn/yJLv RiBBv1X3ImmKK+mIzyts3IUYKKeyEKHmD7MTzE2BFYiEnkbCXAGhGzpwYwR7I7s+LuHD 2s53/z0ElIxP429Z8kQhh8NzdUdoXaKxUEe4TnNOsYkhgZf+2MbTTrdiQLZOIc5VVQpD OXHfVAWMPi/o4eKNV8RtfVTqAfMCh2xnNfuazXZhh86PsIJH/NFGv82Xn1n7ahZHfzzk 86dRerJhw+8xwk1SHwaFhWdYGUPZGI2fTkfZ/Vhz2mVbBYrIK/tcnisIhKefV0ZThrwf SJoQ== 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=QUvZbCp4hiIu4WKEe9vqsUzs+jUu0CQw3Oh1C09dIOU=; b=Aupk4z8FrrXqYSyhzl6pIirDF5vENIxBGxnQkxE/vF90WXP1Zb76N3/r6+7lMxrshQ Y/7hNVdXFtHkA9G4csi0cvS8nBudnZahAn3DUm6BM8shshyo7X/89+sLRv9qporWABmq zRtbTNGOfY3nKyXW7p6APkpfi2uDzbulvBe8uwKL3rpCz56AZOiwH85M4y15BNbdaOKE EmMG6kJVvTzY+c2+XQEemKrlzmx6s2Ho5rSfVPJKbu9Ag4XxGlVHSM6RQU7evhwLCIBA tdZn0+U60TpdkQTbAkWeeRVc79YSgF0m7NThRPowRqwKv0nT0ZwZ2hFq2S329k02HTex hzGA== X-Gm-Message-State: APjAAAVrxxgEM6HYgZ/cdS+Sk9lwg33coGQMetdU5XwquCJAPu0RbfuJ 8Orlm8CsUChNdr6Df1zohfgyr5QbSV8= X-Received: by 2002:a17:902:5995:: with SMTP id p21mr15415797pli.216.1557514486616; Fri, 10 May 2019 11:54:46 -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.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 11:54:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 11:54:35 -0700 Message-Id: <20190510185438.29533-5-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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PULL v2 16/27] target/ppc: 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, qemu-ppc@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: qemu-ppc@nongnu.org Acked-by: David Gibson Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/ppc/cpu.h | 7 +++---- target/ppc/mmu_helper.c | 22 +++++++++++++--------- target/ppc/translate_init.inc.c | 5 ++--- target/ppc/user_only_helper.c | 14 ++++++++------ 4 files changed, 26 insertions(+), 22 deletions(-) -- 2.17.1 diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 5e7cf54b2f..d7f23ad5e0 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1311,10 +1311,9 @@ void ppc_translate_init(void); * is returned if the signal was handled by the virtual CPU. */ int cpu_ppc_signal_handler(int host_signum, void *pinfo, void *puc); -#if defined(CONFIG_USER_ONLY) -int ppc_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw, - int mmu_idx); -#endif +bool ppc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); #if !defined(CONFIG_USER_ONLY) void ppc_store_sdr1(CPUPPCState *env, target_ulong value); diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c index 1dbc9acb75..afcca50530 100644 --- a/target/ppc/mmu_helper.c +++ b/target/ppc/mmu_helper.c @@ -3057,15 +3057,9 @@ void helper_check_tlb_flush_global(CPUPPCState *env) /*****************************************************************************/ -/* - * 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) +bool ppc_cpu_tlb_fill(CPUState *cs, vaddr addr, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { PowerPCCPU *cpu = POWERPC_CPU(cs); PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs); @@ -3078,7 +3072,17 @@ void tlb_fill(CPUState *cs, target_ulong addr, int size, ret = cpu_ppc_handle_mmu_fault(env, addr, access_type, mmu_idx); } if (unlikely(ret != 0)) { + if (probe) { + return false; + } raise_exception_err_ra(env, cs->exception_index, env->error_code, retaddr); } + return true; +} + +void tlb_fill(CPUState *cs, target_ulong addr, int size, + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) +{ + ppc_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr); } diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.inc.c index 0394a9ddad..ad5e14b16f 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -10592,9 +10592,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = ppc_cpu_gdb_read_register; cc->gdb_write_register = ppc_cpu_gdb_write_register; cc->do_unaligned_access = ppc_cpu_do_unaligned_access; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = ppc_cpu_handle_mmu_fault; -#else +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = ppc_cpu_get_phys_page_debug; cc->vmsd = &vmstate_ppc_cpu; #endif @@ -10624,6 +10622,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void *data) #endif #ifdef CONFIG_TCG cc->tcg_initialize = ppc_translate_init; + cc->tlb_fill = ppc_cpu_tlb_fill; #endif cc->disas_set_info = ppc_disas_set_info; diff --git a/target/ppc/user_only_helper.c b/target/ppc/user_only_helper.c index 2f1477f102..683c03390d 100644 --- a/target/ppc/user_only_helper.c +++ b/target/ppc/user_only_helper.c @@ -20,21 +20,24 @@ #include "qemu/osdep.h" #include "cpu.h" +#include "exec/exec-all.h" -int ppc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, - int mmu_idx) + +bool ppc_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; int exception, error_code; - if (rw == 2) { + if (access_type == MMU_INST_FETCH) { exception = POWERPC_EXCP_ISI; error_code = 0x40000000; } else { exception = POWERPC_EXCP_DSI; error_code = 0x40000000; - if (rw) { + if (access_type == MMU_DATA_STORE) { error_code |= 0x02000000; } env->spr[SPR_DAR] = address; @@ -42,6 +45,5 @@ int ppc_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, int rw, } cs->exception_index = exception; env->error_code = error_code; - - return 1; + cpu_loop_exit_restore(cs, retaddr); } From patchwork Fri May 10 18:54:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163943 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2755410ilr; Fri, 10 May 2019 12:00:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPIL0UjrDLOndGSJ0VNLhSLBWb0E0ddWMfxUUAcf1e1CVn6qrUgMkOT762y5M7YimEieft X-Received: by 2002:a17:906:7056:: with SMTP id r22mr5218633ejj.275.1557514806325; Fri, 10 May 2019 12:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557514806; cv=none; d=google.com; s=arc-20160816; b=SwFrfqB61dt3aS550V/qLdYawQ53B6QEeApJVdVNFmr/3gtvPdewYVxb4F99t3se5E 1wMK4Qd4IQjBe1FkwDyAWpRE4i5IvsqkDQoLewWWkV2d3Q+5JAh8fWdRF+Ub42Bykurk kzamGeWOT///e8vhq0sVcbG8auItyz4kUns5DBc4dm3kUx8gJfYD4V4k9hQS4oVt0j81 KiHTBP6INaRxzH2T86STqRKi7xA4wgMsEOMUvoql+wgcV6cnHu+Nm280GwRYkxKj6v18 sVGjdpPWvfpJ4cTJSvaKtED8k/uK5s+kPm0Xqbh5IstrsPoVeTqqP6U9/c6x8g3CckRU V9Rg== 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=2nv1Fz6coVTYizv8OMxkCDga0OEiAnrikMT8xHCBMUM=; b=WUdG97QI6EagKv4/TPsT5Xws6v2ch1OQhWuYqsgnNqzTmJrau6Hi4uohFTIQPbbZIo 1fr2Izh/OUSSuFaEy+fuDK9B2Rcy9v+5q2p0NkwkiOFckL7dmBhD1bbE07cSugKxsqzG lsTeAvvy0e1eEoGh2M2u3IWUilYvqBk0nUsTBASeBMbYS5lz4yXhR75iVUHW3uRH9kag 0MwKkI2VyUQA12oHj3dxvsU8MgkutPYOEw+NrBAZQGXLvAPDVx28EhpWPF6rCYm3FND/ 6jr1YLVirEvPajhp6BD2Tcfq5Ex95QLJ/HA6V6gsRTU0GCJ7otdawwulzt9bcC/u1g6W bXmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XgBIQLVJ; 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 i12si782627edk.333.2019.05.10.12.00.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 12:00:06 -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=XgBIQLVJ; 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]:48564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAkX-0004FQ-72 for patch@linaro.org; Fri, 10 May 2019 15:00:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAfb-0007xI-DM for qemu-devel@nongnu.org; Fri, 10 May 2019 14:55:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPAfR-0005ut-FY for qemu-devel@nongnu.org; Fri, 10 May 2019 14:54:58 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:35381) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hPAfR-0005sM-3W for qemu-devel@nongnu.org; Fri, 10 May 2019 14:54:49 -0400 Received: by mail-pf1-x441.google.com with SMTP id t87so3703326pfa.2 for ; Fri, 10 May 2019 11:54:48 -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=2nv1Fz6coVTYizv8OMxkCDga0OEiAnrikMT8xHCBMUM=; b=XgBIQLVJzunHW2aEjGIPsFY0aDf7tUEK+y/juLg1z7y3bxWJonO47Y3iA2Mqz0roev IoLEp3BQ5hfdE0BNswP1g+XKkzwIffhlo2oXcxmxc8xCfVoIFZhNR1LDyLC5ztXAV1GL ssi59GoxXntsSiPclIP9rGcBblfo55S4rkk9VuDM0GXwuq5VFqSq5fEbAZizCzN5XcZs pFku/IYqEF2HIhcwJL8yc1X8+jQt99yNxMAPSRDtUGVL7SbD5MC6/wCsyk0t7s/P2cic 9K7kuw372YZcVu9kxrusBmYxrjpQHgVNO1EGUOLZCuOf8oilR3gjvmbQQwuhta8bBJ5m w/4A== 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=2nv1Fz6coVTYizv8OMxkCDga0OEiAnrikMT8xHCBMUM=; b=LaIOeGqOlQO+8n+y3IELOeG53ueqHV9Xacc7JxNuoe24Ar2e1N3vRxlo66T0YmaNk7 d582OS4o9GYZw4n2npaoB3O6J5DZPQirg+Mw4gP66xxwKt8KNZ8wOwA6sNrT3YYm1kR+ PwC8BglX79G8SX3sSz78kgXZ3+IHsbqDbCwm+QWeva6fpBbiJNCXl5c5mITCL2SiEJyi phV6bOOt3M0jD4LP+K4On59DlLr7Rr9FcW3d3PVZm2GCDAnfPgDtTnKFp9J0OUajFwVn u+jyPj6oYiw6GSA4MRXBzG6851dJQRZqbbspA7vlp+mgA4elXpbO/rygHvShs7X0qHsx b2UQ== X-Gm-Message-State: APjAAAXaGByph7vbiZvce4qVpC+Ropu5o3OQFFvWT+3SlGIejhwNRlob qOT8EkExAVJvqv4G0DzLXbdNUzcJ4Yg= X-Received: by 2002:aa7:9afc:: with SMTP id y28mr16719834pfp.101.1557514487752; Fri, 10 May 2019 11:54:47 -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.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 11:54:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 11:54:36 -0700 Message-Id: <20190510185438.29533-6-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> 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] [PULL v2 17/27] target/riscv: 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, Palmer Dabbelt , qemu-riscv@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that env->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 riscv_raise_exception. Cc: qemu-riscv@nongnu.org Cc: Palmer Dabbelt Reviewed-by: Alistair Francis Signed-off-by: Richard Henderson --- target/riscv/cpu.h | 5 +++-- target/riscv/cpu.c | 5 ++--- target/riscv/cpu_helper.c | 46 ++++++++++++++++++--------------------- 3 files changed, 26 insertions(+), 30 deletions(-) -- 2.17.1 diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7d9f48973f..c17184f4e4 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -261,8 +261,9 @@ hwaddr riscv_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); -int riscv_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, - int rw, int mmu_idx); +bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); char *riscv_isa_string(RISCVCPU *cpu); void riscv_cpu_list(void); diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 1bcf4eaeb8..b7675707e0 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -355,14 +355,13 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data) #endif cc->gdb_stop_before_watchpoint = true; cc->disas_set_info = riscv_cpu_disas_set_info; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = riscv_cpu_handle_mmu_fault; -#else +#ifndef CONFIG_USER_ONLY cc->do_unaligned_access = riscv_cpu_do_unaligned_access; cc->get_phys_page_debug = riscv_cpu_get_phys_page_debug; #endif #ifdef CONFIG_TCG cc->tcg_initialize = riscv_translate_init; + cc->tlb_fill = riscv_cpu_tlb_fill; #endif /* For now, mark unmigratable: */ cc->vmsd = &vmstate_riscv_cpu; diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index b17f169681..2535435260 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -379,53 +379,49 @@ void riscv_cpu_do_unaligned_access(CPUState *cs, vaddr addr, riscv_raise_exception(env, cs->exception_index, retaddr); } -/* called by qemu's softmmu to fill the qemu tlb */ void tlb_fill(CPUState *cs, target_ulong addr, int size, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - int ret; - ret = riscv_cpu_handle_mmu_fault(cs, addr, size, access_type, mmu_idx); - if (ret == TRANSLATE_FAIL) { - RISCVCPU *cpu = RISCV_CPU(cs); - CPURISCVState *env = &cpu->env; - riscv_raise_exception(env, cs->exception_index, retaddr); - } + riscv_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr); } - #endif -int riscv_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, - int rw, int mmu_idx) +bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { +#ifndef CONFIG_USER_ONLY RISCVCPU *cpu = RISCV_CPU(cs); CPURISCVState *env = &cpu->env; -#if !defined(CONFIG_USER_ONLY) hwaddr pa = 0; int prot; -#endif int ret = TRANSLATE_FAIL; - qemu_log_mask(CPU_LOG_MMU, - "%s pc " TARGET_FMT_lx " ad %" VADDR_PRIx " rw %d mmu_idx \ - %d\n", __func__, env->pc, address, rw, mmu_idx); + qemu_log_mask(CPU_LOG_MMU, "%s ad %" VADDR_PRIx " rw %d mmu_idx %d\n", + __func__, address, access_type, mmu_idx); + + ret = get_physical_address(env, &pa, &prot, address, access_type, mmu_idx); -#if !defined(CONFIG_USER_ONLY) - ret = get_physical_address(env, &pa, &prot, address, rw, mmu_idx); qemu_log_mask(CPU_LOG_MMU, - "%s address=%" VADDR_PRIx " ret %d physical " TARGET_FMT_plx - " prot %d\n", __func__, address, ret, pa, prot); + "%s address=%" VADDR_PRIx " ret %d physical " TARGET_FMT_plx + " prot %d\n", __func__, address, ret, pa, prot); + if (riscv_feature(env, RISCV_FEATURE_PMP) && - !pmp_hart_has_privs(env, pa, TARGET_PAGE_SIZE, 1 << rw)) { + !pmp_hart_has_privs(env, pa, TARGET_PAGE_SIZE, 1 << access_type)) { ret = TRANSLATE_FAIL; } if (ret == TRANSLATE_SUCCESS) { tlb_set_page(cs, address & TARGET_PAGE_MASK, pa & TARGET_PAGE_MASK, prot, mmu_idx, TARGET_PAGE_SIZE); - } else if (ret == TRANSLATE_FAIL) { - raise_mmu_exception(env, address, rw); + return true; + } else if (probe) { + return false; + } else { + raise_mmu_exception(env, address, access_type); + riscv_raise_exception(env, cs->exception_index, retaddr); } #else - switch (rw) { + switch (access_type) { case MMU_INST_FETCH: cs->exception_index = RISCV_EXCP_INST_PAGE_FAULT; break; @@ -436,8 +432,8 @@ int riscv_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, cs->exception_index = RISCV_EXCP_STORE_PAGE_FAULT; break; } + cpu_loop_exit_restore(cs, retaddr); #endif - return ret; } /* From patchwork Fri May 10 18:54:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163941 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2753704ilr; Fri, 10 May 2019 11:58:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJC7U1LpqlvoPjmSrF8nhkw4hUg9ROLs0KWIMA6GQd6OwBx3qRlwDoBJ3I5grABBU7soGd X-Received: by 2002:a50:bdc2:: with SMTP id z2mr12797539edh.245.1557514689045; Fri, 10 May 2019 11:58:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557514689; cv=none; d=google.com; s=arc-20160816; b=N7HwNBtwatdOTLX+fHq/FwX3zho/a3qJ/WbZG6LrGR3OKHbfNgiWOKJzSe7zx8lPJt GvQy31tFVFClwzSd5EFE0evP/69iSuwJ1xYPAkIN3kfPddaVP0InTH3IOhLYgubj7sAO y27eMCO6rCHgzNl27sXR8SlesX+Ua/rM07e4G8TibwuI0+FlEa6sXHZIP8UvoplXozjG ED0EQk5HWXDJOV6QQI4IbwoLARYE1VDC8Thyxn90rDkDsWIKzLPASJ0tyYFVN85LzfRa QH6PyLgUPfDoTKkSdw/TKoNtbyjNk1ghhZ9esCv3DbXnKva6fHhM3tnCsRgbe9IV5YE3 RYAg== 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=8Iw4WcROeIjDVSbOqaJK16F98amSvn2ezBmf0bQYqcE=; b=i+jMBrtfEEsTy1L32mC2McAFFKSnnKFAvtruNOaZ8mFMI8XpZpxImnGXFBLQjiIXTW Q2r4q39tnU0aUMsrEtK2EAFXGEbh5UB+ZhHC488lVcGU/J22SgdmPcAmy7XPNp9IzRI1 /MMVLhl4KgyrHBD7ahznBjACUUnLK0kdL9txwKXw90nUX09hmvQyV/FyrYvf7y914Nms 16M2sy+07jEM54/ZcAq1/CVEv+VMzCFxN5xjSrlw9uuIAKs3rh1IGHoV1AxHiU8fSR9l zVeGwgp1tGXN6cG8bYcoJCOBgLWQvZ1MtJEfLjp0DQCH0iw3xshcHLl3mahcl4cNXceM PdIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZEnP+0mD; 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 t20si2362123ejt.357.2019.05.10.11.58.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 11:58:09 -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=ZEnP+0mD; 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]:48550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAid-0002TP-Sr for patch@linaro.org; Fri, 10 May 2019 14:58:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAff-00080B-Qg for qemu-devel@nongnu.org; Fri, 10 May 2019 14:55:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPAfS-0005yA-Mo for qemu-devel@nongnu.org; Fri, 10 May 2019 14:55:01 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:42950) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hPAfS-0005vV-CF for qemu-devel@nongnu.org; Fri, 10 May 2019 14:54:50 -0400 Received: by mail-pf1-x42c.google.com with SMTP id 13so3687496pfw.9 for ; Fri, 10 May 2019 11:54:50 -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=8Iw4WcROeIjDVSbOqaJK16F98amSvn2ezBmf0bQYqcE=; b=ZEnP+0mDq9lqyepPxPw6HCq8GrAg9zeQZ8/eK35webOD6LUfWtq81bfLBNNVEA7e4Y rT3WqjE7BmY+l53H1FTppq6cxpyxSfmMRkoGPvnAaKVlEy8rbdVBGwCobhbNk5Q1Ydjn leHZCPbEyhWBBKmPVDhsstp3aK+2XnEuY14o9UOR6KK1KxS/ia+vf0DmBvrFFMKAGbrI 8ReMQowtRmLO+pGR34FeqtPVCnP1Ah9Dan/jThuhXEQFcnUyPOnM+XHWVIphpuJGEFBa 4yy6pYGDQIXwoqC0cKitO9Y0QEdhi5mE9V7LGHTLKD4IYODIx/h7C6aJsxGntCmoPge/ Z08A== 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=8Iw4WcROeIjDVSbOqaJK16F98amSvn2ezBmf0bQYqcE=; b=Wwv6E47T+J0WqBIyx0MljPXj0BFDKAEUCyBvhDurn+RWM3TKpZxFlIdakx1BAa/t0T CHw+oPupyo8qVxg+XeQvodF3JTet1IbV3jL8H8MAmLW+cxrN7NueweEJzAggJcn9yeNS IbdNpDDdqR7WCAOPQLazZndRhZqwJTQhDYw2SoVhWcBUaZIC7LS7Bg/Td+0G+gRR9CaL 2zSdMJvaGHsTpdurTf6y3i5ia6UEF+Ntw8L3FMszgFMZqmvjJcObRmNqStaCRHwVTAbb nYhVuEcFql/ehSzoDe0IwDVxQNRiTcppCBhShsvP5HFqd5ROWAcxkzoo2r2PI547V17P G0hQ== X-Gm-Message-State: APjAAAU2aKUSPwr3ofDQmGYUaavuyF4cBw2wd21mbdA+/ouNkWmVGX55 xYEcTfdJiyAlFnN21r6JQsTXN7yKOhg= X-Received: by 2002:aa7:8289:: with SMTP id s9mr16541129pfm.208.1557514488809; Fri, 10 May 2019 11:54:48 -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.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 11:54:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 11:54:37 -0700 Message-Id: <20190510185438.29533-7-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> 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 v2 18/27] target/s390x: 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, qemu-s390x@nongnu.org, Cornelia Huck Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Cc: qemu-s390x@nongnu.org Cc: Cornelia Huck Reviewed-by: David Hildenbrand Signed-off-by: Richard Henderson --- target/s390x/internal.h | 5 +-- target/s390x/cpu.c | 5 ++- target/s390x/excp_helper.c | 73 ++++++++++++++++++++++++++------------ target/s390x/mem_helper.c | 16 --------- 4 files changed, 55 insertions(+), 44 deletions(-) -- 2.17.1 diff --git a/target/s390x/internal.h b/target/s390x/internal.h index 26575f2130..56534b38e0 100644 --- a/target/s390x/internal.h +++ b/target/s390x/internal.h @@ -263,8 +263,9 @@ ObjectClass *s390_cpu_class_by_name(const char *name); void s390x_cpu_debug_excp_handler(CPUState *cs); void s390_cpu_do_interrupt(CPUState *cpu); bool s390_cpu_exec_interrupt(CPUState *cpu, int int_req); -int s390_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int size, int rw, - int mmu_idx); +bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr); void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index b58ef0a8ef..b1df63d82c 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -478,9 +478,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->set_pc = s390_cpu_set_pc; cc->gdb_read_register = s390_cpu_gdb_read_register; cc->gdb_write_register = s390_cpu_gdb_write_register; -#ifdef CONFIG_USER_ONLY - cc->handle_mmu_fault = s390_cpu_handle_mmu_fault; -#else +#ifndef CONFIG_USER_ONLY cc->get_phys_page_debug = s390_cpu_get_phys_page_debug; cc->vmsd = &vmstate_s390_cpu; cc->write_elf64_note = s390_cpu_write_elf64_note; @@ -493,6 +491,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data) cc->disas_set_info = s390_cpu_disas_set_info; #ifdef CONFIG_TCG cc->tcg_initialize = s390x_translate_init; + cc->tlb_fill = s390_cpu_tlb_fill; #endif cc->gdb_num_core_regs = S390_NUM_CORE_REGS; diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index f84bfb1284..a4e134bcab 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -74,8 +74,9 @@ void s390_cpu_do_interrupt(CPUState *cs) cs->exception_index = -1; } -int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, - int rw, int mmu_idx) +bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { S390CPU *cpu = S390_CPU(cs); @@ -83,7 +84,7 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address, int size, /* On real machines this value is dropped into LowMem. Since this is userland, simply put this someplace that cpu_loop can find it. */ cpu->env.__excp_addr = address; - return 1; + cpu_loop_exit_restore(cs, retaddr); } #else /* !CONFIG_USER_ONLY */ @@ -102,19 +103,20 @@ static inline uint64_t cpu_mmu_idx_to_asc(int mmu_idx) } } -int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, int size, - int rw, int mmu_idx) +bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size, + MMUAccessType access_type, int mmu_idx, + bool probe, uintptr_t retaddr) { S390CPU *cpu = S390_CPU(cs); CPUS390XState *env = &cpu->env; target_ulong vaddr, raddr; uint64_t asc; - int prot; + int prot, fail; qemu_log_mask(CPU_LOG_MMU, "%s: addr 0x%" VADDR_PRIx " rw %d mmu_idx %d\n", - __func__, orig_vaddr, rw, mmu_idx); + __func__, address, access_type, mmu_idx); - vaddr = orig_vaddr; + vaddr = address; if (mmu_idx < MMU_REAL_IDX) { asc = cpu_mmu_idx_to_asc(mmu_idx); @@ -122,39 +124,64 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr, int size, if (!(env->psw.mask & PSW_MASK_64)) { vaddr &= 0x7fffffff; } - if (mmu_translate(env, vaddr, rw, asc, &raddr, &prot, true)) { - return 1; - } + fail = mmu_translate(env, vaddr, access_type, asc, &raddr, &prot, true); } else if (mmu_idx == MMU_REAL_IDX) { /* 31-Bit mode */ if (!(env->psw.mask & PSW_MASK_64)) { vaddr &= 0x7fffffff; } - if (mmu_translate_real(env, vaddr, rw, &raddr, &prot)) { - return 1; - } + fail = mmu_translate_real(env, vaddr, access_type, &raddr, &prot); } else { - abort(); + g_assert_not_reached(); } /* check out of RAM access */ - if (!address_space_access_valid(&address_space_memory, raddr, - TARGET_PAGE_SIZE, rw, + if (!fail && + !address_space_access_valid(&address_space_memory, raddr, + TARGET_PAGE_SIZE, access_type, MEMTXATTRS_UNSPECIFIED)) { qemu_log_mask(CPU_LOG_MMU, "%s: raddr %" PRIx64 " > ram_size %" PRIx64 "\n", __func__, (uint64_t)raddr, (uint64_t)ram_size); trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO); - return 1; + fail = 1; } - qemu_log_mask(CPU_LOG_MMU, "%s: set tlb %" PRIx64 " -> %" PRIx64 " (%x)\n", - __func__, (uint64_t)vaddr, (uint64_t)raddr, prot); + if (!fail) { + qemu_log_mask(CPU_LOG_MMU, + "%s: set tlb %" PRIx64 " -> %" PRIx64 " (%x)\n", + __func__, (uint64_t)vaddr, (uint64_t)raddr, prot); + tlb_set_page(cs, address & TARGET_PAGE_MASK, raddr, prot, + mmu_idx, TARGET_PAGE_SIZE); + return true; + } + if (probe) { + return false; + } - tlb_set_page(cs, orig_vaddr & TARGET_PAGE_MASK, raddr, prot, - mmu_idx, TARGET_PAGE_SIZE); + cpu_restore_state(cs, retaddr, true); - return 0; + /* + * The ILC value for code accesses is undefined. The important + * thing here is to *not* leave env->int_pgm_ilen set to ILEN_AUTO, + * which would cause do_program_interrupt to attempt to read from + * env->psw.addr again. C.f. the condition in trigger_page_fault, + * but is not universally applied. + * + * ??? If we remove ILEN_AUTO, by moving the computation of ILEN + * into cpu_restore_state, then we may remove this entirely. + */ + if (access_type == MMU_INST_FETCH) { + env->int_pgm_ilen = 2; + } + + cpu_loop_exit(cs); +} + +void tlb_fill(CPUState *cs, target_ulong addr, int size, + MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) +{ + s390_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr); } static void do_program_interrupt(CPUS390XState *env) diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index 3f76a8abfd..ffd5f02fbe 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -33,22 +33,6 @@ /*****************************************************************************/ /* Softmmu support */ -#if !defined(CONFIG_USER_ONLY) - -/* 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 = s390_cpu_handle_mmu_fault(cs, addr, size, access_type, mmu_idx); - if (unlikely(ret != 0)) { - cpu_loop_exit_restore(cs, retaddr); - } -} - -#endif /* #define DEBUG_HELPER */ #ifdef DEBUG_HELPER From patchwork Fri May 10 18:54:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163944 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp2755571ilr; Fri, 10 May 2019 12:00:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFXKaZYooQBf1r1S3mOgai4wlTFjNQEs7Oo8P0s/6ytc7SjPtEEYxKy8NMlJbT8VqCWLpI X-Received: by 2002:a50:9705:: with SMTP id c5mr13471255edb.258.1557514816189; Fri, 10 May 2019 12:00:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557514816; cv=none; d=google.com; s=arc-20160816; b=eyMweWNPlNbQpqhI5HS/x1pQg1yxGSFo2KYWHATji/HHxK3r/wiJom4PGKomGmI48G oH6lU8K5YUgdl2Wsp0I3sCxGfmrMGCrauwlj/6BrWgRxHoPUvrusHC1QGZ2bx/vR1kPa dU/IOZz1vL81MIhRDj8QvUi28aMbpBPIIyloKRGqjD5SCv7U3K8CNzNUkiIAzqvEJKcy p885I11iLZwWeK9WbjuN2BzleiO5xc6DTvNJeeKWjRNNBM9BTdREewOSqV8CQVcaVZac mTcy62ExQP19NP3T+Ue1v4KlL3ZcJBltJ2ggylaMQ0JKXRI1XkwBRDrR1ff1+X2rRhyP P84A== 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=FhdWRxPNUBrHfeekmUh0a/Oh8OYPBRAtdrB9qKNSsEA=; b=yIYBvpe2w4eiUH2bF2hhEVRLggDB3aQV2nqJ4wj7J3/tFS+FHtE7VZ+AQ5reZiMzbZ E6lR0nKp1n9z1m/gGpNmXXjKTNuoR2JOZQ/VdzBu0radlg+lGF8KVZ8WZHnERJ/ZOcoY NLSlpOCBPNH9lwR2dJWUqnOT6zri/DsqunBPt0WSzf6zYBWbMGpcosAY2LDc9JnvvsT6 b8m/JwTXWukw22UySqlnjC/IoWiQwD0+2WNtYjwaa2PIR5YTLz+ONFNGvJmK/IjjM8y1 y9z3Ln68TZLnY2g6tCsczHIrezP3tb2nZaaoBvD/2NgBDrrrAkt4lVWgdckS+liOY6Jl GSNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QXANxkQC; 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 p49si2104234edc.249.2019.05.10.12.00.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 10 May 2019 12:00:16 -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=QXANxkQC; 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]:48568 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAkh-0004Nt-2Z for patch@linaro.org; Fri, 10 May 2019 15:00:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48891) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hPAfg-00080T-1s for qemu-devel@nongnu.org; Fri, 10 May 2019 14:55:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hPAfU-00061Y-0Q for qemu-devel@nongnu.org; Fri, 10 May 2019 14:55:03 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:36229) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hPAfT-0005ye-I2 for qemu-devel@nongnu.org; Fri, 10 May 2019 14:54:51 -0400 Received: by mail-pf1-x443.google.com with SMTP id v80so3700849pfa.3 for ; Fri, 10 May 2019 11:54:51 -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=FhdWRxPNUBrHfeekmUh0a/Oh8OYPBRAtdrB9qKNSsEA=; b=QXANxkQCu+tSWDVBFP6yfBuTtYSrbCGh5lWkDtXdtKPlNL7/YAX2/4jlPV/JAL82id 2ZyuYQBTbo24rodmmlZTvdxiV5LN13dAP8eNlhhRApgXFARF08ABNovWT57GJhTZbQLH J0fMnNuHoXBe7iIfO4AAtgz4aFHJLHi6WAJxcj+AvxCkSNkePSLisLRGsS6kkGR/kgJV rCpBCf9H6C0T+t6oulTiaeDREFDrqrhfJ3pBV7lhRvosmBSyK7lLXJToWWtvTBUsVLzK +BqdG5DTAwm1ZwZHm2aI/mqLQaAQHgoxVvlx8hVr7MMX0Ko/cfsE8d546Uhwxmb8TlAy To0g== 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=FhdWRxPNUBrHfeekmUh0a/Oh8OYPBRAtdrB9qKNSsEA=; b=We4SKbPm+3YCF9IwbcIscBSN7oOnimaZFRNLXqHD5wxpqyuVRTm0erDVSewunLe1SK NB3rqkUj1TcRAlplZgc8GpGkTKcRf4NRYMeGOpQECQznScyyZfzszqiP5E3m3EnO9RT5 mh/Jwc5C6aW9npTNZnQbhanKGMNjtBGVw2CsTu0BKv3O/jT2IkDLoHcPTeILqe7/w75l EzwN+Rby+LKqUQwdnKxW51udf9V9AtJxiRmRVEi0C4mGfzDBe6ZT7sXLhACQQXussGJx nCQC5e1scyO+47JQRmXH+RFejYsU9QB5QhkiC36ZCFw/13SC71F+39EDnh+2q1co7zZN h/7Q== X-Gm-Message-State: APjAAAURdpcpa4pvKHPqMKXLkjIslBkbxhvDugRHrOVEC5M5VxXlAf2Z fkaa2u+aMz5iYBq5VtiM0ujhc7IUIYI= X-Received: by 2002:a62:bd14:: with SMTP id a20mr16497437pff.107.1557514490087; Fri, 10 May 2019 11:54:50 -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.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 11:54:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 11:54:38 -0700 Message-Id: <20190510185438.29533-8-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::443 Subject: [Qemu-devel] [PULL v2 27/27] tcg: Use tlb_fill probe from tlb_vaddr_to_host 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Most of the existing users would continue around a loop which would fault the tlb entry in via a normal load/store. But for AArch64 SVE we have an existing emulation bug wherein we would mark the first element of a no-fault vector load as faulted (within the FFR, not via exception) just because we did not have its address in the TLB. Now we can properly only mark it as faulted if there really is no valid, readable translation, while still not raising an exception. (Note that beyond the first element of the vector, the hardware may report a fault for any reason whatsoever; with at least one element loaded, forward progress is guaranteed.) Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- include/exec/cpu_ldst.h | 50 ++++++----------------------- accel/tcg/cputlb.c | 69 ++++++++++++++++++++++++++++++++++++----- target/arm/sve_helper.c | 6 +--- 3 files changed, 72 insertions(+), 53 deletions(-) -- 2.17.1 diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index d78041d7a0..7b28a839d2 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -433,50 +433,20 @@ static inline CPUTLBEntry *tlb_entry(CPUArchState *env, uintptr_t mmu_idx, * @mmu_idx: MMU index to use for lookup * * Look up the specified guest virtual index in the TCG softmmu TLB. - * If the TLB contains a host virtual address suitable for direct RAM - * access, then return it. Otherwise (TLB miss, TLB entry is for an - * I/O access, etc) return NULL. - * - * This is the equivalent of the initial fast-path code used by - * TCG backends for guest load and store accesses. + * If we can translate a host virtual address suitable for direct RAM + * access, without causing a guest exception, then return it. + * Otherwise (TLB entry is for an I/O access, guest software + * TLB fill required, etc) return NULL. */ +#ifdef CONFIG_USER_ONLY static inline void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, - int access_type, int mmu_idx) + MMUAccessType access_type, int mmu_idx) { -#if defined(CONFIG_USER_ONLY) return g2h(addr); -#else - CPUTLBEntry *tlbentry = tlb_entry(env, mmu_idx, addr); - abi_ptr tlb_addr; - uintptr_t haddr; - - switch (access_type) { - case 0: - tlb_addr = tlbentry->addr_read; - break; - case 1: - tlb_addr = tlb_addr_write(tlbentry); - break; - case 2: - tlb_addr = tlbentry->addr_code; - break; - default: - g_assert_not_reached(); - } - - if (!tlb_hit(tlb_addr, addr)) { - /* TLB entry is for a different page */ - return NULL; - } - - if (tlb_addr & ~TARGET_PAGE_MASK) { - /* IO access */ - return NULL; - } - - haddr = addr + tlbentry->addend; - return (void *)haddr; -#endif /* defined(CONFIG_USER_ONLY) */ } +#else +void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, + MMUAccessType access_type, int mmu_idx); +#endif #endif /* CPU_LDST_H */ diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index dfcd9ae168..685e0f2ee4 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1007,6 +1007,16 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, } } +static inline target_ulong tlb_read_ofs(CPUTLBEntry *entry, size_t ofs) +{ +#if TCG_OVERSIZED_GUEST + return *(target_ulong *)((uintptr_t)entry + ofs); +#else + /* ofs might correspond to .addr_write, so use atomic_read */ + return atomic_read((target_ulong *)((uintptr_t)entry + ofs)); +#endif +} + /* Return true if ADDR is present in the victim tlb, and has been copied back to the main tlb. */ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index, @@ -1017,14 +1027,7 @@ static bool victim_tlb_hit(CPUArchState *env, size_t mmu_idx, size_t index, assert_cpu_is_self(ENV_GET_CPU(env)); for (vidx = 0; vidx < CPU_VTLB_SIZE; ++vidx) { CPUTLBEntry *vtlb = &env->tlb_v_table[mmu_idx][vidx]; - target_ulong cmp; - - /* elt_ofs might correspond to .addr_write, so use atomic_read */ -#if TCG_OVERSIZED_GUEST - cmp = *(target_ulong *)((uintptr_t)vtlb + elt_ofs); -#else - cmp = atomic_read((target_ulong *)((uintptr_t)vtlb + elt_ofs)); -#endif + target_ulong cmp = tlb_read_ofs(vtlb, elt_ofs); if (cmp == page) { /* Found entry in victim tlb, swap tlb and iotlb. */ @@ -1108,6 +1111,56 @@ void probe_write(CPUArchState *env, target_ulong addr, int size, int mmu_idx, } } +void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, + MMUAccessType access_type, int mmu_idx) +{ + CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr); + uintptr_t tlb_addr, page; + size_t elt_ofs; + + switch (access_type) { + case MMU_DATA_LOAD: + elt_ofs = offsetof(CPUTLBEntry, addr_read); + break; + case MMU_DATA_STORE: + elt_ofs = offsetof(CPUTLBEntry, addr_write); + break; + case MMU_INST_FETCH: + elt_ofs = offsetof(CPUTLBEntry, addr_code); + break; + default: + g_assert_not_reached(); + } + + page = addr & TARGET_PAGE_MASK; + tlb_addr = tlb_read_ofs(entry, elt_ofs); + + if (!tlb_hit_page(tlb_addr, page)) { + uintptr_t index = tlb_index(env, mmu_idx, addr); + + if (!victim_tlb_hit(env, mmu_idx, index, elt_ofs, page)) { + CPUState *cs = ENV_GET_CPU(env); + CPUClass *cc = CPU_GET_CLASS(cs); + + if (!cc->tlb_fill(cs, addr, 0, access_type, mmu_idx, true, 0)) { + /* Non-faulting page table read failed. */ + return NULL; + } + + /* TLB resize via tlb_fill may have moved the entry. */ + entry = tlb_entry(env, mmu_idx, addr); + } + tlb_addr = tlb_read_ofs(entry, elt_ofs); + } + + if (tlb_addr & ~TARGET_PAGE_MASK) { + /* IO access */ + return NULL; + } + + return (void *)((uintptr_t)addr + entry->addend); +} + /* Probe for a read-modify-write atomic operation. Do not allow unaligned * operations, or io operations to proceed. Return the host address. */ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr, diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c index bc847250dd..fd434c66ea 100644 --- a/target/arm/sve_helper.c +++ b/target/arm/sve_helper.c @@ -4598,11 +4598,7 @@ static void sve_ldnf1_r(CPUARMState *env, void *vg, const target_ulong addr, * in the real world, obviously.) * * Then there are the annoying special cases with watchpoints... - * - * TODO: Add a form of tlb_fill that does not raise an exception, - * with a form of tlb_vaddr_to_host and a set of loads to match. - * The non_fault_vaddr_to_host would handle everything, usually, - * and the loads would handle the iomem path for watchpoints. + * TODO: Add a form of non-faulting loads using cc->tlb_fill(probe=true). */ host = tlb_vaddr_to_host(env, addr + mem_off, MMU_DATA_LOAD, mmu_idx); split = max_for_page(addr, mem_off, mem_max);