KVM: s390: two small but important fixes
Claudio Imbrenda
maintainerHi Paolo,
two small but important fixes, please pull :)
Claudio
The following changes since commit b85ea95d086471afb4ad062012a4d73cd328fa86:
Linux 6.7-rc1 (2023-11-12 16:19:07 -0800)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git tags/kvm-s390-master-6.7-1
for you to fetch changes up to 27072b8e18a73ffeffb1c140939023915a35134b:
KVM: s390/mm: Properly reset no-dat (2023-11-14 18:56:46 +0100)
----------------------------------------------------------------
Two small but important bugfixes.
----------------------------------------------------------------
Claudio Imbrenda (2):
KVM: s390: vsie: fix wrong VIR 37 when MSO is used
KVM: s390/mm: Properly reset no-dat
arch/s390/kvm/vsie.c | 4 ---- arch/s390/mm/pgtable.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-)
Signature · 1 line
2.41.0
Claudio Imbrenda
maintainer[GIT PULL v1 1/2] KVM: s390: vsie: fix wrong VIR 37 when MSO is used
When the host invalidates a guest page, it will also check if the page was used to map the prefix of any guest CPUs, in which case they are stopped and marked as needing a prefix refresh. Upon starting the affected CPUs again, their prefix pages are explicitly faulted in and revalidated if they had been invalidated. A bit in the PGSTEs indicates whether or not a page might contain a prefix. The bit is allowed to overindicate. Pages above 2G are skipped, because they cannot be prefixes, since KVM runs all guests with MSO = 0.
The same applies for nested guests (VSIE). When the host invalidates a guest page that maps the prefix of the nested guest, it has to stop the affected nested guest CPUs and mark them as needing a prefix refresh. The same PGSTE bit used for the guest prefix is also used for the nested guest. Pages above 2G are skipped like for normal guests, which is the source of the bug.
The nested guest runs is the guest primary address space. The guest could be running the nested guest using MSO != 0. If the MSO + prefix for the nested guest is above 2G, the check for nested prefix will skip it. This will cause the invalidation notifier to not stop the CPUs of the nested guest and not mark them as needing refresh. When the nested guest is run again, its prefix will not be refreshed, since it has not been marked for refresh. This will cause a fatal validity intercept with VIR code 37.
Fix this by removing the check for 2G for nested guests. Now all invalidations of pages with the notify bit set will always scan the existing VSIE shadow state descriptors.
This allows to catch invalidations of nested guest prefix mappings even when the prefix is above 2G in the guest virtual address space.
Message-ID: <[email protected]>
--- arch/s390/kvm/vsie.c | 4 ---- 1 file changed, 4 deletions(-)
arch/s390/kvm/vsie.c +0 -4
@@ -587,10 +587,6 @@ void kvm_s390_vsie_gmap_notifier(struct gmap *gmap, unsigned long start,if (!gmap_is_shadow (gmap))return ; -if (start >=1UL <<31 ) -/* We are only interested in prefix pages */ -return ; -/* * Only new shadow blocks are added to the list during runtime, * therefore we can safely reference them all the time.
Signature · 1 line
2.41.0
Claudio Imbrenda
maintainer[GIT PULL v1 2/2] KVM: s390/mm: Properly reset no-dat
In reply to Claudio ImbrendaWhen the CMMA state needs to be reset, the no-dat bit also needs to be reset. Failure to do so could cause issues in the guest, since the guest expects the bit to be cleared after a reset.
Message-ID: <[email protected]>
--- arch/s390/mm/pgtable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/mm/pgtable.c +1 -1
@@ -756,7 +756,7 @@ void ptep_zap_unused(struct mm_struct *mm, unsigned long addr,pte_clear (mm, addr, ptep); }if (reset) -pgste_val (pgste) &= ~_PGSTE_GPS_USAGE_MASK; +pgste_val (pgste) &= ~(_PGSTE_GPS_USAGE_MASK | _PGSTE_GPS_NODAT);pgste_set_unlock (ptep, pgste);preempt_enable (); }
Signature · 1 line
2.41.0
Paolo Bonzini
maintainerQuoted 4 lines · Claudio Imbrenda
Hi Paolo,
two small but important fixes, please pull :)
Done, thanks.
Paolo
Quoted 32 lines
Claudio
The following changes since commit
b85ea95d086471afb4ad062012a4d73cd328fa86:Linux 6.7-rc1 (2023-11-12 16:19:07 -0800)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git tags/kvm-s390-master-6.7-1
for you to fetch changes up to
27072b8e18a73ffeffb1c140939023915a35134b:KVM: s390/mm: Properly reset no-dat (2023-11-14 18:56:46 +0100)
----------------------------------------------------------------
Two small but important bugfixes.----------------------------------------------------------------
Claudio Imbrenda (2):
KVM: s390: vsie: fix wrong VIR 37 when MSO is used
KVM: s390/mm: Properly reset no-datarch/s390/kvm/vsie.c | 4 ---- arch/s390/mm/pgtable.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-)--
2.41.0
Paolo Bonzini
maintainerQuoted 1 line · Paolo Bonzini
Quoted 1 line
KVM: s390/mm: Properly reset no-dat
A small question on this one, would it make sense to clear _all_ gmap-related bits, including _PGSTE_GPS_ZERO?
Paolo
Claudio Imbrenda
maintainerQuoted 5 lines · On Fri, 8 Dec 2023 22:02:43 +0100 Paolo Bonzini <[email protected]> wrote:
Quoted 1 line · Paolo Bonzini
Quoted 1 line
KVM: s390/mm: Properly reset no-dat
A small question on this one, would it make sense to clear _all_ gmap-related bits, including
_PGSTE_GPS_ZERO?
That's a good question, I'll have to think about it.
In general, though, not resetting it will not cause issues in the guest.