* [PATCH v2] KVM: s390: vsie: fix race during shadow creation
@ 2023-12-20 12:53 Christian Borntraeger
2023-12-20 12:56 ` Janosch Frank
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Christian Borntraeger @ 2023-12-20 12:53 UTC (permalink / raw)
To: KVM
Cc: Christian Borntraeger, Janosch Frank, David Hildenbrand,
linux-s390, Thomas Huth, Claudio Imbrenda, Heiko Carstens,
Vasily Gorbik, Alexander Gordeev, Marc Hartmayer
Right now it is possible to see gmap->private being zero in
kvm_s390_vsie_gmap_notifier resulting in a crash. This is due to the
fact that we add gmap->private == kvm after creation:
static int acquire_gmap_shadow(struct kvm_vcpu *vcpu,
struct vsie_page *vsie_page)
{
[...]
gmap = gmap_shadow(vcpu->arch.gmap, asce, edat);
if (IS_ERR(gmap))
return PTR_ERR(gmap);
gmap->private = vcpu->kvm;
Let children inherit the private field of the parent.
Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Fixes: a3508fbe9dc6 ("KVM: s390: vsie: initial support for nested virtualization")
Cc: <stable@vger.kernel.org>
Cc: David Hildenbrand <david@redhat.com>
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
---
v1->v2: let the child inherit private from parent instead of accessing
the parent in the notifier
arch/s390/kvm/vsie.c | 1 -
arch/s390/mm/gmap.c | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
index 8207a892bbe2..db9a180de65f 100644
--- a/arch/s390/kvm/vsie.c
+++ b/arch/s390/kvm/vsie.c
@@ -1220,7 +1220,6 @@ static int acquire_gmap_shadow(struct kvm_vcpu *vcpu,
gmap = gmap_shadow(vcpu->arch.gmap, asce, edat);
if (IS_ERR(gmap))
return PTR_ERR(gmap);
- gmap->private = vcpu->kvm;
vcpu->kvm->stat.gmap_shadow_create++;
WRITE_ONCE(vsie_page->gmap, gmap);
return 0;
diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
index 6f96b5a71c63..8da39deb56ca 100644
--- a/arch/s390/mm/gmap.c
+++ b/arch/s390/mm/gmap.c
@@ -1691,6 +1691,7 @@ struct gmap *gmap_shadow(struct gmap *parent, unsigned long asce,
return ERR_PTR(-ENOMEM);
new->mm = parent->mm;
new->parent = gmap_get(parent);
+ new->private = parent->private;
new->orig_asce = asce;
new->edat_level = edat_level;
new->initialized = false;
--
2.41.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] KVM: s390: vsie: fix race during shadow creation
2023-12-20 12:53 [PATCH v2] KVM: s390: vsie: fix race during shadow creation Christian Borntraeger
@ 2023-12-20 12:56 ` Janosch Frank
2023-12-20 13:12 ` David Hildenbrand
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Janosch Frank @ 2023-12-20 12:56 UTC (permalink / raw)
To: Christian Borntraeger, KVM
Cc: David Hildenbrand, linux-s390, Thomas Huth, Claudio Imbrenda,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Marc Hartmayer
On 12/20/23 13:53, Christian Borntraeger wrote:
> Right now it is possible to see gmap->private being zero in
> kvm_s390_vsie_gmap_notifier resulting in a crash. This is due to the
> fact that we add gmap->private == kvm after creation:
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] KVM: s390: vsie: fix race during shadow creation
2023-12-20 12:53 [PATCH v2] KVM: s390: vsie: fix race during shadow creation Christian Borntraeger
2023-12-20 12:56 ` Janosch Frank
@ 2023-12-20 13:12 ` David Hildenbrand
2023-12-21 10:13 ` Claudio Imbrenda
2023-12-21 11:59 ` Christian Borntraeger
3 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2023-12-20 13:12 UTC (permalink / raw)
To: Christian Borntraeger, KVM
Cc: Janosch Frank, linux-s390, Thomas Huth, Claudio Imbrenda,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Marc Hartmayer
On 20.12.23 13:53, Christian Borntraeger wrote:
> Right now it is possible to see gmap->private being zero in
> kvm_s390_vsie_gmap_notifier resulting in a crash. This is due to the
> fact that we add gmap->private == kvm after creation:
>
> static int acquire_gmap_shadow(struct kvm_vcpu *vcpu,
> struct vsie_page *vsie_page)
> {
> [...]
> gmap = gmap_shadow(vcpu->arch.gmap, asce, edat);
> if (IS_ERR(gmap))
> return PTR_ERR(gmap);
> gmap->private = vcpu->kvm;
>
> Let children inherit the private field of the parent.
>
> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Fixes: a3508fbe9dc6 ("KVM: s390: vsie: initial support for nested virtualization")
> Cc: <stable@vger.kernel.org>
> Cc: David Hildenbrand <david@redhat.com>
> Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
> ---
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] KVM: s390: vsie: fix race during shadow creation
2023-12-20 12:53 [PATCH v2] KVM: s390: vsie: fix race during shadow creation Christian Borntraeger
2023-12-20 12:56 ` Janosch Frank
2023-12-20 13:12 ` David Hildenbrand
@ 2023-12-21 10:13 ` Claudio Imbrenda
2023-12-21 11:59 ` Christian Borntraeger
3 siblings, 0 replies; 5+ messages in thread
From: Claudio Imbrenda @ 2023-12-21 10:13 UTC (permalink / raw)
To: Christian Borntraeger
Cc: KVM, Janosch Frank, David Hildenbrand, linux-s390, Thomas Huth,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Marc Hartmayer
On Wed, 20 Dec 2023 13:53:17 +0100
Christian Borntraeger <borntraeger@linux.ibm.com> wrote:
> Right now it is possible to see gmap->private being zero in
> kvm_s390_vsie_gmap_notifier resulting in a crash. This is due to the
> fact that we add gmap->private == kvm after creation:
>
> static int acquire_gmap_shadow(struct kvm_vcpu *vcpu,
> struct vsie_page *vsie_page)
> {
> [...]
> gmap = gmap_shadow(vcpu->arch.gmap, asce, edat);
> if (IS_ERR(gmap))
> return PTR_ERR(gmap);
> gmap->private = vcpu->kvm;
>
> Let children inherit the private field of the parent.
>
> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Fixes: a3508fbe9dc6 ("KVM: s390: vsie: initial support for nested virtualization")
> Cc: <stable@vger.kernel.org>
> Cc: David Hildenbrand <david@redhat.com>
> Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
> v1->v2: let the child inherit private from parent instead of accessing
> the parent in the notifier
> arch/s390/kvm/vsie.c | 1 -
> arch/s390/mm/gmap.c | 1 +
> 2 files changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
> index 8207a892bbe2..db9a180de65f 100644
> --- a/arch/s390/kvm/vsie.c
> +++ b/arch/s390/kvm/vsie.c
> @@ -1220,7 +1220,6 @@ static int acquire_gmap_shadow(struct kvm_vcpu *vcpu,
> gmap = gmap_shadow(vcpu->arch.gmap, asce, edat);
> if (IS_ERR(gmap))
> return PTR_ERR(gmap);
> - gmap->private = vcpu->kvm;
> vcpu->kvm->stat.gmap_shadow_create++;
> WRITE_ONCE(vsie_page->gmap, gmap);
> return 0;
> diff --git a/arch/s390/mm/gmap.c b/arch/s390/mm/gmap.c
> index 6f96b5a71c63..8da39deb56ca 100644
> --- a/arch/s390/mm/gmap.c
> +++ b/arch/s390/mm/gmap.c
> @@ -1691,6 +1691,7 @@ struct gmap *gmap_shadow(struct gmap *parent, unsigned long asce,
> return ERR_PTR(-ENOMEM);
> new->mm = parent->mm;
> new->parent = gmap_get(parent);
> + new->private = parent->private;
> new->orig_asce = asce;
> new->edat_level = edat_level;
> new->initialized = false;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] KVM: s390: vsie: fix race during shadow creation
2023-12-20 12:53 [PATCH v2] KVM: s390: vsie: fix race during shadow creation Christian Borntraeger
` (2 preceding siblings ...)
2023-12-21 10:13 ` Claudio Imbrenda
@ 2023-12-21 11:59 ` Christian Borntraeger
3 siblings, 0 replies; 5+ messages in thread
From: Christian Borntraeger @ 2023-12-21 11:59 UTC (permalink / raw)
To: KVM
Cc: Janosch Frank, David Hildenbrand, linux-s390, Thomas Huth,
Claudio Imbrenda, Heiko Carstens, Vasily Gorbik,
Alexander Gordeev, Marc Hartmayer
Am 20.12.23 um 13:53 schrieb Christian Borntraeger:
> Right now it is possible to see gmap->private being zero in
> kvm_s390_vsie_gmap_notifier resulting in a crash. This is due to the
> fact that we add gmap->private == kvm after creation:
>
> static int acquire_gmap_shadow(struct kvm_vcpu *vcpu,
> struct vsie_page *vsie_page)
> {
> [...]
> gmap = gmap_shadow(vcpu->arch.gmap, asce, edat);
> if (IS_ERR(gmap))
> return PTR_ERR(gmap);
> gmap->private = vcpu->kvm;
>
> Let children inherit the private field of the parent.
>
> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Fixes: a3508fbe9dc6 ("KVM: s390: vsie: initial support for nested virtualization")
> Cc: <stable@vger.kernel.org>
> Cc: David Hildenbrand <david@redhat.com>
> Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
queue on kvms390/master.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-12-21 11:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-20 12:53 [PATCH v2] KVM: s390: vsie: fix race during shadow creation Christian Borntraeger
2023-12-20 12:56 ` Janosch Frank
2023-12-20 13:12 ` David Hildenbrand
2023-12-21 10:13 ` Claudio Imbrenda
2023-12-21 11:59 ` Christian Borntraeger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox