From: Billy Laws blaws05@gmail.com
--- dlls/ntdll/tests/exception.c | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)
diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 7d939acb3d1..a94ef3eef69 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -8049,6 +8049,67 @@ static void test_rtlraiseexception(void) run_rtlraiseexception_test(EXCEPTION_INVALID_HANDLE); }
+static DWORD brk_exception_handler_code; + +static DWORD WINAPI brk_exception_handler( EXCEPTION_RECORD *rec, void *frame, + CONTEXT *context, DISPATCHER_CONTEXT *dispatcher ) +{ + ok( rec->ExceptionCode == brk_exception_handler_code, "got: %08lx\n", rec->ExceptionCode ); + ok( rec->NumberParameters == 0, "got: %ld\n", rec->NumberParameters ); + ok( rec->ExceptionAddress == (void *)context->Pc, "got addr: %p, pc: %p\n", rec->ExceptionAddress, context->Pc ); + context->Pc += 4; + return ExceptionContinueExecution; +} + + +static void test_brk(void) +{ + DWORD call_brk[] = + { + 0xa9bf7bfd, /* 00: stp x29, x30, [sp, #-16]! */ + 0x910003fd, /* 04: mov x29, sp */ + 0x00000000, /* 08: <filled in later> */ + 0xd503201f, /* 0c: nop */ + 0xa8c17bfd, /* 10: ldp x29, x30, [sp], #16 */ + 0xd65f03c0, /* 14: ret */ + }; + + /* brk #0xf000 is tested as part of breakpoint tests */ + + brk_exception_handler_code = STATUS_ASSERTION_FAILURE; + call_brk[2] = 0xd43e0020; /* 08: brk #0xf001 */ + run_exception_test( brk_exception_handler, NULL, call_brk, + sizeof(call_brk), sizeof(call_brk), + PAGE_EXECUTE_READ, UNW_FLAG_EHANDLER, + 0, 0 ); + + /* FIXME: brk #0xf002 needs debug service tests */ + + /* brk #0xf003 is tested as part of fastfail tests*/ + + brk_exception_handler_code = EXCEPTION_INT_DIVIDE_BY_ZERO; + call_brk[2] = 0xd43e0080; /* 08: brk #0xf004 */ + run_exception_test( brk_exception_handler, NULL, call_brk, + sizeof(call_brk), sizeof(call_brk), + PAGE_EXECUTE_READ, UNW_FLAG_EHANDLER, + 0, 0 ); + + /* Any unknown immediate raises EXCEPTION_ILLEGAL_INSTRUCTION */ + + brk_exception_handler_code = EXCEPTION_ILLEGAL_INSTRUCTION; + call_brk[2] = 0xd43e00a0; /* 08: brk #0xf005 */ + run_exception_test( brk_exception_handler, NULL, call_brk, + sizeof(call_brk), sizeof(call_brk), + PAGE_EXECUTE_READ, UNW_FLAG_EHANDLER, + 0, 0 ); + + brk_exception_handler_code = EXCEPTION_ILLEGAL_INSTRUCTION; + call_brk[2] = 0xd4200000; /* 08: brk #0x0 */ + run_exception_test( brk_exception_handler, NULL, call_brk, + sizeof(call_brk), sizeof(call_brk), + PAGE_EXECUTE_READ, UNW_FLAG_EHANDLER, + 0, 0 ); +}
static LONG consolidate_dummy_called; static LONG pass; @@ -11959,6 +12020,7 @@ START_TEST(exception) #elif defined(__aarch64__)
test_continue(); + test_brk(); test_nested_exception(); test_collided_unwind(); test_restore_context();
From: Billy Laws blaws05@gmail.com
--- dlls/ntdll/unix/signal_arm64.c | 43 +++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 14 deletions(-)
diff --git a/dlls/ntdll/unix/signal_arm64.c b/dlls/ntdll/unix/signal_arm64.c index 6fd893b390f..5680712c845 100644 --- a/dlls/ntdll/unix/signal_arm64.c +++ b/dlls/ntdll/unix/signal_arm64.c @@ -1135,29 +1135,44 @@ static void trap_handler( int signal, siginfo_t *siginfo, void *sigcontext ) rec.ExceptionCode = EXCEPTION_SINGLE_STEP; break; case TRAP_BRKPT: - default: /* debug exceptions do not update ESR on Linux, so we fetch the instruction directly. */ if (!(PSTATE_sig( context ) & 0x10) && /* AArch64 (not WoW) */ - !(PC_sig( context ) & 3) && - *(ULONG *)PC_sig( context ) == 0xd43e0060UL) /* brk #0xf003 -> __fastfail */ - { - rec.ExceptionCode = STATUS_STACK_BUFFER_OVERRUN; - rec.ExceptionFlags = EXCEPTION_NONCONTINUABLE; - rec.NumberParameters = 1; - rec.ExceptionInformation[0] = ctx.X[0]; - NtRaiseException( &rec, &ctx, FALSE ); - return; + !(PC_sig( context ) & 3)) { + ULONG imm = (*(ULONG *)PC_sig( context ) >> 5) & 0xffff; + switch (imm) + { + case 0xf000: + ctx.Pc += 4; /* skip the brk instruction */ + rec.ExceptionCode = EXCEPTION_BREAKPOINT; + rec.NumberParameters = 1; + break; + case 0xf001: + rec.ExceptionCode = STATUS_ASSERTION_FAILURE; + break; + case 0xf003: + rec.ExceptionCode = STATUS_STACK_BUFFER_OVERRUN; + rec.ExceptionFlags = EXCEPTION_NONCONTINUABLE; + rec.NumberParameters = 1; + rec.ExceptionInformation[0] = ctx.X[0]; + NtRaiseException( &rec, &ctx, FALSE ); + break; + case 0xf004: + rec.ExceptionCode = EXCEPTION_INT_DIVIDE_BY_ZERO; + break; + default: + rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; + break; + } } - ctx.Pc += 4; /* skip the brk instruction */ - rec.ExceptionCode = EXCEPTION_BREAKPOINT; - rec.NumberParameters = 1; + break; + default: + rec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; break; }
setup_raise_exception( sigcontext, &rec, &ctx ); }
- /********************************************************************** * fpe_handler *
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=150060
Your paranoid android.
=== debian11b (64 bit WoW report) ===
user32: win.c:4070: Test failed: Expected active window 000000000282014E, got 0000000000000000. win.c:4071: Test failed: Expected focus window 000000000282014E, got 0000000000000000.
Jinoh Kang (@iamahuman) commented about dlls/ntdll/tests/exception.c:
+{
- DWORD call_brk[] =
- {
0xa9bf7bfd, /* 00: stp x29, x30, [sp, #-16]! */
0x910003fd, /* 04: mov x29, sp */
0x00000000, /* 08: <filled in later> */
0xd503201f, /* 0c: nop */
0xa8c17bfd, /* 10: ldp x29, x30, [sp], #16 */
0xd65f03c0, /* 14: ret */
- };
- /* brk #0xf000 is tested as part of breakpoint tests */
- brk_exception_handler_code = STATUS_ASSERTION_FAILURE;
- call_brk[2] = 0xd43e0020; /* 08: brk #0xf001 */
- run_exception_test( brk_exception_handler, NULL, call_brk,
Missing `todo_wine`s.
(Yes, I know approximately no one runs aarch64 tests. Still, it'd be a shame to have un-bisectable test commits.)