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

From: Avi Kivity
Date: Mon Nov 27 2006 - 07:34:59 EST


Signed-off-by: Avi Kivity <avi@xxxxxxxxxxxx>

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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/