[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aEp/cHQqI0l09vbd@yzhao56-desk.sh.intel.com>
Date: Thu, 12 Jun 2025 15:19:12 +0800
From: Yan Zhao <yan.y.zhao@...el.com>
To: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>
CC: "seanjc@...gle.com" <seanjc@...gle.com>, "Huang, Kai"
<kai.huang@...el.com>, "binbin.wu@...ux.intel.com"
<binbin.wu@...ux.intel.com>, "Li, Xiaoyao" <xiaoyao.li@...el.com>, "Chatre,
Reinette" <reinette.chatre@...el.com>, "Hunter, Adrian"
<adrian.hunter@...el.com>, "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"pbonzini@...hat.com" <pbonzini@...hat.com>, "Yamahata, Isaku"
<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 Thu, Jun 12, 2025 at 05:16:05AM +0800, Edgecombe, Rick P wrote:
> On Wed, 2025-06-11 at 13:43 -0700, Sean Christopherson wrote:
> > > 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;
>
> Oh, how embarrassing. Yes, I misread the code, but the way it's working is, oh
> man...
>
> TDX isn't setting PFERR_WRITE_MASK or PFERR_PRESENT_MASK in the error_code
> passed into the fault handler. So page_fault_can_be_fast() should return false
> for that reason for private/mirror faults.
Hmm, TDX does set PFERR_WRITE_MASK in the error_code when fault->prefetch is
false (since exit_qual is set to EPT_VIOLATION_ACC_WRITE in
tdx_handle_ept_violation()).
PFERR_PRESENT_MASK is always unset.
page_fault_can_be_fast() does always return false for private mirror faults
though, due to the reason in
https://lore.kernel.org/kvm/aEp6pDQgbjsfrg2h@yzhao56-desk.sh.intel.com :)
Powered by blists - more mailing lists