Re: [PATCH v10 035/108] KVM: x86/mmu: Track shadow MMIO value on a per-VM basis

Huang, Kai
2022-11-09T12:27:45Z

On Sat, 2022-10-29 at 23:22 -0700, isaku.yamahata@intel.com wrote:
> From: Isaku Yamahata <isaku.yamahata@intel.com>
>
> TDX will use a different shadow PTE entry value for MMIO from VMX. Add
> members to kvm_arch and track value for MMIO per-VM instead of global
> variables. By using the per-VM EPT entry value for MMIO, the existing VMX
> logic is kept working. To untangle the logic to initialize
> shadow_mmio_access_mask, introduce a separate setter function.
>

It's weird to mention "shadow_mmio_access_mask" here (and this doesn't stand
anymore anyway as we have changed to only make mmio_value per-vm). Just say
something like "introduce a setter function to set mmio_value for the given
guest so that TDX guest can override later".

Also, seems it's worth to mention the same mmio_mask is used for both TDX guest
and VMX guest so we can still use global shadow_mmio_mask.

[...]

> void kvm_mmu_set_mmio_spte_mask(u64 mmio_value, u64 mmio_mask, u64 access_mask)
> {
> BUG_ON((u64)(unsigned)access_mask != access_mask);
> +
> WARN_ON(mmio_value & shadow_nonpresent_or_rsvd_lower_gfn_mask);

Looks unnecessary change.