On Tue, Jul 12, 2022 at 11:47:43AM +0800, Yuan Yao wrote: >On Mon, Jun 27, 2022 at 02:53:45PM -0700, isaku.yamahata@xxxxxxxxx wrote: >> From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> >> >> TDX doesn't need APIC page depending on vapic and its callback is >> WARN_ON_ONCE(is_tdx). To avoid unnecessary overhead and WARN_ON_ONCE(), >> skip requesting KVM_REQ_APIC_PAGE_RELOAD when TD. !kvm_gfn_shared_mask() doesn't ensure the VM is a TD. Right? >> >> >> Signed-off-by: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> >> --- >> arch/x86/kvm/x86.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> index 8f57dfb2a8c9..c90ec611de2f 100644 >> --- a/arch/x86/kvm/x86.c >> +++ b/arch/x86/kvm/x86.c >> @@ -10042,7 +10042,8 @@ void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, >> * Update it when it becomes invalid. >> */ >> apic_address = gfn_to_hva(kvm, APIC_DEFAULT_PHYS_BASE >> PAGE_SHIFT); >> - if (start <= apic_address && apic_address < end) >> + if (start <= apic_address && apic_address < end && >> + !kvm_gfn_shared_mask(kvm)) > >Minor: please condier to check kvm_gfn_shared_mask(kvm) before range, >means firstly check is or not, then suitable or not. > >> kvm_make_all_cpus_request(kvm, KVM_REQ_APIC_PAGE_RELOAD); >> } >> >> -- >> 2.25.1 >>