[DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Optimizer601
Posts: 13
Joined: Mon Oct 21, 2019 5:57 am

[DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error

Post by Optimizer601 »

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.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: [DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error

Post by Love4Boobies »

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 ]
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: [DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error

Post by alexfru »

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.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: [DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error

Post by Love4Boobies »

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 ]
Optimizer601
Posts: 13
Joined: Mon Oct 21, 2019 5:57 am

Re: [DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error

Post by Optimizer601 »

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.
Optimizer601
Posts: 13
Joined: Mon Oct 21, 2019 5:57 am

Re: [DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error

Post by Optimizer601 »

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
User avatar
pvc
Member
Member
Posts: 201
Joined: Mon Jan 15, 2018 2:27 pm

Re: [DISCUSSION] [SPECIFICATION-ERROR] Multiboot2 Spec Error

Post by pvc »

@Optimizer601 Hahaha… true.
Post Reply