slaunch/txt: fix missing 64-bit arithmetic in MTRR calculation - #42
Open
accek-itl wants to merge 1 commit into
Open
slaunch/txt: fix missing 64-bit arithmetic in MTRR calculation#42accek-itl wants to merge 1 commit into
accek-itl wants to merge 1 commit into
Conversation
Member
|
Made
I think this version is better. The code makes a reasonable assumption that the number of pages within ranges fits into 32-bit integers. Changing types of those variables would have to also update how their values are computed to be consistent. Things go wrong only in those two expressions computing the masks and it makes sense to indicate their 64-bit nature explicitly. |
Cast the range sizes to 64-bit: the 32-bit ~({mtrr_s,pages_in_range} - 1)
dropped PHYSMASK bits above bit 43 on parts with MAXPHYADDR >= 45.
Signed-off-by: Szymon "accek" Acedański <accek@invisiblethingslab.com>
accek-itl
force-pushed
the
ptl-senter-fixes
branch
from
August 13, 2026 12:00
14af24f to
d51e358
Compare
Author
|
Ok, I agree, adjusted commit to the alternative version. |
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.
Make the range sizes 64-bit: the 32-bit
~({mtrr_s,pages_in_range} - 1)dropped PHYSMASK bits above bit 43 on parts with MAXPHYADDR >= 45.The broken calculations (bits above 31 truncated to 0) are here:
Possible alternative version if you prefer: