From 086b0cef41f88768fc64e27d691ac10483bbf82d Mon Sep 17 00:00:00 2001 From: Kaiyeung Luk Date: Fri, 29 Mar 2024 16:15:26 -0700 Subject: [PATCH] i#6744: Use xrstors32 and xsaves32 for invariant checker test on x86-32. (#6747) tool.drcachesim.invariant_checker_test fails on x86-32 with the following error: 1/371 Test https://github.com/DynamoRIO/dynamorio/issues/11: tool.drcachesim.invariant_checker_test ...........................***Failed 0.04 sec Recording |Too many read records| in T1 @ ref # 16 (6 instrs since timestamp 0) Recording |Too many read records| in T1 @ ref # 17 (6 instrs since timestamp 0) Recording |Too many read records| in T1 @ ref # 18 (6 instrs since timestamp 0) Recording |Too many read records| in T1 @ ref # 19 (6 instrs since timestamp 0) Recording |Too many write records| in T1 @ ref # 21 (7 instrs since timestamp 0) Recording |Too many write records| in T1 @ ref # 22 (7 instrs since timestamp 0) Recording |Too many write records| in T1 @ ref # 23 (7 instrs since timestamp 0) Recording |Too many write records| in T1 @ ref # 24 (7 instrs since timestamp 0) Unexpected error: Too many read records at ref: 16 Unexpected error: Too many read records at ref: 17 Unexpected error: Too many read records at ref: 18 Unexpected error: Too many read records at ref: 19 Unexpected error: Too many write records at ref: 21 Unexpected error: Too many write records at ref: 22 Unexpected error: Too many write records at ref: 23 Unexpected error: Too many write records at ref: 24 OP_xsaves64 and OP_xrstors32 are marked as o64 (X86_INVALID) in core/ir/x86/decode_table.c. instr_is_xsave() and instr_is_xrstor() return false on x86-32, hence not skipping the number of read/write record check in the invariant check on x86_32. Use xrstors32 and xsaves32 instead for the test on x86_32. Fixes #6744 --- clients/drcachesim/tests/invariant_checker_test.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/clients/drcachesim/tests/invariant_checker_test.cpp b/clients/drcachesim/tests/invariant_checker_test.cpp index 2a8bdcf521b..0def88b3362 100644 --- a/clients/drcachesim/tests/invariant_checker_test.cpp +++ b/clients/drcachesim/tests/invariant_checker_test.cpp @@ -3272,12 +3272,21 @@ check_kernel_syscall_trace(void) instr_t *sti = INSTR_CREATE_sti(GLOBAL_DCONTEXT); instr_t *nop1 = XINST_CREATE_nop(GLOBAL_DCONTEXT); instr_t *nop2 = XINST_CREATE_nop(GLOBAL_DCONTEXT); +# if defined(X64) instr_t *xrstors = INSTR_CREATE_xrstors64( GLOBAL_DCONTEXT, opnd_create_base_disp(DR_REG_XCX, DR_REG_NULL, 0, 0, OPSZ_xsave)); instr_t *xsaves = INSTR_CREATE_xsaves64( GLOBAL_DCONTEXT, opnd_create_base_disp(DR_REG_XCX, DR_REG_NULL, 0, 0, OPSZ_xsave)); +# else + instr_t *xrstors = INSTR_CREATE_xrstors32( + GLOBAL_DCONTEXT, + opnd_create_base_disp(DR_REG_XCX, DR_REG_NULL, 0, 0, OPSZ_xsave)); + instr_t *xsaves = INSTR_CREATE_xsaves32( + GLOBAL_DCONTEXT, + opnd_create_base_disp(DR_REG_XCX, DR_REG_NULL, 0, 0, OPSZ_xsave)); +# endif instr_t *hlt = INSTR_CREATE_hlt(GLOBAL_DCONTEXT); instr_t *nop3 = XINST_CREATE_nop(GLOBAL_DCONTEXT); instr_t *prefetch = INSTR_CREATE_prefetchnta(