KVM: s390: pv: Two small fixes for 6.5
Claudio Imbrenda
maintainerHi Paolo,
just two small bugfixes for asynchronous destroy.
please pull, thanks!
Claudio
The following changes since commit fdf0eaf11452d72945af31804e2a1048ee1b574c:
Linux 6.5-rc2 (2023-07-16 15:10:37 -0700)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git tags/kvm-s390-master-6.5-1
for you to fetch changes up to c2fceb59bbda16468bda82b002383bff59de89ab:
KVM: s390: pv: fix index value of replaced ASCE (2023-07-18 11:21:51 +0200)
----------------------------------------------------------------
Two fixes for asynchronous destroy
----------------------------------------------------------------
Claudio Imbrenda (2):
KVM: s390: pv: simplify shutdown and fix race
KVM: s390: pv: fix index value of replaced ASCE
arch/s390/kvm/pv.c | 8 ++++++-- arch/s390/mm/gmap.c | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.41.0
Claudio Imbrenda
maintainer[GIT PULL 1/2] KVM: s390: pv: simplify shutdown and fix race
Simplify the shutdown of non-protected VMs. There is no need to do complex manipulations of the counter if it was zero.
This also fixes a very rare race which caused pages to be torn down from the address space with a non-zero counter even on older machines that don't support the UVC instruction, causing a crash.
Message-ID: <[email protected]>
--- arch/s390/kvm/pv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/s390/kvm/pv.c +6 -2
@@ -411,8 +411,12 @@ int kvm_s390_pv_deinit_cleanup_all(struct kvm *kvm, u16 *rc, u16 *rrc)u16 _rc, _rrc;int cc =0 ; -/* Make sure the counter does not reach 0 before calling s390_uv_destroy_range */ -atomic_inc (&kvm->mm->context.protected_count); +/* +* Nothing to do if the counter was already 0. Otherwise make sure +* the counter does not reach 0 before calling s390_uv_destroy_range. +*/ +if (!atomic_inc_not_zero (&kvm->mm->context.protected_count)) +return 0 ; *rc =1 ;/* If the current VM is protected, destroy it */
Signature · 1 line
2.41.0
Claudio Imbrenda
maintainer[GIT PULL 2/2] KVM: s390: pv: fix index value of replaced ASCE
In reply to Claudio ImbrendaThe index field of the struct page corresponding to a guest ASCE should be 0. When replacing the ASCE in s390_replace_asce(), the index of the new ASCE should also be set to 0.
Having the wrong index might lead to the wrong addresses being passed around when notifying pte invalidations, and eventually to validity intercepts (VM crash) if the prefix gets unmapped and the notifier gets called with the wrong address.
Message-ID: <[email protected]>
--- arch/s390/mm/gmap.c | 1 + 1 file changed, 1 insertion(+)
arch/s390/mm/gmap.c +1 -0
@@ -2853,6 +2853,7 @@ int s390_replace_asce(struct gmap *gmap) page =alloc_pages (GFP_KERNEL_ACCOUNT ,CRST_ALLOC_ORDER );if (!page)return -ENOMEM ; + page->index =0 ; table =page_to_virt (page);memcpy (table, gmap->table,1UL << (CRST_ALLOC_ORDER +PAGE_SHIFT ));
Signature · 1 line
2.41.0
Paolo Bonzini
maintainerQuoted 7 lines · Claudio Imbrenda
Hi Paolo,
just two small bugfixes for asynchronous destroy.
please pull, thanks!
Done, thanks.
Paolo
Quoted 31 lines
Claudio
The following changes since commit
fdf0eaf11452d72945af31804e2a1048ee1b574c:Linux 6.5-rc2 (2023-07-16 15:10:37 -0700)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git tags/kvm-s390-master-6.5-1
for you to fetch changes up to
c2fceb59bbda16468bda82b002383bff59de89ab:KVM: s390: pv: fix index value of replaced ASCE (2023-07-18 11:21:51 +0200)
----------------------------------------------------------------
Two fixes for asynchronous destroy----------------------------------------------------------------
Claudio Imbrenda (2):
KVM: s390: pv: simplify shutdown and fix race
KVM: s390: pv: fix index value of replaced ASCEarch/s390/kvm/pv.c | 8 ++++++-- arch/s390/mm/gmap.c | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)--
2.41.0