Skip to content

Commit 189e7d8

Browse files
rosatomjfrankjaa
authored andcommitted
KVM: s390: pci: register pci hooks without interpretation
The kvm registration hooks must be registered even if the facilities necessary for zPCI interpretation are unavailable, as vfio-pci-zdev will expect to use the hooks regardless. This fixes an issue where vfio-pci-zdev will fail its open function because of a missing kvm_register when running on hardware that does not support zPCI interpretation. Fixes: ca922fe ("KVM: s390: pci: Hook to access KVM lowlevel from VFIO") Signed-off-by: Matthew Rosato <[email protected]> Reviewed-by: Pierre Morel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Message-Id: <[email protected]> Signed-off-by: Janosch Frank <[email protected]>
1 parent 70ba8fa commit 189e7d8

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

arch/s390/kvm/kvm-s390.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ int kvm_arch_init(void *opaque)
505505
goto out;
506506
}
507507

508-
if (kvm_s390_pci_interp_allowed()) {
508+
if (IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM)) {
509509
rc = kvm_s390_pci_init();
510510
if (rc) {
511511
pr_err("Unable to allocate AIFT for PCI\n");
@@ -527,7 +527,7 @@ int kvm_arch_init(void *opaque)
527527
void kvm_arch_exit(void)
528528
{
529529
kvm_s390_gib_destroy();
530-
if (kvm_s390_pci_interp_allowed())
530+
if (IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM))
531531
kvm_s390_pci_exit();
532532
debug_unregister(kvm_s390_dbf);
533533
debug_unregister(kvm_s390_dbf_uv);

arch/s390/kvm/pci.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,23 +672,31 @@ int kvm_s390_pci_zpci_op(struct kvm *kvm, struct kvm_s390_zpci_op *args)
672672

673673
int kvm_s390_pci_init(void)
674674
{
675+
zpci_kvm_hook.kvm_register = kvm_s390_pci_register_kvm;
676+
zpci_kvm_hook.kvm_unregister = kvm_s390_pci_unregister_kvm;
677+
678+
if (!kvm_s390_pci_interp_allowed())
679+
return 0;
680+
675681
aift = kzalloc(sizeof(struct zpci_aift), GFP_KERNEL);
676682
if (!aift)
677683
return -ENOMEM;
678684

679685
spin_lock_init(&aift->gait_lock);
680686
mutex_init(&aift->aift_lock);
681-
zpci_kvm_hook.kvm_register = kvm_s390_pci_register_kvm;
682-
zpci_kvm_hook.kvm_unregister = kvm_s390_pci_unregister_kvm;
683687

684688
return 0;
685689
}
686690

687691
void kvm_s390_pci_exit(void)
688692
{
689-
mutex_destroy(&aift->aift_lock);
690693
zpci_kvm_hook.kvm_register = NULL;
691694
zpci_kvm_hook.kvm_unregister = NULL;
692695

696+
if (!kvm_s390_pci_interp_allowed())
697+
return;
698+
699+
mutex_destroy(&aift->aift_lock);
700+
693701
kfree(aift);
694702
}

0 commit comments

Comments
 (0)