public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL v1 0/2] KVM: s390: two small but important fixes
@ 2023-11-15 12:51 Claudio Imbrenda
  2023-11-15 12:51 ` [GIT PULL v1 1/2] KVM: s390: vsie: fix wrong VIR 37 when MSO is used Claudio Imbrenda
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Claudio Imbrenda @ 2023-11-15 12:51 UTC (permalink / raw)
  To: pbonzini
  Cc: linux-kernel, kvm, linux-s390, frankja, borntraeger, hca,
	agordeev, gor

Hi 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(-)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [GIT PULL v1 1/2] KVM: s390: vsie: fix wrong VIR 37 when MSO is used
  2023-11-15 12:51 [GIT PULL v1 0/2] KVM: s390: two small but important fixes Claudio Imbrenda
@ 2023-11-15 12:51 ` Claudio Imbrenda
  2023-11-15 12:51 ` [GIT PULL v1 2/2] KVM: s390/mm: Properly reset no-dat Claudio Imbrenda
  2023-12-08 18:13 ` [GIT PULL v1 0/2] KVM: s390: two small but important fixes Paolo Bonzini
  2 siblings, 0 replies; 6+ messages in thread
From: Claudio Imbrenda @ 2023-11-15 12:51 UTC (permalink / raw)
  To: pbonzini
  Cc: linux-kernel, kvm, linux-s390, frankja, borntraeger, hca,
	agordeev, gor

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.

Fixes: a3508fbe9dc6 ("KVM: s390: vsie: initial support for nested virtualization")
Tested-by: Nico Boehr <nrb@linux.ibm.com>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-ID: <20231102153549.53984-1-imbrenda@linux.ibm.com>
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
 arch/s390/kvm/vsie.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
index 02dcbe82a8e5..8207a892bbe2 100644
--- a/arch/s390/kvm/vsie.c
+++ b/arch/s390/kvm/vsie.c
@@ -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.
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [GIT PULL v1 2/2] KVM: s390/mm: Properly reset no-dat
  2023-11-15 12:51 [GIT PULL v1 0/2] KVM: s390: two small but important fixes Claudio Imbrenda
  2023-11-15 12:51 ` [GIT PULL v1 1/2] KVM: s390: vsie: fix wrong VIR 37 when MSO is used Claudio Imbrenda
@ 2023-11-15 12:51 ` Claudio Imbrenda
  2023-12-08 18:13 ` [GIT PULL v1 0/2] KVM: s390: two small but important fixes Paolo Bonzini
  2 siblings, 0 replies; 6+ messages in thread
From: Claudio Imbrenda @ 2023-11-15 12:51 UTC (permalink / raw)
  To: pbonzini
  Cc: linux-kernel, kvm, linux-s390, frankja, borntraeger, hca,
	agordeev, gor

When 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.

Cc: <stable@vger.kernel.org>
Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
Message-ID: <20231109123624.37314-1-imbrenda@linux.ibm.com>
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
 arch/s390/mm/pgtable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
index 3bd2ab2a9a34..5cb92941540b 100644
--- a/arch/s390/mm/pgtable.c
+++ b/arch/s390/mm/pgtable.c
@@ -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();
 }
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [GIT PULL v1 0/2] KVM: s390: two small but important fixes
  2023-11-15 12:51 [GIT PULL v1 0/2] KVM: s390: two small but important fixes Claudio Imbrenda
  2023-11-15 12:51 ` [GIT PULL v1 1/2] KVM: s390: vsie: fix wrong VIR 37 when MSO is used Claudio Imbrenda
  2023-11-15 12:51 ` [GIT PULL v1 2/2] KVM: s390/mm: Properly reset no-dat Claudio Imbrenda
@ 2023-12-08 18:13 ` Paolo Bonzini
  2023-12-08 21:02   ` Paolo Bonzini
  2 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2023-12-08 18:13 UTC (permalink / raw)
  To: Claudio Imbrenda
  Cc: linux-kernel, kvm, linux-s390, frankja, borntraeger, hca,
	agordeev, gor

On Wed, Nov 15, 2023 at 1:51 PM Claudio Imbrenda <imbrenda@linux.ibm.com> wrote:
>
> Hi Paolo,
>
> two small but important fixes, please pull :)

Done, thanks.

Paolo

>
> 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(-)
>
> --
> 2.41.0
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [GIT PULL v1 0/2] KVM: s390: two small but important fixes
  2023-12-08 18:13 ` [GIT PULL v1 0/2] KVM: s390: two small but important fixes Paolo Bonzini
@ 2023-12-08 21:02   ` Paolo Bonzini
  2023-12-11 10:04     ` Claudio Imbrenda
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2023-12-08 21:02 UTC (permalink / raw)
  To: Claudio Imbrenda
  Cc: linux-kernel, kvm, linux-s390, frankja, borntraeger, hca,
	agordeev, gor

On Fri, Dec 8, 2023 at 7:13 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
> >       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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [GIT PULL v1 0/2] KVM: s390: two small but important fixes
  2023-12-08 21:02   ` Paolo Bonzini
@ 2023-12-11 10:04     ` Claudio Imbrenda
  0 siblings, 0 replies; 6+ messages in thread
From: Claudio Imbrenda @ 2023-12-11 10:04 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: linux-kernel, kvm, linux-s390, frankja, borntraeger, hca,
	agordeev, gor

On Fri, 8 Dec 2023 22:02:43 +0100
Paolo Bonzini <pbonzini@redhat.com> wrote:

> On Fri, Dec 8, 2023 at 7:13 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
> > >       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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-12-11 10:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-15 12:51 [GIT PULL v1 0/2] KVM: s390: two small but important fixes Claudio Imbrenda
2023-11-15 12:51 ` [GIT PULL v1 1/2] KVM: s390: vsie: fix wrong VIR 37 when MSO is used Claudio Imbrenda
2023-11-15 12:51 ` [GIT PULL v1 2/2] KVM: s390/mm: Properly reset no-dat Claudio Imbrenda
2023-12-08 18:13 ` [GIT PULL v1 0/2] KVM: s390: two small but important fixes Paolo Bonzini
2023-12-08 21:02   ` Paolo Bonzini
2023-12-11 10:04     ` Claudio Imbrenda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox