mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Use a dedicated counter to track the number of IRQs that can utilize IRQ
bypass instead of piggybacking the assigned device count. As evidenced by
commit 2edd9cb79f
("kvm: detect assigned device via irqbypass manager"),
it's possible for a device to be able to post IRQs to a vCPU without said
device being assigned to a VM.
Leave the calls to kvm_arch_{start,end}_assignment() alone for the moment
to avoid regressing the MMIO stale data mitigation. KVM is abusing the
assigned device count when applying mmio_stale_data_clear, and it's not at
all clear if vDPA devices rely on this behavior. This will hopefully be
cleaned up in the future, as the number of assigned devices is a terrible
heuristic for detecting if a VM has access to host MMIO.
Link: https://lore.kernel.org/r/20250611224604.313496-55-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
30 lines
902 B
C
30 lines
902 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __KVM_X86_VMX_POSTED_INTR_H
|
|
#define __KVM_X86_VMX_POSTED_INTR_H
|
|
|
|
#include <linux/bitmap.h>
|
|
#include <linux/find.h>
|
|
#include <linux/kvm_host.h>
|
|
|
|
#include <asm/posted_intr.h>
|
|
|
|
void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu);
|
|
void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu);
|
|
void pi_wakeup_handler(void);
|
|
void __init pi_init_cpu(int cpu);
|
|
void pi_apicv_pre_state_restore(struct kvm_vcpu *vcpu);
|
|
bool pi_has_pending_interrupt(struct kvm_vcpu *vcpu);
|
|
int vmx_pi_update_irte(struct kvm_kernel_irqfd *irqfd, struct kvm *kvm,
|
|
unsigned int host_irq, uint32_t guest_irq,
|
|
struct kvm_vcpu *vcpu, u32 vector);
|
|
void vmx_pi_start_bypass(struct kvm *kvm);
|
|
|
|
static inline int pi_find_highest_vector(struct pi_desc *pi_desc)
|
|
{
|
|
int vec;
|
|
|
|
vec = find_last_bit(pi_desc->pir, 256);
|
|
return vec < 256 ? vec : -1;
|
|
}
|
|
|
|
#endif /* __KVM_X86_VMX_POSTED_INTR_H */
|