Heya,
I'm currently writing an 86_64 bare metal kernel.
After a successful boot into my kernel using EDK2 as a bootloader (calling ExitBootServices) I now want to use spinlocks for synchronization (f.e. a synchronized logger and global allocator).
I'm using rust, which in turn gets compiled down to llvm code, so my spinlock implementation uses llvm atomics under the hood for the x86_64-unknown-none-elf target. Currently interrupts are disabled.
This works perfectly in qemu! But when booting on real hardware (either through grub or plain uefi) the locks appear to be always locked.
Now my question:
Does anything need to be activated/set to enable atomics as stated in this post?
Atomic operations deadlock
-
- Member
- Posts: 5563
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Atomic operations deadlock
Probably not. The default memory cache settings are correct in most cases. (Occasionally you might find a PC with broken firmware that doesn't set the MTRRs correctly, but that's pretty unusual.)Julius wrote:Does anything need to be activated/set to enable atomics as stated in this post?
It sounds like some kind of memory corruption. Maybe your loader isn't zeroing .bss, or maybe your stack isn't where it should be, or maybe it's some other problem.
Re: Atomic operations deadlock
You don't need to enable anything to perform atomic operations. I use them all the time in embedded code and OSDev and have never needed to set a bit or anything like that to get them to work -- they just work. I strongly suspect that this is a different issue altogether.
Re: Atomic operations deadlock
Well guess what was commented out in my bootloader..... I thank you so much for your time and keeping up with this.. Sorry and have a good day!Octocontrabass wrote:It sounds like some kind of memory corruption. Maybe your loader isn't zeroing .bss [...]