/* * vaddress union in order to easily decode a virtual address into its * region first index, region second index etc. parts.
*/ union vaddress { unsignedlong addr; struct { unsignedlong rfx : 11; unsignedlong rsx : 11; unsignedlong rtx : 11; unsignedlong sx : 11; unsignedlong px : 8; unsignedlong bx : 12;
}; struct { unsignedlong rfx01 : 2; unsignedlong : 9; unsignedlong rsx01 : 2; unsignedlong : 9; unsignedlong rtx01 : 2; unsignedlong : 9; unsignedlong sx01 : 2; unsignedlong : 29;
};
};
/* * raddress union which will contain the result (real or absolute address) * after a page table walk. The rfaa, sfaa and pfra members are used to * simply assign them the value of a region, segment or page table entry.
*/ union raddress { unsignedlong addr; unsignedlong rfaa : 33; /* Region-Frame Absolute Address */ unsignedlong sfaa : 44; /* Segment-Frame Absolute Address */ unsignedlong pfra : 52; /* Page-Frame Real Address */
};
staticvoid ipte_lock_simple(struct kvm *kvm)
{ union ipte_control old, new, *ic;
mutex_lock(&kvm->arch.ipte_mutex);
kvm->arch.ipte_lock_count++; if (kvm->arch.ipte_lock_count > 1) goto out;
retry:
read_lock(&kvm->arch.sca_lock);
ic = kvm_s390_get_ipte_control(kvm);
old = READ_ONCE(*ic); do { if (old.k) {
read_unlock(&kvm->arch.sca_lock);
cond_resched(); goto retry;
} new = old; new.k = 1;
} while (!try_cmpxchg(&ic->val, &old.val, new.val));
read_unlock(&kvm->arch.sca_lock);
out:
mutex_unlock(&kvm->arch.ipte_mutex);
}
staticvoid ipte_unlock_simple(struct kvm *kvm)
{ union ipte_control old, new, *ic;
mutex_lock(&kvm->arch.ipte_mutex);
kvm->arch.ipte_lock_count--; if (kvm->arch.ipte_lock_count) goto out;
read_lock(&kvm->arch.sca_lock);
ic = kvm_s390_get_ipte_control(kvm);
old = READ_ONCE(*ic); do { new = old; new.k = 0;
} while (!try_cmpxchg(&ic->val, &old.val, new.val));
read_unlock(&kvm->arch.sca_lock);
wake_up(&kvm->arch.ipte_wq);
out:
mutex_unlock(&kvm->arch.ipte_mutex);
}
staticvoid ipte_lock_siif(struct kvm *kvm)
{ union ipte_control old, new, *ic;
retry:
read_lock(&kvm->arch.sca_lock);
ic = kvm_s390_get_ipte_control(kvm);
old = READ_ONCE(*ic); do { if (old.kg) {
read_unlock(&kvm->arch.sca_lock);
cond_resched(); goto retry;
} new = old; new.k = 1; new.kh++;
} while (!try_cmpxchg(&ic->val, &old.val, new.val));
read_unlock(&kvm->arch.sca_lock);
}
staticvoid ipte_unlock_siif(struct kvm *kvm)
{ union ipte_control old, new, *ic;
read_lock(&kvm->arch.sca_lock);
ic = kvm_s390_get_ipte_control(kvm);
old = READ_ONCE(*ic); do { new = old; new.kh--; if (!new.kh) new.k = 0;
} while (!try_cmpxchg(&ic->val, &old.val, new.val));
read_unlock(&kvm->arch.sca_lock); if (!new.kh)
wake_up(&kvm->arch.ipte_wq);
}
switch (code) { case PGM_PROTECTION: switch (prot) { case PROT_TYPE_DUMMY: /* We should never get here, acts like termination */
WARN_ON_ONCE(1); break; case PROT_TYPE_IEP:
teid->b61 = 1;
fallthrough; case PROT_TYPE_LA:
teid->b56 = 1; break; case PROT_TYPE_KEYC:
teid->b60 = 1; break; case PROT_TYPE_ALC:
teid->b60 = 1;
fallthrough; case PROT_TYPE_DAT:
teid->b61 = 1; break;
} if (terminate) {
teid->b56 = 0;
teid->b60 = 0;
teid->b61 = 0;
}
fallthrough; case PGM_ASCE_TYPE: case PGM_PAGE_TRANSLATION: case PGM_REGION_FIRST_TRANS: case PGM_REGION_SECOND_TRANS: case PGM_REGION_THIRD_TRANS: case PGM_SEGMENT_TRANSLATION: /* * op_access_id only applies to MOVE_PAGE -> set bit 61 * exc_access_id has to be set to 0 for some instructions. Both * cases have to be handled by the caller.
*/
teid->addr = gva >> PAGE_SHIFT;
teid->fsi = mode == GACC_STORE ? TEID_FSI_STORE : TEID_FSI_FETCH;
teid->as = psw_bits(vcpu->arch.sie_block->gpsw).as;
fallthrough; case PGM_ALEN_TRANSLATION: case PGM_ALE_SEQUENCE: case PGM_ASTE_VALIDITY: case PGM_ASTE_SEQUENCE: case PGM_EXTENDED_AUTHORITY: /* * We can always store exc_access_id, as it is * undefined for non-ar cases. It is undefined for * most DAT protection exceptions.
*/
pgm->exc_access_id = ar; break;
} return code;
}
/** * guest_translate - translate a guest virtual into a guest absolute address * @vcpu: virtual cpu * @gva: guest virtual address * @gpa: points to where guest physical (absolute) address should be stored * @asce: effective asce * @mode: indicates the access mode to be used * @prot: returns the type for protection exceptions * * Translate a guest virtual address into a guest absolute address by means * of dynamic address translation as specified by the architecture. * If the resulting absolute address is not available in the configuration * an addressing exception is indicated and @gpa will not be changed. * * Returns: - zero on success; @gpa contains the resulting absolute address * - a negative value if guest access failed due to e.g. broken * guest mapping * - a positive value if an access exception happened. In this case * the returned value is the program interruption code as defined * by the architecture
*/ staticunsignedlong guest_translate(struct kvm_vcpu *vcpu, unsignedlong gva, unsignedlong *gpa, constunion asce asce, enum gacc_mode mode, enum prot_type *prot)
{ union vaddress vaddr = {.addr = gva}; union raddress raddr = {.addr = gva}; union page_table_entry pte; int dat_protection = 0; int iep_protection = 0; union ctlreg0 ctlreg0; unsignedlong ptr; int edat1, edat2, iep;
ctlreg0.val = vcpu->arch.sie_block->gcr[0];
edat1 = ctlreg0.edat && test_kvm_facility(vcpu->kvm, 8);
edat2 = edat1 && test_kvm_facility(vcpu->kvm, 78);
iep = ctlreg0.iep && test_kvm_facility(vcpu->kvm, 130); if (asce.r) goto real_address;
ptr = asce.rsto * PAGE_SIZE; switch (asce.dt) { case ASCE_TYPE_REGION1: if (vaddr.rfx01 > asce.tl) return PGM_REGION_FIRST_TRANS;
ptr += vaddr.rfx * 8; break; case ASCE_TYPE_REGION2: if (vaddr.rfx) return PGM_ASCE_TYPE; if (vaddr.rsx01 > asce.tl) return PGM_REGION_SECOND_TRANS;
ptr += vaddr.rsx * 8; break; case ASCE_TYPE_REGION3: if (vaddr.rfx || vaddr.rsx) return PGM_ASCE_TYPE; if (vaddr.rtx01 > asce.tl) return PGM_REGION_THIRD_TRANS;
ptr += vaddr.rtx * 8; break; case ASCE_TYPE_SEGMENT: if (vaddr.rfx || vaddr.rsx || vaddr.rtx) return PGM_ASCE_TYPE; if (vaddr.sx01 > asce.tl) return PGM_SEGMENT_TRANSLATION;
ptr += vaddr.sx * 8; break;
} switch (asce.dt) { case ASCE_TYPE_REGION1: { union region1_table_entry rfte;
if (!kvm_is_gpa_in_memslot(vcpu->kvm, ptr)) return PGM_ADDRESSING; if (deref_table(vcpu->kvm, ptr, &rfte.val)) return -EFAULT; if (rfte.i) return PGM_REGION_FIRST_TRANS; if (rfte.tt != TABLE_TYPE_REGION1) return PGM_TRANSLATION_SPEC; if (vaddr.rsx01 < rfte.tf || vaddr.rsx01 > rfte.tl) return PGM_REGION_SECOND_TRANS; if (edat1)
dat_protection |= rfte.p;
ptr = rfte.rto * PAGE_SIZE + vaddr.rsx * 8;
}
fallthrough; case ASCE_TYPE_REGION2: { union region2_table_entry rste;
if (!kvm_is_gpa_in_memslot(vcpu->kvm, ptr)) return PGM_ADDRESSING; if (deref_table(vcpu->kvm, ptr, &rste.val)) return -EFAULT; if (rste.i) return PGM_REGION_SECOND_TRANS; if (rste.tt != TABLE_TYPE_REGION2) return PGM_TRANSLATION_SPEC; if (vaddr.rtx01 < rste.tf || vaddr.rtx01 > rste.tl) return PGM_REGION_THIRD_TRANS; if (edat1)
dat_protection |= rste.p;
ptr = rste.rto * PAGE_SIZE + vaddr.rtx * 8;
}
fallthrough; case ASCE_TYPE_REGION3: { union region3_table_entry rtte;
if (!kvm_is_gpa_in_memslot(vcpu->kvm, ptr)) return PGM_ADDRESSING; if (deref_table(vcpu->kvm, ptr, &rtte.val)) return -EFAULT; if (rtte.i) return PGM_REGION_THIRD_TRANS; if (rtte.tt != TABLE_TYPE_REGION3) return PGM_TRANSLATION_SPEC; if (rtte.cr && asce.p && edat2) return PGM_TRANSLATION_SPEC; if (rtte.fc && edat2) {
dat_protection |= rtte.fc1.p;
iep_protection = rtte.fc1.iep;
raddr.rfaa = rtte.fc1.rfaa; goto absolute_address;
} if (vaddr.sx01 < rtte.fc0.tf) return PGM_SEGMENT_TRANSLATION; if (vaddr.sx01 > rtte.fc0.tl) return PGM_SEGMENT_TRANSLATION; if (edat1)
dat_protection |= rtte.fc0.p;
ptr = rtte.fc0.sto * PAGE_SIZE + vaddr.sx * 8;
}
fallthrough; case ASCE_TYPE_SEGMENT: { union segment_table_entry ste;
/* access key 0 matches any storage key -> allow */ if (access_key == 0) return 0; /* * caller needs to ensure that gfn is accessible, so we can * assume that this cannot fail
*/
hva = gfn_to_hva(vcpu->kvm, gpa_to_gfn(gpa));
mmap_read_lock(current->mm);
r = get_guest_storage_key(current->mm, hva, &storage_key);
mmap_read_unlock(current->mm); if (r) return r;
access_control = FIELD_GET(_PAGE_ACC_BITS, storage_key); /* access key matches storage key -> allow */ if (access_control == access_key) return 0; if (mode == GACC_FETCH || mode == GACC_IFETCH) { /* it is a fetch and fetch protection is off -> allow */ if (!(storage_key & _PAGE_FP_BIT)) return 0; if (fetch_prot_override_applicable(vcpu, mode, asce) &&
fetch_prot_override_applies(ga, len)) return 0;
} if (storage_prot_override_applicable(vcpu) &&
storage_prot_override_applies(access_control)) return 0; return PGM_PROTECTION;
}
/** * guest_range_to_gpas() - Calculate guest physical addresses of page fragments * covering a logical range * @vcpu: virtual cpu * @ga: guest address, start of range * @ar: access register * @gpas: output argument, may be NULL * @len: length of range in bytes * @asce: address-space-control element to use for translation * @mode: access mode * @access_key: access key to mach the range's storage keys against * * Translate a logical range to a series of guest absolute addresses, * such that the concatenation of page fragments starting at each gpa make up * the whole range. * The translation is performed as if done by the cpu for the given @asce, @ar, * @mode and state of the @vcpu. * If the translation causes an exception, its program interruption code is * returned and the &struct kvm_s390_pgm_info pgm member of @vcpu is modified * such that a subsequent call to kvm_s390_inject_prog_vcpu() will inject * a correct exception into the guest. * The resulting gpas are stored into @gpas, unless it is NULL. * * Note: All fragments except the first one start at the beginning of a page. * When deriving the boundaries of a fragment from a gpa, all but the last * fragment end at the end of the page. * * Return: * * 0 - success * * <0 - translation could not be performed, for example if guest * memory could not be accessed * * >0 - an access exception occurred. In this case the returned value * is the program interruption code and the contents of pgm may * be used to inject an exception into the guest.
*/ staticint guest_range_to_gpas(struct kvm_vcpu *vcpu, unsignedlong ga, u8 ar, unsignedlong *gpas, unsignedlong len, constunion asce asce, enum gacc_mode mode,
u8 access_key)
{
psw_t *psw = &vcpu->arch.sie_block->gpsw; unsignedint offset = offset_in_page(ga); unsignedint fragment_len; int lap_enabled, rc = 0; enum prot_type prot; unsignedlong gpa;
if (!len) return 0;
ga = kvm_s390_logical_to_effective(vcpu, ga);
rc = get_vcpu_asce(vcpu, &asce, ga, ar, mode); if (rc) return rc;
nr_pages = (((ga & ~PAGE_MASK) + len - 1) >> PAGE_SHIFT) + 1;
gpas = gpa_array; if (nr_pages > ARRAY_SIZE(gpa_array))
gpas = vmalloc(array_size(nr_pages, sizeof(unsignedlong))); if (!gpas) return -ENOMEM;
try_fetch_prot_override = fetch_prot_override_applicable(vcpu, mode, asce);
try_storage_prot_override = storage_prot_override_applicable(vcpu);
need_ipte_lock = psw_bits(*psw).dat && !asce.r; if (need_ipte_lock)
ipte_lock(vcpu->kvm); /* * Since we do the access further down ultimately via a move instruction * that does key checking and returns an error in case of a protection * violation, we don't need to do the check during address translation. * Skip it by passing access key 0, which matches any storage key, * obviating the need for any further checks. As a result the check is * handled entirely in hardware on access, we only need to take care to * forego key protection checking if fetch protection override applies or * retry with the special key 9 in case of storage protection override.
*/
rc = guest_range_to_gpas(vcpu, ga, ar, gpas, len, asce, mode, 0); if (rc) goto out_unlock; for (idx = 0; idx < nr_pages; idx++) {
fragment_len = min(PAGE_SIZE - offset_in_page(gpas[idx]), len); if (try_fetch_prot_override && fetch_prot_override_applies(ga, fragment_len)) {
rc = access_guest_page(vcpu->kvm, mode, gpas[idx],
data, fragment_len);
} else {
rc = access_guest_page_with_key(vcpu->kvm, mode, gpas[idx],
data, fragment_len, access_key);
} if (rc == PGM_PROTECTION && try_storage_prot_override)
rc = access_guest_page_with_key(vcpu->kvm, mode, gpas[idx],
data, fragment_len, PAGE_SPO_ACC); if (rc) break;
len -= fragment_len;
data += fragment_len;
ga = kvm_s390_logical_to_effective(vcpu, ga + fragment_len);
} if (rc > 0) { bool terminate = (mode == GACC_STORE) && (idx > 0);
while (len && !rc) {
gpa = kvm_s390_real_to_abs(vcpu, gra);
fragment_len = min(PAGE_SIZE - offset_in_page(gpa), len);
rc = access_guest_page(vcpu->kvm, mode, gpa, data, fragment_len);
len -= fragment_len;
gra += fragment_len;
data += fragment_len;
} if (rc > 0)
vcpu->arch.pgm.code = rc; return rc;
}
/** * cmpxchg_guest_abs_with_key() - Perform cmpxchg on guest absolute address. * @kvm: Virtual machine instance. * @gpa: Absolute guest address of the location to be changed. * @len: Operand length of the cmpxchg, required: 1 <= len <= 16. Providing a * non power of two will result in failure. * @old_addr: Pointer to old value. If the location at @gpa contains this value, * the exchange will succeed. After calling cmpxchg_guest_abs_with_key() * *@old_addr contains the value at @gpa before the attempt to * exchange the value. * @new: The value to place at @gpa. * @access_key: The access key to use for the guest access. * @success: output value indicating if an exchange occurred. * * Atomically exchange the value at @gpa by @new, if it contains *@old. * Honors storage keys. * * Return: * 0: successful exchange * * >0: a program interruption code indicating the reason cmpxchg could * not be attempted * * -EINVAL: address misaligned or len not power of two * * -EAGAIN: transient failure (len 1 or 2) * * -EOPNOTSUPP: read-only memslot (should never occur)
*/ int cmpxchg_guest_abs_with_key(struct kvm *kvm, gpa_t gpa, int len,
__uint128_t *old_addr, __uint128_t new,
u8 access_key, bool *success)
{
gfn_t gfn = gpa_to_gfn(gpa); struct kvm_memory_slot *slot = gfn_to_memslot(kvm, gfn); bool writable;
hva_t hva; int ret;
if (!IS_ALIGNED(gpa, len)) return -EINVAL;
hva = gfn_to_hva_memslot_prot(slot, gfn, &writable); if (kvm_is_error_hva(hva)) return PGM_ADDRESSING; /* * Check if it's a read-only memslot, even though that cannot occur * since those are unsupported. * Don't try to actually handle that case.
*/ if (!writable) return -EOPNOTSUPP;
hva += offset_in_page(gpa); /* * The cmpxchg_user_key macro depends on the type of "old", so we need * a case for each valid length and get some code duplication as long * as we don't introduce a new macro.
*/ switch (len) { case 1: {
u8 old;
ret = cmpxchg_user_key((u8 __user *)hva, &old, *old_addr, new, access_key);
*success = !ret && old == *old_addr;
*old_addr = old; break;
} case 2: {
u16 old;
ret = cmpxchg_user_key((u16 __user *)hva, &old, *old_addr, new, access_key);
*success = !ret && old == *old_addr;
*old_addr = old; break;
} case 4: {
u32 old;
ret = cmpxchg_user_key((u32 __user *)hva, &old, *old_addr, new, access_key);
*success = !ret && old == *old_addr;
*old_addr = old; break;
} case 8: {
u64 old;
ret = cmpxchg_user_key((u64 __user *)hva, &old, *old_addr, new, access_key);
*success = !ret && old == *old_addr;
*old_addr = old; break;
} case 16: {
__uint128_t old;
ret = cmpxchg_user_key((__uint128_t __user *)hva, &old, *old_addr, new, access_key);
*success = !ret && old == *old_addr;
*old_addr = old; break;
} default: return -EINVAL;
} if (*success)
mark_page_dirty_in_slot(kvm, slot, gfn); /* * Assume that the fault is caused by protection, either key protection * or user page write protection.
*/ if (ret == -EFAULT)
ret = PGM_PROTECTION; return ret;
}
/** * guest_translate_address_with_key - translate guest logical into guest absolute address * @vcpu: virtual cpu * @gva: Guest virtual address * @ar: Access register * @gpa: Guest physical address * @mode: Translation access mode * @access_key: access key to mach the storage key with * * Parameter semantics are the same as the ones from guest_translate. * The memory contents at the guest address are not changed. * * Note: The IPTE lock is not taken during this function, so the caller * has to take care of this.
*/ int guest_translate_address_with_key(struct kvm_vcpu *vcpu, unsignedlong gva, u8 ar, unsignedlong *gpa, enum gacc_mode mode,
u8 access_key)
{ union asce asce; int rc;
/** * check_gva_range - test a range of guest virtual addresses for accessibility * @vcpu: virtual cpu * @gva: Guest virtual address * @ar: Access register * @length: Length of test range * @mode: Translation access mode * @access_key: access key to mach the storage keys with
*/ int check_gva_range(struct kvm_vcpu *vcpu, unsignedlong gva, u8 ar, unsignedlong length, enum gacc_mode mode, u8 access_key)
{ union asce asce; int rc = 0;
/** * check_gpa_range - test a range of guest physical addresses for accessibility * @kvm: virtual machine instance * @gpa: guest physical address * @length: length of test range * @mode: access mode to test, relevant for storage keys * @access_key: access key to mach the storage keys with
*/ int check_gpa_range(struct kvm *kvm, unsignedlong gpa, unsignedlong length, enum gacc_mode mode, u8 access_key)
{ unsignedint fragment_len; int rc = 0;
/** * kvm_s390_check_low_addr_prot_real - check for low-address protection * @vcpu: virtual cpu * @gra: Guest real address * * Checks whether an address is subject to low-address protection and set * up vcpu->arch.pgm accordingly if necessary. * * Return: 0 if no protection exception, or PGM_PROTECTION if protected.
*/ int kvm_s390_check_low_addr_prot_real(struct kvm_vcpu *vcpu, unsignedlong gra)
{ union ctlreg0 ctlreg0 = {.val = vcpu->arch.sie_block->gcr[0]};
/** * kvm_s390_shadow_tables - walk the guest page table and create shadow tables * @sg: pointer to the shadow guest address space structure * @saddr: faulting address in the shadow gmap * @pgt: pointer to the beginning of the page table for the given address if * successful (return value 0), or to the first invalid DAT entry in * case of exceptions (return value > 0) * @dat_protection: referenced memory is write protected * @fake: pgt references contiguous guest memory block, not a pgtable
*/ staticint kvm_s390_shadow_tables(struct gmap *sg, unsignedlong saddr, unsignedlong *pgt, int *dat_protection, int *fake)
{ struct kvm *kvm; struct gmap *parent; union asce asce; union vaddress vaddr; unsignedlong ptr; int rc;
*fake = 0;
*dat_protection = 0;
kvm = sg->private;
parent = sg->parent;
vaddr.addr = saddr;
asce.val = sg->orig_asce;
ptr = asce.rsto * PAGE_SIZE; if (asce.r) {
*fake = 1;
ptr = 0;
asce.dt = ASCE_TYPE_REGION1;
} switch (asce.dt) { case ASCE_TYPE_REGION1: if (vaddr.rfx01 > asce.tl && !*fake) return PGM_REGION_FIRST_TRANS; break; case ASCE_TYPE_REGION2: if (vaddr.rfx) return PGM_ASCE_TYPE; if (vaddr.rsx01 > asce.tl) return PGM_REGION_SECOND_TRANS; break; case ASCE_TYPE_REGION3: if (vaddr.rfx || vaddr.rsx) return PGM_ASCE_TYPE; if (vaddr.rtx01 > asce.tl) return PGM_REGION_THIRD_TRANS; break; case ASCE_TYPE_SEGMENT: if (vaddr.rfx || vaddr.rsx || vaddr.rtx) return PGM_ASCE_TYPE; if (vaddr.sx01 > asce.tl) return PGM_SEGMENT_TRANSLATION; break;
}
switch (asce.dt) { case ASCE_TYPE_REGION1: { union region1_table_entry rfte;
if (*fake) {
ptr += vaddr.rfx * _REGION1_SIZE;
rfte.val = ptr; goto shadow_r2t;
}
*pgt = ptr + vaddr.rfx * 8;
rc = gmap_read_table(parent, ptr + vaddr.rfx * 8, &rfte.val); if (rc) return rc; if (rfte.i) return PGM_REGION_FIRST_TRANS; if (rfte.tt != TABLE_TYPE_REGION1) return PGM_TRANSLATION_SPEC; if (vaddr.rsx01 < rfte.tf || vaddr.rsx01 > rfte.tl) return PGM_REGION_SECOND_TRANS; if (sg->edat_level >= 1)
*dat_protection |= rfte.p;
ptr = rfte.rto * PAGE_SIZE;
shadow_r2t:
rc = gmap_shadow_r2t(sg, saddr, rfte.val, *fake); if (rc) return rc;
kvm->stat.gmap_shadow_r1_entry++;
}
fallthrough; case ASCE_TYPE_REGION2: { union region2_table_entry rste;
if (*fake) {
ptr += vaddr.rsx * _REGION2_SIZE;
rste.val = ptr; goto shadow_r3t;
}
*pgt = ptr + vaddr.rsx * 8;
rc = gmap_read_table(parent, ptr + vaddr.rsx * 8, &rste.val); if (rc) return rc; if (rste.i) return PGM_REGION_SECOND_TRANS; if (rste.tt != TABLE_TYPE_REGION2) return PGM_TRANSLATION_SPEC; if (vaddr.rtx01 < rste.tf || vaddr.rtx01 > rste.tl) return PGM_REGION_THIRD_TRANS; if (sg->edat_level >= 1)
*dat_protection |= rste.p;
ptr = rste.rto * PAGE_SIZE;
shadow_r3t:
rste.p |= *dat_protection;
rc = gmap_shadow_r3t(sg, saddr, rste.val, *fake); if (rc) return rc;
kvm->stat.gmap_shadow_r2_entry++;
}
fallthrough; case ASCE_TYPE_REGION3: { union region3_table_entry rtte;
/** * shadow_pgt_lookup() - find a shadow page table * @sg: pointer to the shadow guest address space structure * @saddr: the address in the shadow aguest address space * @pgt: parent gmap address of the page table to get shadowed * @dat_protection: if the pgtable is marked as protected by dat * @fake: pgt references contiguous guest memory block, not a pgtable * * Returns 0 if the shadow page table was found and -EAGAIN if the page * table was not found. * * Called with sg->mm->mmap_lock in read.
*/ staticint shadow_pgt_lookup(struct gmap *sg, unsignedlong saddr, unsignedlong *pgt, int *dat_protection, int *fake)
{ unsignedlong pt_index; unsignedlong *table; struct page *page; int rc;
/** * kvm_s390_shadow_fault - handle fault on a shadow page table * @vcpu: virtual cpu * @sg: pointer to the shadow guest address space structure * @saddr: faulting address in the shadow gmap * @datptr: will contain the address of the faulting DAT table entry, or of * the valid leaf, plus some flags * * Returns: - 0 if the shadow fault was successfully resolved * - > 0 (pgm exception code) on exceptions while faulting * - -EAGAIN if the caller can retry immediately * - -EFAULT when accessing invalid guest addresses * - -ENOMEM if out of memory
*/ int kvm_s390_shadow_fault(struct kvm_vcpu *vcpu, struct gmap *sg, unsignedlong saddr, unsignedlong *datptr)
{ union vaddress vaddr; union page_table_entry pte; unsignedlong pgt = 0; int dat_protection, fake; int rc;
if (KVM_BUG_ON(!gmap_is_shadow(sg), vcpu->kvm)) return -EFAULT;
mmap_read_lock(sg->mm); /* * We don't want any guest-2 tables to change - so the parent * tables/pointers we read stay valid - unshadowing is however * always possible - only guest_table_lock protects us.
*/
ipte_lock(vcpu->kvm);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.