Skip to content

Instantly share code, notes, and snippets.

@azizulhakim
Created June 22, 2016 02:41
Show Gist options
  • Save azizulhakim/e6ea0666fce93e54da1538150be670b3 to your computer and use it in GitHub Desktop.
Save azizulhakim/e6ea0666fce93e54da1538150be670b3 to your computer and use it in GitHub Desktop.
KVM Migration Patch for S2E
/* linux-lts-saucy-3.11.0/arch/x86/kvm/vmx.c */
static int handle_exception(struct kvm_vcpu *vcpu)
{
...
enum emulation_result er;
struct x86_emulate_ctxt *ctxt;
...
if (is_invalid_opcode(intr_info)) {
er = emulate_instruction(vcpu, EMULTYPE_TRAP_UD);
#if 1
ctxt = &vcpu->arch.emulate_ctxt;
printk(KERN_WARNING "\nctxt->eip = 0x%lx\nctxt->_eip = 0x%lx\nctxt->fetch.start = 0x%lx\nctxt->fetch.end = 0x%lx\n", ctxt->eip, ctxt->_eip, ctxt->fetch.start, ctxt->fetch.end);
printk(KERN_WARNING "ctxt->fetch.data[]: 0x%01x 0x%01x\n", ctxt->fetch.data[0], ctxt->fetch.data[1]);
if ((ctxt->fetch.data[0] == 0x0f) && (ctxt->fetch.data[1] == 0x3f))
{
printk(KERN_WARNING "S2E instruction seen!\n");
/* Initiate live migration */
vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
vcpu->run->internal.suberror = 5; /*temporary error code*/
vcpu->run->internal.ndata = 1;
vcpu->run->internal.data[0] = ctxt->eip;
return 0;
}
#endif
if (er != EMULATE_DONE)
kvm_queue_exception(vcpu, UD_VECTOR);
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment