Skip to content

Commit bbc13ae

Browse files
committed
VFIO: KVM: x86: Drop kvm_arch_{start,end}_assignment()
Drop kvm_arch_{start,end}_assignment() and all associated code now that KVM x86 no longer consumes assigned_device_count. Tracking whether or not a VFIO-assigned device is formally associated with a VM is fundamentally flawed, as such an association is optional for general usage, i.e. is prone to false negatives. E.g. prior to commit 2edd9cb ("kvm: detect assigned device via irqbypass manager"), device passthrough via VFIO would fail to enable IRQ bypass if userspace omitted the formal VFIO<=>KVM binding. And device drivers that *need* the VFIO<=>KVM connection, e.g. KVM-GT, shouldn't be relying on generic x86 tracking infrastructure. Cc: Jim Mattson <jmattson@google.com> Link: https://lore.kernel.org/r/20250523011756.3243624-6-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent ff845e6 commit bbc13ae

File tree

4 files changed

+0
-41
lines changed

4 files changed

+0
-41
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,8 +1381,6 @@ struct kvm_arch {
13811381

13821382
#define __KVM_HAVE_ARCH_NONCOHERENT_DMA
13831383
atomic_t noncoherent_dma_count;
1384-
#define __KVM_HAVE_ARCH_ASSIGNED_DEVICE
1385-
atomic_t assigned_device_count;
13861384
unsigned long nr_possible_bypass_irqs;
13871385

13881386
#ifdef CONFIG_KVM_IOAPIC

arch/x86/kvm/x86.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13438,24 +13438,6 @@ bool kvm_arch_can_dequeue_async_page_present(struct kvm_vcpu *vcpu)
1343813438
return kvm_lapic_enabled(vcpu) && apf_pageready_slot_free(vcpu);
1343913439
}
1344013440

13441-
void kvm_arch_start_assignment(struct kvm *kvm)
13442-
{
13443-
atomic_inc(&kvm->arch.assigned_device_count);
13444-
}
13445-
EXPORT_SYMBOL_GPL(kvm_arch_start_assignment);
13446-
13447-
void kvm_arch_end_assignment(struct kvm *kvm)
13448-
{
13449-
atomic_dec(&kvm->arch.assigned_device_count);
13450-
}
13451-
EXPORT_SYMBOL_GPL(kvm_arch_end_assignment);
13452-
13453-
bool noinstr kvm_arch_has_assigned_device(struct kvm *kvm)
13454-
{
13455-
return raw_atomic_read(&kvm->arch.assigned_device_count);
13456-
}
13457-
EXPORT_SYMBOL_GPL(kvm_arch_has_assigned_device);
13458-
1345913441
static void kvm_noncoherent_dma_assignment_start_or_stop(struct kvm *kvm)
1346013442
{
1346113443
/*

include/linux/kvm_host.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,24 +1690,6 @@ static inline bool kvm_arch_has_noncoherent_dma(struct kvm *kvm)
16901690
return false;
16911691
}
16921692
#endif
1693-
#ifdef __KVM_HAVE_ARCH_ASSIGNED_DEVICE
1694-
void kvm_arch_start_assignment(struct kvm *kvm);
1695-
void kvm_arch_end_assignment(struct kvm *kvm);
1696-
bool kvm_arch_has_assigned_device(struct kvm *kvm);
1697-
#else
1698-
static inline void kvm_arch_start_assignment(struct kvm *kvm)
1699-
{
1700-
}
1701-
1702-
static inline void kvm_arch_end_assignment(struct kvm *kvm)
1703-
{
1704-
}
1705-
1706-
static __always_inline bool kvm_arch_has_assigned_device(struct kvm *kvm)
1707-
{
1708-
return false;
1709-
}
1710-
#endif
17111693

17121694
static inline struct rcuwait *kvm_arch_vcpu_get_wait(struct kvm_vcpu *vcpu)
17131695
{

virt/kvm/vfio.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ static int kvm_vfio_file_add(struct kvm_device *dev, unsigned int fd)
175175
kvf->file = get_file(filp);
176176
list_add_tail(&kvf->node, &kv->file_list);
177177

178-
kvm_arch_start_assignment(dev->kvm);
179178
kvm_vfio_file_set_kvm(kvf->file, dev->kvm);
180179
kvm_vfio_update_coherency(dev);
181180

@@ -205,7 +204,6 @@ static int kvm_vfio_file_del(struct kvm_device *dev, unsigned int fd)
205204
continue;
206205

207206
list_del(&kvf->node);
208-
kvm_arch_end_assignment(dev->kvm);
209207
#ifdef CONFIG_SPAPR_TCE_IOMMU
210208
kvm_spapr_tce_release_vfio_group(dev->kvm, kvf);
211209
#endif
@@ -336,7 +334,6 @@ static void kvm_vfio_release(struct kvm_device *dev)
336334
fput(kvf->file);
337335
list_del(&kvf->node);
338336
kfree(kvf);
339-
kvm_arch_end_assignment(dev->kvm);
340337
}
341338

342339
kvm_vfio_update_coherency(dev);

0 commit comments

Comments
 (0)