KVM: VMX: check use I/O bitmap first before unconditional I/O exit
authorZhihui Zhang <zzhsuny@gmail.com>
Mon, 30 Dec 2013 20:56:29 +0000 (15:56 -0500)
committerMarcelo Tosatti <mtosatti@redhat.com>
Wed, 8 Jan 2014 21:01:40 +0000 (19:01 -0200)
According to Table C-1 of Intel SDM 3C, a VM exit happens on an I/O instruction when
"use I/O bitmaps" VM-execution control was 0 _and_ the "unconditional I/O exiting"
VM-execution control was 1. So we can't just check "unconditional I/O exiting" alone.
This patch was improved by suggestion from Jan Kiszka.

Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Zhihui Zhang <zzhsuny@gmail.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/vmx.c

index 9cc54842ae1426aecd1f48b6ff8f4737e18e186b..0abf8b783f191ca2e5215f02c786459898bccfda 100644 (file)
@@ -6521,11 +6521,8 @@ static bool nested_vmx_exit_handled_io(struct kvm_vcpu *vcpu,
        int size;
        u8 b;
 
-       if (nested_cpu_has(vmcs12, CPU_BASED_UNCOND_IO_EXITING))
-               return 1;
-
        if (!nested_cpu_has(vmcs12, CPU_BASED_USE_IO_BITMAPS))
-               return 0;
+               return nested_cpu_has(vmcs12, CPU_BASED_UNCOND_IO_EXITING);
 
        exit_qualification = vmcs_readl(EXIT_QUALIFICATION);