From: Janosch Frank <frankja@linux.ibm.com>
To: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: Andreas Grapentin <gra@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
KVM <kvm@vger.kernel.org>,
linux-s390 <linux-s390@vger.kernel.org>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
David Hildenbrand <david@kernel.org>,
Steffen Eiden <seiden@linux.ibm.com>,
Marc Zyngier <maz@kernel.org>
Subject: Re: [PATCH 0/2] KVM: s390: fix longstanding s390 debug feature bug
Date: Fri, 4 Dec 2026 15:52:33 +0100 [thread overview]
Message-ID: <22598a78-6e72-4c8a-a469-63452cb38bdc@linux.ibm.com> (raw)
In-Reply-To: <20261204151616.609e3fb7@p-imbrenda>
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");
+}
+
prev parent reply other threads:[~2026-12-04 14:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=22598a78-6e72-4c8a-a469-63452cb38bdc@linux.ibm.com \
--to=frankja@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=david@kernel.org \
--cc=gor@linux.ibm.com \
--cc=gra@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=maz@kernel.org \
--cc=seiden@linux.ibm.com \
--cc=svens@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.