* problem with vm-exit exit code
@ 2010-01-18 23:09 Matteo Signorini
2010-01-19 10:46 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Matteo Signorini @ 2010-01-18 23:09 UTC (permalink / raw)
To: kvm
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: problem with vm-exit exit code
2010-01-18 23:09 problem with vm-exit exit code Matteo Signorini
@ 2010-01-19 10:46 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2010-01-19 10:46 UTC (permalink / raw)
To: Matteo Signorini; +Cc: kvm
On 01/19/2010 01:09 AM, Matteo Signorini wrote:
> 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)"
>
Did you check whether your processor supports descriptor-table exiting?
The 'vmxcap' script can help determine that.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-01-19 10:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-18 23:09 problem with vm-exit exit code Matteo Signorini
2010-01-19 10:46 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).