Skip to content

Commit

Permalink
KVM: VMX: Fix exit qualification width on i386
Browse files Browse the repository at this point in the history
According to Intel Software Developer's Manual, Vol. 3B, Appendix H.4.2,
exit qualification should be of natural width. However, current code
uses u64 as the data type for this register, which occasionally
introduces invalid value to VMExit handling logics. This patch fixes
this bug.

I have tested Windows and Linux guest on i386 host, and they can boot
successfully with this patch.

Signed-off-by: Qing He <qing.he@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
  • Loading branch information
He, Qing authored and Avi Kivity committed Oct 13, 2007
1 parent 04d2cc7 commit bfdaab0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/kvm/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1840,12 +1840,12 @@ static int handle_triple_fault(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)

static int handle_io(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
{
u64 exit_qualification;
unsigned long exit_qualification;
int size, down, in, string, rep;
unsigned port;

++vcpu->stat.io_exits;
exit_qualification = vmcs_read64(EXIT_QUALIFICATION);
exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
string = (exit_qualification & 16) != 0;

if (string) {
Expand Down Expand Up @@ -1877,11 +1877,11 @@ vmx_patch_hypercall(struct kvm_vcpu *vcpu, unsigned char *hypercall)

static int handle_cr(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
{
u64 exit_qualification;
unsigned long exit_qualification;
int cr;
int reg;

exit_qualification = vmcs_read64(EXIT_QUALIFICATION);
exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
cr = exit_qualification & 15;
reg = (exit_qualification >> 8) & 15;
switch ((exit_qualification >> 4) & 3) {
Expand Down Expand Up @@ -1950,15 +1950,15 @@ static int handle_cr(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)

static int handle_dr(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
{
u64 exit_qualification;
unsigned long exit_qualification;
unsigned long val;
int dr, reg;

/*
* FIXME: this code assumes the host is debugging the guest.
* need to deal with guest debugging itself too.
*/
exit_qualification = vmcs_read64(EXIT_QUALIFICATION);
exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
dr = exit_qualification & 7;
reg = (exit_qualification >> 8) & 15;
vcpu_load_rsp_rip(vcpu);
Expand Down

0 comments on commit bfdaab0

Please sign in to comment.