Re: [PATCH v2 07/10] KVM: x86: Always populate L1 GPA for KVM_MAP_MEMORY
From: Edgecombe, Rick P
Date: Mon Apr 15 2024 - 15:13:37 EST
I wouldn't call myself much of an expert on nested, but...
On Wed, 2024-04-10 at 15:07 -0700, isaku.yamahata@xxxxxxxxx wrote:
> There are several options to populate L1 GPA irrelevant to vCPU mode.
> - Switch vCPU MMU only: This patch.
> Pros: Concise implementation.
> Cons: Heavily dependent on the KVM MMU implementation.
Is switching just the MMU enough here? Won't the MTRRs and other vcpu bits be
wrong?
> - Use kvm_x86_nested_ops.get/set_state() to switch to/from guest mode.
> Use __get/set_sregs2() to switch to/from SMM mode.
> Pros: straightforward.
> Cons: This may cause unintended side effects.
Cons make sense.
> - Refactor KVM page fault handler not to pass vCPU. Pass around necessary
> parameters and struct kvm.
> Pros: The end result will have clearly no side effects.
> Cons: This will require big refactoring.
But doesn't the fault handler need the vCPU state?
> - Return error on guest mode or SMM mode: Without this patch.
> Pros: No additional patch.
> Cons: Difficult to use.
Hmm... For the non-TDX use cases this is just an optimization, right? For TDX
there shouldn't be an issue. If so, maybe this last one is not so horrible.