Skip to contentSkip to conversation

KVM: TDX: Force split irqchip for TDX at irqchip creation time

PATCH Superseded Sagi Shahar 2 participants 2 messages Aug 28, 2025

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 KVM: TDX: Force split irqchip for TDX at irqchip creation time

TDX module protects the EOI-bitmap which prevents the use of in-kernel I/O APIC. See more details in the original patch [1]

The current implementation already enforces the use of split irqchip for TDX but it does so at the vCPU creation time which is generally to late to fallback to split irqchip.

This patch follows Sean's recommendation from [2] and adds a check if I/O APIC is supported for the VM at irqchip creation time.

[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/

---
 arch/x86/include/asm/kvm_host.h | 1 +
 arch/x86/kvm/vmx/tdx.c          | 1 +
 arch/x86/kvm/x86.c              | 9 +++++++++
 3 files changed, 11 insertions(+)
arch/x86/include/asm/kvm_host.h +1 -0
index f19a76d3ca0e..6a4019d3a184 100644
@@ -1357,6 +1357,7 @@ struct kvm_arch {
 	u8 vm_type;
 	bool has_private_mem;
 	bool has_protected_state;
+	bool has_protected_eoi;
 	bool pre_fault_allowed;
 	struct hlist_head *mmu_page_hash;
 	struct list_head active_mmu_pages;
arch/x86/kvm/vmx/tdx.c +1 -0
index 66744f5768c8..6daa45dcbfb0 100644
@@ -630,6 +630,7 @@ int tdx_vm_init(struct kvm *kvm)
 
 	kvm->arch.has_protected_state = true;
 	kvm->arch.has_private_mem = true;
+	kvm->arch.has_protected_eoi = true;
 	kvm->arch.disabled_quirks |= KVM_X86_QUIRK_IGNORE_GUEST_PAT;
 
 	/*
arch/x86/kvm/x86.c +9 -0
index a1c49bc681c4..57b4d5ba2568 100644
@@ -6966,6 +6966,15 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
 		if (irqchip_in_kernel(kvm))
 			goto create_irqchip_unlock;
 
+		/*
+		 * Disallow an in-kernel I/O APIC if the VM has protected EOIs,
+		 * i.e. if KVM can't intercept EOIs and thus can't properly
+		 * emulate level-triggered interrupts.
+		 */
+		r = -ENOTTY;
+		if (kvm->arch.has_protected_eoi)
+			goto create_irqchip_unlock;
+
 		r = -EINVAL;
 		if (kvm->created_vcpus)
 			goto create_irqchip_unlock;
Signature · 1 line
2.51.0.268.g9569e192d0-goog
Acked-by on v3 1/1
#1 lore raw
Quoted 2 lines · Sagi Shahar

TDX module protects the EOI-bitmap which prevents the use of in-kernel I/O APIC. See more details in the original patch [1]

						      ^
						      missing a period
Quoted 3 lines

The current implementation already enforces the use of split irqchip for TDX but it does so at the vCPU creation time which is generally to late

								  ^
								  too
Quoted 5 lines

to fallback to split irqchip.

This patch follows Sean's recommendation from [2] and adds a check if I/O APIC is supported for the VM at irqchip creation time.

Quoted 7 lines

[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/