Re: [PATCH 5.15.y v3 3/7] KVM: x86/mmu: Derive shadow MMU page role from parent

From: Sean Christopherson

Date: Thu Sep 24 2026 - 13:36:33 EST


On Mon, Sep 14, 2026, Sasha Levin wrote:
> > - role.direct = direct;
> > - if (role.direct)
> > - role.gpte_is_8_bytes = true;
> > [...]
> > + if (!role.gpte_is_8_bytes) {
> > + struct kvm_mmu_page *parent_sp = sptep_to_sp(sptep);
> > + role.quadrant = (sptep - parent_sp->spt) % 2;
>
> The "if (role.direct) role.gpte_is_8_bytes = true;" that kvm_mmu_get_page()
> used to do is removed here, and kvm_mmu_child_role() does not put it back.
>
> That works upstream because the field there is has_4_byte_gpte, which
> defaults to 0. On 5.15 the field is gpte_is_8_bytes, the inverse, so the
> translation flips: for a non-paging guest
> kvm_calc_shadow_root_page_role_common() leaves gpte_is_8_bytes at 0 while
> kvm_calc_shadow_mmu_root_page_role() sets direct to 1, and a direct shadow
> page ends up with a quadrant stamped onto it.
>
> Keeping "if (role.direct) role.gpte_is_8_bytes = true;" in
> kvm_mmu_child_role() preserves the upstream behaviour. The alternative is to
> backport the upstream role-computation change first so the field carries the
> mainline sense.

I vote to backport the relevant upstream commits. Reviewing this without those
commits is a pain. I think it's these, to get fairly clean cherry-picks?

dc1ce45575b3401102568dd60ba8894849d1d64b KVM: MMU: update comment on the number of page role combinations
41e35604eaff2266ba8523787ebe99c5ca4c4045 KVM: X86: Remove useless code to set role.gpte_is_8_bytes when role.direct
b46a13cb7ea1137b2e01dfaafcacd5cd79db8390 KVM: X86: Calculate quadrant when !role.gpte_is_8_bytes
bb3b394d35e80d7a58ce015191e4960a13f54ba5 KVM: X86: Rename gpte_is_8_bytes to has_4_byte_gpte and invert the direction