On 3/8/22 03:03, Sean Christopherson wrote:
On Thu, Mar 03, 2022, Hao Peng wrote:
On Thu, Mar 3, 2022 at 9:29 AM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
On Wed, Mar 02, 2022, Hao Peng wrote:
Thanks for pointing this out. However, other than shadow_root_level,
other fields of context will not
change during the entire operation, such as
page_fault/sync_page/direct_map and so on under
the condition of tdp_mmu.
Is this patch still viable after careful confirmation of the fields
that won't be modified?
No, passing around the "init" flag is a hack.
But, we can achieve what you want simply by initializing the constant data once
per vCPU. There's a _lot_ of state that is constant for a given MMU now that KVM
uses separate MMUs for L1 vs. L2 when TDP is enabled. I should get patches posted
tomorrow, just need to test (famous last words).
Famous last words indeed. Long story short, the patches were mostly easy, but I
wandered deep into a rabbit hole when trying to make ->inject_page_fault() constant
per MMU. I'll get something posted this week, though exactly what that something is
remains to be seen :-)
This is exactly what I have posted a few weeks ago:
https://patchew.org/linux/20220221162243.683208-1-pbonzini@xxxxxxxxxx/
See in particular
KVM: nVMX/nSVM: do not monkey-patch inject_page_fault callback
KVM: x86/mmu: initialize constant-value fields just once
Paolo