On 08.07.2018 17:30, Mouse wrote: > Caveat: this is all opinion. I'm not the one doing the work here. > >>>>> src/sys/arch/x86/x86: mpbios.c > >>>>> Remove unaligned access to mpbios_page[] > >>>>> sys/arch/x86/x86/mpbios.c:308:11, load of misaligned address 0xffff800031c7a413 for type 'const __uint16_t' which requires 2 byte alignment > >>> Can we please do NOT do such stupid changes? > >> Kernel Undefined Behavior Sanitizer detects various portability >> issues including alignment. > > Portability issues are, in general, not issues when they are in code > that is inherently already nonportable - such as almost everything > under sys/arch/. > >> Misaligned pointer is explicitly documented as undefined behavior in >> the C standard (C11 6.3.2.3 p7). > > So what? Do you have reason to think that sys/arch/x86 will at some > point be ported to a compiler (I would say "and architecture", but it's > already tightly bound to a very small set of CPU architectures) that > does something unexpected with that code? Expecting the MD code in the > low levels of an OS to never produce formally implementation-defined or > undefined behaviour is a fool's dream. > > Programs such as undefined-behaviour detectors are tools to serve us, > not shackles to bind us. Intelligence should be applied when using > their results, including not expecting portability from inherently > nonportable code. > Due to UB a compiler is free to perform optimization and treat x86 like a RISC architecture... especially with more instruction sets like SSE (as noted by Christos). x86 sanitizers experienced alignment trouble too. MOVDQA used to break sanitizers in the interceptor of __tls_get_addr(). https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066 I will try to propose a macro as noted in a reply to Jason Thorpe.
Attachment:
signature.asc
Description: OpenPGP digital signature