Re: [RFC 11/19] KVM: x86/mmu: Factor shadow_zero_check out of make_spte
From: Sean Christopherson
Date: Wed Nov 17 2021 - 21:05:23 EST
On Wed, Nov 10, 2021, Ben Gardon wrote:
> In the interest of devloping a version of make_spte that can function
> without a vCPU pointer, factor out the shadow_zero_mask to be an
> additional argument to the function.
> No functional change intended.
> Signed-off-by: Ben Gardon <bgardon@xxxxxxxxxx>
> arch/x86/kvm/mmu/spte.c | 11 +++++++----
> arch/x86/kvm/mmu/spte.h | 3 ++-
> 2 files changed, 9 insertions(+), 5 deletions(-)
> diff --git a/arch/x86/kvm/mmu/spte.c b/arch/x86/kvm/mmu/spte.c
> index b7271daa06c5..d3b059e96c6e 100644
> --- a/arch/x86/kvm/mmu/spte.c
> +++ b/arch/x86/kvm/mmu/spte.c
> @@ -93,7 +93,8 @@ bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
> struct kvm_memory_slot *slot, unsigned int pte_access,
> gfn_t gfn, kvm_pfn_t pfn, u64 old_spte, bool prefetch,
> bool can_unsync, bool host_writable, bool ad_need_write_protect,
> - u64 mt_mask, u64 *new_spte)
> + u64 mt_mask, struct rsvd_bits_validate *shadow_zero_check,
Ugh, so I had a big email written about how I think we should add a module param
to control 4-level vs. 5-level for all TDP pages, but then I realized it wouldn't
work for nested EPT because that follows the root level used by L1. We could
still make a global non_nested_tdp_shadow_zero_check or whatever, but then make_spte()
would have to do some work to find the right rsvd_bits_validate, and the end result
would likely be a mess.
One idea to avoid exploding make_spte() would be to add a backpointer to the MMU
in kvm_mmu_page. I don't love the idea, but I also don't love passing in rsvd_bits_validate.