OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Aug 13, 2022 1:16 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Atomic operations deadlock
PostPosted: Sun Jun 26, 2022 11:11 pm 
Offline
User avatar

Joined: Sun Jun 26, 2022 10:23 pm
Posts: 2
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?


Top
 Profile  
 
 Post subject: Re: Atomic operations deadlock
PostPosted: Mon Jun 27, 2022 6:37 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 4006
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.


Top
 Profile  
 
 Post subject: Re: Atomic operations deadlock
PostPosted: Mon Jun 27, 2022 10:47 pm 
Offline
Member
Member

Joined: Sun Jun 23, 2019 5:36 pm
Posts: 595
Location: North Dakota, United States
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.


Top
 Profile  
 
 Post subject: Re: Atomic operations deadlock
PostPosted: Tue Jun 28, 2022 2:39 am 
Offline
User avatar

Joined: Sun Jun 26, 2022 10:23 pm
Posts: 2
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group