From patchwork Thu May 9 06:02:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163669 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp547564ilr; Wed, 8 May 2019 23:11:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSZSa//E7tHpPOnP0Bq4V3Y5oGzVj/pVp4EToLS19EEttPyGC01s5UTm8B6LlYyZyeWeH9 X-Received: by 2002:adf:82b2:: with SMTP id 47mr1506882wrc.76.1557382311557; Wed, 08 May 2019 23:11:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557382311; cv=none; d=google.com; s=arc-20160816; b=LjlEUoowmFbLxp5odq+csDxAM8liMpIjWARKKaYkq+u0IPxjKVWEi7jYYipXbFVBsa HDOcdVfaczU8dW1sBImQ1Fa7MqYHKY9jrV16F6SzqD2+MJSPO2/JS8OW5cBL3YTZjGno l1Qg5Bi1ys3holxWMKNLfG/dORbhRMQRZg5ntYpAnhOJmNaniQ/CPzdMUPurPAmOznbg iBaO9zVak9QOsLVuPgTidTQfGSRPxo77so8uMz5kiNE4sNn2QZJmIjllP+airi50zACS dRXPBVzRkYBHPwE9HXhXhAEP58ZYnqORNAceIO8B9e0XYf/Fp2J7zIPP2DLJOETxbFqL 3/sQ== 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=s87CuOmfhyfGLXIPM91Iv48ElcI94bqoXpVc6e0DK1o=; b=d5YwbRyrDiNffLcG3yuWtq8CVccL+xYr7U8Wd9zKRnvE2ur9BJF6xybjUAqIyayZRo OxPrS3lSnFaF+/WfJ/QwR0TEZGLDyc997++Xs1rPCbpbwVMAGLZoVvjLhkvvr7Ges1Z3 ZzGnZ9flfwLQEKOpEC5SUYkyETTgNB79yfsZoChybx/cOXJ+HBRK7vhYPbMyaHHA/PJP k1/Z7UOxUnIL4XmnXaeSujj8qRQCG2yV9IZ9mu7NaxF91BKDWiDMexqrKvUwqEH5cSr3 8N6VG88bmOsV3d/XG5g3tvpc7JqIRvUroeFW9r8c2OhNQkC0gCRDyP7OTp80BYkRME26 BT0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gLbGq7hI; 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 f132si838598wme.37.2019.05.08.23.11.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 May 2019 23:11:51 -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=gLbGq7hI; 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]:48700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOcHW-0006Ce-C0 for patch@linaro.org; Thu, 09 May 2019 02:11:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:44836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOc8z-0005zi-6I for qemu-devel@nongnu.org; Thu, 09 May 2019 02:03:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOc8x-00074r-Tq for qemu-devel@nongnu.org; Thu, 09 May 2019 02:03:01 -0400 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:41592) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOc8w-00073O-Hn for qemu-devel@nongnu.org; Thu, 09 May 2019 02:02:59 -0400 Received: by mail-pf1-x441.google.com with SMTP id l132so714848pfc.8 for ; Wed, 08 May 2019 23:02:56 -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=s87CuOmfhyfGLXIPM91Iv48ElcI94bqoXpVc6e0DK1o=; b=gLbGq7hIR8VObBn+DXEe0jkq61LnfjzwfYICuIvS8cVSjrwwfHapXT97QTN5AFQJnv gBYGdz49nzNwHtLHs3fHRmF8nxAYwM28SzUKJhZ5utCt+15MZu8yRQhX0Rv/dpXyjaB9 LxY8TxqrPakG/QML/opf42nwxVQSX9E/uxiZb68NBFWLqkKbEI6kP4rDHbBoXYpCsrTR 4sjumjbolTePZeJbzgKfRv6BqRnzvNPaByP8iu8Chvk5llUlwQEivosnlUOowt23ElSF LBaVUMQHBxU+RiyVM1RvJBKKsKuLCdURJBgOqh1Ko9y3VHvcSx34Y8gpxmcaq67qloVa UQwQ== 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=s87CuOmfhyfGLXIPM91Iv48ElcI94bqoXpVc6e0DK1o=; b=oZ6rcO8soRdZmds6BVSoNtxCXwt6MK641wah9ywyr6VH9QxDRNVrpeXB1qvwn/1VbL vVduJj26iR7sNcJ8YRd6nvNReApZPQGWxFg4mIPRFEIpYU86mp9xwOeUE4jBlihaWraE zDthouOWXNX3TY89MPCoVTuOvENA+fbZrGP6N0JxF+AUC11oQsHeok8+AkGLeL57cMfH Vrj592uW1KaYPreKbM3j85KV7H71FuR5iGBOrxYtoqSNHIL94M+ZHZ8f8qRk3weO3kQf ak5V3dlcDKRdtUNM3Oi54bWpbwfEQO0oXMEH2VOjqwfBXhjVU8LMb6ODzTIBTQzmIwBD PXkw== X-Gm-Message-State: APjAAAUxs3l/14VtMEDt1C/nQo+qIdvbepRkCRk1xOKZePy3/EdYmPlZ Qy5QlCALMc+1Ez2liwPd5JMnDTq3a8k= X-Received: by 2002:a63:191b:: with SMTP id z27mr3145439pgl.327.1557381775707; Wed, 08 May 2019 23:02:55 -0700 (PDT) Received: from localhost.localdomain (97-113-27-95.tukw.qwest.net. [97.113.27.95]) by smtp.gmail.com with ESMTPSA id n7sm1496109pff.45.2019.05.08.23.02.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 May 2019 23:02:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 8 May 2019 23:02:25 -0700 Message-Id: <20190509060246.4031-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190509060246.4031-1-richard.henderson@linaro.org> References: <20190509060246.4031-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::441 Subject: [Qemu-devel] [PATCH 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: Paolo Bonzini , Eduardo Habkost 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..3c98869577 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5915,9 +5915,8 @@ 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 + cc->tlb_fill = x86_cpu_tlb_fill; +#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; 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