Skip to content

Commit f303406

Browse files
author
Claudio Imbrenda
committed
KVM: s390: Fix a deadlock
In some scenarios, a deadlock can happen, involving _do_shadow_pte(). Convert all usages of pgste_get_lock() to pgste_get_trylock() in _do_shadow_pte() and return -EAGAIN. All callers can already deal with -EAGAIN being returned. Fixes: e38c884 ("KVM: s390: Switch to new gmap") Tested-by: Christian Borntraeger <borntraeger@linux.ibm.com> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: Christoph Schlameuss <schlameuss@linux.ibm.com> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
1 parent 5ee8dbf commit f303406

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

arch/s390/kvm/gaccess.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,8 @@ static int _do_shadow_pte(struct gmap *sg, gpa_t raddr, union pte *ptep_h, union
14341434
if (rc)
14351435
return rc;
14361436

1437-
pgste = pgste_get_lock(ptep_h);
1437+
if (!pgste_get_trylock(ptep_h, &pgste))
1438+
return -EAGAIN;
14381439
newpte = _pte(f->pfn, f->writable, !p, 0);
14391440
newpte.s.d |= ptep->s.d;
14401441
newpte.s.sd |= ptep->s.sd;
@@ -1444,7 +1445,8 @@ static int _do_shadow_pte(struct gmap *sg, gpa_t raddr, union pte *ptep_h, union
14441445
pgste_set_unlock(ptep_h, pgste);
14451446

14461447
newpte = _pte(f->pfn, 0, !p, 0);
1447-
pgste = pgste_get_lock(ptep);
1448+
if (!pgste_get_trylock(ptep, &pgste))
1449+
return -EAGAIN;
14481450
pgste = __dat_ptep_xchg(ptep, pgste, newpte, gpa_to_gfn(raddr), sg->asce, uses_skeys(sg));
14491451
pgste_set_unlock(ptep, pgste);
14501452

0 commit comments

Comments
 (0)