Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3230060pxb; Tue, 20 Apr 2021 03:43:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWKEeqD4YQtFeTuYALClR5P/1Sg09+Qb8a6xZHyFk1BHf/8F+RAkhbJOLLIvJk9v9n4bW4 X-Received: by 2002:a05:6402:1103:: with SMTP id u3mr30966241edv.205.1618915428707; Tue, 20 Apr 2021 03:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618915428; cv=none; d=google.com; s=arc-20160816; b=thZkLT/ifvugT86FETjQ2ETKBOl0cmDaN7USHMzHWycCmrtradtV76p3+wbZYKElWz 3/PNPhO1rSaaqPLCS6Tsrv84BQBdndFcwG7mBGxNE5HI+zRKPPot7htRNkAd6Gp/Rc3g 2UN9YI61vAGaMrXPA7P92DOY24x6LIh8j95+kgwA8AiGxISaW5XJ0IQCau/BGe4DvVKJ oQsd/kTPKoeoUqAVmLuHNLtG6D5Bl7XcDyNqzVqbjeQ3m6u2CkK7Pm9aGGdqlyrEylP+ n8wwStqd+iP/0TiOhFublBFYNXK36ia2dzaGdd7/qYnmTJnUeSLfbw+maSRP1FapVys/ KmZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=optmTq5UmxjQvW7dcl4Gto5koX5i722AfjtT6wC3Be8=; b=IJSn1vDfvUlTMurRqfFDX4sQN3SX2WR7zwY7aM5iKG0yIPoNPWucAT/t6DgLQmkOeK 48Y3A45cHgNCBI7yeLGkv9hR8VSHyAq8N8K2jqMNcMk/xnVaY9CRCxvKAtYhqKcikQZY lZ6SEzUsj5QWMRCdCcbHA04aRMJcv6lhqVquDg1w64UfCAB8Z+1UIsiD6WVjmK6Vca44 Z2gecek5bUiCvWxQCjghiLQCL4LBqX2TJOQ4OyIeT9VZ6mOzQM6By4//FPVAjlYQOhgN q8gAlXxalj8mb668du7UoNDl0lr3Y0VT/WIwdz8vXGCZMEaEfC2wF+2donOs6M6LAZtc yw5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c7si14015813ejx.166.2021.04.20.03.43.25; Tue, 20 Apr 2021 03:43:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231816AbhDTKm1 (ORCPT + 99 others); Tue, 20 Apr 2021 06:42:27 -0400 Received: from mga17.intel.com ([192.55.52.151]:34977 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231673AbhDTKmP (ORCPT ); Tue, 20 Apr 2021 06:42:15 -0400 IronPort-SDR: WmtMsDdnQcW9PLisK/XFWrU0/Sw4c0K1LeKD7Upv/L7GYHQ3NyN8ER+mmKYqfEot8JWo++C6o6 5xB9p4r1kU7A== X-IronPort-AV: E=McAfee;i="6200,9189,9959"; a="175590750" X-IronPort-AV: E=Sophos;i="5.82,236,1613462400"; d="scan'208";a="175590750" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 03:41:43 -0700 IronPort-SDR: JzBBEeoVTFEeeF5P7MLchV5zSIx4r8Y6tDi57ehNB4oySwK4/QHxmj+F22OnduJ/WzfuLx6h6i 7RF0Gzc/pOeg== X-IronPort-AV: E=Sophos;i="5.82,236,1613462400"; d="scan'208";a="426872765" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 03:41:43 -0700 From: Isaku Yamahata To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson Cc: isaku.yamahata@gmail.com, Isaku Yamahata Subject: [RFC PATCH 02/10] KVM: x86/mmu: make kvm_mmu:page_fault receive single argument Date: Tue, 20 Apr 2021 03:39:12 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Convert kvm_mmu:page_fault callback to receive struct kvm_page_fault instead of many arguments. The following functions are converted by this patch. kvm_tdp_page_fault(), nonpaging_page_fault() and, FNAME(page_fault). No functional change is intended. Signed-off-by: Isaku Yamahata --- arch/x86/include/asm/kvm_host.h | 4 ++-- arch/x86/kvm/mmu.h | 9 +++------ arch/x86/kvm/mmu/mmu.c | 19 ++++++++++--------- arch/x86/kvm/mmu/paging_tmpl.h | 7 +++++-- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 3768819693e5..97e72076f358 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -351,6 +351,7 @@ struct kvm_mmu_root_info { #define KVM_HAVE_MMU_RWLOCK struct kvm_mmu_page; +struct kvm_page_fault; /* * x86 supports 4 paging modes (5-level 64-bit, 4-level 64-bit, 3-level 32-bit, @@ -360,8 +361,7 @@ struct kvm_mmu_page; struct kvm_mmu { unsigned long (*get_guest_pgd)(struct kvm_vcpu *vcpu); u64 (*get_pdptr)(struct kvm_vcpu *vcpu, int index); - int (*page_fault)(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u32 err, - bool prefault); + int (*page_fault)(struct kvm_page_fault *kpf); void (*inject_page_fault)(struct kvm_vcpu *vcpu, struct x86_exception *fault); gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gpa_t gva_or_gpa, diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h index 245c5d7fd3dd..7fcd9c147e63 100644 --- a/arch/x86/kvm/mmu.h +++ b/arch/x86/kvm/mmu.h @@ -124,18 +124,15 @@ static inline void kvm_page_fault_init( kpf->prefault = prefault; } -int kvm_tdp_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, - bool prefault); +int kvm_tdp_page_fault(struct kvm_page_fault *kpf); static inline int kvm_mmu_do_page_fault(struct kvm_page_fault *kpf) { #ifdef CONFIG_RETPOLINE if (likely(kpf->vcpu->arch.mmu->page_fault == kvm_tdp_page_fault)) - return kvm_tdp_page_fault(kpf->vcpu, kpf->cr2_or_gpa, - kpf->error_code, kpf->prefault); + return kvm_tdp_page_fault(kpf); #endif - return kpf->vcpu->arch.mmu->page_fault(kpf->vcpu, kpf->cr2_or_gpa, - kpf->error_code, kpf->prefault); + return kpf->vcpu->arch.mmu->page_fault(kpf); } /* diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 8ea2afcb528c..46998cfabfd3 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -3745,14 +3745,15 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, return r; } -static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, - u32 error_code, bool prefault) +static int nonpaging_page_fault(struct kvm_page_fault *kpf) { - pgprintk("%s: gva %lx error %x\n", __func__, gpa, error_code); + pgprintk("%s: gva %lx error %x\n", __func__, + kpf->cr2_or_gpa, kpf->error_code); /* This path builds a PAE pagetable, we can map 2mb pages at maximum. */ - return direct_page_fault(vcpu, gpa & PAGE_MASK, error_code, prefault, - PG_LEVEL_2M, false); + return direct_page_fault(kpf->vcpu, kpf->cr2_or_gpa & PAGE_MASK, + kpf->error_code, + kpf->prefault, PG_LEVEL_2M, false); } int kvm_handle_page_fault(struct kvm_vcpu *vcpu, u64 error_code, @@ -3788,9 +3789,9 @@ int kvm_handle_page_fault(struct kvm_vcpu *vcpu, u64 error_code, } EXPORT_SYMBOL_GPL(kvm_handle_page_fault); -int kvm_tdp_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, - bool prefault) +int kvm_tdp_page_fault(struct kvm_page_fault *kpf) { + u32 gpa = kpf->cr2_or_gpa; int max_level; for (max_level = KVM_MAX_HUGEPAGE_LEVEL; @@ -3799,11 +3800,11 @@ int kvm_tdp_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, int page_num = KVM_PAGES_PER_HPAGE(max_level); gfn_t base = (gpa >> PAGE_SHIFT) & ~(page_num - 1); - if (kvm_mtrr_check_gfn_range_consistency(vcpu, base, page_num)) + if (kvm_mtrr_check_gfn_range_consistency(kpf->vcpu, base, page_num)) break; } - return direct_page_fault(vcpu, gpa, error_code, prefault, + return direct_page_fault(kpf->vcpu, gpa, kpf->error_code, kpf->prefault, max_level, true); } diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h index 55d7b473ac44..dc814463a8df 100644 --- a/arch/x86/kvm/mmu/paging_tmpl.h +++ b/arch/x86/kvm/mmu/paging_tmpl.h @@ -789,9 +789,12 @@ FNAME(is_self_change_mapping)(struct kvm_vcpu *vcpu, * Returns: 1 if we need to emulate the instruction, 0 otherwise, or * a negative value on error. */ -static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t addr, u32 error_code, - bool prefault) +static int FNAME(page_fault)(struct kvm_page_fault *kpf) { + struct kvm_vcpu *vcpu = kpf->vcpu; + gpa_t addr = kpf->cr2_or_gpa; + u32 error_code = kpf->error_code; + bool prefault = kpf->prefault; bool write_fault = error_code & PFERR_WRITE_MASK; bool user_fault = error_code & PFERR_USER_MASK; struct guest_walker walker; -- 2.25.1