Commit 7a036a6f authored by Radim Krčmář's avatar Radim Krčmář Committed by Paolo Bonzini

KVM: x86: add read_phys to x86_emulate_ops

We want to read the physical memory when emulating RSM.

X86EMUL_IO_NEEDED is returned on all errors for consistency with other
helpers.
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
Tested-by: default avatarLaszlo Ersek <lersek@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 2da29bcc
...@@ -111,6 +111,16 @@ struct x86_emulate_ops { ...@@ -111,6 +111,16 @@ struct x86_emulate_ops {
unsigned int bytes, unsigned int bytes,
struct x86_exception *fault); struct x86_exception *fault);
/*
* read_phys: Read bytes of standard (non-emulated/special) memory.
* Used for descriptor reading.
* @addr: [IN ] Physical address from which to read.
* @val: [OUT] Value read from memory.
* @bytes: [IN ] Number of bytes to read from memory.
*/
int (*read_phys)(struct x86_emulate_ctxt *ctxt, unsigned long addr,
void *val, unsigned int bytes);
/* /*
* write_std: Write bytes of standard (non-emulated/special) memory. * write_std: Write bytes of standard (non-emulated/special) memory.
* Used for descriptor writing. * Used for descriptor writing.
......
...@@ -4089,6 +4089,15 @@ static int kvm_read_guest_virt_system(struct x86_emulate_ctxt *ctxt, ...@@ -4089,6 +4089,15 @@ static int kvm_read_guest_virt_system(struct x86_emulate_ctxt *ctxt,
return kvm_read_guest_virt_helper(addr, val, bytes, vcpu, 0, exception); return kvm_read_guest_virt_helper(addr, val, bytes, vcpu, 0, exception);
} }
static int kvm_read_guest_phys_system(struct x86_emulate_ctxt *ctxt,
unsigned long addr, void *val, unsigned int bytes)
{
struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
int r = kvm_vcpu_read_guest(vcpu, addr, val, bytes);
return r < 0 ? X86EMUL_IO_NEEDED : X86EMUL_CONTINUE;
}
int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt, int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
gva_t addr, void *val, gva_t addr, void *val,
unsigned int bytes, unsigned int bytes,
...@@ -4824,6 +4833,7 @@ static const struct x86_emulate_ops emulate_ops = { ...@@ -4824,6 +4833,7 @@ static const struct x86_emulate_ops emulate_ops = {
.write_gpr = emulator_write_gpr, .write_gpr = emulator_write_gpr,
.read_std = kvm_read_guest_virt_system, .read_std = kvm_read_guest_virt_system,
.write_std = kvm_write_guest_virt_system, .write_std = kvm_write_guest_virt_system,
.read_phys = kvm_read_guest_phys_system,
.fetch = kvm_fetch_guest_virt, .fetch = kvm_fetch_guest_virt,
.read_emulated = emulator_read_emulated, .read_emulated = emulator_read_emulated,
.write_emulated = emulator_write_emulated, .write_emulated = emulator_write_emulated,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment