[PATCH 24/38] KVM: Use the general purpose register accessors rather than direct access

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

 



Signed-off-by: Avi Kivity <[email protected]>

Index: linux-2.6/drivers/kvm/kvm_main.c
===================================================================
--- linux-2.6.orig/drivers/kvm/kvm_main.c
+++ linux-2.6/drivers/kvm/kvm_main.c
@@ -1130,7 +1130,7 @@ static void report_emulation_failure(str
 {
 	static int reported;
 	u8 opcodes[4];
-	unsigned long rip = vmcs_readl(GUEST_RIP);
+	unsigned long rip = ctxt->vcpu->rip;
 	unsigned long rip_linear;
 
 	rip_linear = rip + get_segment_base(ctxt->vcpu, VCPU_SREG_CS);
@@ -1406,13 +1406,15 @@ static int kvm_dev_ioctl_get_regs(struct
 	if (!vcpu)
 		return -ENOENT;
 
+	kvm_arch_ops->cache_regs(vcpu);
+
 	regs->rax = vcpu->regs[VCPU_REGS_RAX];
 	regs->rbx = vcpu->regs[VCPU_REGS_RBX];
 	regs->rcx = vcpu->regs[VCPU_REGS_RCX];
 	regs->rdx = vcpu->regs[VCPU_REGS_RDX];
 	regs->rsi = vcpu->regs[VCPU_REGS_RSI];
 	regs->rdi = vcpu->regs[VCPU_REGS_RDI];
-	regs->rsp = vmcs_readl(GUEST_RSP);
+	regs->rsp = vcpu->regs[VCPU_REGS_RSP];
 	regs->rbp = vcpu->regs[VCPU_REGS_RBP];
 #ifdef __x86_64__
 	regs->r8 = vcpu->regs[VCPU_REGS_R8];
@@ -1425,7 +1427,7 @@ static int kvm_dev_ioctl_get_regs(struct
 	regs->r15 = vcpu->regs[VCPU_REGS_R15];
 #endif
 
-	regs->rip = vmcs_readl(GUEST_RIP);
+	regs->rip = vcpu->rip;
 	regs->rflags = vmcs_readl(GUEST_RFLAGS);
 
 	/*
@@ -1456,7 +1458,7 @@ static int kvm_dev_ioctl_set_regs(struct
 	vcpu->regs[VCPU_REGS_RDX] = regs->rdx;
 	vcpu->regs[VCPU_REGS_RSI] = regs->rsi;
 	vcpu->regs[VCPU_REGS_RDI] = regs->rdi;
-	vmcs_writel(GUEST_RSP, regs->rsp);
+	vcpu->regs[VCPU_REGS_RSP] = regs->rsp;
 	vcpu->regs[VCPU_REGS_RBP] = regs->rbp;
 #ifdef __x86_64__
 	vcpu->regs[VCPU_REGS_R8] = regs->r8;
@@ -1469,9 +1471,11 @@ static int kvm_dev_ioctl_set_regs(struct
 	vcpu->regs[VCPU_REGS_R15] = regs->r15;
 #endif
 
-	vmcs_writel(GUEST_RIP, regs->rip);
+	vcpu->rip = regs->rip;
 	vmcs_writel(GUEST_RFLAGS, regs->rflags);
 
+	kvm_arch_ops->decache_regs(vcpu);
+
 	vcpu_put(vcpu);
 
 	return 0;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux