@@ -45,6 +45,7 @@
#include "ioapic.h"
#include "lapic.h"
#include "irq.h"
+#include "x86.h"
static int ioapic_service(struct kvm_ioapic *vioapic, int irq,
bool line_status);
@@ -311,6 +312,10 @@ void kvm_arch_post_irq_ack_notifier_list_update(struct kvm *kvm)
{
if (!ioapic_in_kernel(kvm))
return;
+
+ if (WARN_ON_ONCE(kvm_eoi_intercept_disallowed(kvm)))
+ return;
+
kvm_make_scan_ioapic_request(kvm);
}
@@ -123,7 +123,12 @@ EXPORT_SYMBOL_GPL(kvm_set_msi_irq);
static inline bool kvm_msi_route_invalid(struct kvm *kvm,
struct kvm_kernel_irq_routing_entry *e)
{
- return kvm->arch.x2apic_format && (e->msi.address_hi & 0xff);
+ struct msi_msg msg = { .address_lo = e->msi.address_lo,
+ .address_hi = e->msi.address_hi,
+ .data = e->msi.data };
+ return (kvm_eoi_intercept_disallowed(kvm) &&
+ msg.arch_data.is_level) ||
+ (kvm->arch.x2apic_format && (msg.address_hi & 0xff));
}
int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
@@ -385,7 +390,7 @@ int kvm_setup_empty_irq_routing(struct kvm *kvm)
void kvm_arch_post_irq_routing_update(struct kvm *kvm)
{
- if (!irqchip_split(kvm))
+ if (!irqchip_split(kvm) || kvm_eoi_intercept_disallowed(kvm))
return;
kvm_make_scan_ioapic_request(kvm);
}
@@ -281,7 +281,8 @@ void kvm_recalculate_apic_map(struct kvm *kvm)
if (old)
call_rcu(&old->rcu, kvm_apic_map_free);
- kvm_make_scan_ioapic_request(kvm);
+ if (!kvm_eoi_intercept_disallowed(kvm))
+ kvm_make_scan_ioapic_request(kvm);
}
static inline void apic_set_spiv(struct kvm_lapic *apic, u32 val)
@@ -6023,6 +6023,9 @@ long kvm_arch_vm_ioctl(struct file *filp,
goto create_irqchip_unlock;
r = -EINVAL;
+ if (kvm_eoi_intercept_disallowed(kvm))
+ goto create_irqchip_unlock;
+
if (kvm->created_vcpus)
goto create_irqchip_unlock;
@@ -6053,6 +6056,9 @@ long kvm_arch_vm_ioctl(struct file *filp,
u.pit_config.flags = KVM_PIT_SPEAKER_DUMMY;
goto create_pit;
case KVM_CREATE_PIT2:
+ r = -EINVAL;
+ if (kvm_eoi_intercept_disallowed(kvm))
+ goto out;
r = -EFAULT;
if (copy_from_user(&u.pit_config, argp,
sizeof(struct kvm_pit_config)))
@@ -451,6 +451,11 @@ static __always_inline bool kvm_tsc_immutable(struct kvm_vcpu *vcpu)
return vcpu->kvm->arch.vm_type == KVM_X86_TDX_VM;
}
+static __always_inline bool kvm_eoi_intercept_disallowed(struct kvm *kvm)
+{
+ return kvm->arch.vm_type == KVM_X86_TDX_VM;
+}
+
void kvm_load_guest_xsave_state(struct kvm_vcpu *vcpu);
void kvm_load_host_xsave_state(struct kvm_vcpu *vcpu);
int kvm_spec_ctrl_test_value(u64 value);