Skip to content

feat(x86_64): add PVH support#2366

Draft
mkroening wants to merge 1 commit intomainfrom
pvh
Draft

feat(x86_64): add PVH support#2366
mkroening wants to merge 1 commit intomainfrom
pvh

Conversation

@mkroening
Copy link
Copy Markdown
Member

@mkroening mkroening commented Apr 8, 2026

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 pvh crate was successfully published.

Closes #2373.

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like CR0 is set up twice.

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.

Tracking issue for PVH boot support

2 participants