@@ -4245,21 +4245,20 @@ static int kvm_fetch_guest_virt(struct x86_emulate_ctxt *ctxt,
4245
4245
return X86EMUL_CONTINUE ;
4246
4246
}
4247
4247
4248
- int kvm_read_guest_virt (struct x86_emulate_ctxt * ctxt ,
4248
+ int kvm_read_guest_virt (struct kvm_vcpu * vcpu ,
4249
4249
gva_t addr , void * val , unsigned int bytes ,
4250
4250
struct x86_exception * exception )
4251
4251
{
4252
- struct kvm_vcpu * vcpu = emul_to_vcpu (ctxt );
4253
4252
u32 access = (kvm_x86_ops -> get_cpl (vcpu ) == 3 ) ? PFERR_USER_MASK : 0 ;
4254
4253
4255
4254
return kvm_read_guest_virt_helper (addr , val , bytes , vcpu , access ,
4256
4255
exception );
4257
4256
}
4258
4257
EXPORT_SYMBOL_GPL (kvm_read_guest_virt );
4259
4258
4260
- static int kvm_read_guest_virt_system (struct x86_emulate_ctxt * ctxt ,
4261
- gva_t addr , void * val , unsigned int bytes ,
4262
- struct x86_exception * exception )
4259
+ static int emulator_read_std (struct x86_emulate_ctxt * ctxt ,
4260
+ gva_t addr , void * val , unsigned int bytes ,
4261
+ struct x86_exception * exception )
4263
4262
{
4264
4263
struct kvm_vcpu * vcpu = emul_to_vcpu (ctxt );
4265
4264
return kvm_read_guest_virt_helper (addr , val , bytes , vcpu , 0 , exception );
@@ -4274,18 +4273,16 @@ static int kvm_read_guest_phys_system(struct x86_emulate_ctxt *ctxt,
4274
4273
return r < 0 ? X86EMUL_IO_NEEDED : X86EMUL_CONTINUE ;
4275
4274
}
4276
4275
4277
- int kvm_write_guest_virt_system (struct x86_emulate_ctxt * ctxt ,
4278
- gva_t addr , void * val ,
4279
- unsigned int bytes ,
4280
- struct x86_exception * exception )
4276
+ static int kvm_write_guest_virt_helper (gva_t addr , void * val , unsigned int bytes ,
4277
+ struct kvm_vcpu * vcpu , u32 access ,
4278
+ struct x86_exception * exception )
4281
4279
{
4282
- struct kvm_vcpu * vcpu = emul_to_vcpu (ctxt );
4283
4280
void * data = val ;
4284
4281
int r = X86EMUL_CONTINUE ;
4285
4282
4286
4283
while (bytes ) {
4287
4284
gpa_t gpa = vcpu -> arch .walk_mmu -> gva_to_gpa (vcpu , addr ,
4288
- PFERR_WRITE_MASK ,
4285
+ access ,
4289
4286
exception );
4290
4287
unsigned offset = addr & (PAGE_SIZE - 1 );
4291
4288
unsigned towrite = min (bytes , (unsigned )PAGE_SIZE - offset );
@@ -4306,6 +4303,22 @@ int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
4306
4303
out :
4307
4304
return r ;
4308
4305
}
4306
+
4307
+ static int emulator_write_std (struct x86_emulate_ctxt * ctxt , gva_t addr , void * val ,
4308
+ unsigned int bytes , struct x86_exception * exception )
4309
+ {
4310
+ struct kvm_vcpu * vcpu = emul_to_vcpu (ctxt );
4311
+
4312
+ return kvm_write_guest_virt_helper (addr , val , bytes , vcpu ,
4313
+ PFERR_WRITE_MASK , exception );
4314
+ }
4315
+
4316
+ int kvm_write_guest_virt_system (struct kvm_vcpu * vcpu , gva_t addr , void * val ,
4317
+ unsigned int bytes , struct x86_exception * exception )
4318
+ {
4319
+ return kvm_write_guest_virt_helper (addr , val , bytes , vcpu ,
4320
+ PFERR_WRITE_MASK , exception );
4321
+ }
4309
4322
EXPORT_SYMBOL_GPL (kvm_write_guest_virt_system );
4310
4323
4311
4324
static int vcpu_mmio_gva_to_gpa (struct kvm_vcpu * vcpu , unsigned long gva ,
@@ -5025,8 +5038,8 @@ static void emulator_set_hflags(struct x86_emulate_ctxt *ctxt, unsigned emul_fla
5025
5038
static const struct x86_emulate_ops emulate_ops = {
5026
5039
.read_gpr = emulator_read_gpr ,
5027
5040
.write_gpr = emulator_write_gpr ,
5028
- .read_std = kvm_read_guest_virt_system ,
5029
- .write_std = kvm_write_guest_virt_system ,
5041
+ .read_std = emulator_read_std ,
5042
+ .write_std = emulator_write_std ,
5030
5043
.read_phys = kvm_read_guest_phys_system ,
5031
5044
.fetch = kvm_fetch_guest_virt ,
5032
5045
.read_emulated = emulator_read_emulated ,
0 commit comments