[PATCH kvm-unit-tests 1/3] x86: Check rflags.rf is cleared after emulation

From: Nadav Amit
Date: Mon Jul 21 2014 - 07:41:25 EST


RFLAGS.RF should be cleared after every instruction emulation. Recently
discovered bug indicated this is not the case. This patch adds a test to check
this behavior. It is done by setting RF, executing IRET and checking whether
the saved RF is cleared. Since the flags are saved several instructions after
IRET is executed, RF should be cleared.

Signed-off-by: Nadav Amit <namit@xxxxxxxxxxxxxxxxx>
---
x86/realmode.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/x86/realmode.c b/x86/realmode.c
index 10c3e03..09e6aa7 100644
--- a/x86/realmode.c
+++ b/x86/realmode.c
@@ -744,7 +744,7 @@ void test_iret()
MK_INSN(iret_flags32, "pushfl\n\t"
"popl %eax\n\t"
"andl $~0x2, %eax\n\t"
- "orl $0xffc08028, %eax\n\t"
+ "orl $0xffc18028, %eax\n\t"
"pushl %eax\n\t"
"pushl %cs\n\t"
"call 1f\n\t"
@@ -773,6 +773,7 @@ void test_iret()

exec_in_big_real_mode(&insn_iret_flags32);
report("iret 3", R_AX, 1);
+ report("rflags.rf", ~0, !(outregs.eflags & (1 << 16)));

exec_in_big_real_mode(&insn_iret_flags16);
report("iret 4", R_AX, 1);
--
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/