[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] x86: consolidate frame state manipulation functions
# HG changeset patch # User Jan Beulich <jbeulich@xxxxxxxx> # Date 1349334324 -7200 # Node ID 761def707575b154fa29e29d7962048352165c0d # Parent d0d7e20b998969234eb5dc41a56e91d7f7f1378a x86: consolidate frame state manipulation functions Rather than doing this in multiple places, have a single central function (decode_register()) to be used by all other code. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Keir Fraser <keir@xxxxxxx> --- diff -r d0d7e20b9989 -r 761def707575 xen/arch/x86/hvm/hvm.c --- a/xen/arch/x86/hvm/hvm.c Thu Oct 04 09:03:06 2012 +0200 +++ b/xen/arch/x86/hvm/hvm.c Thu Oct 04 09:05:24 2012 +0200 @@ -1585,7 +1585,7 @@ int hvm_mov_to_cr(unsigned int cr, unsig struct vcpu *curr = current; unsigned long val, *reg; - if ( (reg = get_x86_gpr(guest_cpu_user_regs(), gpr)) == NULL ) + if ( (reg = decode_register(gpr, guest_cpu_user_regs(), 0)) == NULL ) { gdprintk(XENLOG_ERR, "invalid gpr: %u\n", gpr); goto exit_and_crash; @@ -1627,7 +1627,7 @@ int hvm_mov_from_cr(unsigned int cr, uns struct vcpu *curr = current; unsigned long val = 0, *reg; - if ( (reg = get_x86_gpr(guest_cpu_user_regs(), gpr)) == NULL ) + if ( (reg = decode_register(gpr, guest_cpu_user_regs(), 0)) == NULL ) { gdprintk(XENLOG_ERR, "invalid gpr: %u\n", gpr); goto exit_and_crash; diff -r d0d7e20b9989 -r 761def707575 xen/arch/x86/hvm/vmx/vvmx.c --- a/xen/arch/x86/hvm/vmx/vvmx.c Thu Oct 04 09:03:06 2012 +0200 +++ b/xen/arch/x86/hvm/vmx/vvmx.c Thu Oct 04 09:05:24 2012 +0200 @@ -223,56 +223,18 @@ void __set_vvmcs(void *vvmcs, u32 vmcs_e static unsigned long reg_read(struct cpu_user_regs *regs, enum vmx_regs_enc index) { - unsigned long value = 0; + unsigned long *pval = decode_register(index, regs, 0); - switch ( index ) { - CASE_GET_REG(RAX, eax); - CASE_GET_REG(RCX, ecx); - CASE_GET_REG(RDX, edx); - CASE_GET_REG(RBX, ebx); - CASE_GET_REG(RBP, ebp); - CASE_GET_REG(RSI, esi); - CASE_GET_REG(RDI, edi); - CASE_GET_REG(RSP, esp); - CASE_GET_REG(R8, r8); - CASE_GET_REG(R9, r9); - CASE_GET_REG(R10, r10); - CASE_GET_REG(R11, r11); - CASE_GET_REG(R12, r12); - CASE_GET_REG(R13, r13); - CASE_GET_REG(R14, r14); - CASE_GET_REG(R15, r15); - default: - break; - } - - return value; + return *pval; } static void reg_write(struct cpu_user_regs *regs, enum vmx_regs_enc index, unsigned long value) { - switch ( index ) { - CASE_SET_REG(RAX, eax); - CASE_SET_REG(RCX, ecx); - CASE_SET_REG(RDX, edx); - CASE_SET_REG(RBX, ebx); - CASE_SET_REG(RBP, ebp); - CASE_SET_REG(RSI, esi); - CASE_SET_REG(RDI, edi); - CASE_SET_REG(RSP, esp); - CASE_SET_REG(R8, r8); - CASE_SET_REG(R9, r9); - CASE_SET_REG(R10, r10); - CASE_SET_REG(R11, r11); - CASE_SET_REG(R12, r12); - CASE_SET_REG(R13, r13); - CASE_SET_REG(R14, r14); - CASE_SET_REG(R15, r15); - default: - break; - } + unsigned long *pval = decode_register(index, regs, 0); + + *pval = value; } static inline u32 __n2_exec_control(struct vcpu *v) diff -r d0d7e20b9989 -r 761def707575 xen/arch/x86/traps.c --- a/xen/arch/x86/traps.c Thu Oct 04 09:03:06 2012 +0200 +++ b/xen/arch/x86/traps.c Thu Oct 04 09:05:24 2012 +0200 @@ -367,34 +367,6 @@ void vcpu_show_execution_state(struct vc vcpu_unpause(v); } -unsigned long *get_x86_gpr(struct cpu_user_regs *regs, unsigned int modrm_reg) -{ - void *p; - - switch ( modrm_reg ) - { - case 0: p = ®s->eax; break; - case 1: p = ®s->ecx; break; - case 2: p = ®s->edx; break; - case 3: p = ®s->ebx; break; - case 4: p = ®s->esp; break; - case 5: p = ®s->ebp; break; - case 6: p = ®s->esi; break; - case 7: p = ®s->edi; break; - case 8: p = ®s->r8; break; - case 9: p = ®s->r9; break; - case 10: p = ®s->r10; break; - case 11: p = ®s->r11; break; - case 12: p = ®s->r12; break; - case 13: p = ®s->r13; break; - case 14: p = ®s->r14; break; - case 15: p = ®s->r15; break; - default: p = NULL; break; - } - - return p; -} - static char *trapstr(int trapnr) { static char *strings[] = { diff -r d0d7e20b9989 -r 761def707575 xen/include/asm-x86/processor.h --- a/xen/include/asm-x86/processor.h Thu Oct 04 09:03:06 2012 +0200 +++ b/xen/include/asm-x86/processor.h Thu Oct 04 09:05:24 2012 +0200 @@ -552,8 +552,6 @@ void microcode_set_module(unsigned int); int microcode_update(XEN_GUEST_HANDLE(const_void), unsigned long len); int microcode_resume_cpu(int cpu); -unsigned long *get_x86_gpr(struct cpu_user_regs *regs, unsigned int modrm_reg); - #endif /* !__ASSEMBLY__ */ #endif /* __ASM_X86_PROCESSOR_H */ _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |