# HG changeset patch # User Alex Olson <alex.ol...@starlab.io> # Date 1657558891 18000 # Mon Jul 11 12:01:31 2022 -0500 # Node ID 0552b7ac10e28b378dd139e5ca3838039c472827 # Parent fa60b63892e8f9d4278950b44ed136d2b12d19cc Correct IDT exception handler addresses
The exception handlers configured in the IDT weren't properly executed during exceptions as _start/TBOOT_START are not 64K aligned (0x804000). This revision corrects the arithmetic so that the "int_handler" routine gets properly executed instead of "int_handler - 0x4000". NOTE: A simple way to test this is to insert 'asm volatile("ud2");' in begin_launch(). Signed-off-by: Alex Olson <alex.ol...@starlab.io> diff -r fa60b63892e8 -r 0552b7ac10e2 tboot/common/boot.S --- a/tboot/common/boot.S Fri Jun 17 11:39:11 2022 +0300 +++ b/tboot/common/boot.S Mon Jul 11 12:01:31 2022 -0500 @@ -400,23 +400,28 @@ .align 8 +/* Below assumes "_start" is exactly at TBOOT_START and is needed to allow arithmetic: */ +#define INT_HANDLER_ADDR (int_handler - _start + TBOOT_START) +#define INT_HANDLER_LO16 (INT_HANDLER_ADDR & 0xffff) +#define INT_HANDLER_HI16 (INT_HANDLER_ADDR >> 16) + idt_table: .rept 18 - .word int_handler - _start + .word INT_HANDLER_LO16 .word cs_sel .word 0x8e00 /* present, DPL=0, 32b, interrupt */ - .word (int_handler - _start + TBOOT_START) >> 16 + .word INT_HANDLER_HI16 .endr /* for machine-check exception */ - .word int_handler - _start + .word INT_HANDLER_LO16 .word cs_sel .word 0x8f00 /* present, DPL=0, 32b, trap */ - .word (int_handler - _start + TBOOT_START) >> 16 + .word INT_HANDLER_HI16 .rept 237 - .word int_handler - _start + .word INT_HANDLER_LO16 .word cs_sel .word 0x8e00 /* present, DPL=0, 32b, interrupt */ - .word (int_handler - _start + TBOOT_START) >> 16 + .word INT_HANDLER_HI16 .endr idt_table_end: _______________________________________________ tboot-devel mailing list tboot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tboot-devel