OSDev.org
https://forum.osdev.org/

Atomic operations deadlock
https://forum.osdev.org/viewtopic.php?f=1&t=56336
Page 1 of 1

Author:  Julius [ Sun Jun 26, 2022 11:11 pm ]
Post subject:  Atomic operations deadlock

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?

Author:  Octocontrabass [ Mon Jun 27, 2022 6:37 pm ]
Post subject:  Re: Atomic operations deadlock

Julius wrote:
Does anything need to be activated/set to enable atomics as stated in this post?

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.)

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.

Author:  Ethin [ Mon Jun 27, 2022 10:47 pm ]
Post subject:  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.

Author:  Julius [ Tue Jun 28, 2022 2:39 am ]
Post subject:  Re: Atomic operations deadlock

Octocontrabass wrote:
It sounds like some kind of memory corruption. Maybe your loader isn't zeroing .bss [...]


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!

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/