x86emul: add read-modify-write hook
authorJan Beulich <jbeulich@suse.com>
Thu, 22 Mar 2018 09:39:32 +0000 (10:39 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 22 Mar 2018 09:39:32 +0000 (10:39 +0100)
commitf26186f2d4314ab57826a593126b5047a96fd4f4
tree277740269c872a89584e58a08657e6709edc8caa
parent3aaa72b3f1132d078e0b1f1af5b2bcc2d1629b92
x86emul: add read-modify-write hook

In order to correctly emulate read-modify-write insns, especially
LOCKed ones, we should not issue reads and writes separately. Use a
new hook to combine both, and don't uniformly read the memory
destination anymore. Instead, DstMem opcodes without Mov now need to
have done so in their respective case blocks.

Also strip bogus _ prefixes from macro parameters when this only affects
lines which are being changed anyway.

In the test harness, besides some re-ordering to facilitate running a
few tests twice (one without and a second time with the .rmw hook in
place), tighten a few EFLAGS checks and add a test for NOT with memory
operand (in particular to verify EFLAGS don't get altered there).

For now make use of the hook optional for callers; eventually we may
want to consider making this mandatory.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/tests/x86_emulator/test_x86_emulator.c
xen/arch/x86/x86_emulate/x86_emulate.c
xen/arch/x86/x86_emulate/x86_emulate.h