Re: [PATCH v3 15/23] KVM: s390: Add helper functions for fault handling

Heiko Carstens
2025-11-18T15:10:13Z

On Thu, Nov 06, 2025 at 05:11:09PM +0100, Claudio Imbrenda wrote:
> Add some helper functions for handling multiple guest faults at the
> same time.
>
> This will be needed for VSIE, where a nested guest access also needs to
> access all the page tables that map it.
>
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
> arch/s390/include/asm/kvm_host.h | 1 +
> arch/s390/kvm/Makefile | 2 +-
> arch/s390/kvm/faultin.c | 148 +++++++++++++++++++++++++++++++
> arch/s390/kvm/faultin.h | 92 +++++++++++++++++++
> arch/s390/kvm/kvm-s390.c | 2 +-
> arch/s390/kvm/kvm-s390.h | 2 +
> 6 files changed, 245 insertions(+), 2 deletions(-)
> create mode 100644 arch/s390/kvm/faultin.c
> create mode 100644 arch/s390/kvm/faultin.h

...

> +int kvm_s390_faultin_gfn(struct kvm_vcpu *vcpu, struct kvm *kvm, struct guest_fault *f)
> +{

...

> + scoped_guard(read_lock, &kvm->mmu_lock) {
> + if (!mmu_invalidate_retry_gfn(kvm, inv_seq, f->gfn)) {
> + f->valid = true;
> + rc = gmap_link(mc, kvm->arch.gmap, f);
> + kvm_release_faultin_page(kvm, f->page, !!rc, f->write_attempt);
> + f->page = NULL;
> + }
> + }
> + kvm_release_faultin_page(kvm, f->page, true, false);
> +
> + if (rc == -ENOMEM) {
> + rc = kvm_s390_mmu_cache_topup(mc);

If I'm not mistaken then gmap_link() -> dat_link() maps the possible -ENOMEM
return value of dat_entry() to -EAGAIN. So the case where -ENOMEM leads to a
kvm_s390_mmu_cache_topup() call will never happen.