From: Yan Zhao <yan.y.zhao@intel.com>
To: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
Cc: "seanjc@google.com" <seanjc@google.com>,
"Huang, Kai" <kai.huang@intel.com>,
"binbin.wu@linux.intel.com" <binbin.wu@linux.intel.com>,
"Li, Xiaoyao" <xiaoyao.li@intel.com>,
"Chatre, Reinette" <reinette.chatre@intel.com>,
"Hunter, Adrian" <adrian.hunter@intel.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"Yamahata, Isaku" <isaku.yamahata@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"tony.lindgren@linux.intel.com" <tony.lindgren@linux.intel.com>
Subject: Re: [PATCH] KVM: x86/mmu: Embed direct bits into gpa for KVM_PRE_FAULT_MEMORY
Date: Thu, 12 Jun 2025 15:19:12 +0800 [thread overview]
Message-ID: <aEp/cHQqI0l09vbd@yzhao56-desk.sh.intel.com> (raw)
In-Reply-To: <2ea853668cb6b3124d3a01bb610c6072cb4d57e6.camel@intel.com>
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 :)
next prev parent reply other threads:[~2025-06-12 7:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-11 0:10 [PATCH] KVM: x86/mmu: Embed direct bits into gpa for KVM_PRE_FAULT_MEMORY Xiaoyao Li
2025-06-11 18:10 ` Sean Christopherson
2025-06-11 18:21 ` Paolo Bonzini
2025-06-11 19:37 ` Sean Christopherson
2025-06-11 20:25 ` Edgecombe, Rick P
2025-06-11 20:43 ` Sean Christopherson
2025-06-11 21:16 ` Edgecombe, Rick P
2025-06-12 7:19 ` Yan Zhao [this message]
2025-06-12 18:50 ` Edgecombe, Rick P
2025-06-13 1:14 ` Yan Zhao
2025-06-12 6:58 ` Yan Zhao
2025-06-11 20:45 ` Edgecombe, Rick P
2025-06-11 21:09 ` Sean Christopherson
2025-06-12 12:20 ` Yan Zhao
2025-06-12 18:40 ` Edgecombe, Rick P
2025-06-13 0:09 ` Sean Christopherson
2025-06-13 16:12 ` Edgecombe, Rick P
2025-06-12 4:44 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aEp/cHQqI0l09vbd@yzhao56-desk.sh.intel.com \
--to=yan.y.zhao@intel.com \
--cc=adrian.hunter@intel.com \
--cc=binbin.wu@linux.intel.com \
--cc=isaku.yamahata@intel.com \
--cc=kai.huang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=reinette.chatre@intel.com \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=tony.lindgren@linux.intel.com \
--cc=xiaoyao.li@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox