Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: PPC: Move xics_debugfs_init out of create

As we are about to hold the kvm->lock during the create operation on KVM
devices, we should move the call to xics_debugfs_init into its own
function, since holding a mutex over extended amounts of time might not
be a good idea.

Introduce an init operation on the kvm_device_ops struct which cannot
fail and call this, if configured, after the device has been created.

Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>

authored by

Christoffer Dall and committed by
Radim Krčmář
023e9fdd 29b4817d

+17 -2
+8 -2
arch/powerpc/kvm/book3s_xics.c
··· 1341 1341 return ret; 1342 1342 } 1343 1343 1344 - xics_debugfs_init(xics); 1345 - 1346 1344 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 1347 1345 if (cpu_has_feature(CPU_FTR_ARCH_206)) { 1348 1346 /* Enable real mode support */ ··· 1352 1354 return 0; 1353 1355 } 1354 1356 1357 + static void kvmppc_xics_init(struct kvm_device *dev) 1358 + { 1359 + struct kvmppc_xics *xics = (struct kvmppc_xics *)dev->private; 1360 + 1361 + xics_debugfs_init(xics); 1362 + } 1363 + 1355 1364 struct kvm_device_ops kvm_xics_ops = { 1356 1365 .name = "kvm-xics", 1357 1366 .create = kvmppc_xics_create, 1367 + .init = kvmppc_xics_init, 1358 1368 .destroy = kvmppc_xics_free, 1359 1369 .set_attr = xics_set_attr, 1360 1370 .get_attr = xics_get_attr,
+6
include/linux/kvm_host.h
··· 1116 1116 int (*create)(struct kvm_device *dev, u32 type); 1117 1117 1118 1118 /* 1119 + * init is called after create if create is successful and is called 1120 + * outside of holding kvm->lock. 1121 + */ 1122 + void (*init)(struct kvm_device *dev); 1123 + 1124 + /* 1119 1125 * Destroy is responsible for freeing dev. 1120 1126 * 1121 1127 * Destroy may be called before or after destructors are called
+3
virt/kvm/kvm_main.c
··· 2838 2838 return ret; 2839 2839 } 2840 2840 2841 + if (ops->init) 2842 + ops->init(dev); 2843 + 2841 2844 ret = anon_inode_getfd(ops->name, &kvm_device_fops, dev, O_RDWR | O_CLOEXEC); 2842 2845 if (ret < 0) { 2843 2846 ops->destroy(dev);