[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH V2 2/2] xen: 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. In the future, other registers can also be set via a vm_event reply by using this flag. The VCPU needs to be paused for this flag to take effect. Signed-off-by: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx> --- Changes since V1: - Renamed the patch (VM_EVENT_FLAG_SET_EIP -> VM_EVENT_FLAG_SET_REGISTERS). - As suggested by Tamas Lengyel, EIP is now being set via a dedicated generic vm_event_set_registers() function that can be extended to set other registers in the future. --- xen/arch/x86/vm_event.c | 5 +++++ 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 | 6 ++++++ 5 files changed, 22 insertions(+) diff --git a/xen/arch/x86/vm_event.c b/xen/arch/x86/vm_event.c index e4e0aa4..a59ba79 100644 --- a/xen/arch/x86/vm_event.c +++ b/xen/arch/x86/vm_event.c @@ -95,6 +95,11 @@ 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.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..51539af 100644 --- a/xen/include/public/vm_event.h +++ b/xen/include/public/vm_event.h @@ -89,6 +89,12 @@ * 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. + * Currently only applies to 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 -- 1.7.9.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |