Skip to content

Conversation

@mkroening
Copy link
Member

@mkroening mkroening commented Jan 12, 2026

This PR is split off from #574 to discuss and merge the OffsetPageTable changes separately.

Best reviewed commit by commit:

  1. Rename PhysOffset::offset to phys_offset. This change does not change the public API but aligns the internal field's name to the public API.
  2. Make PhysOffset public. This straightforward PageTableFrameMapping implementation makes MappedPageTable usable as an OffsetPageTable, which is useful for generic code that otherwise would need to distinguish between the two.
  3. Make OffsetPageTable a type alias. This allows calling MappedPageTable methods on OffsetPageTable. User migration should be as easy as replacing OffsetPageTable::new with OffsetPageTable::from_phys_offset.
  4. Modify the changelog.

@mkroening
Copy link
Member Author

mkroening commented Jan 12, 2026

One thing I am not sure about is whether we should deprecate the type alias and eventually remove it. This would reduce possibly confusing documentation entries and deduplicate some methods but would force the user to use longer method chains to replace them.

@mkroening mkroening marked this pull request as ready for review January 12, 2026 10:18
@Freax13
Copy link
Member

Freax13 commented Jan 12, 2026

Best reviewed commit by commit:

  1. Merge master into next. Is this the way to do this? Should I split this into a separate PR to make the diff of this PR easier to review?

Yes, please create a separate PR for that. Were there any merge issues you had to resolve?

  1. Derive Clone and Copy for PhysOffset. This was used in the display implementation previously but is not needed anymore. Should I rather remove this commit?

I'd err on the side of caution and say yes. If someone has a use-case for this, we can always add it later.

  1. Make OffsetPageTable a type alias. This allows calling MappedPageTable methods on OffsetPageTable. User migration should be as easy as replacing OffsetPageTable::new with OffsetPageTable::new_offset.

Tbh, I'm not loving the new name of the new_offset function, but I think it's worth the trade-off for unifying MappedPageTable and OffsetPageTable.

Thanks for your work on all of this (including splitting up the PRs), I appreciate it!

@mkroening
Copy link
Member Author

  1. Derive Clone and Copy for PhysOffset. This was used in the display implementation previously but is not needed anymore. Should I rather remove this commit?

I'd err on the side of caution and say yes. If someone has a use-case for this, we can always add it later.

Done. 👍

  1. Make OffsetPageTable a type alias. This allows calling MappedPageTable methods on OffsetPageTable. User migration should be as easy as replacing OffsetPageTable::new with OffsetPageTable::new_offset.

Tbh, I'm not loving the new name of the new_offset function, but I think it's worth the trade-off for unifying MappedPageTable and OffsetPageTable.

Ah, I had changed the code already but did not update the PR's description.
I had changed it to from_phys_offset, aligning to both the PhysOffset type and the phys_offset: VirtAddr argument.
OffsetPageTable::from_phys_offset and MappedPageTable::from_offset do not look too bad in my opinion, but I am happy to change it back or to something else if you prefer that.

Thanks for your work on all of this (including splitting up the PRs), I appreciate it!

Thanks for the swift and helpful reviews! :)

Any thoughts on whether to deprecate or remove anything?
If not, this should be ready to merge from my side, barring any change requests from you.

Copy link
Member

@Freax13 Freax13 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! :shipit:

  1. Make OffsetPageTable a type alias. This allows calling MappedPageTable methods on OffsetPageTable. User migration should be as easy as replacing OffsetPageTable::new with OffsetPageTable::new_offset.

Tbh, I'm not loving the new name of the new_offset function, but I think it's worth the trade-off for unifying MappedPageTable and OffsetPageTable.

Ah, I had changed the code already but did not update the PR's description. I had changed it to from_phys_offset, aligning to both the PhysOffset type and the phys_offset: VirtAddr argument. OffsetPageTable::from_phys_offset and MappedPageTable::from_offset do not look too bad in my opinion, but I am happy to change it back or to something else if you prefer that.

Ah, nice, I didn't notice that. I like that name better, good call.

Any thoughts on whether to deprecate or remove anything? If not, this should be ready to merge from my side, barring any change requests from you.

I think the OffsetPageTable type alias is useful to keep around as a short-cut.

@Freax13 Freax13 merged commit 2836e54 into rust-osdev:next Jan 12, 2026
11 of 12 checks passed
@mkroening mkroening deleted the offset_page_table branch January 12, 2026 19:35
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