{% raw %}
Philipp Oppermann

There is some discussion on hacker news, /r/rust, and /r/programming.

Rajivteja Nagipogu

Error while using x86_64::shared::control_regs.
There was no `shared` in x86_64.
Thanks for the help. :)

Philipp Oppermann

Thanks for reporting! Fixed in #301.

Rajivteja Nagipogu

Thank you. You have done awesome work here.

Rhys Kenwell

Trying to get this to work, my code looks identical to yours, save for the occasional twist for aesthetics, or different variable name, but after enabling the nxe bit, when according to you it should boot successfully, it crashes for me.

A bit of sleuthing on my part deduced the issue, I'm getting a double fault when I try to write to the cr3 register. A bit more debugging helped me find the culprit, when I write to cr3 in the switch method, something happens and the CPU double faults.

The exact instruction that the pc points to in the register dump is "add $0x18, %rsp"

Thanks in advance for helping me resolve this.

Rhys Kenwell

Looked a bit further, the original fault is a page fault with the present, write, and reserved write bits set

Philipp Oppermann

Hmm, sounds like your CPU somehow thinks that you set a reserved bit. If it works fine before setting the NXE bit, it could be caused by:

  • a wrong register (should be IA32_EFER)
  • a wrong bit number (should be 1 << 11)
  • your CPU somehow doesn't support it (if you run it on real hardware)
    • does in work in QEMU?
    • The AMD manual says: “Before setting this bit, system software must verify the processor supports the NX feature by checking the CPUID NX feature flag (CPUID Fn8000_0001_EDX[NX]).”

Hope this helps!

Hi, just leaving this here for future reference. I had the same problem and discovered that it was actually a typo, I didn't notice the ! on the if checking for ELF_SECTION_EXECUTABLE in EntryFlags::from_elf_section_flags. Maybe this will shed some light on your problem, if you still have it.

Nick von Bulow

Note on the footnote: I paste in your "most useful GDB command", and it tells me "syntax error in expression, near `int*)0xfffffffffffff000)@512' "

Philipp Oppermann

I think it's a problem across gdb versions. I had a similar problem recently. It seems like newer versions no longer understand some casts, but I couldn't find out whether that's a bug or an intentional syntax change.

{% endraw %}