OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 5:57 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: [DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error
PostPosted: Sun Mar 22, 2020 11:44 pm 
Offline

Joined: Mon Oct 21, 2019 5:57 am
Posts: 13
I was implementing multiboot2 in my kernel and was following GRUB multiboot2 spec (https://www.gnu.org/software/grub/manua ... iboot.html).

There's an error in the spec and I spent quite a bit of time debugging my kernel for no reason. I don't know where to report so I thought I may post it here.

Section in question : 3.6.12 Framebuffer info

3.6.12 Framebuffer info
+--------------------+
u32 | type = 8 |
u32 | size |
u64 | framebuffer_addr |
u32 | framebuffer_pitch |
u32 | framebuffer_width |
u32 | framebuffer_height |
u8 | framebuffer_bpp |
u8 | framebuffer_type |
u8 | reserved |
varies | color_info |
+--------------------+

Spec states reserved flag is 8 bit but it should be 16 bit.
When you use 8 bit you get gibberish for color_info.

NOTE : Multiboot2 Example OS given in the same website implements correct struct. it uses 16 bit.


Top
 Profile  
 
 Post subject: Re: [DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error
PostPosted: Mon Mar 23, 2020 12:59 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
You seem to be correct. Here is the relevant code. I have submitted a bug report with a link to this thread.

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: [DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error
PostPosted: Mon Mar 23, 2020 1:17 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
If a plain C struct was used for the initial part (with the reserved field at its end), the trailing uint8_t would be padded with another one by the compiler. IOW, this problem is more likely to occur when using assembly or manually/explicitly packing C structs.


Top
 Profile  
 
 Post subject: Re: [DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error
PostPosted: Mon Mar 23, 2020 2:11 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
Obviously, the Multiboot specifications expect things to be serialized so padding and alignment aren't the issue here. The reason no one noticed this until now is likely that people generally use GRUB's headers rather than implement their own.

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: [DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error
PostPosted: Mon Mar 23, 2020 2:20 am 
Offline

Joined: Mon Oct 21, 2019 5:57 am
Posts: 13
Love4Boobies wrote:
You seem to be correct. Here is the relevant code. I have submitted a bug report with a link to this thread.


Amazing. Thanks for reporting.


Top
 Profile  
 
 Post subject: Re: [DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error
PostPosted: Mon Mar 23, 2020 2:35 am 
Offline

Joined: Mon Oct 21, 2019 5:57 am
Posts: 13
alexfru wrote:
If a plain C struct was used for the initial part (with the reserved field at its end), the trailing uint8_t would be padded with another one by the compiler. IOW, this problem is more likely to occur when using assembly or manually/explicitly packing C structs.


Spec can't assume nor rely on that.

https://imgur.com/a/f0CoR6H


Top
 Profile  
 
 Post subject: Re: [DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error
PostPosted: Tue Mar 24, 2020 12:02 pm 
Offline
Member
Member
User avatar

Joined: Mon Jan 15, 2018 2:27 pm
Posts: 201
@Optimizer601 Hahaha… true.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot], rdos and 213 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