mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
KVM: s390: Fix gmap_link()
The slow path of the fault handler ultimately called gmap_link(), which assumed the fault was a major fault, and blindly called dat_link(). In case of minor faults, things were not always handled properly; in particular the prefix and vsie marker bits were ignored. Move dat_link() into gmap.c, renaming it accordingly. Once moved, the new _gmap_link() function will be able to correctly honour the prefix and vsie markers. This will cause spurious unshadows in some uncommon cases. Fixes:94fd9b16cc("KVM: s390: KVM page table management functions: lifecycle management") Fixes:a2c17f9270("KVM: s390: New gmap code") Reviewed-by: Steffen Eiden <seiden@linux.ibm.com> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
This commit is contained in:
@@ -997,54 +997,6 @@ bool dat_test_age_gfn(union asce asce, gfn_t start, gfn_t end)
|
||||
return _dat_walk_gfn_range(start, end, asce, &test_age_ops, 0, NULL) > 0;
|
||||
}
|
||||
|
||||
int dat_link(struct kvm_s390_mmu_cache *mc, union asce asce, int level,
|
||||
bool uses_skeys, struct guest_fault *f)
|
||||
{
|
||||
union crste oldval, newval;
|
||||
union pte newpte, oldpte;
|
||||
union pgste pgste;
|
||||
int rc = 0;
|
||||
|
||||
rc = dat_entry_walk(mc, f->gfn, asce, DAT_WALK_ALLOC_CONTINUE, level, &f->crstep, &f->ptep);
|
||||
if (rc == -EINVAL || rc == -ENOMEM)
|
||||
return rc;
|
||||
if (rc)
|
||||
return -EAGAIN;
|
||||
|
||||
if (WARN_ON_ONCE(unlikely(get_level(f->crstep, f->ptep) > level)))
|
||||
return -EINVAL;
|
||||
|
||||
if (f->ptep) {
|
||||
pgste = pgste_get_lock(f->ptep);
|
||||
oldpte = *f->ptep;
|
||||
newpte = _pte(f->pfn, f->writable, f->write_attempt | oldpte.s.d, !f->page);
|
||||
newpte.s.sd = oldpte.s.sd;
|
||||
oldpte.s.sd = 0;
|
||||
if (oldpte.val == _PTE_EMPTY.val || oldpte.h.pfra == f->pfn) {
|
||||
pgste = __dat_ptep_xchg(f->ptep, pgste, newpte, f->gfn, asce, uses_skeys);
|
||||
if (f->callback)
|
||||
f->callback(f);
|
||||
} else {
|
||||
rc = -EAGAIN;
|
||||
}
|
||||
pgste_set_unlock(f->ptep, pgste);
|
||||
} else {
|
||||
oldval = READ_ONCE(*f->crstep);
|
||||
newval = _crste_fc1(f->pfn, oldval.h.tt, f->writable,
|
||||
f->write_attempt | oldval.s.fc1.d);
|
||||
newval.s.fc1.sd = oldval.s.fc1.sd;
|
||||
if (oldval.val != _CRSTE_EMPTY(oldval.h.tt).val &&
|
||||
crste_origin_large(oldval) != crste_origin_large(newval))
|
||||
return -EAGAIN;
|
||||
if (!dat_crstep_xchg_atomic(f->crstep, oldval, newval, f->gfn, asce))
|
||||
return -EAGAIN;
|
||||
if (f->callback)
|
||||
f->callback(f);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static long dat_set_pn_crste(union crste *crstep, gfn_t gfn, gfn_t next, struct dat_walk *walk)
|
||||
{
|
||||
union crste newcrste, oldcrste;
|
||||
|
||||
Reference in New Issue
Block a user