Conversation
TSnake41
suggested changes
Apr 17, 2026
Comment on lines
+28
to
+36
| # Set CR0 (PM-bit is already set) | ||
| mov eax, cr0 | ||
| and eax, ~(1 << 2) # disable FPU emulation | ||
| or eax, (1 << 1) # enable FPU montitoring | ||
| and eax, ~(1 << 30) # enable caching | ||
| and eax, ~(1 << 29) # disable write through caching | ||
| and eax, ~(1 << 16) # allow kernel write access to read-only pages | ||
| or eax, (1 << 31) # enable paging | ||
| mov cr0, eax |
There was a problem hiding this comment.
PVH ABI (https://xenbits.xen.org/docs/unstable/misc/pvh.html) define CR0 state as
cr0: bit 0 (PE) must be set. All the other writeable bits are cleared.
Hence you don't need to to clear some of these bits.
Member
Author
There was a problem hiding this comment.
Thanks for pointing this out! :)
This is still very much work-in-progress. I will clean it up. 👍
Comment on lines
+23
to
+36
| mov eax, cr0 | ||
| or eax, CR0_FLAGS_PROTECTED_MODE_ENABLE | CR0_FLAGS_PAGING | ||
| mov cr0, eax | ||
|
|
||
|
|
||
| # Set CR0 (PM-bit is already set) | ||
| mov eax, cr0 | ||
| and eax, ~(1 << 2) # disable FPU emulation | ||
| or eax, (1 << 1) # enable FPU montitoring | ||
| and eax, ~(1 << 30) # enable caching | ||
| and eax, ~(1 << 29) # disable write through caching | ||
| and eax, ~(1 << 16) # allow kernel write access to read-only pages | ||
| or eax, (1 << 31) # enable paging | ||
| mov cr0, eax |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds PVH boot support directly to the kernel. This allows the kernel to be booted in QEMU, Firecracker, and Cloud Hypervisor directly, without the loader.
The
pvhcrate was successfully published.Closes #2373.