Re: [PATCH v3 18/23] KVM: s390: Switch to new gmap

Heiko Carstens
2025-11-18T15:18:27Z

On Thu, Nov 06, 2025 at 05:11:12PM +0100, Claudio Imbrenda wrote:
> Switch KVM/s390 to use the new gmap code.
>
> Remove includes to <gmap.h> and include "gmap.h" instead; fix all the
> existing users of the old gmap functions to use the new ones instead.
>
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
> arch/s390/Kconfig | 2 +-
> arch/s390/include/asm/kvm_host.h | 5 +-
> arch/s390/include/asm/mmu_context.h | 4 -
> arch/s390/include/asm/tlb.h | 3 -
> arch/s390/kvm/Makefile | 2 +-
> arch/s390/kvm/diag.c | 2 +-
> arch/s390/kvm/gaccess.c | 552 +++++++++++----------
> arch/s390/kvm/gaccess.h | 16 +-
> arch/s390/kvm/gmap-vsie.c | 141 ------
> arch/s390/kvm/gmap.c | 6 +-
> arch/s390/kvm/intercept.c | 15 +-
> arch/s390/kvm/interrupt.c | 2 +-
> arch/s390/kvm/kvm-s390.c | 727 ++++++++--------------------
> arch/s390/kvm/kvm-s390.h | 20 +-
> arch/s390/kvm/priv.c | 207 +++-----
> arch/s390/kvm/pv.c | 64 +--
> arch/s390/kvm/vsie.c | 117 +++--
> arch/s390/mm/gmap_helpers.c | 29 --
> 18 files changed, 710 insertions(+), 1204 deletions(-)
> delete mode 100644 arch/s390/kvm/gmap-vsie.c

...

> +static int _gaccess_do_shadow(struct kvm_s390_mmu_cache *mc, struct gmap *sg,
> + unsigned long saddr, struct pgtwalk *w)
> +{

...

> + /*
> + * Skip levels that are already protected. For each level, protect
> + * only the page containing the entry, not the whole table.
> + */
> + for (i = gl ; i > w->level; i--)
> + gmap_protect_rmap(mc, sg, entries[i - 1].gfn, gpa_to_gfn(saddr),
> + entries[i - 1].pfn, i, entries[i - 1].writable);
> +

Why is it ok to ignore the potential -ENOMEM return value of
gmap_protect_rmap()?