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

[Xen-devel] [PATCH v5 3/4] x86emul: use switch()-wide local variable 'cr4'



... rather than various smaller scope ones.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
v2: Re-base over PUSHF adjustment in earlier patch.

--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -862,13 +862,10 @@ do {
 #define put_fpu(_fic)                                           \
 do {                                                            \
     _put_fpu();                                                 \
-    if( (_fic)->exn_raised == EXC_XM && ops->read_cr )          \
-    {                                                           \
-        unsigned long cr4;                                      \
-        if ( (ops->read_cr(4, &cr4, ctxt) == X86EMUL_OKAY) &&   \
-             !(cr4 & CR4_OSXMMEXCPT) )                          \
-            (_fic)->exn_raised = EXC_UD;                        \
-    }                                                           \
+    if ( (_fic)->exn_raised == EXC_XM && ops->read_cr &&        \
+         ops->read_cr(4, &cr4, ctxt) == X86EMUL_OKAY &&         \
+         !(cr4 & CR4_OSXMMEXCPT) )                              \
+        (_fic)->exn_raised = EXC_UD;                            \
     generate_exception_if((_fic)->exn_raised >= 0,              \
                           (_fic)->exn_raised);                  \
 } while (0)
@@ -1183,7 +1180,7 @@ _mode_iopl(
     _iopl;                                      \
 })
 #define mode_vif() ({                                        \
-    unsigned long cr4 = 0;                                   \
+    cr4 = 0;                                                 \
     if ( ops->read_cr && get_cpl(ctxt, ops) == 3 )           \
     {                                                        \
         rc = ops->read_cr(4, &cr4, ctxt);                    \
@@ -2783,6 +2780,7 @@ x86_emulate(
     {
         enum x86_segment seg;
         struct segment_register cs, sreg;
+        unsigned long cr4;
 
     case 0x00 ... 0x05: add: /* add */
         emulate_2op_SrcV("add", src, dst, _regs._eflags);
@@ -3281,8 +3279,7 @@ x86_emulate(
         if ( (_regs._eflags & EFLG_VM) &&
              MASK_EXTR(_regs._eflags, EFLG_IOPL) != 3 )
         {
-            unsigned long cr4 = 0;
-
+            cr4 = 0;
             if ( op_bytes == 2 && ops->read_cr )
             {
                 rc = ops->read_cr(4, &cr4, ctxt);
@@ -3300,8 +3297,8 @@ x86_emulate(
 
     case 0x9d: /* popf */ {
         uint32_t mask = EFLG_VIP | EFLG_VIF | EFLG_VM;
-        unsigned long cr4 = 0;
 
+        cr4 = 0;
         if ( !mode_ring0() )
         {
             if ( _regs._eflags & EFLG_VM )
@@ -4586,9 +4583,6 @@ x86_emulate(
 
 #ifdef __XEN__
         case 0xd1: /* xsetbv */
-        {
-            unsigned long cr4;
-
             generate_exception_if(vex.pfx, EXC_UD);
             if ( !ops->read_cr || ops->read_cr(4, &cr4, ctxt) != X86EMUL_OKAY )
                 cr4 = 0;
@@ -4598,7 +4592,6 @@ x86_emulate(
                                                 _regs._eax | (_regs.rdx << 
32)),
                                   EXC_GP, 0);
             goto no_writeback;
-        }
 #endif
 
         case 0xd4: /* vmfunc */
@@ -5126,8 +5119,8 @@ x86_emulate(
         break;
 
     case X86EMUL_OPC(0x0f, 0x31): rdtsc: /* rdtsc */ {
-        unsigned long cr4;
         uint64_t val;
+
         if ( !mode_ring0() )
         {
             fail_if(ops->read_cr == NULL);
@@ -5499,9 +5492,6 @@ x86_emulate(
         break;
 
     case X86EMUL_OPC_F3(0x0f, 0xae): /* Grp15 */
-    {
-        unsigned long cr4;
-
         fail_if(modrm_mod != 3);
         generate_exception_if((modrm_reg & 4) || !mode_64bit(), EXC_UD);
         fail_if(!ops->read_cr);
@@ -5536,7 +5526,6 @@ x86_emulate(
                 goto done;
         }
         break;
-    }
 
     case X86EMUL_OPC(0x0f, 0xaf): /* imul */
         emulate_2op_SrcV_srcmem("imul", src, dst, _regs._eflags);


Attachment: x86emul-fold-CR4.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

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