On Tue, 2025-05-20 at 17:34 +0800, Zhao, Yan Y wrote: > On Tue, May 20, 2025 at 12:53:33AM +0800, Edgecombe, Rick P wrote: > > On Mon, 2025-05-19 at 16:32 +0800, Yan Zhao wrote: > > > > On the opposite, if other non-Linux TDs don't follow 1G->2M->4K accept > > > > order, > > > > e.g., they always accept 4K, there could be *endless EPT violation* if I > > > > understand your words correctly. > > > > > > > > Isn't this yet-another reason we should choose to return PG_LEVEL_4K instead > > > > of > > > > 2M if no accept level is provided in the fault? > > > As I said, returning PG_LEVEL_4K would disallow huge pages for non-Linux TDs. > > > TD's accept operations at size > 4KB will get TDACCEPT_SIZE_MISMATCH. > > > > TDX_PAGE_SIZE_MISMATCH is a valid error code that the guest should handle. The > > docs say the VMM needs to demote *if* the mapping is large and the accept size > > is small. But if we map at 4k size for non-accept EPT violations, we won't hit > > this case. I also wonder what is preventing the TDX module from handling a 2MB > > accept size at 4k mappings. It could be changed maybe. > > > > But I think Kai's question was: why are we complicating the code for the case of > > non-Linux TDs that also use #VE for accept? It's not necessary to be functional, > > and there aren't any known TDs like that which are expected to use KVM today. > > (err, except the MMU stress test). So in another form the question is: should we > > optimize KVM for a case we don't even know if anyone will use? The answer seems > > obviously no to me. > So, you want to disallow huge pages for non-Linux TDs, then we have no need > to support splitting in the fault path, right? > > I'm OK if we don't care non-Linux TDs for now. > This can simplify the splitting code and we can add the support when there's a > need. For the record, I am not saying we don't care non-Linux TDs. I am worrying about the *endless* EPT violation in your below words: ... The worst outcome to ignore the resulting splitting request is an endless EPT violation. This would not happen for a Linux guest, which does not expect any #VE. And the point is, it's not OK if a *legal* guest behaviour can trigger this.