Skip to contentSkip to conversation

KVM: s390: unregister debug feature on failing arch init

PATCH David Hildenbrand 1 participant 1 message Nov 29, 2018 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

David Hildenbrand

author Reviewed-by
#1 lore raw
Quoted 33 lines · Michael Mueller

Make sure the debug feature and its allocated resources get released upon unsuccessful architecture initialization.

A related idication of the issue will be reported by common kvm code.

---
 arch/s390/kvm/kvm-s390.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
arch/s390/kvm/kvm-s390.c +4 -2
index fe24150ff666..d9635d21563f 100644
@@ -417,19 +417,29 @@ static void kvm_s390_cpu_feat_init(void)
 
 int kvm_arch_init(void *opaque)
 {
+	int rc;
+
 	kvm_s390_dbf = debug_register("kvm-trace", 32, 1, 7 * sizeof(long));
 	if (!kvm_s390_dbf)
 		return -ENOMEM;
 
 	if (debug_register_view(kvm_s390_dbf, &debug_sprintf_view)) {
-		debug_unregister(kvm_s390_dbf);
-		return -ENOMEM;
+		rc = -ENOMEM;
+		goto out_unreg;
 	}
 
 	kvm_s390_cpu_feat_init();

arch/s390/kvm/kvm-s390.c static void kvm_s390_cpu_feat_init(void) · line 440

Quoted 10 lines
arch/s390/kvm/kvm-s390.c +7 -1
 
 	/* Register floating interrupt controller interface. */
-	return kvm_register_device_ops(&kvm_flic_ops, KVM_DEV_TYPE_FLIC);
+	rc = kvm_register_device_ops(&kvm_flic_ops, KVM_DEV_TYPE_FLIC);
+	if (rc)
+		goto out_unreg;
+
+	return 0;
+
+out_unreg:

I would call this out_debug_unreg as we have two different registrations here.

arch/s390/kvm/kvm-s390.c static void kvm_s390_cpu_feat_init(void) · line 445

Quoted 6 lines
arch/s390/kvm/kvm-s390.c +2 -0
+	debug_unregister(kvm_s390_dbf);
+	return rc;
 }
 
 void kvm_arch_exit(void)

BTW, at first I thought we were missing

arch/s390/kvm/kvm-s390.c +1 -0
index fe24150ff666..d6b911c4fc5b 100644
@@ -434,6 +434,7 @@ int kvm_arch_init(void *opaque)
 
 void kvm_arch_exit(void)
 {
+       kvm_unregister_device_ops(KVM_DEV_TYPE_FLIC);
        debug_unregister(kvm_s390_dbf);
 }
 

But turns out the global table is part of the module that will be recreated when reloading the module after it has been unloaded.

Signature · 3 lines
Thanks,

David / dhildenb