problem with vm-exit exit code

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

 



Hi guys,

I would like to intercept the vm-exit whenever the guest executes a
lidt/sidt instruction.
I know that lidt/sidt instructions cause a vm-exit if and only if
these condition are satisfied:

   -commands are executed in vmx non-root environment
   -the "descriptor-table exiting" field of the secondary vm-execution
control structure is enabled

The first condition is satisfied because the guest OS executes the
lidt/sidt in the boot routine so we are in the vmx non-root
environment.
To satisfy the second condition, I set up the 31th bit in the primary
vm-execution control to 1 to enable the secondary vm-execution
control,
then I set up the 2nd bit of the secondary vm-execution control to 1
to enable the "descriptor-table exiting".

The problem is that I never get the exit_code=46 (that should
correspond to the IDTR access as shown in the Intel developer's
manual).
What I get is exit_code=0 and then the VM freezes.

I wonder why I get 0 as exit reason instead of 46?

Qemu gives me the following error message:
"kvm: unhandled exit 7
kvm_run returned -22"

The unhandled exit code correspond to the 7th vm-instruction error
number referred to: "VM-Entry with invalid control field(s)"

Here are the diffs:

--- x86/default_vmx.c 2010-01-18 11:24:11.726860478 +0100
+++ x86/vmx.c 2010-01-18 11:31:41.116842970 +0100
@@ -2347,6 +2347,7 @@
exec_control &= ~SECONDARY_EXEC_ENABLE_EPT;
if (!enable_unrestricted_guest)
exec_control &= ~SECONDARY_EXEC_UNRESTRICTED_
GUEST;
+ exec_control |= SECONDARY_EXEC_DT_EXITING;
vmcs_write32(SECONDARY_VM_EXEC_CONTROL, exec_control);
}

@@ -3398,6 +3399,10 @@
vmx->invalid_state_emulation_result = err;
}

+static void handle_gdtr_idtr_access(struct kvm_vcpu *vcpu, struct
kvm_run *kvm_run){
+ printk(KERN_INFO "line = %d\n",__LINE__);
+}
+
/*
* The exit handlers return 1 if the exit was handled fully and guest execution
* may resume. Otherwise they set the kvm_run parameter to indicate what needs
@@ -3435,6 +3440,7 @@
[EXIT_REASON_MCE_DURING_VMENTRY] =      handle_machine_check,
[EXIT_REASON_EPT_VIOLATION] =                    handle_ept_violation,
[EXIT_REASON_EPT_MISCONFIG] =                   handle_ept_misconfig,
+ [EXIT_REASON_ACCESS_GDTR_IDTR] =         handle_gdtr_idtr_access,
};


--- include/asm/default_vmx.h 2010-01-18 11:26:51.126860209 +0100
+++ include/asm/vmx.h 2010-01-18 11:33:23.866760764 +0100
@@ -96,6 +96,7 @@
#define SECONDARY_EXEC_ENABLE_VPID                0x00000020
#define SECONDARY_EXEC_WBINVD_EXITING            0x00000040
#define SECONDARY_EXEC_UNRESTRICTED_GUEST 0x00000080
+#define SECONDARY_EXEC_DT_EXITING                   0x00000004


@@ -291,6 +292,7 @@
#define EXIT_REASON_MCE_DURING_VMENTRY       41
#define EXIT_REASON_TPR_BELOW_THRESHOLD    43
#define EXIT_REASON_APIC_ACCESS                       44
+#define EXIT_REASON_ACCESS_GDTR_IDTR           46
#define EXIT_REASON_EPT_VIOLATION                     48
#define EXIT_REASON_EPT_MISCONFIG                    49
#define EXIT_REASON_WBINVD                                54

---------------------------------------------------------------------------------------------------------

I am on an Intel Intel Core2 Duo P8700 CPU, Ubuntu 9.10 with kernel
2.6.31-17-generic, kvm 2.6.32.3 and qemu 0.12.1.1
What am I doing wrong???
Thanks

Matteo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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