OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Nov 28, 2022 11:37 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: [Solved] QEMU: Booting x86_64 kernel via PVH
PostPosted: Tue Jul 27, 2021 5:29 pm 
Offline

Joined: Tue Jul 27, 2021 3:09 pm
Posts: 2
After getting a basic 32-bit i386 kernel emulating through QEMU, I figured I would go ahead and get one fired up on x86_64. I am still completely in the "Let's make sure this actually works before doing anything else" phase. Running "qemu-system-x86_64 -kernel out.bin" results in QEMU spitting out "Error loading uncompressed kernel without PVH ELF Note." The binary file has been verified with grub-file as well.

I've read around that QEMU does not support multiboot2 so I figured I would just give it what it wants and include the elf note. My only issue here is figuring out how to do this correctly. As of now I have
Code:
section .note
align 4
   dd 3 ; name size
   dd 4 ; data size
   dd 18 ; type (0x12)
align 4
   db 'Xen' ; name
align 4
   dd _start ; data

and my linker puts the section at the right spot in the file.
Code:
   .note :
   {
      *(.note)
   }


Running readelf does show that the elfnote is present and contains what I thought was the correct information (see below). QEMU still tells me that it wants its PVH elfnote despite this. I have exhausted every resource trying to get it to work over the past week and I'm about at the end of my ropes; Thinking I misunderstood something big-time. Would love if someone could point me in the right direction here on where I went wrong.

Note data:
Code:
Displaying notes found in: .note
  Owner                Data size        Description
  Xen                  0x00000004       Unknown note type: (0x00000012)
   description data: 00 20 00 00


https://xenbits.xen.org/docs/unstable/misc/pvh.html


Last edited by lukecreator on Wed Jul 28, 2021 11:05 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: QEMU: Booting x86_64 kernel via PVH
PostPosted: Wed Jul 28, 2021 9:03 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 4327
I'm no PVH expert, but I think you might run into trouble if you tell QEMU your kernel supports paravirtualization when it actually doesn't.

Code:
section .note

I'm not sure if it makes a difference, but Xen uses the section name ".note.Xen" in the ELFNOTE macro.

Code:
   dd 3 ; name size

This should be 4.

Code:
   db 'Xen' ; name

The missing 4th byte is a null terminator.


Top
 Profile  
 
 Post subject: Re: QEMU: Booting x86_64 kernel via PVH
PostPosted: Wed Jul 28, 2021 10:52 am 
Offline

Joined: Tue Jul 27, 2021 3:09 pm
Posts: 2
Octocontrabass wrote:
I'm no PVH expert, but I think you might run into trouble if you tell QEMU your kernel supports paravirtualization when it actually doesn't.

Code:
section .note

I'm not sure if it makes a difference, but Xen uses the section name ".note.Xen" in the ELFNOTE macro.

Code:
   dd 3 ; name size

This should be 4.

Code:
   db 'Xen' ; name

The missing 4th byte is a null terminator.


Thank you! You're probably right on the first part but I'm going to give it a shot anyway and see if everything doesn't blow up. Good to know that the name field absolutely requires null termination at the end; I have tried that already but I haven't tried putting the labeled note section so I'll give it a go and let you know what comes out of it.

EDIT: The section naming was it! Words cannot explain how ecstatic I am to see something so mediocre working right now haha


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], iansjack, TOG and 6 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