[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aEnqbfih0gE4CDM-@google.com>
Date: Wed, 11 Jun 2025 13:43:25 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Rick P Edgecombe <rick.p.edgecombe@...el.com>
Cc: "pbonzini@...hat.com" <pbonzini@...hat.com>, Kai Huang <kai.huang@...el.com>,
"binbin.wu@...ux.intel.com" <binbin.wu@...ux.intel.com>, Xiaoyao Li <xiaoyao.li@...el.com>,
Reinette Chatre <reinette.chatre@...el.com>, Adrian Hunter <adrian.hunter@...el.com>,
Yan Y Zhao <yan.y.zhao@...el.com>, "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
Isaku Yamahata <isaku.yamahata@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"tony.lindgren@...ux.intel.com" <tony.lindgren@...ux.intel.com>
Subject: Re: [PATCH] KVM: x86/mmu: Embed direct bits into gpa for KVM_PRE_FAULT_MEMORY
On Wed, Jun 11, 2025, Rick P Edgecombe wrote:
> On Wed, 2025-06-11 at 12:37 -0700, Sean Christopherson wrote:
> > Ugh, and the whole tdp_mmu_get_root_for_fault() handling is broken.
> > is_page_fault_stale() only looks at mmu->root.hpa, i.e. could theoretically blow
> > up if the shared root is somehow valid but the mirror root is not. Probably can't
> > happen in practice, but it's ugly.
>
> We had some discussion on this root valid/invalid pattern:
> https://lore.kernel.org/kvm/d33d00b88707961126a24b19f940de43ba6e6c56.camel@intel.com/
>
> It's brittle though.
Hmm, yeah, the is_page_fault_stale() thing is definitely benign, just odd.
> > Oof, and I've no idea what kvm_tdp_mmu_fast_pf_get_last_sptep() is doing. It
> > says:
> >
> > /* Fast pf is not supported for mirrored roots */
> >
> > but I don't see anything that actually enforces that.
>
> Functionally, page_fault_can_be_fast() should prevented this with the check of
> kvm->arch.has_private_mem.
No? I see this:
if (kvm->arch.has_private_mem &&
fault->is_private != kvm_mem_is_private(kvm, fault->gfn))
return false;
I.e. a private fault can be fast, so long as the page is already in the correct
shared vs. private state. I can imagine that it's impossible for TDX to generate
protection violations, but I think kvm_tdp_mmu_fast_pf_get_last_sptep() could be
reached with a mirror root if kvm_ad_enabled=false.
if (!fault->present)
return !kvm_ad_enabled;
/*
* Note, instruction fetches and writes are mutually exclusive, ignore
* the "exec" flag.
*/
return fault->write;
> But, yea it's not correct for being readable. The mirror/external concepts
> only work if they make sense as independent concepts. Otherwise it's just
> naming obfuscation.
Powered by blists - more mailing lists