Re: [PATCH v2 17/18] KVM: nVMX: add option to perform early consistency checks via H/W

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sean,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kvm/linux-next]
[also build test WARNING on v4.19-rc1 next-20180830]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Sean-Christopherson/KVM-nVMX-add-option-to-perform-early-consistency-checks-via-H-W/20180830-231534
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git linux-next
config: i386-randconfig-x076-201834 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   arch/x86/kvm/vmx.c: In function 'nested_vmx_check_vmentry_hw':
>> arch/x86/kvm/vmx.c:12595:25: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     vmcs_writel(GUEST_RIP, 0xf0f0ULL << 48);
                            ^~~~~~~~~

vim +12595 arch/x86/kvm/vmx.c

 12573	
 12574	static int __noclone nested_vmx_check_vmentry_hw(struct kvm_vcpu *vcpu)
 12575	{
 12576		struct vcpu_vmx *vmx = to_vmx(vcpu);
 12577		unsigned long cr3, cr4;
 12578	
 12579		if (!early_consistency_checks)
 12580			return 0;
 12581	
 12582		if (vmx->msr_autoload.host.nr)
 12583			vmcs_write32(VM_EXIT_MSR_LOAD_COUNT, 0);
 12584		if (vmx->msr_autoload.guest.nr)
 12585			vmcs_write32(VM_ENTRY_MSR_LOAD_COUNT, 0);
 12586	
 12587		preempt_disable();
 12588	
 12589		vmx_prepare_switch_to_guest(vcpu);
 12590	
 12591		/*
 12592		 * prepare_vmcs02() writes GUEST_RIP unconditionally, no need
 12593		 * to save/restore or set dirty bits.
 12594		 */
 12595		vmcs_writel(GUEST_RIP, 0xf0f0ULL << 48);
 12596	
 12597		vmcs_writel(HOST_RIP, vmx_early_consistency_check_return);
 12598	
 12599		cr3 = __get_current_cr3_fast();
 12600		if (unlikely(cr3 != vmx->loaded_vmcs->host_state.cr3)) {
 12601			vmcs_writel(HOST_CR3, cr3);
 12602			vmx->loaded_vmcs->host_state.cr3 = cr3;
 12603		}
 12604	
 12605		cr4 = cr4_read_shadow();
 12606		if (unlikely(cr4 != vmx->loaded_vmcs->host_state.cr4)) {
 12607			vmcs_writel(HOST_CR4, cr4);
 12608			vmx->loaded_vmcs->host_state.cr4 = cr4;
 12609		}
 12610	
 12611		vmx->__launched = vmx->loaded_vmcs->launched;
 12612	
 12613		asm(
 12614			/* Set HOST_RSP */
 12615			__ex(ASM_VMX_VMWRITE_RSP_RDX) "\n\t"
 12616			"mov %%" _ASM_SP ", %c[host_rsp](%0)\n\t"
 12617	
 12618			/* Check if vmlaunch of vmresume is needed */
 12619			"cmpl $0, %c[launched](%0)\n\t"
 12620			"je 1f\n\t"
 12621			__ex(ASM_VMX_VMRESUME) "\n\t"
 12622			"jmp 2f\n\t"
 12623			"1: " __ex(ASM_VMX_VMLAUNCH) "\n\t"
 12624			"jmp 2f\n\t"
 12625			"2: "
 12626	
 12627			/* Set vmx->fail accordingly */
 12628			"setbe %c[fail](%0)\n\t"
 12629	
 12630			".pushsection .rodata\n\t"
 12631			".global vmx_early_consistency_check_return\n\t"
 12632			"vmx_early_consistency_check_return: " _ASM_PTR " 2b\n\t"
 12633			".popsection"
 12634		      :
 12635		      : "c"(vmx), "d"((unsigned long)HOST_RSP),
 12636			[launched]"i"(offsetof(struct vcpu_vmx, __launched)),
 12637			[fail]"i"(offsetof(struct vcpu_vmx, fail)),
 12638			[host_rsp]"i"(offsetof(struct vcpu_vmx, host_rsp))
 12639		      : "rax", "cc", "memory"
 12640		);
 12641	
 12642		vmcs_writel(HOST_RIP, vmx_return);
 12643	
 12644		preempt_enable();
 12645	
 12646		if (vmx->msr_autoload.host.nr)
 12647			vmcs_write32(VM_EXIT_MSR_LOAD_COUNT, vmx->msr_autoload.host.nr);
 12648		if (vmx->msr_autoload.guest.nr)
 12649			vmcs_write32(VM_ENTRY_MSR_LOAD_COUNT, vmx->msr_autoload.guest.nr);
 12650	
 12651		if (vmx->fail) {
 12652			WARN_ON_ONCE(vmcs_read32(VM_INSTRUCTION_ERROR) !=
 12653				     VMXERR_ENTRY_INVALID_CONTROL_FIELD);
 12654			vmx->fail = 0;
 12655			return 1;
 12656		}
 12657	
 12658		/*
 12659		 * VMExit clears RFLAGS.IF and DR7, even on a consistency check.
 12660		 */
 12661		local_irq_enable();
 12662		if (hw_breakpoint_active())
 12663			set_debugreg(__this_cpu_read(cpu_dr7), 7);
 12664	
 12665		/*
 12666		 * A non-failing VMEntry means we somehow entered guest mode with
 12667		 * an illegal RIP, and that's just the tip of the iceberg.  There
 12668		 * is no telling what memory has been modified or what state has
 12669		 * been exposed to unknown code.  Hitting this all but guarantees
 12670		 * a (very critical) hardware issue.
 12671		 */
 12672		WARN_ON(!(vmcs_read32(VM_EXIT_REASON) &
 12673			VMX_EXIT_REASONS_FAILED_VMENTRY));
 12674	
 12675		return 0;
 12676	}
 12677	STACK_FRAME_NON_STANDARD(nested_vmx_check_vmentry_hw);
 12678	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux