The per-VM s390dbf area is named "kvm-". When one process creates more than one VM, the second debug_register() will fail with debugfs: 'kvm-' already exists in 's390dbf' The VM is still created, but no debugging can be done. Append a sequence number that goes up by one for each VM created, so every VM gets its own directory: "kvm--". Signed-off-by: Christian Borntraeger --- arch/s390/kvm/s390/s390.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/s390/kvm/s390/s390.c b/arch/s390/kvm/s390/s390.c index ee8e61a828bb8..60521c58cfdc8 100644 --- a/arch/s390/kvm/s390/s390.c +++ b/arch/s390/kvm/s390/s390.c @@ -3239,7 +3239,8 @@ void kvm_arch_free_vm(struct kvm *kvm) int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) { gfp_t alloc_flags = GFP_KERNEL_ACCOUNT | __GFP_ZERO; - char debug_name[16]; + static atomic_t vm_seq = ATOMIC_INIT(0); + char debug_name[32]; int i, rc; mutex_init(&kvm->arch.pv.import_lock); @@ -3265,7 +3266,8 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) if (!kvm->arch.sca) goto out_err; - snprintf(debug_name, sizeof(debug_name), "kvm-%u", current->pid); + snprintf(debug_name, sizeof(debug_name), "kvm-%u-%u", current->pid, + atomic_inc_return(&vm_seq)); kvm->arch.dbf = debug_register(debug_name, 32, 1, 7 * sizeof(long)); if (!kvm->arch.dbf) -- 2.53.0 The per-VM s390dbf area is named "kvm-arm64--". Two VMs of the same process can still get the same random number, and debugfs then fails to create the second directory. Use the new s390 scheme. Signed-off-by: Christian Borntraeger --- arch/s390/kvm/arm64/arm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/s390/kvm/arm64/arm.c b/arch/s390/kvm/arm64/arm.c index bd9d85235f438..6fd0ba2061dcc 100644 --- a/arch/s390/kvm/arm64/arm.c +++ b/arch/s390/kvm/arm64/arm.c @@ -106,6 +106,7 @@ static int kvm_vm_type_ipa_size_shift(unsigned long type) int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) { + static atomic_t vm_seq = ATOMIC_INIT(0); char debug_name[32]; int ret; @@ -121,7 +122,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) bitmap_zero(kvm->arch.vcpu_features, KVM_VCPU_MAX_FEATURES); snprintf(debug_name, sizeof(debug_name), "kvm-arm64-%u-%u", - current->pid, get_random_u32()); + current->pid, atomic_inc_return(&vm_seq)); kvm->arch.dbf = debug_register(debug_name, 32, 1, 7 * sizeof(long)); if (!kvm->arch.dbf) return -ENOMEM; -- 2.53.0