Skip to content

openhcl_boot: Account for control bits in CR3 #1375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

romank-msft
Copy link
Contributor

The CR3 register isn't just a page root base address: its 12 LSBs may contain
control bits. See
* AMD PPR Vol 2 "Syetem Programming", "3.1.2 CR2 and CR3 Registers"
* Intel SDM Vol 3 "System Programming", "4.5.2 Use of CR3 ..."
for details.

Clear out the 12 LSBs to be follow the letter of the processor manuals.

```
The CR3 register isn't just a page root base address: its 12 LSBs may contain
control bits. See
* AMD PPR Vol 2 "Syetem Programming", "3.1.2 CR2 and CR3 Registers"
* Intel SDM Vol 3 "System Programming", "4.5.2 Use of CR3 ..."
for details.

Clear out the 12 LSBs to be follow the letter of the processor manuals.
```
@romank-msft romank-msft requested a review from a team as a code owner May 16, 2025 23:05
@jstarks
Copy link
Member

jstarks commented May 19, 2025

This is fine, but we control how cr3 gets set in the loader, so the only way there'd be some low bits is if we put them there, right?

@jstarks
Copy link
Member

jstarks commented May 19, 2025

(As a side note, it therefore seems weird to even have to read cr3 to get the page table base, since we should already know where it is.)

@romank-msft
Copy link
Contributor Author

This is fine, but we control how cr3 gets set in the loader, so the only way there'd be some low bits is if we put them there, right?

Right! It felt very decoupled, and should things change on one side when setting cr3, here the code would blow up. Your other comment captures perfectly where the room for improving is! Instead of using cr3 as the "storage medium" for the page root, could add a field to the ShimParams struct.

@romank-msft
Copy link
Contributor Author

(As a side note, it therefore seems weird to even have to read cr3 to get the page table base, since we should already know where it is.)

YEP

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