aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2011-04-20 06:37:53 -0400
committerAvi Kivity <avi@redhat.com>2011-05-22 08:39:03 -0400
commit717746e382e58f075642403eaac26bce0640b2c5 (patch)
treeaa942f278b9382de50df2e9e15614c99eff7330e /arch/x86/kvm/x86.c
parent4bff1e86ad286d4b3a54902540abeeaf95e64db3 (diff)
KVM: x86 emulator: drop vcpu argument from cr/dr/cpl/msr callbacks
Making the emulator caller agnostic. Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 6a7fbf671b26..16373a5bfd01 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4160,15 +4160,15 @@ int emulate_clts(struct kvm_vcpu *vcpu)
4160 return X86EMUL_CONTINUE; 4160 return X86EMUL_CONTINUE;
4161} 4161}
4162 4162
4163int emulator_get_dr(int dr, unsigned long *dest, struct kvm_vcpu *vcpu) 4163int emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long *dest)
4164{ 4164{
4165 return _kvm_get_dr(vcpu, dr, dest); 4165 return _kvm_get_dr(emul_to_vcpu(ctxt), dr, dest);
4166} 4166}
4167 4167
4168int emulator_set_dr(int dr, unsigned long value, struct kvm_vcpu *vcpu) 4168int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr, unsigned long value)
4169{ 4169{
4170 4170
4171 return __kvm_set_dr(vcpu, dr, value); 4171 return __kvm_set_dr(emul_to_vcpu(ctxt), dr, value);
4172} 4172}
4173 4173
4174static u64 mk_cr_64(u64 curr_cr, u32 new_val) 4174static u64 mk_cr_64(u64 curr_cr, u32 new_val)
@@ -4176,8 +4176,9 @@ static u64 mk_cr_64(u64 curr_cr, u32 new_val)
4176 return (curr_cr & ~((1ULL << 32) - 1)) | new_val; 4176 return (curr_cr & ~((1ULL << 32) - 1)) | new_val;
4177} 4177}
4178 4178
4179static unsigned long emulator_get_cr(int cr, struct kvm_vcpu *vcpu) 4179static unsigned long emulator_get_cr(struct x86_emulate_ctxt *ctxt, int cr)
4180{ 4180{
4181 struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
4181 unsigned long value; 4182 unsigned long value;
4182 4183
4183 switch (cr) { 4184 switch (cr) {
@@ -4204,8 +4205,9 @@ static unsigned long emulator_get_cr(int cr, struct kvm_vcpu *vcpu)
4204 return value; 4205 return value;
4205} 4206}
4206 4207
4207static int emulator_set_cr(int cr, unsigned long val, struct kvm_vcpu *vcpu) 4208static int emulator_set_cr(struct x86_emulate_ctxt *ctxt, int cr, ulong val)
4208{ 4209{
4210 struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
4209 int res = 0; 4211 int res = 0;
4210 4212
4211 switch (cr) { 4213 switch (cr) {
@@ -4232,9 +4234,9 @@ static int emulator_set_cr(int cr, unsigned long val, struct kvm_vcpu *vcpu)
4232 return res; 4234 return res;
4233} 4235}
4234 4236
4235static int emulator_get_cpl(struct kvm_vcpu *vcpu) 4237static int emulator_get_cpl(struct x86_emulate_ctxt *ctxt)
4236{ 4238{
4237 return kvm_x86_ops->get_cpl(vcpu); 4239 return kvm_x86_ops->get_cpl(emul_to_vcpu(ctxt));
4238} 4240}
4239 4241
4240static void emulator_get_gdt(struct x86_emulate_ctxt *ctxt, struct desc_ptr *dt) 4242static void emulator_get_gdt(struct x86_emulate_ctxt *ctxt, struct desc_ptr *dt)
@@ -4335,6 +4337,18 @@ static void emulator_set_segment_selector(struct x86_emulate_ctxt *ctxt,
4335 kvm_set_segment(emul_to_vcpu(ctxt), &kvm_seg, seg); 4337 kvm_set_segment(emul_to_vcpu(ctxt), &kvm_seg, seg);
4336} 4338}
4337 4339
4340static int emulator_get_msr(struct x86_emulate_ctxt *ctxt,
4341 u32 msr_index, u64 *pdata)
4342{
4343 return kvm_get_msr(emul_to_vcpu(ctxt), msr_index, pdata);
4344}
4345
4346static int emulator_set_msr(struct x86_emulate_ctxt *ctxt,
4347 u32 msr_index, u64 data)
4348{
4349 return kvm_set_msr(emul_to_vcpu(ctxt), msr_index, data);
4350}
4351
4338static void emulator_get_fpu(struct x86_emulate_ctxt *ctxt) 4352static void emulator_get_fpu(struct x86_emulate_ctxt *ctxt)
4339{ 4353{
4340 preempt_disable(); 4354 preempt_disable();
@@ -4379,8 +4393,8 @@ static struct x86_emulate_ops emulate_ops = {
4379 .cpl = emulator_get_cpl, 4393 .cpl = emulator_get_cpl,
4380 .get_dr = emulator_get_dr, 4394 .get_dr = emulator_get_dr,
4381 .set_dr = emulator_set_dr, 4395 .set_dr = emulator_set_dr,
4382 .set_msr = kvm_set_msr, 4396 .set_msr = emulator_set_msr,
4383 .get_msr = kvm_get_msr, 4397 .get_msr = emulator_get_msr,
4384 .get_fpu = emulator_get_fpu, 4398 .get_fpu = emulator_get_fpu,
4385 .put_fpu = emulator_put_fpu, 4399 .put_fpu = emulator_put_fpu,
4386 .intercept = emulator_intercept, 4400 .intercept = emulator_intercept,