mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-24 19:45:06 +08:00
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: ca922fecda
("KVM: s390: pci: Hook to access KVM lowlevel from VFIO")
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
Link: https://lore.kernel.org/r/20220920193025.135655-1-mjrosato@linux.ibm.com
Message-Id: <20220920193025.135655-1-mjrosato@linux.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
This commit is contained in:
parent
70ba8fae27
commit
189e7d876e
@ -505,7 +505,7 @@ int kvm_arch_init(void *opaque)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kvm_s390_pci_interp_allowed()) {
|
if (IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM)) {
|
||||||
rc = kvm_s390_pci_init();
|
rc = kvm_s390_pci_init();
|
||||||
if (rc) {
|
if (rc) {
|
||||||
pr_err("Unable to allocate AIFT for PCI\n");
|
pr_err("Unable to allocate AIFT for PCI\n");
|
||||||
@ -527,7 +527,7 @@ out:
|
|||||||
void kvm_arch_exit(void)
|
void kvm_arch_exit(void)
|
||||||
{
|
{
|
||||||
kvm_s390_gib_destroy();
|
kvm_s390_gib_destroy();
|
||||||
if (kvm_s390_pci_interp_allowed())
|
if (IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM))
|
||||||
kvm_s390_pci_exit();
|
kvm_s390_pci_exit();
|
||||||
debug_unregister(kvm_s390_dbf);
|
debug_unregister(kvm_s390_dbf);
|
||||||
debug_unregister(kvm_s390_dbf_uv);
|
debug_unregister(kvm_s390_dbf_uv);
|
||||||
|
@ -672,23 +672,31 @@ out:
|
|||||||
|
|
||||||
int kvm_s390_pci_init(void)
|
int kvm_s390_pci_init(void)
|
||||||
{
|
{
|
||||||
|
zpci_kvm_hook.kvm_register = kvm_s390_pci_register_kvm;
|
||||||
|
zpci_kvm_hook.kvm_unregister = kvm_s390_pci_unregister_kvm;
|
||||||
|
|
||||||
|
if (!kvm_s390_pci_interp_allowed())
|
||||||
|
return 0;
|
||||||
|
|
||||||
aift = kzalloc(sizeof(struct zpci_aift), GFP_KERNEL);
|
aift = kzalloc(sizeof(struct zpci_aift), GFP_KERNEL);
|
||||||
if (!aift)
|
if (!aift)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
spin_lock_init(&aift->gait_lock);
|
spin_lock_init(&aift->gait_lock);
|
||||||
mutex_init(&aift->aift_lock);
|
mutex_init(&aift->aift_lock);
|
||||||
zpci_kvm_hook.kvm_register = kvm_s390_pci_register_kvm;
|
|
||||||
zpci_kvm_hook.kvm_unregister = kvm_s390_pci_unregister_kvm;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void kvm_s390_pci_exit(void)
|
void kvm_s390_pci_exit(void)
|
||||||
{
|
{
|
||||||
mutex_destroy(&aift->aift_lock);
|
|
||||||
zpci_kvm_hook.kvm_register = NULL;
|
zpci_kvm_hook.kvm_register = NULL;
|
||||||
zpci_kvm_hook.kvm_unregister = NULL;
|
zpci_kvm_hook.kvm_unregister = NULL;
|
||||||
|
|
||||||
|
if (!kvm_s390_pci_interp_allowed())
|
||||||
|
return;
|
||||||
|
|
||||||
|
mutex_destroy(&aift->aift_lock);
|
||||||
|
|
||||||
kfree(aift);
|
kfree(aift);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user