-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LLVM-compiled CheriBSD kernel experiences alignment fault: adjacent but unsuitably aligned 'sw' instructions merged? #309
Comments
This is expected, I believe. We have told LLVM that CHERI supports unaligned loads and stores, so it should emit the code assuming that this is the case and, if the CPU doesn't support it (e.g. if the values span cache lines) then the fault handler should fix it up. |
That's tricky to do in kernel C code, as the exception handler is implemented in C! More generally: something a bit odd is going on here -- the zeroing of the prior instance of the structure is not similarly getting coalesced into a larger store just a few instructions earlier, and the kernel boots and runs for a BERI MIPS configuration fine as well -- it's when we configure a CHERI kernel that it goes wrong using LLVM. Perhaps we're just unlucky as memory allocation / layout has changed slightly between the two. |
Presumably when targeting BERI, we are telling the compiler that it's a generic MIPS III CPU, whereas when it's targeting CHERI we are telling the compiler that it's a CHERI CPU. The former is defined in LLVM not to support unaligned loads and stores, the latter to support them. Given that we have no |
It is now possible for targets to support unaligned access for a subset of address spaces. Would it help if clang emitted |
Seems to be fixed now, MIPS uses |
When compiling a
CHERI_DE4_USBROOT
kernel for CHERI, I experience an alignment fault in which thep_sigqueue
member ofstruct proc
appears to have insufficient alignment for 64-bit pointers:Caller,
proc_linkup(9)
:And callee,
sigqueue_init(9)
:The process pointer
p
($a1 at 0xffffffff803154b0) is properly aligned with value 0x9800000001108a80. Its memberp_sigqueue
hasThe
p_sigqueue
field has typesigqueue_t
:sigset_t
is four uint32_ts in a row:It appears that two of the adjacent (but not 64-bit aligned) 32-bit stores have been coalesced into a single store double?
The build command line is:
Preprocessed kern_sig.c: https://gist.github.com/rwatson/269dc1d9621e6530af6c
LLVM version: 388f6926b8f9bb0557c65b74badb8a34734f13dc
Clang version: 473591c52d2160071616e8574dc80305abfdda52
The text was updated successfully, but these errors were encountered: