CC: [email protected] CC: [email protected] CC: [email protected] TO: Vitaly Kuznetsov <[email protected]> CC: Paolo Bonzini <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 36a21d51725af2ce0700c6ebcb6b9594aac658a6 commit: f5c7e8425f18fdb9bdb7d13340651d7876890329 KVM: nVMX: Always make an attempt to map eVMCS after migration date: 3 months ago :::::: branch date: 14 hours ago :::::: commit date: 3 months ago config: x86_64-randconfig-c001-20210806 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 42b9c2a17a0b63cccf3ac197a82f91b28e53e643) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install x86_64 cross compiling tool for clang build # apt-get install binutils-x86-64-linux-gnu # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f5c7e8425f18fdb9bdb7d13340651d7876890329 git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git fetch --no-tags linus master git checkout f5c7e8425f18fdb9bdb7d13340651d7876890329 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <[email protected]> clang-analyzer warnings: (new ones prefixed by >>) 4 warnings generated. Suppressed 4 warnings (3 in non-user code, 1 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 3 warnings generated. Suppressed 3 warnings (3 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 5 warnings generated. arch/x86/include/asm/xen/hypercall.h:358:9: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign] return _hypercall2(int, event_channel_op, cmd, arg); ^ arch/x86/include/asm/xen/hypercall.h:169:2: note: expanded from macro '_hypercall2' __HYPERCALL_DECLS; \ ^ arch/x86/include/asm/xen/hypercall.h:113:2: note: expanded from macro '__HYPERCALL_DECLS' register unsigned long __arg1 asm(__HYPERCALL_ARG1REG) = __arg1; \ ^ drivers/xen/events/events_2l.c:89:21: note: Loop condition is false. Exiting loop unsigned int cpu = get_cpu(); ^ include/linux/smp.h:260:23: note: expanded from macro 'get_cpu' #define get_cpu() ({ preempt_disable(); __smp_processor_id(); }) ^ include/linux/preempt.h:175:27: note: expanded from macro 'preempt_disable' #define preempt_disable() \ ^ drivers/xen/events/events_2l.c:92:10: note: Loop condition is false. Exiting loop BUG_ON(!irqs_disabled()); ^ include/linux/irqflags.h:254:3: note: expanded from macro 'irqs_disabled' raw_local_save_flags(_flags); \ ^ include/linux/irqflags.h:180:2: note: expanded from macro 'raw_local_save_flags' do { \ ^ drivers/xen/events/events_2l.c:92:2: note: Taking false branch BUG_ON(!irqs_disabled()); ^ include/asm-generic/bug.h:63:32: note: expanded from macro 'BUG_ON' #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0) ^ drivers/xen/events/events_2l.c:92:2: note: Loop condition is false. Exiting loop BUG_ON(!irqs_disabled()); ^ include/asm-generic/bug.h:63:27: note: expanded from macro 'BUG_ON' #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0) ^ drivers/xen/events/events_2l.c:96:16: note: Assuming the condition is true if (unlikely((cpu != cpu_from_evtchn(port)))) ^ include/linux/compiler.h:78:42: note: expanded from macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^ drivers/xen/events/events_2l.c:96:2: note: Taking true branch if (unlikely((cpu != cpu_from_evtchn(port)))) ^ drivers/xen/events/events_2l.c:119:6: note: 'do_hypercall' is 1 if (do_hypercall) { ^~~~~~~~~~~~ drivers/xen/events/events_2l.c:119:2: note: Taking true branch if (do_hypercall) { ^ drivers/xen/events/events_2l.c:121:9: note: Calling 'HYPERVISOR_event_channel_op' (void)HYPERVISOR_event_channel_op(EVTCHNOP_unmask, &unmask); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/include/asm/xen/hypercall.h:358:9: note: Assigned value is garbage or undefined return _hypercall2(int, event_channel_op, cmd, arg); ^ arch/x86/include/asm/xen/hypercall.h:169:2: note: expanded from macro '_hypercall2' __HYPERCALL_DECLS; \ ^~~~~~~~~~~~~~~~~ arch/x86/include/asm/xen/hypercall.h:113:2: note: expanded from macro '__HYPERCALL_DECLS' register unsigned long __arg1 asm(__HYPERCALL_ARG1REG) = __arg1; \ ^ ~~~~~~ drivers/xen/events/events_2l.c:207:4: warning: Value stored to 'bit_idx' is never read [clang-analyzer-deadcode.DeadStores] bit_idx = 0; ^ ~ drivers/xen/events/events_2l.c:207:4: note: Value stored to 'bit_idx' is never read bit_idx = 0; ^ ~ Suppressed 3 warnings (2 in non-user code, 1 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 5 warnings generated. Suppressed 5 warnings (5 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 9 warnings generated. Suppressed 9 warnings (9 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 12 warnings generated. >> arch/x86/kvm/vmx/nested.c:3362:30: warning: Assigned value is garbage or >> undefined [clang-analyzer-core.uninitialized.Assign] vmcs12->exit_qualification = entry_failure_code; ^ arch/x86/kvm/vmx/nested.c:6165:6: note: Assuming field 'format' is equal to KVM_STATE_NESTED_FORMAT_VMX if (kvm_state->format != KVM_STATE_NESTED_FORMAT_VMX) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/vmx/nested.c:6165:2: note: Taking false branch if (kvm_state->format != KVM_STATE_NESTED_FORMAT_VMX) ^ arch/x86/kvm/vmx/nested.c:6168:6: note: Assuming the condition is false if (kvm_state->hdr.vmx.vmxon_pa == -1ull) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/vmx/nested.c:6168:2: note: Taking false branch if (kvm_state->hdr.vmx.vmxon_pa == -1ull) { ^ arch/x86/kvm/vmx/nested.c:6187:7: note: Assuming the condition is false if (!nested_vmx_allowed(vcpu)) ^~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/vmx/nested.c:6187:3: note: Taking false branch if (!nested_vmx_allowed(vcpu)) ^ arch/x86/kvm/vmx/nested.c:6190:3: note: Taking false branch if (!page_address_valid(vcpu, kvm_state->hdr.vmx.vmxon_pa)) ^ arch/x86/kvm/vmx/nested.c:6194:7: note: Assuming the condition is false if ((kvm_state->hdr.vmx.smm.flags & KVM_STATE_NESTED_SMM_GUEST_MODE) && ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/vmx/nested.c:6194:71: note: Left side of '&&' is false if ((kvm_state->hdr.vmx.smm.flags & KVM_STATE_NESTED_SMM_GUEST_MODE) && ^ arch/x86/kvm/vmx/nested.c:6198:6: note: Assuming the condition is false if (kvm_state->hdr.vmx.smm.flags & ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/vmx/nested.c:6198:2: note: Taking false branch if (kvm_state->hdr.vmx.smm.flags & ^ arch/x86/kvm/vmx/nested.c:6202:6: note: Assuming the condition is false if (kvm_state->hdr.vmx.flags & ~KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/vmx/nested.c:6202:2: note: Taking false branch if (kvm_state->hdr.vmx.flags & ~KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE) ^ arch/x86/kvm/vmx/nested.c:6210:6: note: Assuming the condition is true if (is_smm(vcpu) ? ^~~~~~~~~~~~ arch/x86/kvm/vmx/nested.c:6210:6: note: '?' condition is true arch/x86/kvm/vmx/nested.c:6210:6: note: Assuming the condition is false if (is_smm(vcpu) ? ^~~~~~ arch/x86/kvm/vmx/nested.c:6210:2: note: Taking false branch if (is_smm(vcpu) ? ^ arch/x86/kvm/vmx/nested.c:6216:71: note: Left side of '&&' is false if ((kvm_state->hdr.vmx.smm.flags & KVM_STATE_NESTED_SMM_GUEST_MODE) && ^ arch/x86/kvm/vmx/nested.c:6220:7: note: Assuming the condition is false if ((kvm_state->flags & KVM_STATE_NESTED_EVMCS) && ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/vmx/nested.c:6220:50: note: Left side of '&&' is false if ((kvm_state->flags & KVM_STATE_NESTED_EVMCS) && ^ arch/x86/kvm/vmx/nested.c:6226:2: note: Taking false branch if (kvm_state->hdr.vmx.vmxon_pa == -1ull) ^ arch/x86/kvm/vmx/nested.c:6231:6: note: 'ret' is 0 if (ret) ^~~ arch/x86/kvm/vmx/nested.c:6231:2: note: Taking false branch if (ret) ^ arch/x86/kvm/vmx/nested.c:6235:6: note: Assuming the condition is false if (kvm_state->size < sizeof(*kvm_state) + sizeof(*vmcs12)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/vmx/nested.c:6235:2: note: Taking false branch if (kvm_state->size < sizeof(*kvm_state) + sizeof(*vmcs12)) { ^ arch/x86/kvm/vmx/nested.c:6245:6: note: Assuming the condition is true if (kvm_state->hdr.vmx.vmcs12_pa != -1ull) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/vmx/nested.c:6245:2: note: Taking true branch if (kvm_state->hdr.vmx.vmcs12_pa != -1ull) { ^ arch/x86/kvm/vmx/nested.c:6246:7: note: Assuming field 'vmcs12_pa' is not equal to field 'vmxon_pa' if (kvm_state->hdr.vmx.vmcs12_pa == kvm_state->hdr.vmx.vmxon_pa || ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/vmx/nested.c:6246:7: note: Left side of '||' is false arch/x86/kvm/vmx/nested.c:6246:3: note: Taking false branch if (kvm_state->hdr.vmx.vmcs12_pa == kvm_state->hdr.vmx.vmxon_pa || ^ arch/x86/kvm/vmx/nested.c:6263:6: note: Assuming the condition is false if (kvm_state->hdr.vmx.smm.flags & KVM_STATE_NESTED_SMM_VMXON) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/vmx/nested.c:6263:2: note: Taking false branch if (kvm_state->hdr.vmx.smm.flags & KVM_STATE_NESTED_SMM_VMXON) { ^ arch/x86/kvm/vmx/nested.c:6272:6: note: Assuming the condition is false if (copy_from_user(vmcs12, user_vmx_nested_state->vmcs12, sizeof(*vmcs12))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/kvm/vmx/nested.c:6272:2: note: Taking false branch if (copy_from_user(vmcs12, user_vmx_nested_state->vmcs12, sizeof(*vmcs12))) ^ vim +3362 arch/x86/kvm/vmx/nested.c 55d2375e58a61b Sean Christopherson 2018-12-03 3273 55d2375e58a61b Sean Christopherson 2018-12-03 3274 static void load_vmcs12_host_state(struct kvm_vcpu *vcpu, 55d2375e58a61b Sean Christopherson 2018-12-03 3275 struct vmcs12 *vmcs12); 55d2375e58a61b Sean Christopherson 2018-12-03 3276 55d2375e58a61b Sean Christopherson 2018-12-03 3277 /* 55d2375e58a61b Sean Christopherson 2018-12-03 3278 * If from_vmentry is false, this is being called from state restore (either RSM 55d2375e58a61b Sean Christopherson 2018-12-03 3279 * or KVM_SET_NESTED_STATE). Otherwise it's called from vmlaunch/vmresume. 671ddc700fd08b Jim Mattson 2019-10-15 3280 * 671ddc700fd08b Jim Mattson 2019-10-15 3281 * Returns: 463bfeeead9741 Miaohe Lin 2020-02-14 3282 * NVMX_VMENTRY_SUCCESS: Entered VMX non-root mode 463bfeeead9741 Miaohe Lin 2020-02-14 3283 * NVMX_VMENTRY_VMFAIL: Consistency check VMFail 463bfeeead9741 Miaohe Lin 2020-02-14 3284 * NVMX_VMENTRY_VMEXIT: Consistency check VMExit 463bfeeead9741 Miaohe Lin 2020-02-14 3285 * NVMX_VMENTRY_KVM_INTERNAL_ERROR: KVM internal error 55d2375e58a61b Sean Christopherson 2018-12-03 3286 */ 671ddc700fd08b Jim Mattson 2019-10-15 3287 enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, 671ddc700fd08b Jim Mattson 2019-10-15 3288 bool from_vmentry) 55d2375e58a61b Sean Christopherson 2018-12-03 3289 { 55d2375e58a61b Sean Christopherson 2018-12-03 3290 struct vcpu_vmx *vmx = to_vmx(vcpu); 55d2375e58a61b Sean Christopherson 2018-12-03 3291 struct vmcs12 *vmcs12 = get_vmcs12(vcpu); 68cda40d9f3c4c Sean Christopherson 2020-05-11 3292 enum vm_entry_failure_code entry_failure_code; 55d2375e58a61b Sean Christopherson 2018-12-03 3293 bool evaluate_pending_interrupts; 8e53324021645f Sean Christopherson 2020-11-06 3294 union vmx_exit_reason exit_reason = { 8e53324021645f Sean Christopherson 2020-11-06 3295 .basic = EXIT_REASON_INVALID_STATE, 8e53324021645f Sean Christopherson 2020-11-06 3296 .failed_vmentry = 1, 8e53324021645f Sean Christopherson 2020-11-06 3297 }; 8e53324021645f Sean Christopherson 2020-11-06 3298 u32 failed_index; 55d2375e58a61b Sean Christopherson 2018-12-03 3299 eeeb4f67a6cd43 Sean Christopherson 2020-03-20 3300 if (kvm_check_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu)) eeeb4f67a6cd43 Sean Christopherson 2020-03-20 3301 kvm_vcpu_flush_tlb_current(vcpu); eeeb4f67a6cd43 Sean Christopherson 2020-03-20 3302 2183f5645ae7e0 Sean Christopherson 2019-05-07 3303 evaluate_pending_interrupts = exec_controls_get(vmx) & 4e2a0bc56ad197 Xiaoyao Li 2019-12-06 3304 (CPU_BASED_INTR_WINDOW_EXITING | CPU_BASED_NMI_WINDOW_EXITING); 55d2375e58a61b Sean Christopherson 2018-12-03 3305 if (likely(!evaluate_pending_interrupts) && kvm_vcpu_apicv_active(vcpu)) 55d2375e58a61b Sean Christopherson 2018-12-03 3306 evaluate_pending_interrupts |= vmx_has_apicv_interrupt(vcpu); 55d2375e58a61b Sean Christopherson 2018-12-03 3307 55d2375e58a61b Sean Christopherson 2018-12-03 3308 if (!(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS)) 55d2375e58a61b Sean Christopherson 2018-12-03 3309 vmx->nested.vmcs01_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL); 55d2375e58a61b Sean Christopherson 2018-12-03 3310 if (kvm_mpx_supported() && 55d2375e58a61b Sean Christopherson 2018-12-03 3311 !(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS)) 55d2375e58a61b Sean Christopherson 2018-12-03 3312 vmx->nested.vmcs01_guest_bndcfgs = vmcs_read64(GUEST_BNDCFGS); 55d2375e58a61b Sean Christopherson 2018-12-03 3313 f087a02941feac Sean Christopherson 2019-06-07 3314 /* f087a02941feac Sean Christopherson 2019-06-07 3315 * Overwrite vmcs01.GUEST_CR3 with L1's CR3 if EPT is disabled *and* f087a02941feac Sean Christopherson 2019-06-07 3316 * nested early checks are disabled. In the event of a "late" VM-Fail, f087a02941feac Sean Christopherson 2019-06-07 3317 * i.e. a VM-Fail detected by hardware but not KVM, KVM must unwind its f087a02941feac Sean Christopherson 2019-06-07 3318 * software model to the pre-VMEntry host state. When EPT is disabled, f087a02941feac Sean Christopherson 2019-06-07 3319 * GUEST_CR3 holds KVM's shadow CR3, not L1's "real" CR3, which causes f087a02941feac Sean Christopherson 2019-06-07 3320 * nested_vmx_restore_host_state() to corrupt vcpu->arch.cr3. Stuffing f087a02941feac Sean Christopherson 2019-06-07 3321 * vmcs01.GUEST_CR3 results in the unwind naturally setting arch.cr3 to f087a02941feac Sean Christopherson 2019-06-07 3322 * the correct value. Smashing vmcs01.GUEST_CR3 is safe because nested f087a02941feac Sean Christopherson 2019-06-07 3323 * VM-Exits, and the unwind, reset KVM's MMU, i.e. vmcs01.GUEST_CR3 is f087a02941feac Sean Christopherson 2019-06-07 3324 * guaranteed to be overwritten with a shadow CR3 prior to re-entering f087a02941feac Sean Christopherson 2019-06-07 3325 * L1. Don't stuff vmcs01.GUEST_CR3 when using nested early checks as f087a02941feac Sean Christopherson 2019-06-07 3326 * KVM modifies vcpu->arch.cr3 if and only if the early hardware checks f087a02941feac Sean Christopherson 2019-06-07 3327 * pass, and early VM-Fails do not reset KVM's MMU, i.e. the VM-Fail f087a02941feac Sean Christopherson 2019-06-07 3328 * path would need to manually save/restore vmcs01.GUEST_CR3. f087a02941feac Sean Christopherson 2019-06-07 3329 */ f087a02941feac Sean Christopherson 2019-06-07 3330 if (!enable_ept && !nested_early_check) f087a02941feac Sean Christopherson 2019-06-07 3331 vmcs_writel(GUEST_CR3, vcpu->arch.cr3); f087a02941feac Sean Christopherson 2019-06-07 3332 55d2375e58a61b Sean Christopherson 2018-12-03 3333 vmx_switch_vmcs(vcpu, &vmx->nested.vmcs02); 55d2375e58a61b Sean Christopherson 2018-12-03 3334 55d2375e58a61b Sean Christopherson 2018-12-03 3335 prepare_vmcs02_early(vmx, vmcs12); 55d2375e58a61b Sean Christopherson 2018-12-03 3336 55d2375e58a61b Sean Christopherson 2018-12-03 3337 if (from_vmentry) { b89d5ad00e7899 Sean Christopherson 2020-09-23 3338 if (unlikely(!nested_get_vmcs12_pages(vcpu))) { b89d5ad00e7899 Sean Christopherson 2020-09-23 3339 vmx_switch_vmcs(vcpu, &vmx->vmcs01); 671ddc700fd08b Jim Mattson 2019-10-15 3340 return NVMX_VMENTRY_KVM_INTERNAL_ERROR; b89d5ad00e7899 Sean Christopherson 2020-09-23 3341 } 55d2375e58a61b Sean Christopherson 2018-12-03 3342 55d2375e58a61b Sean Christopherson 2018-12-03 3343 if (nested_vmx_check_vmentry_hw(vcpu)) { 55d2375e58a61b Sean Christopherson 2018-12-03 3344 vmx_switch_vmcs(vcpu, &vmx->vmcs01); 671ddc700fd08b Jim Mattson 2019-10-15 3345 return NVMX_VMENTRY_VMFAIL; 55d2375e58a61b Sean Christopherson 2018-12-03 3346 } 55d2375e58a61b Sean Christopherson 2018-12-03 3347 68cda40d9f3c4c Sean Christopherson 2020-05-11 3348 if (nested_vmx_check_guest_state(vcpu, vmcs12, 68cda40d9f3c4c Sean Christopherson 2020-05-11 3349 &entry_failure_code)) { 8e53324021645f Sean Christopherson 2020-11-06 3350 exit_reason.basic = EXIT_REASON_INVALID_STATE; 68cda40d9f3c4c Sean Christopherson 2020-05-11 3351 vmcs12->exit_qualification = entry_failure_code; 55d2375e58a61b Sean Christopherson 2018-12-03 3352 goto vmentry_fail_vmexit; 55d2375e58a61b Sean Christopherson 2018-12-03 3353 } 68cda40d9f3c4c Sean Christopherson 2020-05-11 3354 } 55d2375e58a61b Sean Christopherson 2018-12-03 3355 55d2375e58a61b Sean Christopherson 2018-12-03 3356 enter_guest_mode(vcpu); 5e3d394fdd9e6b Xiaoyao Li 2019-12-06 3357 if (vmcs12->cpu_based_vm_exec_control & CPU_BASED_USE_TSC_OFFSETTING) 55d2375e58a61b Sean Christopherson 2018-12-03 3358 vcpu->arch.tsc_offset += vmcs12->tsc_offset; 55d2375e58a61b Sean Christopherson 2018-12-03 3359 68cda40d9f3c4c Sean Christopherson 2020-05-11 3360 if (prepare_vmcs02(vcpu, vmcs12, &entry_failure_code)) { 8e53324021645f Sean Christopherson 2020-11-06 3361 exit_reason.basic = EXIT_REASON_INVALID_STATE; 68cda40d9f3c4c Sean Christopherson 2020-05-11 @3362 vmcs12->exit_qualification = entry_failure_code; 55d2375e58a61b Sean Christopherson 2018-12-03 3363 goto vmentry_fail_vmexit_guest_mode; 68cda40d9f3c4c Sean Christopherson 2020-05-11 3364 } 55d2375e58a61b Sean Christopherson 2018-12-03 3365 55d2375e58a61b Sean Christopherson 2018-12-03 3366 if (from_vmentry) { 68cda40d9f3c4c Sean Christopherson 2020-05-11 3367 failed_index = nested_vmx_load_msr(vcpu, 55d2375e58a61b Sean Christopherson 2018-12-03 3368 vmcs12->vm_entry_msr_load_addr, 55d2375e58a61b Sean Christopherson 2018-12-03 3369 vmcs12->vm_entry_msr_load_count); 68cda40d9f3c4c Sean Christopherson 2020-05-11 3370 if (failed_index) { 8e53324021645f Sean Christopherson 2020-11-06 3371 exit_reason.basic = EXIT_REASON_MSR_LOAD_FAIL; 68cda40d9f3c4c Sean Christopherson 2020-05-11 3372 vmcs12->exit_qualification = failed_index; 55d2375e58a61b Sean Christopherson 2018-12-03 3373 goto vmentry_fail_vmexit_guest_mode; 68cda40d9f3c4c Sean Christopherson 2020-05-11 3374 } 55d2375e58a61b Sean Christopherson 2018-12-03 3375 } else { 55d2375e58a61b Sean Christopherson 2018-12-03 3376 /* 55d2375e58a61b Sean Christopherson 2018-12-03 3377 * The MMU is not initialized to point at the right entities yet and 55d2375e58a61b Sean Christopherson 2018-12-03 3378 * "get pages" would need to read data from the guest (i.e. we will 55d2375e58a61b Sean Christopherson 2018-12-03 3379 * need to perform gpa to hpa translation). Request a call 55d2375e58a61b Sean Christopherson 2018-12-03 3380 * to nested_get_vmcs12_pages before the next VM-entry. The MSRs 55d2375e58a61b Sean Christopherson 2018-12-03 3381 * have already been set at vmentry time and should not be reset. 55d2375e58a61b Sean Christopherson 2018-12-03 3382 */ 729c15c20f1a7c Paolo Bonzini 2020-09-22 3383 kvm_make_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu); 55d2375e58a61b Sean Christopherson 2018-12-03 3384 } 55d2375e58a61b Sean Christopherson 2018-12-03 3385 55d2375e58a61b Sean Christopherson 2018-12-03 3386 /* 55d2375e58a61b Sean Christopherson 2018-12-03 3387 * If L1 had a pending IRQ/NMI until it executed 55d2375e58a61b Sean Christopherson 2018-12-03 3388 * VMLAUNCH/VMRESUME which wasn't delivered because it was 55d2375e58a61b Sean Christopherson 2018-12-03 3389 * disallowed (e.g. interrupts disabled), L0 needs to 55d2375e58a61b Sean Christopherson 2018-12-03 3390 * evaluate if this pending event should cause an exit from L2 55d2375e58a61b Sean Christopherson 2018-12-03 3391 * to L1 or delivered directly to L2 (e.g. In case L1 don't 55d2375e58a61b Sean Christopherson 2018-12-03 3392 * intercept EXTERNAL_INTERRUPT). 55d2375e58a61b Sean Christopherson 2018-12-03 3393 * 55d2375e58a61b Sean Christopherson 2018-12-03 3394 * Usually this would be handled by the processor noticing an 55d2375e58a61b Sean Christopherson 2018-12-03 3395 * IRQ/NMI window request, or checking RVI during evaluation of 55d2375e58a61b Sean Christopherson 2018-12-03 3396 * pending virtual interrupts. However, this setting was done 55d2375e58a61b Sean Christopherson 2018-12-03 3397 * on VMCS01 and now VMCS02 is active instead. Thus, we force L0 55d2375e58a61b Sean Christopherson 2018-12-03 3398 * to perform pending event evaluation by requesting a KVM_REQ_EVENT. 55d2375e58a61b Sean Christopherson 2018-12-03 3399 */ 55d2375e58a61b Sean Christopherson 2018-12-03 3400 if (unlikely(evaluate_pending_interrupts)) 55d2375e58a61b Sean Christopherson 2018-12-03 3401 kvm_make_request(KVM_REQ_EVENT, vcpu); 55d2375e58a61b Sean Christopherson 2018-12-03 3402 359a6c3ddc5184 Paolo Bonzini 2019-01-29 3403 /* 359a6c3ddc5184 Paolo Bonzini 2019-01-29 3404 * Do not start the preemption timer hrtimer until after we know 359a6c3ddc5184 Paolo Bonzini 2019-01-29 3405 * we are successful, so that only nested_vmx_vmexit needs to cancel 359a6c3ddc5184 Paolo Bonzini 2019-01-29 3406 * the timer. 359a6c3ddc5184 Paolo Bonzini 2019-01-29 3407 */ 359a6c3ddc5184 Paolo Bonzini 2019-01-29 3408 vmx->nested.preemption_timer_expired = false; 850448f35aaf45 Peter Shier 2020-05-26 3409 if (nested_cpu_has_preemption_timer(vmcs12)) { 850448f35aaf45 Peter Shier 2020-05-26 3410 u64 timer_value = vmx_calc_preemption_timer_value(vcpu); 850448f35aaf45 Peter Shier 2020-05-26 3411 vmx_start_preemption_timer(vcpu, timer_value); 850448f35aaf45 Peter Shier 2020-05-26 3412 } 359a6c3ddc5184 Paolo Bonzini 2019-01-29 3413 55d2375e58a61b Sean Christopherson 2018-12-03 3414 /* 55d2375e58a61b Sean Christopherson 2018-12-03 3415 * Note no nested_vmx_succeed or nested_vmx_fail here. At this point 55d2375e58a61b Sean Christopherson 2018-12-03 3416 * we are no longer running L1, and VMLAUNCH/VMRESUME has not yet 55d2375e58a61b Sean Christopherson 2018-12-03 3417 * returned as far as L1 is concerned. It will only return (and set 55d2375e58a61b Sean Christopherson 2018-12-03 3418 * the success flag) when L2 exits (see nested_vmx_vmexit()). 55d2375e58a61b Sean Christopherson 2018-12-03 3419 */ 671ddc700fd08b Jim Mattson 2019-10-15 3420 return NVMX_VMENTRY_SUCCESS; 55d2375e58a61b Sean Christopherson 2018-12-03 3421 55d2375e58a61b Sean Christopherson 2018-12-03 3422 /* 55d2375e58a61b Sean Christopherson 2018-12-03 3423 * A failed consistency check that leads to a VMExit during L1's 55d2375e58a61b Sean Christopherson 2018-12-03 3424 * VMEnter to L2 is a variation of a normal VMexit, as explained in 55d2375e58a61b Sean Christopherson 2018-12-03 3425 * 26.7 "VM-entry failures during or after loading guest state". 55d2375e58a61b Sean Christopherson 2018-12-03 3426 */ 55d2375e58a61b Sean Christopherson 2018-12-03 3427 vmentry_fail_vmexit_guest_mode: 5e3d394fdd9e6b Xiaoyao Li 2019-12-06 3428 if (vmcs12->cpu_based_vm_exec_control & CPU_BASED_USE_TSC_OFFSETTING) 55d2375e58a61b Sean Christopherson 2018-12-03 3429 vcpu->arch.tsc_offset -= vmcs12->tsc_offset; 55d2375e58a61b Sean Christopherson 2018-12-03 3430 leave_guest_mode(vcpu); 55d2375e58a61b Sean Christopherson 2018-12-03 3431 55d2375e58a61b Sean Christopherson 2018-12-03 3432 vmentry_fail_vmexit: 55d2375e58a61b Sean Christopherson 2018-12-03 3433 vmx_switch_vmcs(vcpu, &vmx->vmcs01); 55d2375e58a61b Sean Christopherson 2018-12-03 3434 55d2375e58a61b Sean Christopherson 2018-12-03 3435 if (!from_vmentry) 671ddc700fd08b Jim Mattson 2019-10-15 3436 return NVMX_VMENTRY_VMEXIT; 55d2375e58a61b Sean Christopherson 2018-12-03 3437 55d2375e58a61b Sean Christopherson 2018-12-03 3438 load_vmcs12_host_state(vcpu, vmcs12); 8e53324021645f Sean Christopherson 2020-11-06 3439 vmcs12->vm_exit_reason = exit_reason.full; 55d2375e58a61b Sean Christopherson 2018-12-03 3440 if (enable_shadow_vmcs || vmx->nested.hv_evmcs) 3731905ef28fc1 Sean Christopherson 2019-05-07 3441 vmx->nested.need_vmcs12_to_shadow_sync = true; 671ddc700fd08b Jim Mattson 2019-10-15 3442 return NVMX_VMENTRY_VMEXIT; 55d2375e58a61b Sean Christopherson 2018-12-03 3443 } 55d2375e58a61b Sean Christopherson 2018-12-03 3444 :::::: The code at line 3362 was first introduced by commit :::::: 68cda40d9f3c4cb880108eb22f974d9e3d5dc6c5 KVM: nVMX: Tweak handling of failure code for nested VM-Enter failure :::::: TO: Sean Christopherson <[email protected]> :::::: CC: Paolo Bonzini <[email protected]> --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/[email protected]
.config.gz
Description: application/gzip
_______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
