Re: [PATCH v3] KVM: x86: fix DR6 delivery for various cases of #DB injection

From: kbuild test robot
Date: Wed May 06 2020 - 18:02:15 EST


Hi Paolo,

I love your patch! Yet something to improve:

[auto build test ERROR on tip/auto-latest]
[also build test ERROR on linus/master v5.7-rc4 next-20200505]
[cannot apply to kvm/linux-next linux/master]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Paolo-Bonzini/KVM-x86-fix-DR6-delivery-for-various-cases-of-DB-injection/20200507-022910
base: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 5545b0d34f37831e20cb401ae8160284d20bba30
config: i386-allyesconfig (attached as .config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

arch/x86/kvm/vmx/vmx.c: In function 'handle_exception_nmi':
>> arch/x86/kvm/vmx/vmx.c:4683:4: error: implicit declaration of function 'kvm_queue_exception_p'; did you mean 'kvm_queue_exception_e'? [-Werror=implicit-function-declaration]
kvm_queue_exception_p(vcpu, DB_VECTOR, dr6);
^~~~~~~~~~~~~~~~~~~~~
kvm_queue_exception_e
cc1: some warnings being treated as errors

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

4610
4611 static int handle_exception_nmi(struct kvm_vcpu *vcpu)
4612 {
4613 struct vcpu_vmx *vmx = to_vmx(vcpu);
4614 struct kvm_run *kvm_run = vcpu->run;
4615 u32 intr_info, ex_no, error_code;
4616 unsigned long cr2, rip, dr6;
4617 u32 vect_info;
4618
4619 vect_info = vmx->idt_vectoring_info;
4620 intr_info = vmx->exit_intr_info;
4621
4622 if (is_machine_check(intr_info) || is_nmi(intr_info))
4623 return 1; /* handled by handle_exception_nmi_irqoff() */
4624
4625 if (is_invalid_opcode(intr_info))
4626 return handle_ud(vcpu);
4627
4628 error_code = 0;
4629 if (intr_info & INTR_INFO_DELIVER_CODE_MASK)
4630 error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE);
4631
4632 if (!vmx->rmode.vm86_active && is_gp_fault(intr_info)) {
4633 WARN_ON_ONCE(!enable_vmware_backdoor);
4634
4635 /*
4636 * VMware backdoor emulation on #GP interception only handles
4637 * IN{S}, OUT{S}, and RDPMC, none of which generate a non-zero
4638 * error code on #GP.
4639 */
4640 if (error_code) {
4641 kvm_queue_exception_e(vcpu, GP_VECTOR, error_code);
4642 return 1;
4643 }
4644 return kvm_emulate_instruction(vcpu, EMULTYPE_VMWARE_GP);
4645 }
4646
4647 /*
4648 * The #PF with PFEC.RSVD = 1 indicates the guest is accessing
4649 * MMIO, it is better to report an internal error.
4650 * See the comments in vmx_handle_exit.
4651 */
4652 if ((vect_info & VECTORING_INFO_VALID_MASK) &&
4653 !(is_page_fault(intr_info) && !(error_code & PFERR_RSVD_MASK))) {
4654 vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
4655 vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_SIMUL_EX;
4656 vcpu->run->internal.ndata = 3;
4657 vcpu->run->internal.data[0] = vect_info;
4658 vcpu->run->internal.data[1] = intr_info;
4659 vcpu->run->internal.data[2] = error_code;
4660 return 0;
4661 }
4662
4663 if (is_page_fault(intr_info)) {
4664 cr2 = vmcs_readl(EXIT_QUALIFICATION);
4665 /* EPT won't cause page fault directly */
4666 WARN_ON_ONCE(!vcpu->arch.apf.host_apf_reason && enable_ept);
4667 return kvm_handle_page_fault(vcpu, error_code, cr2, NULL, 0);
4668 }
4669
4670 ex_no = intr_info & INTR_INFO_VECTOR_MASK;
4671
4672 if (vmx->rmode.vm86_active && rmode_exception(vcpu, ex_no))
4673 return handle_rmode_exception(vcpu, ex_no, error_code);
4674
4675 switch (ex_no) {
4676 case DB_VECTOR:
4677 dr6 = vmcs_readl(EXIT_QUALIFICATION);
4678 if (!(vcpu->guest_debug &
4679 (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))) {
4680 if (is_icebp(intr_info))
4681 WARN_ON(!skip_emulated_instruction(vcpu));
4682
> 4683 kvm_queue_exception_p(vcpu, DB_VECTOR, dr6);
4684 return 1;
4685 }
4686 kvm_run->debug.arch.dr6 = dr6 | DR6_FIXED_1;
4687 kvm_run->debug.arch.dr7 = vmcs_readl(GUEST_DR7);
4688 /* fall through */
4689 case BP_VECTOR:
4690 /*
4691 * Update instruction length as we may reinject #BP from
4692 * user space while in guest debugging mode. Reading it for
4693 * #DB as well causes no harm, it is not used in that case.
4694 */
4695 vmx->vcpu.arch.event_exit_inst_len =
4696 vmcs_read32(VM_EXIT_INSTRUCTION_LEN);
4697 kvm_run->exit_reason = KVM_EXIT_DEBUG;
4698 rip = kvm_rip_read(vcpu);
4699 kvm_run->debug.arch.pc = vmcs_readl(GUEST_CS_BASE) + rip;
4700 kvm_run->debug.arch.exception = ex_no;
4701 break;
4702 case AC_VECTOR:
4703 if (guest_inject_ac(vcpu)) {
4704 kvm_queue_exception_e(vcpu, AC_VECTOR, error_code);
4705 return 1;
4706 }
4707
4708 /*
4709 * Handle split lock. Depending on detection mode this will
4710 * either warn and disable split lock detection for this
4711 * task or force SIGBUS on it.
4712 */
4713 if (handle_guest_split_lock(kvm_rip_read(vcpu)))
4714 return 1;
4715 fallthrough;
4716 default:
4717 kvm_run->exit_reason = KVM_EXIT_EXCEPTION;
4718 kvm_run->ex.exception = ex_no;
4719 kvm_run->ex.error_code = error_code;
4720 break;
4721 }
4722 return 0;
4723 }
4724

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip