Re: [PATCH] mm: pull writability check to follow_pfnmap_start()

Paolo Bonzini <[email protected]> Fri, 31 Jul 2026 18:41:21 +0200
Newsgroups dev.linux.lists.sashiko-reviews,org.kernel.vger.kvm,org.kernel.vger.linux-s390
Message-ID <CABgObfbkqYNsPQnKxK1_4adXF_tSdtScPU5-Xrg-sXyeWfMVfQ@mail.gmail.com>
On Fri, Jul 31, 2026 at 6:20=E2=80=AFPM <[email protected]> wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issu=
e(s) to consider:
> - [High] KVM fails to return KVM_PFN_ERR_RO_FAULT on write faults to read=
-only PFNMAP VMAs, breaking MMIO emulation.

Let's look at the bright side, I only messed up the part that *I* maintain.

Yeah this is correct and fixed with something like:

    /*
     * A write to a VMA that isn't writable can never be fixed up, as
     * fixup_user_fault() rejects it outright; report it without even
     * trying follow_pfnmap_start().
     */
    if (args.write_fault && !(vma->vm_flags & VM_WRITE)) {
        *p_pfn =3D KVM_PFN_ERR_RO_FAULT;
        return 0;
    }

before the first

     r =3D follow_pfnmap_start(&args);

Paolo