Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: VMX: Move Intel PT shenanigans out of VMXON/VMXOFF flows

Move the Intel PT tracking outside of the VMXON/VMXOFF helpers so that
a future patch can drop KVM's kvm_cpu_vmxoff() in favor of the kernel's
cpu_vmxoff() without an associated PT functional change, and without
losing symmetry between the VMXON and VMXOFF flows.

Barring undocumented behavior, this should have no meaningful effects
as Intel PT behavior does not interact with CR4.VMXE.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20201231002702.2223707-6-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Sean Christopherson and committed by
Paolo Bonzini
5ef940bd 150f17bf

+7 -4
+7 -4
arch/x86/kvm/vmx/vmx.c
··· 2313 2313 u64 msr; 2314 2314 2315 2315 cr4_set_bits(X86_CR4_VMXE); 2316 - intel_pt_handle_vmx(1); 2317 2316 2318 2317 asm_volatile_goto("1: vmxon %[vmxon_pointer]\n\t" 2319 2318 _ASM_EXTABLE(1b, %l[fault]) ··· 2323 2324 fault: 2324 2325 WARN_ONCE(1, "VMXON faulted, MSR_IA32_FEAT_CTL (0x3a) = 0x%llx\n", 2325 2326 rdmsrl_safe(MSR_IA32_FEAT_CTL, &msr) ? 0xdeadbeef : msr); 2326 - intel_pt_handle_vmx(0); 2327 2327 cr4_clear_bits(X86_CR4_VMXE); 2328 2328 2329 2329 return -EFAULT; ··· 2345 2347 !hv_get_vp_assist_page(cpu)) 2346 2348 return -EFAULT; 2347 2349 2350 + intel_pt_handle_vmx(1); 2351 + 2348 2352 r = kvm_cpu_vmxon(phys_addr); 2349 - if (r) 2353 + if (r) { 2354 + intel_pt_handle_vmx(0); 2350 2355 return r; 2356 + } 2351 2357 2352 2358 if (enable_ept) 2353 2359 ept_sync_global(); ··· 2377 2375 { 2378 2376 asm volatile (__ex("vmxoff")); 2379 2377 2380 - intel_pt_handle_vmx(0); 2381 2378 cr4_clear_bits(X86_CR4_VMXE); 2382 2379 } 2383 2380 ··· 2384 2383 { 2385 2384 vmclear_local_loaded_vmcss(); 2386 2385 kvm_cpu_vmxoff(); 2386 + 2387 + intel_pt_handle_vmx(0); 2387 2388 } 2388 2389 2389 2390 /*