Re: [PATCH v7 035/102] KVM: x86/mmu: Explicitly check for MMIO spte in fast page fault

From: Isaku Yamahata
Date: Wed Jul 13 2022 - 04:35:24 EST

On Thu, Jun 30, 2022 at 11:37:15PM +1200,
Kai Huang <kai.huang@xxxxxxxxx> wrote:

> On Mon, 2022-06-27 at 14:53 -0700, isaku.yamahata@xxxxxxxxx wrote:
> > From: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
> >
> > Explicitly check for an MMIO spte in the fast page fault flow. TDX will
> > use a not-present entry for MMIO sptes, which can be mistaken for an
> > access-tracked spte since both have SPTE_SPECIAL_MASK set.
> SPTE_SPECIAL_MASK has been removed in latest KVM code. The changelog needs
> update.

It was renamed to SPTE_TDP_AD_MASK. not removed.

> In fact, if I understand correctly, I don't think this changelog is correct:

> The existing code doesn't check is_mmio_spte() because:
> 1) If MMIO caching is enabled, MMIO fault is always handled in
> handle_mmio_page_fault() before reaching here;
> 2) If MMIO caching is disabled, is_shadow_present_pte() always returns false for
> MMIO spte, and is_mmio_spte() also always return false for MMIO spte, so there's
> no need check here.
> "A non-present entry for MMIO spte" doesn't necessarily mean
> is_shadow_present_pte() will return true for it, and there's no explanation at
> all that for TDX guest a MMIO spte could reach here and is_shadow_present_pte()
> returns true for it.

Although it was needed, I noticed the following commit made this patch
unnecessary. So I'll drop this patch. Kudos to Sean.

"KVM: x86/mmu: Use a dedicated bit to track shadow/MMU-present SPTEs"

Isaku Yamahata <isaku.yamahata@xxxxxxxxx>