rust-osdev/acpi

Address allocation retrieves non-canonical addresses

ethindp opened this issue · 7 comments

I've switched to using the Stivale2 boot protocol. However, when using the RSDP now, I get non-canonical addresses (e.g. FFFF80007FB7E014). Not sure if I have to add an offset or something, but bits 48-64 are FFFF, and that's causing kernel panics on my end.

I'm not sure what you mean from this level of detail.

Please show us:

  • How you're now getting the RSDP from the bootloader, what address it supplies, and whether that memory contains a real RSDP
  • What environment you're in (QEMU? Real hardware? SeaBios or OVMF?)
  • What structure you're getting the noncanonical address from, and what it's supposed to point to

Sorry about that. I'm using the Limine boot loader (https://github.com/limine-bootloader/limine), running in Qemu via OVMF. My environment follows:

  • Protected memmory regions: Yes
  • 5-level paging enabled if supported: yes
  • Kernel-level ASLR and randomization enabled: yes
  • Physical base: 0x7856e000
  • Virtual base: 0xffffffffd5b8e000
  • Memory slide: 0x55b8e000
  • RSDP address: 0x7fb7e000
  • XSDP address: 0x7fb7e014
  • Kernel is using XSDP address at address FFFF80007FB7E014

Apparently the system is trying to map the XSDP; it tries mapping FFFF80007FB7E014, but bits 48-64 are set, so it bales out (even in the x86_64 library). I'm getting this info directly from the bootloader via the RSDP tag as specified in the stivale2 specification (https://github.com/stivale/stivale/blob/master/STIVALE2.md).

Apparently the system is trying to map the XSDP; it tries mapping FFFF80007FB7E014

It's your job to tell acpi what virtual address you've mapped a structure at, given its physical address, so I don't think this is our fault. The physical address of the RSDP looks like its probably valid - how are you turning that into 0xFFFF80007FB7E014 (looks like you're sticking it onto a base of 0xffff800000000000 somewhere)?

I'm just using the address the bootloader gives me. I'm not modifying the address -- for now I'm just trusting that the bootloader will give me the right address. Should I subtract FFFF80000000 or something like that?

I'd heavily suggest you instead work out if Limine really is giving you a non-canonical address, and if it is, why. I think it might have something to do with this REPORTED_ADDR and directed_map_offset stuff going on - it does look vaguely like it might not be correctly canonicalising addresses, but I haven't looked into it closely.

It also seems weird to me that the bootloader is mapping the RSDP for you at all, but my reading of the Stivale2 spec makes me think it has to too

I'll look into that, thanks.

@ethindp have you had any luck?

I don't think this is a problem in acpi so am going to close this for now; please feel free to re-open if needed.