Re: [PATCH v2 00/25] TDX vCPU/VM creation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 7.01.25 г. 9:37 ч., Tony Lindgren wrote:
On Sat, Jan 04, 2025 at 01:43:56AM +0000, Edgecombe, Rick P wrote:
On Mon, 2024-12-23 at 17:25 +0100, Paolo Bonzini wrote:
22: missing review comment from v1

+     /* TDX only supports x2APIC, which requires an in-kernel local APIC. */
+     if (!vcpu->arch.apic)
+             return -EINVAL;

nit: Use kvm_apic_present()

Oops, nice catch.

Sorry this fell through. I made a patch for this earlier but missed it
while rebasing to a later dev branch and never sent it.

Below is a rebased version against the current KVM CoCo queue to fold
in if still needed. Sounds like this might be already dealt with in
Paolo's upcoming CoCo queue branch though.

Regards,

Tony

8< --------------------
 From aac264e9923c15522baf9ae765b1d58165c24523 Mon Sep 17 00:00:00 2001
From: Tony Lindgren <tony.lindgren@xxxxxxxxxxxxxxx>
Date: Mon, 2 Sep 2024 13:52:20 +0300
Subject: [PATCH 1/1] KVM/TDX: Use kvm_apic_present() in tdx_vcpu_create()

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);

Is it really required to expose this symbol? apic_hw_disabled is defined as static inline in the header?

> +> __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);





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux