[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] x86: consolidate frame state manipulation functions


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Thu, 04 Oct 2012 21:11:07 +0000
  • Delivery-date: Thu, 04 Oct 2012 21:11:20 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# 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 = &regs->eax; break;
-    case  1: p = &regs->ecx; break;
-    case  2: p = &regs->edx; break;
-    case  3: p = &regs->ebx; break;
-    case  4: p = &regs->esp; break;
-    case  5: p = &regs->ebp; break;
-    case  6: p = &regs->esi; break;
-    case  7: p = &regs->edi; break;
-    case  8: p = &regs->r8;  break;
-    case  9: p = &regs->r9;  break;
-    case 10: p = &regs->r10; break;
-    case 11: p = &regs->r11; break;
-    case 12: p = &regs->r12; break;
-    case 13: p = &regs->r13; break;
-    case 14: p = &regs->r14; break;
-    case 15: p = &regs->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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.