Skip to content

Conversation

@DimaThenekov
Copy link
Contributor

@DimaThenekov DimaThenekov commented Dec 2, 2025

Thanks to the comment #845 (comment) I tried adding the NX-bit, but I ran into the definition of read for execution and read for data. Can you give any implementation tips?

When starting an OS that requires NX-bit (Windows 8/10), I see a message in the logs about enabling the NX bit, but the result is the same as before.

  1. I understand that this is a difficult task, but the number of function calls to read from memory is too large. Can this be simplified?
  2. Am I doing the right thing by storing the nx flag in tlb?
  3. I also don't quite understand how the implementation of the nx bit can improve OS support, since this flag is only needed for security.
  4. I don't know how to test this. I couldn't run any kvm tests other than realmode.flat.

@copy
Copy link
Owner

copy commented Dec 24, 2025

I understand that this is a difficult task, but the number of function calls to read from memory is too large. Can this be simplified?

Sure, I'm open to suggestions. A good starting point is the read_imm family of functions, which is by far the most common case of reading instructions.

Am I doing the right thing by storing the nx flag in tlb?

Yes, I believe that's the right approach.

I also don't quite understand how the implementation of the nx bit can improve OS support, since this flag is only needed for security.

Supposedly Windows 8 doesn't work without NX support unless you use workarounds. I haven't tested it. And it's a pre-req for 64-bit support.

I don't know how to test this. I couldn't run any kvm tests other than realmode.flat.

At the very least:

  • Boot some OSes and check that they detect and apply the NX bit. This can be added to tests/full/run.js
  • Write some unit tests that set up a page tables with NX protection, jump into them and observe that the page fault is being hit. This could be added to tests/nasm or tests/qemu or tests/jit-paging (this one could be forked) or kvm-unit-test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants