I’ve just started messing with seL4, and I’m currently trying to allocate objects from untyped memory passed to the rootserver. However, I’ve noticed that when I call seL4_Untyped_Retype on a specific untyped memory capability, a triple fault occurs in the kernel. There is no error message - the machine simply resets. The qemu log also reports a triple fault occurred.
I suspect this may have to do with the way I’m booting the kernel, because it works fine when I run the simulate script in the build folder. I’m booting it by creating a GRUB boot image that multiboots the kernel and rootserver, and I haven’t had any other issues with this so far. If anyone has any insight into why there might be a difference between the two boot methods, it would be greatly appreciated. Some more details are below:
The fault seems to happen no matter how much memory I assign qemu, the type of object I retype from the memory, the size of the object, or which empty slot I use as the destination.
The physical address of the untyped memory is 0xA00000 and it is 2MB in size. OSDev’s typical x86 memory map doesn’t list anything special about this region.
From what I can tell, the fault seems to be occurring in the memzero function, called from clearMemory, from resetUntypedCap, from invokeUntyped_Retype. Specifically, it occurs when a 0 is written to address 0xffffff8000a0df00.
If any other details are required or if this post belongs somewhere else, let me know! Any guidance is appreciated.
Are you using the current version from git? If not, try that first.
I have no experience running seL4 on x86, so no quick insights that may help you here.
Does the same happen with other untyped memories? Or does any retype call cause a triple fault?
Double check that the machine qemu is emulating matches the sel4 kernel configuration. E.g. hypervisor support etc.
I think the kernel might assume all user accessible memory is above the kernel itself, 0xA00000 may break that assumption. But I’m not sure about this and it may only apply to other platforms than x86, or more likely, not at all.
Or something went quite wrong and the kernel itself is located at 0xA00000.
Oops, I think you might be right! I completely missed that footnote on the OSDev page. After double checking the log, I do see the kernel is being loaded from 0x100000 - 0xC12000. Still though, if the kernel knows that address range is being used by itself, it shouldn’t provide it as retype-able memory - after all, userland code has no idea that memory should be off-limits.
With that said, there’s another problematic untyped (4KB @ 0x80A000) that really does seem to be outside any used address ranges. This time I actually get a proper kernel exception message when attempting to retype it, if it may prove useful. Through decompiling, it looks like the IP is at the start of the restore_user_context function this time - weird.
Yep, I’m using the current version from git - I just redownloaded all components from git (kernel, tools, musllibc, seL4_libs, util_libs, and runtime)
Most of the time retyping works ok, but sometimes a triple fault occurs, sometimes it just freezes without restarting, and sometimes it prints out a kernel exception message.
I’m running the boot image using the exact same qemu binary and command that the simulate script uses. The only difference is I’ve removed the -kernel and -initrd arguments, and added the -drive argument to use the boot image.
Sure, it is in that range. I just provided it as an example in case the exception log and stack trace would be useful to someone in the future, and as a further example of weird behavior (even if it might be expected given what we’ve learned).
Still though, why does the kernel provide a capability to that memory if I’m not supposed to use it? The kernel knows where itself is loaded - it even prints out the address during boot. I admit I’m not familiar with the codebase, but I imagine it should be possible to exclude these regions from being provided to the root task, no?
Until then, I’ll just use untypeds above 0x00EFFFFF. Giving up a handful of MB on x86 won’t be the end of the world!
As far as I know, the kernel isn’t supposed to do this. So either the way you boot the system breaks an assumption made by seL4, or it’s a bug in seL4, or a bug in GRUB.
If you want to get to the bottom of this you could add debug prints to the seL4 bootup code.