@@ -27,6 +27,30 @@ impl Lapic {
2727 /// # Safety
2828 /// The caller must ensure that the LAPIC base address is valid and aligned.
2929 pub unsafe fn new ( base : * mut u8 ) -> Self {
30+ // FIXME(qix-): I have no idea why this works. I have gone down the
31+ // FIXME(qix-): rabbit hole of even rewriting literally everything
32+ // FIXME(qix-): as volatile reads to a painstaking amount and
33+ // FIXME(qix-): Rust still miscompiles this. For some reason, this
34+ // FIXME(qix-): black box solves the problem.
35+ // FIXME(qix-):
36+ // FIXME(qix-): From what I can tell, without this, the compiler does some
37+ // FIXME(qix-): incredibly aggressive optimization to even the caller that
38+ // FIXME(qix-): completely breaks not only the pointer value but also how
39+ // FIXME(qix-): ACPI tables are read in general. It doesn't (seemingly)
40+ // FIXME(qix-): appear to be a volatility issue, despite my inclinations.
41+ // FIXME(qix-):
42+ // FIXME(qix-): I'm almost definitely invoking some undefined behavior here,
43+ // FIXME(qix-): but given that I've gone to great lengths to make this "safe"
44+ // FIXME(qix-): without any success, I'm at a loss. At the time of writing,
45+ // FIXME(qix-): this only happens in release mode, when the debug logging macros
46+ // FIXME(qix-): are disabled (I assume since there's one in the panic handler).
47+ // FIXME(qix-):
48+ // FIXME(qix-): If you have any idea what's happening, PLEASE let me know.
49+ // FIXME(qix-):
50+ // FIXME(qix-): Time spent on this: 8 hours.
51+ :: core:: hint:: black_box ( & base) ;
52+
53+ assert ! ( !base. is_null( ) , "LAPIC base is null" ) ;
3054 assert_eq ! (
3155 base. align_offset( 16 ) ,
3256 0 ,
0 commit comments