From nobody Thu Sep 18 05:38:09 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7BCFC4167B for ; Fri, 9 Dec 2022 03:34:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229907AbiLIDdu (ORCPT ); Thu, 8 Dec 2022 22:33:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbiLIDdr (ORCPT ); Thu, 8 Dec 2022 22:33:47 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0326B1D304; Thu, 8 Dec 2022 19:33:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670556817; x=1702092817; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Vq9nMkdKxWUfGxjoZszTdIqmn0HDQzbbMF06hbT4nuU=; b=cvYMeTtz/GCPH9JPBHzmNYSpG8q2nqZkVgfsvo5NgewLkfzraTk55f1t 0uNkc0S8NjbtdCVyZnUtdHrBioUx+3mUsy0OXVb9CnSsVcGQTOwaj89mP qNxiPT+iq14rbd3kMmQE0w+/dzjfn54Zsp7l7dwAxqbNvEhq8FEJmyoF2 MHosa6zvA2H5GmkFJwb2UxSZlpZLEf9A5nnfAxPhuRUmu5sqAk5NUFkWF xZCXIPtFKnI9iknhdEYjjasZgHGWQWFUrqDy87PwtFszWWWdPJ0qbl9R6 vKNCulhw0f1+gKYHIdfsoC/D80bITxVJ1+9PhCDb8rtKVYsG4BgRb7Q7p Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="300790107" X-IronPort-AV: E=Sophos;i="5.96,228,1665471600"; d="scan'208";a="300790107" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2022 19:26:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10555"; a="892508970" X-IronPort-AV: E=Sophos;i="5.96,228,1665471600"; d="scan'208";a="892508970" Received: from skxmcp01.bj.intel.com ([10.240.193.86]) by fmsmga006.fm.intel.com with ESMTP; 08 Dec 2022 19:26:13 -0800 From: Yu Zhang To: pbonzini@redhat.com, seanjc@google.com, kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] KVM: X86: Use the common definition - 'GPA_INVALID' for X86 Date: Fri, 9 Dec 2022 10:36:22 +0800 Message-Id: <20221209023622.274715-1-yu.c.zhang@linux.intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" KVM already has a 'GPA_INVALID' defined as (~(gpa_t)0) in kvm_types.h, and it is used by ARM and X86 xen code. We do not need a replicated 'INVALID_GPA' for X86 specifically. Just replace it with the common one. Tested by rebuilding KVM. No functional change intended. Signed-off-by: Yu Zhang --- arch/x86/include/asm/kvm_host.h | 2 - arch/x86/kvm/hyperv.c | 2 +- arch/x86/kvm/mmu/paging_tmpl.h | 6 +-- arch/x86/kvm/svm/nested.c | 4 +- arch/x86/kvm/svm/svm.c | 4 +- arch/x86/kvm/vmx/nested.c | 66 ++++++++++++++++----------------- arch/x86/kvm/vmx/sgx.c | 2 +- arch/x86/kvm/vmx/vmx.c | 6 +-- arch/x86/kvm/x86.c | 18 ++++----- 9 files changed, 54 insertions(+), 56 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_hos= t.h index d1013c4f673c..461c0b699a38 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -134,8 +134,6 @@ #define INVALID_PAGE (~(hpa_t)0) #define VALID_PAGE(x) ((x) !=3D INVALID_PAGE) =20 -#define INVALID_GPA (~(gpa_t)0) - /* KVM Hugepage definitions for x86 */ #define KVM_MAX_HUGEPAGE_LEVEL PG_LEVEL_1G #define KVM_NR_PAGE_SIZES (KVM_MAX_HUGEPAGE_LEVEL - PG_LEVEL_4K + 1) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 2c7f2a26421e..09282f0cf0cd 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -1945,7 +1945,7 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, st= ruct kvm_hv_hcall *hc) */ if (!hc->fast && is_guest_mode(vcpu)) { hc->ingpa =3D translate_nested_gpa(vcpu, hc->ingpa, 0, NULL); - if (unlikely(hc->ingpa =3D=3D INVALID_GPA)) + if (unlikely(hc->ingpa =3D=3D GPA_INVALID)) return HV_STATUS_INVALID_HYPERCALL_INPUT; } =20 diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h index 0f6455072055..2709c135a798 100644 --- a/arch/x86/kvm/mmu/paging_tmpl.h +++ b/arch/x86/kvm/mmu/paging_tmpl.h @@ -378,7 +378,7 @@ static int FNAME(walk_addr_generic)(struct guest_walker= *walker, * information to fix the exit_qualification or exit_info_1 * fields. */ - if (unlikely(real_gpa =3D=3D INVALID_GPA)) + if (unlikely(real_gpa =3D=3D GPA_INVALID)) return 0; =20 host_addr =3D kvm_vcpu_gfn_to_hva_prot(vcpu, gpa_to_gfn(real_gpa), @@ -431,7 +431,7 @@ static int FNAME(walk_addr_generic)(struct guest_walker= *walker, #endif =20 real_gpa =3D kvm_translate_gpa(vcpu, mmu, gfn_to_gpa(gfn), access, &walke= r->fault); - if (real_gpa =3D=3D INVALID_GPA) + if (real_gpa =3D=3D GPA_INVALID) return 0; =20 walker->gfn =3D real_gpa >> PAGE_SHIFT; @@ -962,7 +962,7 @@ static gpa_t FNAME(gva_to_gpa)(struct kvm_vcpu *vcpu, s= truct kvm_mmu *mmu, struct x86_exception *exception) { struct guest_walker walker; - gpa_t gpa =3D INVALID_GPA; + gpa_t gpa =3D GPA_INVALID; int r; =20 #ifndef CONFIG_X86_64 diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index bc9cd7086fa9..5531263f6045 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -1169,7 +1169,7 @@ void svm_free_nested(struct vcpu_svm *svm) * * When the vmcb02 is freed, this optimization becomes invalid. */ - svm->nested.last_vmcb12_gpa =3D INVALID_GPA; + svm->nested.last_vmcb12_gpa =3D GPA_INVALID; =20 svm->nested.initialized =3D false; } @@ -1180,7 +1180,7 @@ void svm_leave_nested(struct kvm_vcpu *vcpu) =20 if (is_guest_mode(vcpu)) { svm->nested.nested_run_pending =3D 0; - svm->nested.vmcb12_gpa =3D INVALID_GPA; + svm->nested.vmcb12_gpa =3D GPA_INVALID; =20 leave_guest_mode(vcpu); =20 diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 91352d692845..4d88f5293968 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1275,8 +1275,8 @@ static void init_vmcb(struct kvm_vcpu *vcpu) svm->current_vmcb->asid_generation =3D 0; svm->asid =3D 0; =20 - svm->nested.vmcb12_gpa =3D INVALID_GPA; - svm->nested.last_vmcb12_gpa =3D INVALID_GPA; + svm->nested.vmcb12_gpa =3D GPA_INVALID; + svm->nested.last_vmcb12_gpa =3D GPA_INVALID; =20 if (!kvm_pause_in_guest(vcpu->kvm)) { control->pause_filter_count =3D pause_filter_count; diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index b28be793de29..b903957b2b0b 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -192,7 +192,7 @@ static int nested_vmx_fail(struct kvm_vcpu *vcpu, u32 v= m_instruction_error) * failValid writes the error number to the current VMCS, which * can't be done if there isn't a current VMCS. */ - if (vmx->nested.current_vmptr =3D=3D INVALID_GPA && + if (vmx->nested.current_vmptr =3D=3D GPA_INVALID && !evmptr_is_valid(vmx->nested.hv_evmcs_vmptr)) return nested_vmx_failInvalid(vcpu); =20 @@ -219,7 +219,7 @@ static inline u64 vmx_control_msr(u32 low, u32 high) static void vmx_disable_shadow_vmcs(struct vcpu_vmx *vmx) { secondary_exec_controls_clearbit(vmx, SECONDARY_EXEC_SHADOW_VMCS); - vmcs_write64(VMCS_LINK_POINTER, INVALID_GPA); + vmcs_write64(VMCS_LINK_POINTER, GPA_INVALID); vmx->nested.need_vmcs12_to_shadow_sync =3D false; } =20 @@ -236,7 +236,7 @@ static inline void nested_release_evmcs(struct kvm_vcpu= *vcpu) vmx->nested.hv_evmcs_vmptr =3D EVMPTR_INVALID; =20 if (hv_vcpu) { - hv_vcpu->nested.pa_page_gpa =3D INVALID_GPA; + hv_vcpu->nested.pa_page_gpa =3D GPA_INVALID; hv_vcpu->nested.vm_id =3D 0; hv_vcpu->nested.vp_id =3D 0; } @@ -304,10 +304,10 @@ static void free_nested(struct kvm_vcpu *vcpu) =20 vmx->nested.vmxon =3D false; vmx->nested.smm.vmxon =3D false; - vmx->nested.vmxon_ptr =3D INVALID_GPA; + vmx->nested.vmxon_ptr =3D GPA_INVALID; free_vpid(vmx->nested.vpid02); vmx->nested.posted_intr_nv =3D -1; - vmx->nested.current_vmptr =3D INVALID_GPA; + vmx->nested.current_vmptr =3D GPA_INVALID; if (enable_shadow_vmcs) { vmx_disable_shadow_vmcs(vmx); vmcs_clear(vmx->vmcs01.shadow_vmcs); @@ -667,7 +667,7 @@ static void nested_cache_shadow_vmcs12(struct kvm_vcpu = *vcpu, struct gfn_to_hva_cache *ghc =3D &vmx->nested.shadow_vmcs12_cache; =20 if (!nested_cpu_has_shadow_vmcs(vmcs12) || - vmcs12->vmcs_link_pointer =3D=3D INVALID_GPA) + vmcs12->vmcs_link_pointer =3D=3D GPA_INVALID) return; =20 if (ghc->gpa !=3D vmcs12->vmcs_link_pointer && @@ -686,7 +686,7 @@ static void nested_flush_cached_shadow_vmcs12(struct kv= m_vcpu *vcpu, struct gfn_to_hva_cache *ghc =3D &vmx->nested.shadow_vmcs12_cache; =20 if (!nested_cpu_has_shadow_vmcs(vmcs12) || - vmcs12->vmcs_link_pointer =3D=3D INVALID_GPA) + vmcs12->vmcs_link_pointer =3D=3D GPA_INVALID) return; =20 if (ghc->gpa !=3D vmcs12->vmcs_link_pointer && @@ -2008,7 +2008,7 @@ static enum nested_evmptrld_status nested_vmx_handle_= enlightened_vmptrld( } =20 if (unlikely(evmcs_gpa !=3D vmx->nested.hv_evmcs_vmptr)) { - vmx->nested.current_vmptr =3D INVALID_GPA; + vmx->nested.current_vmptr =3D GPA_INVALID; =20 nested_release_evmcs(vcpu); =20 @@ -2197,7 +2197,7 @@ static void prepare_vmcs02_constant_state(struct vcpu= _vmx *vmx) } =20 if (cpu_has_vmx_encls_vmexit()) - vmcs_write64(ENCLS_EXITING_BITMAP, INVALID_GPA); + vmcs_write64(ENCLS_EXITING_BITMAP, GPA_INVALID); =20 if (kvm_notify_vmexit_enabled(kvm)) vmcs_write32(NOTIFY_WINDOW, kvm->arch.notify_window); @@ -2219,7 +2219,7 @@ static void prepare_vmcs02_early_rare(struct vcpu_vmx= *vmx, { prepare_vmcs02_constant_state(vmx); =20 - vmcs_write64(VMCS_LINK_POINTER, INVALID_GPA); + vmcs_write64(VMCS_LINK_POINTER, GPA_INVALID); =20 if (enable_vpid) { if (nested_cpu_has_vpid(vmcs12) && vmx->nested.vpid02) @@ -2984,7 +2984,7 @@ static int nested_vmx_check_vmcs_link_ptr(struct kvm_= vcpu *vcpu, struct gfn_to_hva_cache *ghc =3D &vmx->nested.shadow_vmcs12_cache; struct vmcs_hdr hdr; =20 - if (vmcs12->vmcs_link_pointer =3D=3D INVALID_GPA) + if (vmcs12->vmcs_link_pointer =3D=3D GPA_INVALID) return 0; =20 if (CC(!page_address_valid(vcpu, vmcs12->vmcs_link_pointer))) @@ -3242,7 +3242,7 @@ static bool nested_get_vmcs12_pages(struct kvm_vcpu *= vcpu) * Write an illegal value to VIRTUAL_APIC_PAGE_ADDR to * force VM-Entry to fail. */ - vmcs_write64(VIRTUAL_APIC_PAGE_ADDR, INVALID_GPA); + vmcs_write64(VIRTUAL_APIC_PAGE_ADDR, GPA_INVALID); } } =20 @@ -3567,7 +3567,7 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool= launch) return nested_vmx_failInvalid(vcpu); =20 if (CC(!evmptr_is_valid(vmx->nested.hv_evmcs_vmptr) && - vmx->nested.current_vmptr =3D=3D INVALID_GPA)) + vmx->nested.current_vmptr =3D=3D GPA_INVALID)) return nested_vmx_failInvalid(vcpu); =20 vmcs12 =3D get_vmcs12(vcpu); @@ -5083,7 +5083,7 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu) if (!vmx->nested.cached_vmcs12) goto out_cached_vmcs12; =20 - vmx->nested.shadow_vmcs12_cache.gpa =3D INVALID_GPA; + vmx->nested.shadow_vmcs12_cache.gpa =3D GPA_INVALID; vmx->nested.cached_shadow_vmcs12 =3D kzalloc(VMCS12_SIZE, GFP_KERNEL_ACCO= UNT); if (!vmx->nested.cached_shadow_vmcs12) goto out_cached_shadow_vmcs12; @@ -5194,7 +5194,7 @@ static inline void nested_release_vmcs12(struct kvm_v= cpu *vcpu) { struct vcpu_vmx *vmx =3D to_vmx(vcpu); =20 - if (vmx->nested.current_vmptr =3D=3D INVALID_GPA) + if (vmx->nested.current_vmptr =3D=3D GPA_INVALID) return; =20 copy_vmcs02_to_vmcs12_rare(vcpu, get_vmcs12(vcpu)); @@ -5214,7 +5214,7 @@ static inline void nested_release_vmcs12(struct kvm_v= cpu *vcpu) =20 kvm_mmu_free_roots(vcpu->kvm, &vcpu->arch.guest_mmu, KVM_MMU_ROOTS_ALL); =20 - vmx->nested.current_vmptr =3D INVALID_GPA; + vmx->nested.current_vmptr =3D GPA_INVALID; } =20 /* Emulate the VMXOFF instruction */ @@ -5312,12 +5312,12 @@ static int handle_vmread(struct kvm_vcpu *vcpu) =20 if (!evmptr_is_valid(vmx->nested.hv_evmcs_vmptr)) { /* - * In VMX non-root operation, when the VMCS-link pointer is INVALID_GPA, + * In VMX non-root operation, when the VMCS-link pointer is GPA_INVALID, * any VMREAD sets the ALU flags for VMfailInvalid. */ - if (vmx->nested.current_vmptr =3D=3D INVALID_GPA || + if (vmx->nested.current_vmptr =3D=3D GPA_INVALID || (is_guest_mode(vcpu) && - get_vmcs12(vcpu)->vmcs_link_pointer =3D=3D INVALID_GPA)) + get_vmcs12(vcpu)->vmcs_link_pointer =3D=3D GPA_INVALID)) return nested_vmx_failInvalid(vcpu); =20 offset =3D get_vmcs12_field_offset(field); @@ -5422,12 +5422,12 @@ static int handle_vmwrite(struct kvm_vcpu *vcpu) return 1; =20 /* - * In VMX non-root operation, when the VMCS-link pointer is INVALID_GPA, + * In VMX non-root operation, when the VMCS-link pointer is GPA_INVALID, * any VMWRITE sets the ALU flags for VMfailInvalid. */ - if (vmx->nested.current_vmptr =3D=3D INVALID_GPA || + if (vmx->nested.current_vmptr =3D=3D GPA_INVALID || (is_guest_mode(vcpu) && - get_vmcs12(vcpu)->vmcs_link_pointer =3D=3D INVALID_GPA)) + get_vmcs12(vcpu)->vmcs_link_pointer =3D=3D GPA_INVALID)) return nested_vmx_failInvalid(vcpu); =20 if (instr_info & BIT(10)) @@ -5880,7 +5880,7 @@ bool nested_vmx_check_io_bitmaps(struct kvm_vcpu *vcp= u, unsigned int port, gpa_t bitmap, last_bitmap; u8 b; =20 - last_bitmap =3D INVALID_GPA; + last_bitmap =3D GPA_INVALID; b =3D -1; =20 while (size > 0) { @@ -6364,8 +6364,8 @@ static int vmx_get_nested_state(struct kvm_vcpu *vcpu, .format =3D KVM_STATE_NESTED_FORMAT_VMX, .size =3D sizeof(kvm_state), .hdr.vmx.flags =3D 0, - .hdr.vmx.vmxon_pa =3D INVALID_GPA, - .hdr.vmx.vmcs12_pa =3D INVALID_GPA, + .hdr.vmx.vmxon_pa =3D GPA_INVALID, + .hdr.vmx.vmcs12_pa =3D GPA_INVALID, .hdr.vmx.preemption_timer_deadline =3D 0, }; struct kvm_vmx_nested_state_data __user *user_vmx_nested_state =3D @@ -6391,7 +6391,7 @@ static int vmx_get_nested_state(struct kvm_vcpu *vcpu, =20 if (is_guest_mode(vcpu) && nested_cpu_has_shadow_vmcs(vmcs12) && - vmcs12->vmcs_link_pointer !=3D INVALID_GPA) + vmcs12->vmcs_link_pointer !=3D GPA_INVALID) kvm_state.size +=3D sizeof(user_vmx_nested_state->shadow_vmcs12); } =20 @@ -6467,7 +6467,7 @@ static int vmx_get_nested_state(struct kvm_vcpu *vcpu, return -EFAULT; =20 if (nested_cpu_has_shadow_vmcs(vmcs12) && - vmcs12->vmcs_link_pointer !=3D INVALID_GPA) { + vmcs12->vmcs_link_pointer !=3D GPA_INVALID) { if (copy_to_user(user_vmx_nested_state->shadow_vmcs12, get_shadow_vmcs12(vcpu), VMCS12_SIZE)) return -EFAULT; @@ -6499,11 +6499,11 @@ static int vmx_set_nested_state(struct kvm_vcpu *vc= pu, if (kvm_state->format !=3D KVM_STATE_NESTED_FORMAT_VMX) return -EINVAL; =20 - if (kvm_state->hdr.vmx.vmxon_pa =3D=3D INVALID_GPA) { + if (kvm_state->hdr.vmx.vmxon_pa =3D=3D GPA_INVALID) { if (kvm_state->hdr.vmx.smm.flags) return -EINVAL; =20 - if (kvm_state->hdr.vmx.vmcs12_pa !=3D INVALID_GPA) + if (kvm_state->hdr.vmx.vmcs12_pa !=3D GPA_INVALID) return -EINVAL; =20 /* @@ -6557,7 +6557,7 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu, =20 vmx_leave_nested(vcpu); =20 - if (kvm_state->hdr.vmx.vmxon_pa =3D=3D INVALID_GPA) + if (kvm_state->hdr.vmx.vmxon_pa =3D=3D GPA_INVALID) return 0; =20 vmx->nested.vmxon_ptr =3D kvm_state->hdr.vmx.vmxon_pa; @@ -6570,13 +6570,13 @@ static int vmx_set_nested_state(struct kvm_vcpu *vc= pu, /* See vmx_has_valid_vmcs12. */ if ((kvm_state->flags & KVM_STATE_NESTED_GUEST_MODE) || (kvm_state->flags & KVM_STATE_NESTED_EVMCS) || - (kvm_state->hdr.vmx.vmcs12_pa !=3D INVALID_GPA)) + (kvm_state->hdr.vmx.vmcs12_pa !=3D GPA_INVALID)) return -EINVAL; else return 0; } =20 - if (kvm_state->hdr.vmx.vmcs12_pa !=3D INVALID_GPA) { + if (kvm_state->hdr.vmx.vmcs12_pa !=3D GPA_INVALID) { if (kvm_state->hdr.vmx.vmcs12_pa =3D=3D kvm_state->hdr.vmx.vmxon_pa || !page_address_valid(vcpu, kvm_state->hdr.vmx.vmcs12_pa)) return -EINVAL; @@ -6621,7 +6621,7 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu, =20 ret =3D -EINVAL; if (nested_cpu_has_shadow_vmcs(vmcs12) && - vmcs12->vmcs_link_pointer !=3D INVALID_GPA) { + vmcs12->vmcs_link_pointer !=3D GPA_INVALID) { struct vmcs12 *shadow_vmcs12 =3D get_shadow_vmcs12(vcpu); =20 if (kvm_state->size < diff --git a/arch/x86/kvm/vmx/sgx.c b/arch/x86/kvm/vmx/sgx.c index 8f95c7c01433..7c5a9bbe2908 100644 --- a/arch/x86/kvm/vmx/sgx.c +++ b/arch/x86/kvm/vmx/sgx.c @@ -79,7 +79,7 @@ static int sgx_gva_to_gpa(struct kvm_vcpu *vcpu, gva_t gv= a, bool write, else *gpa =3D kvm_mmu_gva_to_gpa_read(vcpu, gva, &ex); =20 - if (*gpa =3D=3D INVALID_GPA) { + if (*gpa =3D=3D GPA_INVALID) { kvm_inject_emulated_page_fault(vcpu, &ex); return -EFAULT; } diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index cea8c07f5229..21109269b88a 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -4593,7 +4593,7 @@ static void init_vmcs(struct vcpu_vmx *vmx) if (cpu_has_vmx_msr_bitmap()) vmcs_write64(MSR_BITMAP, __pa(vmx->vmcs01.msr_bitmap)); =20 - vmcs_write64(VMCS_LINK_POINTER, INVALID_GPA); /* 22.3.1.5 */ + vmcs_write64(VMCS_LINK_POINTER, GPA_INVALID); /* 22.3.1.5 */ =20 /* Control */ pin_controls_set(vmx, vmx_pin_based_exec_ctrl(vmx)); @@ -4712,8 +4712,8 @@ static void __vmx_vcpu_reset(struct kvm_vcpu *vcpu) vcpu_setup_sgx_lepubkeyhash(vcpu); =20 vmx->nested.posted_intr_nv =3D -1; - vmx->nested.vmxon_ptr =3D INVALID_GPA; - vmx->nested.current_vmptr =3D INVALID_GPA; + vmx->nested.vmxon_ptr =3D GPA_INVALID; + vmx->nested.current_vmptr =3D GPA_INVALID; vmx->nested.hv_evmcs_vmptr =3D EVMPTR_INVALID; =20 vcpu->arch.microcode_version =3D 0x100000000ULL; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 72ac6bf05c8b..fe984df5c602 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -871,7 +871,7 @@ int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr= 3) */ real_gpa =3D kvm_translate_gpa(vcpu, mmu, gfn_to_gpa(pdpt_gfn), PFERR_USER_MASK | PFERR_WRITE_MASK, NULL); - if (real_gpa =3D=3D INVALID_GPA) + if (real_gpa =3D=3D GPA_INVALID) return 0; =20 /* Note the offset, PDPTRs are 32 byte aligned when using PAE paging. */ @@ -7200,7 +7200,7 @@ static int kvm_read_guest_virt_helper(gva_t addr, voi= d *val, unsigned int bytes, unsigned toread =3D min(bytes, (unsigned)PAGE_SIZE - offset); int ret; =20 - if (gpa =3D=3D INVALID_GPA) + if (gpa =3D=3D GPA_INVALID) return X86EMUL_PROPAGATE_FAULT; ret =3D kvm_vcpu_read_guest_page(vcpu, gpa >> PAGE_SHIFT, data, offset, toread); @@ -7231,7 +7231,7 @@ static int kvm_fetch_guest_virt(struct x86_emulate_ct= xt *ctxt, /* Inline kvm_read_guest_virt_helper for speed. */ gpa_t gpa =3D mmu->gva_to_gpa(vcpu, mmu, addr, access|PFERR_FETCH_MASK, exception); - if (unlikely(gpa =3D=3D INVALID_GPA)) + if (unlikely(gpa =3D=3D GPA_INVALID)) return X86EMUL_PROPAGATE_FAULT; =20 offset =3D addr & (PAGE_SIZE-1); @@ -7292,7 +7292,7 @@ static int kvm_write_guest_virt_helper(gva_t addr, vo= id *val, unsigned int bytes unsigned towrite =3D min(bytes, (unsigned)PAGE_SIZE - offset); int ret; =20 - if (gpa =3D=3D INVALID_GPA) + if (gpa =3D=3D GPA_INVALID) return X86EMUL_PROPAGATE_FAULT; ret =3D kvm_vcpu_write_guest(vcpu, gpa, data, towrite); if (ret < 0) { @@ -7406,7 +7406,7 @@ static int vcpu_mmio_gva_to_gpa(struct kvm_vcpu *vcpu= , unsigned long gva, =20 *gpa =3D mmu->gva_to_gpa(vcpu, mmu, gva, access, exception); =20 - if (*gpa =3D=3D INVALID_GPA) + if (*gpa =3D=3D GPA_INVALID) return -1; =20 return vcpu_is_mmio_gpa(vcpu, gva, *gpa, write); @@ -7643,7 +7643,7 @@ static int emulator_cmpxchg_emulated(struct x86_emula= te_ctxt *ctxt, =20 gpa =3D kvm_mmu_gva_to_gpa_write(vcpu, addr, NULL); =20 - if (gpa =3D=3D INVALID_GPA || + if (gpa =3D=3D GPA_INVALID || (gpa & PAGE_MASK) =3D=3D APIC_DEFAULT_PHYS_BASE) goto emul_write; =20 @@ -8439,7 +8439,7 @@ static bool reexecute_instruction(struct kvm_vcpu *vc= pu, gpa_t cr2_or_gpa, * If the mapping is invalid in guest, let cpu retry * it to generate fault. */ - if (gpa =3D=3D INVALID_GPA) + if (gpa =3D=3D GPA_INVALID) return true; } =20 @@ -11426,7 +11426,7 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *= vcpu, gpa =3D kvm_mmu_gva_to_gpa_system(vcpu, vaddr, NULL); srcu_read_unlock(&vcpu->kvm->srcu, idx); tr->physical_address =3D gpa; - tr->valid =3D gpa !=3D INVALID_GPA; + tr->valid =3D gpa !=3D GPA_INVALID; tr->writeable =3D 1; tr->usermode =3D 0; =20 @@ -13096,7 +13096,7 @@ void kvm_fixup_and_inject_pf_error(struct kvm_vcpu = *vcpu, gva_t gva, u16 error_c (PFERR_WRITE_MASK | PFERR_FETCH_MASK | PFERR_USER_MASK); =20 if (!(error_code & PFERR_PRESENT_MASK) || - mmu->gva_to_gpa(vcpu, mmu, gva, access, &fault) !=3D INVALID_GPA) { + mmu->gva_to_gpa(vcpu, mmu, gva, access, &fault) !=3D GPA_INVALID) { /* * If vcpu->arch.walk_mmu->gva_to_gpa succeeded, the page * tables probably do not match the TLB. Just proceed --=20 2.25.1