From: Gautam Gala <ggala@linux.ibm.com>
To: kvm@vger.kernel.org
Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
David Hildenbrand <david@kernel.org>,
Steffen Eiden <seiden@linux.ibm.com>,
Andreas Grapentin <gra@linux.ibm.com>,
Marc Zyngier <maz@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>
Subject: [PATCH v1 1/2] KVM: s390: reserve mmu cache before stopping migration mode
Date: Fri, 20 Nov 2026 08:53:44 +0100 [thread overview]
Message-ID: <20261120075345.116521-2-ggala@linux.ibm.com> (raw)
In-Reply-To: <20261120075345.116521-1-ggala@linux.ibm.com>
Creating or moving a memslot without KVM_MEM_LOG_DIRTY_PAGES stops
migration mode in s390_kvm_mmu_prepare_memory_region(). If the mmu
cache reservation fails afterwards, the ioctl returns -ENOMEM with
the memslots unchanged, but migration mode stays stopped: the CMMA
state cleared by kvm_s390_vm_stop_migration() cannot be restored,
so an in-flight migration aborts over an unrelated allocation
failure.
Reserve the mmu cache before tearing down migration mode so the
error path leaves both memslots and migration state untouched.
Fixes: 19192a404327 ("KVM: s390: Move all code into s390_kvm_mmu_prepare_memory_region()")
Reported-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Gautam Gala <ggala@linux.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
arch/s390/kvm/gmap/kvm_mmu.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/s390/kvm/gmap/kvm_mmu.c b/arch/s390/kvm/gmap/kvm_mmu.c
index 4e2da60b9859..120980cf6ac6 100644
--- a/arch/s390/kvm/gmap/kvm_mmu.c
+++ b/arch/s390/kvm/gmap/kvm_mmu.c
@@ -78,6 +78,14 @@ int s390_kvm_mmu_prepare_memory_region(struct kvm *kvm,
return -EINVAL;
if (!asce_contains_gfn(kvm->arch.gmap->asce, new->base_gfn + new->npages - 1))
return -EINVAL;
+
+ /*
+ * Must be allocated before migration mode is stopped below:
+ * kvm_s390_vm_stop_migration() is not rolled back on failure.
+ */
+ mc = kvm_s390_new_mmu_cache();
+ if (!mc)
+ return -ENOMEM;
}
if (kvm_s390_is_migration_mode(kvm)) {
@@ -97,12 +105,7 @@ int s390_kvm_mmu_prepare_memory_region(struct kvm *kvm,
if (change == KVM_MR_FLAGS_ONLY)
return 0;
- if (change != KVM_MR_DELETE) {
- /* Enough capacity to add a new memslot */
- mc = kvm_s390_new_mmu_cache();
- if (!mc)
- return -ENOMEM;
- }
+
scoped_guard(write_lock, &kvm->mmu_lock) {
kvm_s390_update_cmma_dirty(kvm, old);
if (change == KVM_MR_DELETE || change == KVM_MR_MOVE)
--
2.56.0
next prev parent reply other threads:[~2026-11-20 7:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 7:53 [PATCH v1 0/2] KVM: s390: fix migration mode teardown in memslot handling Gautam Gala
2026-11-20 7:53 ` Gautam Gala [this message]
2026-11-20 7:53 ` [PATCH v1 2/2] KVM: s390: make kvm_s390_vm_stop_migration() void Gautam Gala
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=20261120075345.116521-2-ggala@linux.ibm.com \
--to=ggala@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=david@kernel.org \
--cc=frankja@linux.ibm.com \
--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-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®