[PATCH 1/1] KVM/TDX: Use kvm_apic_present() in tdx_vcpu_create()
From: Tony Lindgren
Date: Mon Sep 02 2024 - 06:52:20 EST
Use kvm_apic_present() in tdx_vcpu_create(). We need to now export
apic_hw_disabled for kvm-intel to use it.
Suggested-by: Nikolay Borisov <nik.borisov@xxxxxxxx>
Signed-off-by: Tony Lindgren <tony.lindgren@xxxxxxxxxxxxxxx>
---
arch/x86/kvm/lapic.c | 2 ++
arch/x86/kvm/vmx/tdx.c | 3 ++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index fcf3a8907196..2b83092eace2 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -139,6 +139,8 @@ __read_mostly DEFINE_STATIC_KEY_FALSE(kvm_has_noapic_vcpu);
EXPORT_SYMBOL_GPL(kvm_has_noapic_vcpu);
__read_mostly DEFINE_STATIC_KEY_DEFERRED_FALSE(apic_hw_disabled, HZ);
+EXPORT_SYMBOL_GPL(apic_hw_disabled);
+
__read_mostly DEFINE_STATIC_KEY_DEFERRED_FALSE(apic_sw_disabled, HZ);
static inline int apic_enabled(struct kvm_lapic *apic)
diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
index d0dc3200fa37..6c68567d964d 100644
--- a/arch/x86/kvm/vmx/tdx.c
+++ b/arch/x86/kvm/vmx/tdx.c
@@ -8,6 +8,7 @@
#include "capabilities.h"
#include "mmu.h"
#include "x86_ops.h"
+#include "lapic.h"
#include "tdx.h"
#include "vmx.h"
#include "mmu/spte.h"
@@ -674,7 +675,7 @@ int tdx_vcpu_create(struct kvm_vcpu *vcpu)
return -EIO;
/* TDX only supports x2APIC, which requires an in-kernel local APIC. */
- if (!vcpu->arch.apic)
+ if (!kvm_apic_present(vcpu))
return -EINVAL;
fpstate_set_confidential(&vcpu->arch.guest_fpu);
--
2.47.1