SMBIOS/64-bit pointer woes

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
User avatar
PavelChekov
Member
Member
Posts: 113
Joined: Mon Sep 21, 2020 9:51 am
Location: Aboard the Enterprise

SMBIOS/64-bit pointer woes

Post by PavelChekov »

I'm currently collecting the SMBIOS data in my bootloader (getting the table pointer from the entry point), but finding that relies on using physical addresses, yet the pointer to the table is a 64-bit address. I can't access that outside of long mode, but I need to enable paging to get to long mode, thus making the whole exercise moot, because my kernel wouldn't be able to access the physical address. Is there a commonly accepted solution to this problem? What can I do short of making a copy of the table in a location that will be mapped and passing the address of that?

Thanks.
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe

Live Long And Prosper

Slava Ukraini!
Слава Україні!
nullplan
Member
Member
Posts: 1789
Joined: Wed Aug 30, 2017 8:24 am

Re: SMBIOS/64-bit pointer woes

Post by nullplan »

PavelChekov wrote:but finding that relies on using physical addresses, yet the pointer to the table is a 64-bit address. I can't access that outside of long mode,
You're wrong, you can use PAE paging in 32-bit mode and access as much of the 64-bit physical address space as in long mode (namely the architecturally defined 52 bits). Of course I'd recommend 64-bit mode over 32-bit mode, but that doesn't mean you can't use it still.
PavelChekov wrote:thus making the whole exercise moot, because my kernel wouldn't be able to access the physical address.
Surely your kernel has some way to map arbitrary physical addresses, right? It must have, since many device drivers require this. When you write any driver for a PCI device, it will read the IO base address out of some BAR, and then need to access that memory block as MMIO. You can't use a normal RAM mapping for this, because you need to map the memory as uncached. My solution for this is to have a function ioremap() that takes a physical address and a memory type and returns a virtual address. On x86_64, this basically adds or modifies the mapping in the linear range to have the requested memory type.
Carpe diem!
User avatar
PavelChekov
Member
Member
Posts: 113
Joined: Mon Sep 21, 2020 9:51 am
Location: Aboard the Enterprise

Re: SMBIOS/64-bit pointer woes

Post by PavelChekov »

nullplan wrote:
PavelChekov wrote:but finding that relies on using physical addresses, yet the pointer to the table is a 64-bit address. I can't access that outside of long mode,
You're wrong, you can use PAE paging in 32-bit mode and access as much of the 64-bit physical address space as in long mode (namely the architecturally defined 52 bits). Of course I'd recommend 64-bit mode over 32-bit mode, but that doesn't mean you can't use it still.
Thank you. I didn't think of PAE as an individual feature in that way.
USS Enterprise NCC-1701,
The Final Frontier,
Space,
The Universe

Live Long And Prosper

Slava Ukraini!
Слава Україні!
Post Reply