RFC ARM: introduce sjlj structured exception handling
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest4 patches 2 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | ARM: implement sjlj-based TRY/CATCH exception handlingcommon/ common/ include/ +1 more | +860 | 2 replies | |
| 2/4 | startup: wrap barebox startup in TRY/CATCHcommon/ | +25 | 0 replies | |
| 3/4 | ARM: rethrow CPU exceptions as sjlj-exceptionsarch/ common/ | +39 | 0 replies | |
| 4/4 | commands: implement except test commandcommands/ commands/ commands/ | +136 | 0 replies |
Reviews trailers per patch
All 4 patches have a Reviewed-by or Acked-by.
| Patch | Ahmad Fatoum |
|---|---|
| 1/4 | R-b |
| 2/4 | R-b |
| 3/4 | R-b |
| 4/4 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [RFC PATCH 0/4] ARM: introduce sjlj structured exception handling
We are already using data_abort_mask at a hand full of places to integrate Hardware exceptions with normal flow control mechanisms.
While cumbersome to use, these few code blocks have a terrific track record in stability, having so far never crashed due to NULL pointer exceptions.
Having something like this everywhere in barebox would have been great for software stability[1][2][3][4][5] in the past.
This patch takes this idea a bit further, by introducing new TRY/CATCH primitives, inspired by Microsoft Visual C Structured Exception Handling (SEH), into barebox. These can now be wielded to beat any and all error conditions into total and utter submission:
u32 cycles;
TRY {
u32 div = readl(NULL);
cycles = ticks / div;
cycles = ((void (*)())cycles)();
if (cycles == 0)
THROW(RuntimeError);
} CATCH_3(DataAbortException, UndefinedInstructionException, RuntimerError) {
cycles = 42;
}
ENDTRY;As a first step, this patch series is introduced as a RFC for ARM. Other platforms can follow when setjmp/longjump (sjlj) is implemented for them. This will allow all barebox hackers to benefit from state-of-the-art tooling in building the same highly robust and crash resistant software that has been possible since SEH's introduction with Windows 95.
This is of course not only limited to hardware faults, as the example above shows.
By blurring the line between hardware fault handling and software error propagation, it also allows a more natural control flow than having to deal with arcane UNIX signals running in restricted contexts or *shudder* check against NULL before using a pointer.
Hoping you are as hyped as I am.
[1]: dc5100e6b ("state: backend_storage: deal
gracefully with runtime bucket corruption")
[2]: 09d11c546 ("video/ssd1307fb: fix NULL pointer dereference in probe") [3]: 671a7d5df ("driver: bail out, don't crash, if drv->name is not set") [4]: 8a774977b ("mci: dove: fix dereference of nullable pointer") [5]: bb414a64b ("drivers: video: Fix parsing oftree timings")
Cheers,
Ahmad (4):
ARM: implement sjlj-based TRY/CATCH exception handling
startup: wrap barebox startup in TRY/CATCH
ARM: rethrow CPU exceptions as sjlj-exceptions
commands: implement except test command
arch/arm/cpu/interrupts.c | 32 +-- commands/Kconfig | 5 + commands/Makefile | 1 + commands/except.c | 130 ++++++++++++ common/Makefile | 3 + common/except.c | 282 +++++++++++++++++++++++++ common/startup.c | 70 +++++-- include/except.h | 156 ++++++++++++++ include/exceptions.h | 419 ++++++++++++++++++++++++++++++++++++++ 9 files changed, 1058 insertions(+), 40 deletions(-) create mode 100644 commands/except.c create mode 100644 common/except.c create mode 100644 include/except.h create mode 100644 include/exceptions.h
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox