[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] introduce VM_EVENT_FLAG_SET_REGISTERS
commit 975efd3baa8dc5a0af8a9f3af6b95566339ae0b2 Author: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx> AuthorDate: Wed Sep 30 14:46:32 2015 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Wed Sep 30 14:46:32 2015 +0200 introduce VM_EVENT_FLAG_SET_REGISTERS A previous version of this patch dealing with support for skipping the current instruction when a vm_event response requested it computed the instruction length in the hypervisor, adding non-trivial code dependencies. This patch allows a userspace vm_event client to simply request that the guest's EIP is set to an arbitary value, computed by the introspection application. The registers that can now be set are EAX-EDX, ESP, EBP, ESI, EDI, R8-R15, EFLAGS, and EIP. CR0, CR3 and CR4 are not set, as at the time of vm_event_resume() we can't call hvm_set_cr{0,3,4}() and simply setting v->arch.hvm_vcpu.guest_cr[{0,3,4}] is unlikely to have the desired effect. The rest of the vm_event registers are not set because they're not being filled by hvm_event_fill_regs(), but only by p2m_vm_event_fill_regs(). Currently x86-only. The VCPU needs to be paused for this flag to take effect. Signed-off-by: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx> Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Acked-by: Tamas K Lengyel <tamas@xxxxxxxxxxxxx> --- xen/arch/x86/vm_event.c | 24 ++++++++++++++++++++++++ xen/common/vm_event.c | 3 +++ xen/include/asm-arm/vm_event.h | 6 ++++++ xen/include/asm-x86/vm_event.h | 2 ++ xen/include/public/vm_event.h | 7 +++++++ 5 files changed, 42 insertions(+), 0 deletions(-) diff --git a/xen/arch/x86/vm_event.c b/xen/arch/x86/vm_event.c index c38d37b..9677ecc 100644 --- a/xen/arch/x86/vm_event.c +++ b/xen/arch/x86/vm_event.c @@ -97,6 +97,30 @@ void vm_event_register_write_resume(struct vcpu *v, vm_event_response_t *rsp) } } +void vm_event_set_registers(struct vcpu *v, vm_event_response_t *rsp) +{ + v->arch.user_regs.eax = rsp->data.regs.x86.rax; + v->arch.user_regs.ebx = rsp->data.regs.x86.rbx; + v->arch.user_regs.ecx = rsp->data.regs.x86.rcx; + v->arch.user_regs.edx = rsp->data.regs.x86.rdx; + v->arch.user_regs.esp = rsp->data.regs.x86.rsp; + v->arch.user_regs.ebp = rsp->data.regs.x86.rbp; + v->arch.user_regs.esi = rsp->data.regs.x86.rsi; + v->arch.user_regs.edi = rsp->data.regs.x86.rdi; + + v->arch.user_regs.r8 = rsp->data.regs.x86.r8; + v->arch.user_regs.r9 = rsp->data.regs.x86.r9; + v->arch.user_regs.r10 = rsp->data.regs.x86.r10; + v->arch.user_regs.r11 = rsp->data.regs.x86.r11; + v->arch.user_regs.r12 = rsp->data.regs.x86.r12; + v->arch.user_regs.r13 = rsp->data.regs.x86.r13; + v->arch.user_regs.r14 = rsp->data.regs.x86.r14; + v->arch.user_regs.r15 = rsp->data.regs.x86.r15; + + v->arch.user_regs.eflags = rsp->data.regs.x86.rflags; + v->arch.user_regs.eip = rsp->data.regs.x86.rip; +} + /* * Local variables: * mode: C diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index ef84b0f..e1f9580 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -417,6 +417,9 @@ void vm_event_resume(struct domain *d, struct vm_event_domain *ved) if ( rsp.flags & VM_EVENT_FLAG_VCPU_PAUSED ) { + if ( rsp.flags & VM_EVENT_FLAG_SET_REGISTERS ) + vm_event_set_registers(v, &rsp); + if ( rsp.flags & VM_EVENT_FLAG_TOGGLE_SINGLESTEP ) vm_event_toggle_singlestep(d, v); diff --git a/xen/include/asm-arm/vm_event.h b/xen/include/asm-arm/vm_event.h index 976fdf1..4d0fbf7 100644 --- a/xen/include/asm-arm/vm_event.h +++ b/xen/include/asm-arm/vm_event.h @@ -47,4 +47,10 @@ void vm_event_register_write_resume(struct vcpu *v, vm_event_response_t *rsp) /* Not supported on ARM. */ } +static inline +void vm_event_set_registers(struct vcpu *v, vm_event_response_t *rsp) +{ + /* Not supported on ARM. */ +} + #endif /* __ASM_ARM_VM_EVENT_H__ */ diff --git a/xen/include/asm-x86/vm_event.h b/xen/include/asm-x86/vm_event.h index 2ff2cab..5aff834 100644 --- a/xen/include/asm-x86/vm_event.h +++ b/xen/include/asm-x86/vm_event.h @@ -42,4 +42,6 @@ void vm_event_toggle_singlestep(struct domain *d, struct vcpu *v); void vm_event_register_write_resume(struct vcpu *v, vm_event_response_t *rsp); +void vm_event_set_registers(struct vcpu *v, vm_event_response_t *rsp); + #endif /* __ASM_X86_VM_EVENT_H__ */ diff --git a/xen/include/public/vm_event.h b/xen/include/public/vm_event.h index ff2f217..9270d52 100644 --- a/xen/include/public/vm_event.h +++ b/xen/include/public/vm_event.h @@ -89,6 +89,13 @@ * by the altp2m_idx response field if possible. */ #define VM_EVENT_FLAG_ALTERNATE_P2M (1 << 7) +/* + * Set the vCPU registers to the values in the vm_event response. + * At the moment x86-only, applies to EAX-EDX, ESP, EBP, ESI, EDI, R8-R15, + * EFLAGS, and EIP. + * Requires the vCPU to be paused already (synchronous events only). + */ +#define VM_EVENT_FLAG_SET_REGISTERS (1 << 8) /* * Reasons for the vm event request -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |