Skip to contentSkip to conversation

x86: don't clear high 32 bits of RAX on sub-word guest I/O port reads

PATCH In review Jan Beulich 3 participants 4 messages May 8, 2015 – May 12, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: don't clear high 32 bits of RAX on sub-word guest I/O port reads

1- or 2-byte operations never alter the high halves of registers.

xen/arch/x86/traps.c +1 -1
@@ -2234,7 +2234,7 @@ static int emulate_privileged_op(struct 
             if ( op_bytes == 4 )
                 regs->eax = 0;
             else
-                regs->eax &= ~((1u << (op_bytes * 8)) - 1);
+                regs->eax &= ~((1 << (op_bytes * 8)) - 1);
             regs->eax |= guest_io_read(port, op_bytes, v, regs);
         }
         bpmatch = check_guest_io_breakpoint(v, port, op_bytes);

x86: don't clear high 32 bits of RAX on sub-word guest I/O port reads

1- or 2-byte operations never alter the high halves of registers.

xen/arch/x86/traps.c +1 -1
@@ -2234,7 +2234,7 @@ static int emulate_privileged_op(struct 
             if ( op_bytes == 4 )
                 regs->eax = 0;
             else
-                regs->eax &= ~((1u << (op_bytes * 8)) - 1);
+                regs->eax &= ~((1 << (op_bytes * 8)) - 1);
             regs->eax |= guest_io_read(port, op_bytes, v, regs);
         }
         bpmatch = check_guest_io_breakpoint(v, port, op_bytes);

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

Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Jan Beulich

1- or 2-byte operations never alter the high halves of registers.

Quoted 15 lines
xen/arch/x86/traps.c +1 -1
@@ -2234,7 +2234,7 @@ static int emulate_privileged_op(struct 
             if ( op_bytes == 4 )
                 regs->eax = 0;
             else
-                regs->eax &= ~((1u << (op_bytes * 8)) - 1);
+                regs->eax &= ~((1 << (op_bytes * 8)) - 1);
             regs->eax |= guest_io_read(port, op_bytes, v, regs);
         }
         bpmatch = check_guest_io_breakpoint(v, port, op_bytes);
#2 lore raw
In reply to Jan Beulich
Quoted 2 lines · Jan Beulich

1- or 2-byte operations never alter the high halves of registers.

That is impressive. How possibly did you spot this?

Was it due to reviewing some other code that got you looking at this?

Thanks!

Quoted 39 lines
xen/arch/x86/traps.c +1 -1
@@ -2234,7 +2234,7 @@ static int emulate_privileged_op(struct 
             if ( op_bytes == 4 )
                 regs->eax = 0;
             else
-                regs->eax &= ~((1u << (op_bytes * 8)) - 1);
+                regs->eax &= ~((1 << (op_bytes * 8)) - 1);
             regs->eax |= guest_io_read(port, op_bytes, v, regs);
         }
         bpmatch = check_guest_io_breakpoint(v, port, op_bytes);

x86: don't clear high 32 bits of RAX on sub-word guest I/O port reads

1- or 2-byte operations never alter the high halves of registers.

xen/arch/x86/traps.c +1 -1
@@ -2234,7 +2234,7 @@ static int emulate_privileged_op(struct 
             if ( op_bytes == 4 )
                 regs->eax = 0;
             else
-                regs->eax &= ~((1u << (op_bytes * 8)) - 1);
+                regs->eax &= ~((1 << (op_bytes * 8)) - 1);
             regs->eax |= guest_io_read(port, op_bytes, v, regs);
         }
         bpmatch = check_guest_io_breakpoint(v, port, op_bytes);

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

#3 lore raw
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 11.05.15 at 17:15, <[email protected]> wrote:
Quoted 2 lines · Jan Beulich

1- or 2-byte operations never alter the high halves of registers.

That is impressive. How possibly did you spot this?

Was it due to reviewing some other code that got you looking at this?

Yes, while reviewing the patches from Roger (or rather investigating the need to revert).

Jan