Skip to contentSkip to conversation

x86/emul: Further simplify DstBitBase handling

PATCH In review Andrew Cooper 2 participants 2 messages Dec 14, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/emul: Further simplify DstBitBase handling

The masking of src.val is common to both paths. Move it later and simplify the entry condition for adjusting the memory operand.

---
CC: Jan Beulich <[email protected]>

---
 xen/arch/x86/x86_emulate/x86_emulate.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
xen/arch/x86/x86_emulate/x86_emulate.c +5 -6
index 1b5becf..05fa342 100644
@@ -2637,11 +2637,7 @@ x86_emulate(
         }
         break;
     case DstBitBase:
-        if ( ((d & SrcMask) == SrcImmByte) || (ea.type == OP_REG) )
-        {
-            src.val &= (op_bytes << 3) - 1;
-        }
-        else
+        if ( ea.type == OP_MEM )
         {
             /*
              * Instructions such as bt can reference an arbitrary offset from
@@ -2664,8 +2660,11 @@ x86_emulate(
                     op_bytes + (((-src.val - 1) >> 3) & ~(op_bytes - 1L));
             else
                 ea.mem.off += (src.val >> 3) & ~(op_bytes - 1L);
-            src.val &= (op_bytes << 3) - 1;
         }
+
+        /* Bit index always truncated to within range. */
+        src.val &= (op_bytes << 3) - 1;
+
         d = (d & ~DstMask) | DstMem;
         /* Becomes a normal DstMem operation from here on. */
     case DstMem:
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 14.12.16 at 12:04, <[email protected]> wrote:

The masking of src.val is common to both paths. Move it later and simplify the entry condition for adjusting the memory operand.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel