From: Christian Borntraeger <borntraeger@linux.ibm.com>
To: KVM <kvm@vger.kernel.org>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
David Hildenbrand <david@kernel.org>,
linux-s390 <linux-s390@vger.kernel.org>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
Douglas Freimuth <freimuth@linux.ibm.com>
Subject: [PATCH v3 6/8] KVM: s390: Take srcu when importing watchpoint data
Date: Wed, 5 Aug 2026 13:04:53 +0200 [thread overview]
Message-ID: <20260805110455.7200-7-borntraeger@linux.ibm.com> (raw)
In-Reply-To: <20260805110455.7200-1-borntraeger@linux.ibm.com>
__import_wp_info() backs up the original guest memory contents of a
watchpoint with read_guest_abs(), which is kvm_read_guest() and therefore
resolves the memslot via __kvm_memslots(). That requires kvm->srcu (or
kvm->slots_lock) to be held, otherwise a concurrent memslot update can
free the memslots array under us once its SRCU grace period has elapsed.
As this is not fast path, following lock ordering (mutex first, then
srcu) take the big hammer and hold the srcu for the full import.
Fixes: 27291e2165b6 ("KVM: s390: hardware support for guest debugging")
Cc: stable@vger.kernel.org
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
---
arch/s390/kvm/kvm-s390.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index c47c3a930db7..e0548926dc49 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -4247,8 +4247,10 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
/* enforce guest PER */
kvm_s390_set_cpuflags(vcpu, CPUSTAT_P);
- if (dbg->control & KVM_GUESTDBG_USE_HW_BP)
- rc = kvm_s390_import_bp_data(vcpu, dbg);
+ if (dbg->control & KVM_GUESTDBG_USE_HW_BP) {
+ scoped_guard(srcu, &vcpu->kvm->srcu)
+ rc = kvm_s390_import_bp_data(vcpu, dbg);
+ }
} else {
kvm_s390_clear_cpuflags(vcpu, CPUSTAT_P);
vcpu->arch.guestdbg.last_bp = 0;
--
2.53.0
next prev parent reply other threads:[~2026-08-05 11:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 11:04 [PATCH v3 0/8] KVM: s390: More fixes Christian Borntraeger
2026-08-05 11:04 ` [PATCH v3 1/8] KVM: s390: Remove user triggerable WARN_ON Christian Borntraeger
2026-08-05 11:15 ` sashiko-bot
2026-08-05 11:04 ` [PATCH v3 2/8] KVM: s390: Zero initialize data structures for inject_pfault_token Christian Borntraeger
2026-08-05 11:31 ` sashiko-bot
2026-08-05 11:04 ` [PATCH v3 3/8] KVM: s390: Zero initialize irq in reinject_machine_check Christian Borntraeger
2026-08-05 11:29 ` sashiko-bot
2026-08-05 11:04 ` [PATCH v3 4/8] KVM: s390: Fix memory leak in guest debug handling Christian Borntraeger
2026-08-05 11:36 ` sashiko-bot
2026-08-05 11:04 ` [PATCH v3 5/8] KVM: s390: Fix old_data leak in guest debug error path Christian Borntraeger
2026-08-05 11:30 ` sashiko-bot
2026-08-05 11:04 ` Christian Borntraeger [this message]
2026-08-05 11:31 ` [PATCH v3 6/8] KVM: s390: Take srcu when importing watchpoint data sashiko-bot
2026-08-05 11:04 ` [PATCH v3 7/8] KVM: s390: Free guest debug data on vcpu destroy Christian Borntraeger
2026-08-05 11:26 ` sashiko-bot
2026-08-05 11:04 ` [PATCH v3 8/8] KVM: s390: Fix length check __import_wp_info() Christian Borntraeger
2026-08-05 11:32 ` sashiko-bot
2026-08-05 11:55 ` [PATCH v3 0/8] KVM: s390: More fixes Claudio Imbrenda
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=20260805110455.7200-7-borntraeger@linux.ibm.com \
--to=borntraeger@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--cc=freimuth@linux.ibm.com \
--cc=gor@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=mjrosato@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox