lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aEp6pDQgbjsfrg2h@yzhao56-desk.sh.intel.com>
Date: Thu, 12 Jun 2025 14:58:44 +0800
From: Yan Zhao <yan.y.zhao@...el.com>
To: Sean Christopherson <seanjc@...gle.com>
CC: Rick P Edgecombe <rick.p.edgecombe@...el.com>, "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>, "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 at 01:43:25PM -0700, Sean Christopherson wrote:
> 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.
Agreed.

> > > 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;
For TDX private fault,
-fault->present is always false if !fault->prefetch as its error_code is
 PFERR_PRIVATE_ACCESS | PFERR_WRITE_MASK due to exit quilification being
 hardcoded to EPT_VIOLATION_ACC_WRITE.
-fault->present is false if fault->prefetch is true as its erro_code is
 PFERR_PRIVATE_ACCESS | PFERR_GUEST_FINAL_MASK.

In tdx_bringup(), enable_ept_ad_bits is checked as a prerequisit of TDX, so
kvm_ad_enabled should be true.

So, page_fault_can_be_fast() should always return false for mirror root.


> 	/*
> 	 * 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

Powered by Openwall GNU/*/Linux Powered by OpenVZ