* [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug
@ 2026-12-04 9:11 Christian Borntraeger
2026-12-04 9:11 ` [PATCH 1/2] KVM: s390: Use a unique s390dbf name per VM Christian Borntraeger
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: Christian Borntraeger @ 2026-12-04 9:11 UTC (permalink / raw)
To: Janosch Frank, Claudio Imbrenda
Cc: KVM, Christian Borntraeger, linux-s390, Heiko Carstens,
Vasily Gorbik, Alexander Gordeev, Sven Schnelle,
David Hildenbrand, Steffen Eiden, Andreas Grapentin, Marc Zyngier
There is a longstanding bug in s390 kvm that was already fixed by
the arm on s390 variant.
If a process creates 2 VMs the s390 debug feature does not work:
debugfs: 'kvm-<pid>' already exists in 's390dbf'
Fix this for s390 and change the arm64 variant to match the numbering.
Christian Borntraeger (2):
KVM: s390: Use a unique s390dbf name per VM
KVM: s390: arm64: Use a sequence number in the s390dbf name
arch/s390/kvm/arm64/arm.c | 3 ++-
arch/s390/kvm/s390/s390.c | 6 ++++--
2 files changed, 6 insertions(+), 3 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/2] KVM: s390: Use a unique s390dbf name per VM
2026-12-04 9:11 [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug Christian Borntraeger
@ 2026-12-04 9:11 ` Christian Borntraeger
2026-12-04 9:21 ` sashiko-bot
2026-12-04 9:11 ` [PATCH 2/2] KVM: s390: arm64: Use a sequence number in the s390dbf name Christian Borntraeger
` (2 subsequent siblings)
3 siblings, 1 reply; 13+ messages in thread
From: Christian Borntraeger @ 2026-12-04 9:11 UTC (permalink / raw)
To: Janosch Frank, Claudio Imbrenda
Cc: KVM, Christian Borntraeger, linux-s390, Heiko Carstens,
Vasily Gorbik, Alexander Gordeev, Sven Schnelle,
David Hildenbrand, Steffen Eiden, Andreas Grapentin, Marc Zyngier
The per-VM s390dbf area is named "kvm-<pid>". When one process creates
more than one VM, the second debug_register() will fail with
debugfs: 'kvm-<pid>' 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-<pid>-<n>".
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
---
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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/2] KVM: s390: arm64: Use a sequence number in the s390dbf name
2026-12-04 9:11 [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug Christian Borntraeger
2026-12-04 9:11 ` [PATCH 1/2] KVM: s390: Use a unique s390dbf name per VM Christian Borntraeger
@ 2026-12-04 9:11 ` Christian Borntraeger
2026-12-04 9:19 ` sashiko-bot
2026-12-04 12:00 ` [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug Janosch Frank
2026-12-04 12:49 ` Claudio Imbrenda
3 siblings, 1 reply; 13+ messages in thread
From: Christian Borntraeger @ 2026-12-04 9:11 UTC (permalink / raw)
To: Janosch Frank, Claudio Imbrenda
Cc: KVM, Christian Borntraeger, linux-s390, Heiko Carstens,
Vasily Gorbik, Alexander Gordeev, Sven Schnelle,
David Hildenbrand, Steffen Eiden, Andreas Grapentin, Marc Zyngier
The per-VM s390dbf area is named "kvm-arm64-<pid>-<random>". 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 <borntraeger@linux.ibm.com>
---
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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] KVM: s390: arm64: Use a sequence number in the s390dbf name
2026-12-04 9:11 ` [PATCH 2/2] KVM: s390: arm64: Use a sequence number in the s390dbf name Christian Borntraeger
@ 2026-12-04 9:19 ` sashiko-bot
0 siblings, 0 replies; 13+ messages in thread
From: sashiko-bot @ 2026-12-04 9:19 UTC (permalink / raw)
To: Christian Borntraeger
Cc: KVM, linux-s390, Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] KVM: s390: arm64: missing Fixes trailer for kvm_arch_init_vm()
dbf naming fix
--
commit 273944c4d557f17d2e09e91c6c7ba23952b5c156
Author: Christian Borntraeger <borntraeger@linux.ibm.com>
> KVM: s390: arm64: Use a sequence number in the s390dbf name
>
> The per-VM s390dbf area is named "kvm-arm64-<pid>-<random>". 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 <borntraeger@linux.ibm.com>
[Severity: Low]
This fixes a debugfs directory name collision in kvm_arch_init_vm().
Should this include:
Fixes: 90246e7d1476 ("KVM: s390: arm64: Implement vm/vcpu create destroy")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204091131.150681-1-borntraeger@linux.ibm.com?part=2
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/2] KVM: s390: Use a unique s390dbf name per VM
2026-12-04 9:11 ` [PATCH 1/2] KVM: s390: Use a unique s390dbf name per VM Christian Borntraeger
@ 2026-12-04 9:21 ` sashiko-bot
0 siblings, 0 replies; 13+ messages in thread
From: sashiko-bot @ 2026-12-04 9:21 UTC (permalink / raw)
To: Christian Borntraeger
Cc: KVM, linux-s390, Heiko Carstens, Vasily Gorbik, Alexander Gordeev
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] KVM: s390: missing Fixes trailer for s390dbf name collision fix
--
commit 44f60dc949bf9736d39d3d369619a275bbd044f6
Author: Christian Borntraeger <borntraeger@linux.ibm.com>
> KVM: s390: Use a unique s390dbf name per VM
>
> The per-VM s390dbf area is named "kvm-<pid>". When one process creates
> more than one VM, the second debug_register() will fail with
>
> debugfs: 'kvm-<pid>' 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-<pid>-<n>".
>
> Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
[Severity: Low]
This fixes the s390dbf directory name collision when a process creates more
than one VM. Should this include a Fixes tag for the commit that introduced
the PID-only naming?
Fixes: b0c632db637d ("KVM: s390: arch backend for the kvm kernel module")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204091131.150681-1-borntraeger@linux.ibm.com?part=1
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug
2026-12-04 9:11 [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug Christian Borntraeger
2026-12-04 9:11 ` [PATCH 1/2] KVM: s390: Use a unique s390dbf name per VM Christian Borntraeger
2026-12-04 9:11 ` [PATCH 2/2] KVM: s390: arm64: Use a sequence number in the s390dbf name Christian Borntraeger
@ 2026-12-04 12:00 ` Janosch Frank
2026-12-04 12:03 ` Christian Borntraeger
2026-12-04 12:49 ` Claudio Imbrenda
3 siblings, 1 reply; 13+ messages in thread
From: Janosch Frank @ 2026-12-04 12:00 UTC (permalink / raw)
To: Christian Borntraeger, Claudio Imbrenda
Cc: KVM, linux-s390, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Sven Schnelle, David Hildenbrand, Steffen Eiden,
Andreas Grapentin, Marc Zyngier
On 12/4/26 10:11 AM, Christian Borntraeger wrote:
> There is a longstanding bug in s390 kvm that was already fixed by
> the arm on s390 variant.
>
> If a process creates 2 VMs the s390 debug feature does not work:
> debugfs: 'kvm-<pid>' already exists in 's390dbf'
> Fix this for s390 and change the arm64 variant to match the numbering.
>
Series:
Reviewed-by Janosch Frank <frankja@linux.ibm.com>
Slightly OT:
I'm wondering why we keep that separate from the KVM debugfs directory
anyway. Why don't we use kvm_arch_create_vm_debugfs() like the other
platforms?
Yes, s390dbf provides a nice framework but we're once again different
and have two separate paths to get debug data from. Do we consider the
s390dbf KVM files an interface we're not allowed to change?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug
2026-12-04 12:00 ` [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug Janosch Frank
@ 2026-12-04 12:03 ` Christian Borntraeger
0 siblings, 0 replies; 13+ messages in thread
From: Christian Borntraeger @ 2026-12-04 12:03 UTC (permalink / raw)
To: Janosch Frank, Claudio Imbrenda
Cc: KVM, linux-s390, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
Sven Schnelle, David Hildenbrand, Steffen Eiden,
Andreas Grapentin, Marc Zyngier
Am 04.12.26 um 13:00 schrieb Janosch Frank:
> On 12/4/26 10:11 AM, Christian Borntraeger wrote:
>> There is a longstanding bug in s390 kvm that was already fixed by
>> the arm on s390 variant.
>>
>> If a process creates 2 VMs the s390 debug feature does not work:
>> debugfs: 'kvm-<pid>' already exists in 's390dbf'
>> Fix this for s390 and change the arm64 variant to match the numbering.
>>
> Series:
> Reviewed-by Janosch Frank <frankja@linux.ibm.com>
>
> Slightly OT:
> I'm wondering why we keep that separate from the KVM debugfs directory anyway. Why don't we use kvm_arch_create_vm_debugfs() like the other platforms?
>
> Yes, s390dbf provides a nice framework but we're once again different and have two separate paths to get debug data from. Do we consider the s390dbf KVM files an interface we're not allowed to change?
We would have to re-implement what the s390dbf provides, including support for crash dumps etc.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug
2026-12-04 9:11 [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug Christian Borntraeger
` (2 preceding siblings ...)
2026-12-04 12:00 ` [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug Janosch Frank
@ 2026-12-04 12:49 ` Claudio Imbrenda
2026-12-04 13:08 ` Christian Borntraeger
3 siblings, 1 reply; 13+ messages in thread
From: Claudio Imbrenda @ 2026-12-04 12:49 UTC (permalink / raw)
To: Christian Borntraeger
Cc: Janosch Frank, KVM, linux-s390, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Sven Schnelle, David Hildenbrand,
Steffen Eiden, Andreas Grapentin, Marc Zyngier
On Fri, 4 Dec 2026 10:11:29 +0100
Christian Borntraeger <borntraeger@linux.ibm.com> wrote:
> There is a longstanding bug in s390 kvm that was already fixed by
> the arm on s390 variant.
>
> If a process creates 2 VMs the s390 debug feature does not work:
> debugfs: 'kvm-<pid>' already exists in 's390dbf'
> Fix this for s390 and change the arm64 variant to match the numbering.
>
> Christian Borntraeger (2):
> KVM: s390: Use a unique s390dbf name per VM
> KVM: s390: arm64: Use a sequence number in the s390dbf name
>
> arch/s390/kvm/arm64/arm.c | 3 ++-
> arch/s390/kvm/s390/s390.c | 6 ++++--
> 2 files changed, 6 insertions(+), 3 deletions(-)
>
I don't like that the counters are global, and not per-pid. Apart from
the fact that it doesn't look nice, it also means that it can overflow
"easily" (think of a system that spawns lots of very short lived
micro-vms all the time).
can you make it an atomic64_t? (and then also increase the size of the
buffer). That way still won't look nice, but at least we can
exclude overflows.
otherwise make the counter per-pid, but that sounds unnecessarily
complicated.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug
2026-12-04 12:49 ` Claudio Imbrenda
@ 2026-12-04 13:08 ` Christian Borntraeger
2026-12-04 13:22 ` Andreas Grapentin
0 siblings, 1 reply; 13+ messages in thread
From: Christian Borntraeger @ 2026-12-04 13:08 UTC (permalink / raw)
To: Claudio Imbrenda
Cc: Janosch Frank, KVM, linux-s390, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Sven Schnelle, David Hildenbrand,
Steffen Eiden, Andreas Grapentin, Marc Zyngier
Am 04.12.26 um 13:49 schrieb Claudio Imbrenda:
> On Fri, 4 Dec 2026 10:11:29 +0100
> Christian Borntraeger <borntraeger@linux.ibm.com> wrote:
>
>> There is a longstanding bug in s390 kvm that was already fixed by
>> the arm on s390 variant.
>>
>> If a process creates 2 VMs the s390 debug feature does not work:
>> debugfs: 'kvm-<pid>' already exists in 's390dbf'
>> Fix this for s390 and change the arm64 variant to match the numbering.
>>
>> Christian Borntraeger (2):
>> KVM: s390: Use a unique s390dbf name per VM
>> KVM: s390: arm64: Use a sequence number in the s390dbf name
>>
>> arch/s390/kvm/arm64/arm.c | 3 ++-
>> arch/s390/kvm/s390/s390.c | 6 ++++--
>> 2 files changed, 6 insertions(+), 3 deletions(-)
>>
>
> I don't like that the counters are global, and not per-pid. Apart from
> the fact that it doesn't look nice, it also means that it can overflow
> "easily" (think of a system that spawns lots of very short lived
> micro-vms all the time).
>
> can you make it an atomic64_t? (and then also increase the size of the
> buffer). That way still won't look nice, but at least we can
> exclude overflows.
>
> otherwise make the counter per-pid, but that sounds unnecessarily
> complicated.
agreed. Lets improve that.
I also dont think the s390/arm variant (getrandom) is ideal.
The fd number would be ideal but not available. Let me have a look.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug
2026-12-04 13:08 ` Christian Borntraeger
@ 2026-12-04 13:22 ` Andreas Grapentin
2026-12-04 13:50 ` Janosch Frank
0 siblings, 1 reply; 13+ messages in thread
From: Andreas Grapentin @ 2026-12-04 13:22 UTC (permalink / raw)
To: Christian Borntraeger
Cc: Claudio Imbrenda, Janosch Frank, KVM, linux-s390, Heiko Carstens,
Vasily Gorbik, Alexander Gordeev, Sven Schnelle,
David Hildenbrand, Steffen Eiden, Marc Zyngier
On Dec 04 26, Christian Borntraeger wrote:
>
>
> Am 04.12.26 um 13:49 schrieb Claudio Imbrenda:
> > On Fri, 4 Dec 2026 10:11:29 +0100
> > Christian Borntraeger <borntraeger@linux.ibm.com> wrote:
> >
> > > There is a longstanding bug in s390 kvm that was already fixed by
> > > the arm on s390 variant.
> > >
> > > If a process creates 2 VMs the s390 debug feature does not work:
> > > debugfs: 'kvm-<pid>' already exists in 's390dbf'
> > > Fix this for s390 and change the arm64 variant to match the numbering.
> > >
> > > Christian Borntraeger (2):
> > > KVM: s390: Use a unique s390dbf name per VM
> > > KVM: s390: arm64: Use a sequence number in the s390dbf name
> > >
> > > arch/s390/kvm/arm64/arm.c | 3 ++-
> > > arch/s390/kvm/s390/s390.c | 6 ++++--
> > > 2 files changed, 6 insertions(+), 3 deletions(-)
> > >
> >
> > I don't like that the counters are global, and not per-pid. Apart from
> > the fact that it doesn't look nice, it also means that it can overflow
> > "easily" (think of a system that spawns lots of very short lived
> > micro-vms all the time).
> >
> > can you make it an atomic64_t? (and then also increase the size of the
> > buffer). That way still won't look nice, but at least we can
> > exclude overflows.
> >
> > otherwise make the counter per-pid, but that sounds unnecessarily
> > complicated.
>
> agreed. Lets improve that.
> I also dont think the s390/arm variant (getrandom) is ideal.
> The fd number would be ideal but not available. Let me have a look.
Two ideas that come to mind:
Assuming the case that a process spawns multiple VMs that attempt to
create colliding debugfs endpoints is a rare exception, then you could
add a slow path that queries existing entries in the debugfs and
increments until it finds a "free" spot.
Alternatively, you could encode (a hash of) the address of struct kvm
into the node name. The tuple of pid and struct kvm address should avoid
virtually all of the possible collisions.
Thanks,
-A
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug
2026-12-04 13:22 ` Andreas Grapentin
@ 2026-12-04 13:50 ` Janosch Frank
2026-12-04 14:16 ` Claudio Imbrenda
0 siblings, 1 reply; 13+ messages in thread
From: Janosch Frank @ 2026-12-04 13:50 UTC (permalink / raw)
To: Andreas Grapentin, Christian Borntraeger
Cc: Claudio Imbrenda, KVM, linux-s390, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Sven Schnelle, David Hildenbrand,
Steffen Eiden, Marc Zyngier
On 12/4/26 2:22 PM, Andreas Grapentin wrote:
> On Dec 04 26, Christian Borntraeger wrote:
>>
>>
>> Am 04.12.26 um 13:49 schrieb Claudio Imbrenda:
>>> On Fri, 4 Dec 2026 10:11:29 +0100
>>> Christian Borntraeger <borntraeger@linux.ibm.com> wrote:
>>>
>>>> There is a longstanding bug in s390 kvm that was already fixed by
>>>> the arm on s390 variant.
>>>>
>>>> If a process creates 2 VMs the s390 debug feature does not work:
>>>> debugfs: 'kvm-<pid>' already exists in 's390dbf'
>>>> Fix this for s390 and change the arm64 variant to match the numbering.
>>>>
>>>> Christian Borntraeger (2):
>>>> KVM: s390: Use a unique s390dbf name per VM
>>>> KVM: s390: arm64: Use a sequence number in the s390dbf name
>>>>
>>>> arch/s390/kvm/arm64/arm.c | 3 ++-
>>>> arch/s390/kvm/s390/s390.c | 6 ++++--
>>>> 2 files changed, 6 insertions(+), 3 deletions(-)
>>>>
>>>
>>> I don't like that the counters are global, and not per-pid. Apart from
>>> the fact that it doesn't look nice, it also means that it can overflow
>>> "easily" (think of a system that spawns lots of very short lived
>>> micro-vms all the time).
>>>
>>> can you make it an atomic64_t? (and then also increase the size of the
>>> buffer). That way still won't look nice, but at least we can
>>> exclude overflows.
>>>
>>> otherwise make the counter per-pid, but that sounds unnecessarily
>>> complicated.
>>
>> agreed. Lets improve that.
>> I also dont think the s390/arm variant (getrandom) is ideal.
>> The fd number would be ideal but not available. Let me have a look.
>
> Two ideas that come to mind:
>
> Assuming the case that a process spawns multiple VMs that attempt to
> create colliding debugfs endpoints is a rare exception, then you could
> add a slow path that queries existing entries in the debugfs and
> increments until it finds a "free" spot.
>
> Alternatively, you could encode (a hash of) the address of struct kvm
> into the node name. The tuple of pid and struct kvm address should avoid
> virtually all of the possible collisions.
>
If they try to do that then they deserve the error return code that we
send them back when the names collide... This is not about safety.
We need to make sure that a legitimate user won't receive the error.
Not sure why anyone would need 64 bits worth of VMs in a single pid though.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug
2026-12-04 13:50 ` Janosch Frank
@ 2026-12-04 14:16 ` Claudio Imbrenda
2026-12-04 14:52 ` Janosch Frank
0 siblings, 1 reply; 13+ messages in thread
From: Claudio Imbrenda @ 2026-12-04 14:16 UTC (permalink / raw)
To: Janosch Frank
Cc: Andreas Grapentin, Christian Borntraeger, KVM, linux-s390,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Sven Schnelle,
David Hildenbrand, Steffen Eiden, Marc Zyngier
On Fri, 4 Dec 2026 14:50:51 +0100
Janosch Frank <frankja@linux.ibm.com> wrote:
> On 12/4/26 2:22 PM, Andreas Grapentin wrote:
> > On Dec 04 26, Christian Borntraeger wrote:
> >>
> >>
> >> Am 04.12.26 um 13:49 schrieb Claudio Imbrenda:
> >>> On Fri, 4 Dec 2026 10:11:29 +0100
> >>> Christian Borntraeger <borntraeger@linux.ibm.com> wrote:
> >>>
> >>>> There is a longstanding bug in s390 kvm that was already fixed by
> >>>> the arm on s390 variant.
> >>>>
> >>>> If a process creates 2 VMs the s390 debug feature does not work:
> >>>> debugfs: 'kvm-<pid>' already exists in 's390dbf'
> >>>> Fix this for s390 and change the arm64 variant to match the numbering.
> >>>>
> >>>> Christian Borntraeger (2):
> >>>> KVM: s390: Use a unique s390dbf name per VM
> >>>> KVM: s390: arm64: Use a sequence number in the s390dbf name
> >>>>
> >>>> arch/s390/kvm/arm64/arm.c | 3 ++-
> >>>> arch/s390/kvm/s390/s390.c | 6 ++++--
> >>>> 2 files changed, 6 insertions(+), 3 deletions(-)
> >>>>
> >>>
> >>> I don't like that the counters are global, and not per-pid. Apart from
> >>> the fact that it doesn't look nice, it also means that it can overflow
> >>> "easily" (think of a system that spawns lots of very short lived
> >>> micro-vms all the time).
> >>>
> >>> can you make it an atomic64_t? (and then also increase the size of the
> >>> buffer). That way still won't look nice, but at least we can
> >>> exclude overflows.
> >>>
> >>> otherwise make the counter per-pid, but that sounds unnecessarily
> >>> complicated.
> >>
> >> agreed. Lets improve that.
> >> I also dont think the s390/arm variant (getrandom) is ideal.
> >> The fd number would be ideal but not available. Let me have a look.
> >
> > Two ideas that come to mind:
> >
> > Assuming the case that a process spawns multiple VMs that attempt to
> > create colliding debugfs endpoints is a rare exception, then you could
> > add a slow path that queries existing entries in the debugfs and
> > increments until it finds a "free" spot.
> >
> > Alternatively, you could encode (a hash of) the address of struct kvm
> > into the node name. The tuple of pid and struct kvm address should avoid
> > virtually all of the possible collisions.
> >
> If they try to do that then they deserve the error return code that we
> send them back when the names collide... This is not about safety.
>
> We need to make sure that a legitimate user won't receive the error.
> Not sure why anyone would need 64 bits worth of VMs in a single pid though.
the problem is that the counters are not per-pid, they are global
if they were per-pid I would agree with you
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug
2026-12-04 14:16 ` Claudio Imbrenda
@ 2026-12-04 14:52 ` Janosch Frank
0 siblings, 0 replies; 13+ messages in thread
From: Janosch Frank @ 2026-12-04 14:52 UTC (permalink / raw)
To: Claudio Imbrenda
Cc: Andreas Grapentin, Christian Borntraeger, KVM, linux-s390,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Sven Schnelle,
David Hildenbrand, Steffen Eiden, Marc Zyngier
On 12/4/26 3:16 PM, Claudio Imbrenda wrote:
> On Fri, 4 Dec 2026 14:50:51 +0100
> Janosch Frank <frankja@linux.ibm.com> wrote:
>
>> On 12/4/26 2:22 PM, Andreas Grapentin wrote:
>>> On Dec 04 26, Christian Borntraeger wrote:
>>>>
>>>>
>>>> Am 04.12.26 um 13:49 schrieb Claudio Imbrenda:
>>>>> On Fri, 4 Dec 2026 10:11:29 +0100
>>>>> Christian Borntraeger <borntraeger@linux.ibm.com> wrote:
>>>>>
>>>>>> There is a longstanding bug in s390 kvm that was already fixed by
>>>>>> the arm on s390 variant.
>>>>>>
>>>>>> If a process creates 2 VMs the s390 debug feature does not work:
>>>>>> debugfs: 'kvm-<pid>' already exists in 's390dbf'
>>>>>> Fix this for s390 and change the arm64 variant to match the numbering.
>>>>>>
>>>>>> Christian Borntraeger (2):
>>>>>> KVM: s390: Use a unique s390dbf name per VM
>>>>>> KVM: s390: arm64: Use a sequence number in the s390dbf name
>>>>>>
>>>>>> arch/s390/kvm/arm64/arm.c | 3 ++-
>>>>>> arch/s390/kvm/s390/s390.c | 6 ++++--
>>>>>> 2 files changed, 6 insertions(+), 3 deletions(-)
>>>>>>
>>>>>
>>>>> I don't like that the counters are global, and not per-pid. Apart from
>>>>> the fact that it doesn't look nice, it also means that it can overflow
>>>>> "easily" (think of a system that spawns lots of very short lived
>>>>> micro-vms all the time).
>>>>>
>>>>> can you make it an atomic64_t? (and then also increase the size of the
>>>>> buffer). That way still won't look nice, but at least we can
>>>>> exclude overflows.
>>>>>
>>>>> otherwise make the counter per-pid, but that sounds unnecessarily
>>>>> complicated.
>>>>
>>>> agreed. Lets improve that.
>>>> I also dont think the s390/arm variant (getrandom) is ideal.
>>>> The fd number would be ideal but not available. Let me have a look.
>>>
>>> Two ideas that come to mind:
>>>
>>> Assuming the case that a process spawns multiple VMs that attempt to
>>> create colliding debugfs endpoints is a rare exception, then you could
>>> add a slow path that queries existing entries in the debugfs and
>>> increments until it finds a "free" spot.
>>>
>>> Alternatively, you could encode (a hash of) the address of struct kvm
>>> into the node name. The tuple of pid and struct kvm address should avoid
>>> virtually all of the possible collisions.
>>>
>> If they try to do that then they deserve the error return code that we
>> send them back when the names collide... This is not about safety.
>>
>> We need to make sure that a legitimate user won't receive the error.
>> Not sure why anyone would need 64 bits worth of VMs in a single pid though.
>
> the problem is that the counters are not per-pid, they are global
>
> if they were per-pid I would agree with you
Right.
We can still steal the name from KVM if we move s390dbf creation to the
arch hook. We'll loose the creation message (which we can add back) and
there are three function calls which won't have dbf coverage since they
are between arch init and debugfs create.
Bob helped me make this dream come true:
+/*
+ * Called once the per-VM debugfs directory exists. Name the s390 debug
+ * feature after it so both can be correlated. Events logged before this
+ * point are dropped, as the debug macros ignore a NULL kvm->arch.dbf.
+ */
+void kvm_arch_create_vm_debugfs(struct kvm *kvm)
+{
+ char debug_name[32];
+
+ snprintf(debug_name, sizeof(debug_name), "kvm-%pd",
kvm->debugfs_dentry);
+
+ kvm->arch.dbf = debug_register(debug_name, 32, 1, 7 * sizeof(long));
+ if (!kvm->arch.dbf)
+ return;
+
+ debug_register_view(kvm->arch.dbf, &debug_sprintf_view);
+ VM_EVENT(kvm, 3, "vm created");
+}
+
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-12-04 14:52 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 9:11 [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug Christian Borntraeger
2026-12-04 9:11 ` [PATCH 1/2] KVM: s390: Use a unique s390dbf name per VM Christian Borntraeger
2026-12-04 9:21 ` sashiko-bot
2026-12-04 9:11 ` [PATCH 2/2] KVM: s390: arm64: Use a sequence number in the s390dbf name Christian Borntraeger
2026-12-04 9:19 ` sashiko-bot
2026-12-04 12:00 ` [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug Janosch Frank
2026-12-04 12:03 ` Christian Borntraeger
2026-12-04 12:49 ` Claudio Imbrenda
2026-12-04 13:08 ` Christian Borntraeger
2026-12-04 13:22 ` Andreas Grapentin
2026-12-04 13:50 ` Janosch Frank
2026-12-04 14:16 ` Claudio Imbrenda
2026-12-04 14:52 ` Janosch Frank
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.