aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r--drivers/kvm/kvm_main.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 6ad1b04f3099..a65a145f3050 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1020,9 +1020,8 @@ void mark_page_dirty(struct kvm *kvm, gfn_t gfn)
1020static int emulator_read_std(unsigned long addr, 1020static int emulator_read_std(unsigned long addr,
1021 void *val, 1021 void *val,
1022 unsigned int bytes, 1022 unsigned int bytes,
1023 struct x86_emulate_ctxt *ctxt) 1023 struct kvm_vcpu *vcpu)
1024{ 1024{
1025 struct kvm_vcpu *vcpu = ctxt->vcpu;
1026 void *data = val; 1025 void *data = val;
1027 1026
1028 while (bytes) { 1027 while (bytes) {
@@ -1056,7 +1055,7 @@ static int emulator_read_std(unsigned long addr,
1056static int emulator_write_std(unsigned long addr, 1055static int emulator_write_std(unsigned long addr,
1057 const void *val, 1056 const void *val,
1058 unsigned int bytes, 1057 unsigned int bytes,
1059 struct x86_emulate_ctxt *ctxt) 1058 struct kvm_vcpu *vcpu)
1060{ 1059{
1061 printk(KERN_ERR "emulator_write_std: addr %lx n %d\n", 1060 printk(KERN_ERR "emulator_write_std: addr %lx n %d\n",
1062 addr, bytes); 1061 addr, bytes);
@@ -1083,9 +1082,8 @@ static struct kvm_io_device *vcpu_find_pio_dev(struct kvm_vcpu *vcpu,
1083static int emulator_read_emulated(unsigned long addr, 1082static int emulator_read_emulated(unsigned long addr,
1084 void *val, 1083 void *val,
1085 unsigned int bytes, 1084 unsigned int bytes,
1086 struct x86_emulate_ctxt *ctxt) 1085 struct kvm_vcpu *vcpu)
1087{ 1086{
1088 struct kvm_vcpu *vcpu = ctxt->vcpu;
1089 struct kvm_io_device *mmio_dev; 1087 struct kvm_io_device *mmio_dev;
1090 gpa_t gpa; 1088 gpa_t gpa;
1091 1089
@@ -1093,7 +1091,7 @@ static int emulator_read_emulated(unsigned long addr,
1093 memcpy(val, vcpu->mmio_data, bytes); 1091 memcpy(val, vcpu->mmio_data, bytes);
1094 vcpu->mmio_read_completed = 0; 1092 vcpu->mmio_read_completed = 0;
1095 return X86EMUL_CONTINUE; 1093 return X86EMUL_CONTINUE;
1096 } else if (emulator_read_std(addr, val, bytes, ctxt) 1094 } else if (emulator_read_std(addr, val, bytes, vcpu)
1097 == X86EMUL_CONTINUE) 1095 == X86EMUL_CONTINUE)
1098 return X86EMUL_CONTINUE; 1096 return X86EMUL_CONTINUE;
1099 1097
@@ -1140,9 +1138,8 @@ static int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
1140static int emulator_write_emulated_onepage(unsigned long addr, 1138static int emulator_write_emulated_onepage(unsigned long addr,
1141 const void *val, 1139 const void *val,
1142 unsigned int bytes, 1140 unsigned int bytes,
1143 struct x86_emulate_ctxt *ctxt) 1141 struct kvm_vcpu *vcpu)
1144{ 1142{
1145 struct kvm_vcpu *vcpu = ctxt->vcpu;
1146 struct kvm_io_device *mmio_dev; 1143 struct kvm_io_device *mmio_dev;
1147 gpa_t gpa = vcpu->mmu.gva_to_gpa(vcpu, addr); 1144 gpa_t gpa = vcpu->mmu.gva_to_gpa(vcpu, addr);
1148 1145
@@ -1175,28 +1172,28 @@ static int emulator_write_emulated_onepage(unsigned long addr,
1175static int emulator_write_emulated(unsigned long addr, 1172static int emulator_write_emulated(unsigned long addr,
1176 const void *val, 1173 const void *val,
1177 unsigned int bytes, 1174 unsigned int bytes,
1178 struct x86_emulate_ctxt *ctxt) 1175 struct kvm_vcpu *vcpu)
1179{ 1176{
1180 /* Crossing a page boundary? */ 1177 /* Crossing a page boundary? */
1181 if (((addr + bytes - 1) ^ addr) & PAGE_MASK) { 1178 if (((addr + bytes - 1) ^ addr) & PAGE_MASK) {
1182 int rc, now; 1179 int rc, now;
1183 1180
1184 now = -addr & ~PAGE_MASK; 1181 now = -addr & ~PAGE_MASK;
1185 rc = emulator_write_emulated_onepage(addr, val, now, ctxt); 1182 rc = emulator_write_emulated_onepage(addr, val, now, vcpu);
1186 if (rc != X86EMUL_CONTINUE) 1183 if (rc != X86EMUL_CONTINUE)
1187 return rc; 1184 return rc;
1188 addr += now; 1185 addr += now;
1189 val += now; 1186 val += now;
1190 bytes -= now; 1187 bytes -= now;
1191 } 1188 }
1192 return emulator_write_emulated_onepage(addr, val, bytes, ctxt); 1189 return emulator_write_emulated_onepage(addr, val, bytes, vcpu);
1193} 1190}
1194 1191
1195static int emulator_cmpxchg_emulated(unsigned long addr, 1192static int emulator_cmpxchg_emulated(unsigned long addr,
1196 const void *old, 1193 const void *old,
1197 const void *new, 1194 const void *new,
1198 unsigned int bytes, 1195 unsigned int bytes,
1199 struct x86_emulate_ctxt *ctxt) 1196 struct kvm_vcpu *vcpu)
1200{ 1197{
1201 static int reported; 1198 static int reported;
1202 1199
@@ -1204,7 +1201,7 @@ static int emulator_cmpxchg_emulated(unsigned long addr,
1204 reported = 1; 1201 reported = 1;
1205 printk(KERN_WARNING "kvm: emulating exchange as write\n"); 1202 printk(KERN_WARNING "kvm: emulating exchange as write\n");
1206 } 1203 }
1207 return emulator_write_emulated(addr, new, bytes, ctxt); 1204 return emulator_write_emulated(addr, new, bytes, vcpu);
1208} 1205}
1209 1206
1210static unsigned long get_segment_base(struct kvm_vcpu *vcpu, int seg) 1207static unsigned long get_segment_base(struct kvm_vcpu *vcpu, int seg)
@@ -1266,7 +1263,7 @@ static void report_emulation_failure(struct x86_emulate_ctxt *ctxt)
1266 if (reported) 1263 if (reported)
1267 return; 1264 return;
1268 1265
1269 emulator_read_std(rip_linear, (void *)opcodes, 4, ctxt); 1266 emulator_read_std(rip_linear, (void *)opcodes, 4, ctxt->vcpu);
1270 1267
1271 printk(KERN_ERR "emulation failed but !mmio_needed?" 1268 printk(KERN_ERR "emulation failed but !mmio_needed?"
1272 " rip %lx %02x %02x %02x %02x\n", 1269 " rip %lx %02x %02x %02x %02x\n",