Re: [PATCH 08/28] KVM: x86/mmu: separate more EPT/non-EPT permission_fault()

Sean Christopherson
2026-04-30T18:35:35Z

On Thu, Apr 30, 2026, Paolo Bonzini wrote:
> - if (!ept) {
> + if (ept) {
> + rf = (pfec & PFERR_USER_MASK) ? (u8)~u : 0;
> + ff = (pfec & PFERR_FETCH_MASK) ? (u16)~x : 0;
> + } else {
> /* Faults from kernel mode accesses to user pages */
> u8 kf = (pfec & PFERR_USER_MASK) ? 0 : u;
>
> - /* Not really needed: !nx will cause pte.nx to fault */
> - if (!efer_nx)
> - ff = 0;
> + uf = (pfec & PFERR_USER_MASK) ? (u8)~u : 0;
> +
> + if (efer_nx)
> + ff = (pfec & PFERR_FETCH_MASK) ? (u16)~x : 0;

Uber nit, probably makes sense to do:

ff |= (pfec & PFERR_FETCH_MASK) ? (u16)~x : 0;

so that the ordering between efer_nx and cr4_smep doesn't matter.

If you end up doing fixup, this patch really should use (u8) instead (u16), and
then convert everything in "KVM: x86/mmu: introduce ACC_READ_MASK". Doesn't
impact functionality, but it looks odd.

> /* Allow supervisor writes if !cr0.wp */
> if (!cr0_wp)