WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] A simple clean up of __get_instruction_length & __update_gue

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] A simple clean up of __get_instruction_length & __update_guest_eip
From: "Dong, Eddie" <eddie.dong@xxxxxxxxx>
Date: Wed, 15 Sep 2010 22:34:24 +0800
Accept-language: en-US
Acceptlanguage: en-US
Cc: "Dong, Eddie" <eddie.dong@xxxxxxxxx>
Delivery-date: Wed, 15 Sep 2010 07:40:11 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: ActU4xgk2rNW4igXRHu7os/i32rS5A==
Thread-topic: A simple clean up of __get_instruction_length & __update_guest_eip
Replace so many sparsed __get_instruction_length & __update_guest_eip with one 
function call.

Signed-off-by: Eddie Dong <eddie.dong@xxxxxxxxx>

diff -r 221cf46cbf2c xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Wed Sep 15 17:31:53 2010 +0800
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Wed Sep 15 17:46:24 2010 +0800
@@ -1494,6 +1494,14 @@
         vmx_inject_hw_exception(TRAP_debug, HVM_DELIVER_NO_ERROR_CODE);
 }
 
+static void update_guest_eip(void)
+{
+    unsigned long inst_len;
+
+    inst_len = __get_instruction_length();
+    __update_guest_eip(inst_len);
+}
+
 static void vmx_fpu_dirty_intercept(void)
 {
     struct vcpu *curr = current;
@@ -2244,8 +2252,7 @@
     if ( (((exit_qualification >> 12) & 0xf) == 1) &&
          ((exit_qualification & 0xfff) == APIC_EOI) )
     {
-        int inst_len = __get_instruction_length(); /* Safe: APIC data write */
-        __update_guest_eip(inst_len);
+        update_guest_eip();
         vlapic_EOI_set(vcpu_vlapic(current));
         return 1;
     }
@@ -2424,8 +2431,7 @@
         case TRAP_int3:
             if ( !v->domain->debugger_attached )
                 goto exit_and_crash;
-            inst_len = __get_instruction_length(); /* Safe: INT3 */
-            __update_guest_eip(inst_len);
+            update_guest_eip();
             current->arch.gdbsx_vcpu_event = TRAP_int3;
             domain_pause_for_debugger();
             break;
@@ -2516,18 +2522,15 @@
         break;
     }
     case EXIT_REASON_CPUID:
-        inst_len = __get_instruction_length(); /* Safe: CPUID */
-        __update_guest_eip(inst_len);
+        update_guest_eip();
         vmx_do_cpuid(regs);
         break;
     case EXIT_REASON_HLT:
-        inst_len = __get_instruction_length(); /* Safe: HLT */
-        __update_guest_eip(inst_len);
+        update_guest_eip();
         hvm_hlt(regs->eflags);
         break;
     case EXIT_REASON_INVLPG:
-        inst_len = __get_instruction_length(); /* Safe: INVLPG */
-        __update_guest_eip(inst_len);
+        update_guest_eip();
         exit_qualification = __vmread(EXIT_QUALIFICATION);
         vmx_invlpg_intercept(exit_qualification);
         break;
@@ -2535,19 +2538,17 @@
         regs->ecx = hvm_msr_tsc_aux(v);
         /* fall through */
     case EXIT_REASON_RDTSC:
-        inst_len = __get_instruction_length();
-        __update_guest_eip(inst_len);
+        update_guest_eip();
         hvm_rdtsc_intercept(regs);
         break;
     case EXIT_REASON_VMCALL:
     {
         int rc;
         HVMTRACE_1D(VMMCALL, regs->eax);
-        inst_len = __get_instruction_length(); /* Safe: VMCALL */
         rc = hvm_do_hypercall(regs);
         if ( rc != HVM_HCALL_preempted )
         {
-            __update_guest_eip(inst_len);
+            update_guest_eip();
             if ( rc == HVM_HCALL_invalidate )
                 send_invalidate_req();
         }
@@ -2556,9 +2557,8 @@
     case EXIT_REASON_CR_ACCESS:
     {
         exit_qualification = __vmread(EXIT_QUALIFICATION);
-        inst_len = __get_instruction_length(); /* Safe: MOV Cn, LMSW, CLTS */
         if ( vmx_cr_access(exit_qualification, regs) )
-            __update_guest_eip(inst_len);
+            update_guest_eip();
         break;
     }
     case EXIT_REASON_DR_ACCESS:
@@ -2568,22 +2568,20 @@
     case EXIT_REASON_MSR_READ:
     {
         uint64_t msr_content;
-        inst_len = __get_instruction_length(); /* Safe: RDMSR */
         if ( hvm_msr_read_intercept(regs->ecx, &msr_content) == X86EMUL_OKAY )
         {
             regs->eax = (uint32_t)msr_content;
             regs->edx = (uint32_t)(msr_content >> 32);
-            __update_guest_eip(inst_len);
+            update_guest_eip();
         }
         break;
     }
     case EXIT_REASON_MSR_WRITE:
     {
         uint64_t msr_content;
-        inst_len = __get_instruction_length(); /* Safe: WRMSR */
         msr_content = ((uint64_t)regs->edx << 32) | (uint32_t)regs->eax;
         if ( hvm_msr_write_intercept(regs->ecx, msr_content) == X86EMUL_OKAY )
-            __update_guest_eip(inst_len);
+            update_guest_eip();
         break;
     }
 
@@ -2652,8 +2650,7 @@
     case EXIT_REASON_INVD:
     case EXIT_REASON_WBINVD:
     {
-        inst_len = __get_instruction_length(); /* Safe: INVD, WBINVD */
-        __update_guest_eip(inst_len);
+        update_guest_eip();
         vmx_wbinvd_intercept();
         break;
     }
@@ -2686,8 +2683,7 @@
         u64 new_bv  =  (((u64)regs->edx) << 32) | regs->eax;
         if ( vmx_handle_xsetbv(new_bv) == 0 )
         {
-            inst_len = __get_instruction_length();
-            __update_guest_eip(inst_len);
+            update_guest_eip();
         }
         break;
     }

Attachment: clean1.patch
Description: clean1.patch

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>