aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2008-06-27 13:58:02 -0400
committerAvi Kivity <avi@qumranet.com>2008-10-15 04:13:57 -0400
commit5fdbf9765b7ba6a45100851154768de703d51e76 (patch)
treeec34ec9357575dc4190e5228a6eabfd5f81b66a5 /include/asm-x86
parentca60dfbb69afb549e33527cbf676e4daf8febfb5 (diff)
KVM: x86: accessors for guest registers
As suggested by Avi, introduce accessors to read/write guest registers. This simplifies the ->cache_regs/->decache_regs interface, and improves register caching which is important for VMX, where the cost of vmcs_read/vmcs_write is significant. [avi: fix warnings] Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'include/asm-x86')
-rw-r--r--include/asm-x86/kvm_host.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
index 69794547f514..8c886be0103f 100644
--- a/include/asm-x86/kvm_host.h
+++ b/include/asm-x86/kvm_host.h
@@ -89,7 +89,7 @@ extern struct list_head vm_list;
89struct kvm_vcpu; 89struct kvm_vcpu;
90struct kvm; 90struct kvm;
91 91
92enum { 92enum kvm_reg {
93 VCPU_REGS_RAX = 0, 93 VCPU_REGS_RAX = 0,
94 VCPU_REGS_RCX = 1, 94 VCPU_REGS_RCX = 1,
95 VCPU_REGS_RDX = 2, 95 VCPU_REGS_RDX = 2,
@@ -108,6 +108,7 @@ enum {
108 VCPU_REGS_R14 = 14, 108 VCPU_REGS_R14 = 14,
109 VCPU_REGS_R15 = 15, 109 VCPU_REGS_R15 = 15,
110#endif 110#endif
111 VCPU_REGS_RIP,
111 NR_VCPU_REGS 112 NR_VCPU_REGS
112}; 113};
113 114
@@ -219,8 +220,13 @@ struct kvm_vcpu_arch {
219 int interrupt_window_open; 220 int interrupt_window_open;
220 unsigned long irq_summary; /* bit vector: 1 per word in irq_pending */ 221 unsigned long irq_summary; /* bit vector: 1 per word in irq_pending */
221 DECLARE_BITMAP(irq_pending, KVM_NR_INTERRUPTS); 222 DECLARE_BITMAP(irq_pending, KVM_NR_INTERRUPTS);
222 unsigned long regs[NR_VCPU_REGS]; /* for rsp: vcpu_load_rsp_rip() */ 223 /*
223 unsigned long rip; /* needs vcpu_load_rsp_rip() */ 224 * rip and regs accesses must go through
225 * kvm_{register,rip}_{read,write} functions.
226 */
227 unsigned long regs[NR_VCPU_REGS];
228 u32 regs_avail;
229 u32 regs_dirty;
224 230
225 unsigned long cr0; 231 unsigned long cr0;
226 unsigned long cr2; 232 unsigned long cr2;
@@ -414,8 +420,7 @@ struct kvm_x86_ops {
414 unsigned long (*get_dr)(struct kvm_vcpu *vcpu, int dr); 420 unsigned long (*get_dr)(struct kvm_vcpu *vcpu, int dr);
415 void (*set_dr)(struct kvm_vcpu *vcpu, int dr, unsigned long value, 421 void (*set_dr)(struct kvm_vcpu *vcpu, int dr, unsigned long value,
416 int *exception); 422 int *exception);
417 void (*cache_regs)(struct kvm_vcpu *vcpu); 423 void (*cache_reg)(struct kvm_vcpu *vcpu, enum kvm_reg reg);
418 void (*decache_regs)(struct kvm_vcpu *vcpu);
419 unsigned long (*get_rflags)(struct kvm_vcpu *vcpu); 424 unsigned long (*get_rflags)(struct kvm_vcpu *vcpu);
420 void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags); 425 void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags);
421 426