Skip to content

Comments

fix(TLB): L1 TLB will not save the high bit of PPN#4455

Merged
linjuanZ merged 1 commit intomasterfrom
mmu-fix-0325
Mar 27, 2025
Merged

fix(TLB): L1 TLB will not save the high bit of PPN#4455
linjuanZ merged 1 commit intomasterfrom
mmu-fix-0325

Conversation

@good-circle
Copy link
Contributor

Actually, the bit-width of s1ppn is sectorppnLen, which is defined as PaddrBits(48) - Offset(12) - TLB compression(3). In contrast, the L2 TLB returns item.s1.entry.ppn with a bit-width of sectorptePPNLen, which equals ptePaddrLen(56) - Offset(12) - TLB compression(3).

The part of the PPN beyond PaddrBits is only used to generate gpaddr when a guest page fault occurs, so it isn’t stored in the L1 TLB entry. Here, we simply assign the lower (sectorppnLen - 1, 0) bits. In fact, the original implementation would also work correctly, as it automatically truncates the lower bits of item.s1.entry.ppn and assigns them to s1ppn.

TODO: Not storing gpaddr (the upper PPN bits) in the L1 TLB currently provides minimal benefits and significantly increases the complexity, scalability, and maintainability issues of the TLB. In the new architecture, we need to store gpaddr in the L1 TLB to avoid all the additional handling related to guest page faults (gpf).

Actually, the bit-width of s1ppn is sectorppnLen, which is defined as PaddrBits(48) - Offset(12) - TLB compression(3). In contrast, the L2 TLB returns item.s1.entry.ppn with a bit-width of sectorptePPNLen, which equals ptePaddrLen(56) - Offset(12) - TLB compression(3).

The part of the PPN beyond PaddrBits is only used to generate gpaddr when a guest page fault occurs, so it isn’t stored in the L1 TLB entry. Here, we simply assign the lower (sectorppnLen - 1, 0) bits. In fact, the original implementation would also work correctly, as it automatically truncates the lower bits of item.s1.entry.ppn and assigns them to s1ppn.

TODO: Not storing gpaddr (the upper PPN bits) in the L1 TLB currently provides minimal benefits and significantly increases the complexity, scalability, and maintainability issues of the TLB. In the new architecture, we need to store gpaddr in the L1 TLB to avoid all the additional handling related to guest page faults (gpf).
@XiangShanRobot
Copy link

[Generated by IPC robot]
commit: f953dd7

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
f953dd7 1.824 0.442 2.641 1.225 2.150 1.681 2.135 2.361 0.938 1.389 2.027 3.112 2.555 2.271 3.304

master branch:

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
f8c4173 1.824 0.442 2.641 1.228 2.150 1.681 2.135 2.361 0.938 1.378 2.027 3.112 2.555 2.271 3.304
69e67bb 1.824 0.442 2.641 1.228 2.150 1.681 2.135 2.361 0.938 1.389 2.027 3.112 2.555 2.271 3.304
96f46b9 1.824 0.442 2.641 1.233 2.150 1.681 2.135 2.361 0.938 1.378 2.027 3.112 2.555 2.271 3.304
0ae8869 1.811 0.442 2.641 1.238 2.150 1.681 2.135 2.361 0.938 1.378 2.027 3.112 2.555 2.271 3.304
2c8aeb6 1.811 0.442 2.641 1.227 2.150 1.681 2.135 2.361 0.938 1.378 2.027 3.112 2.555 2.271 3.304
dac94c4 1.824 0.442 2.641 1.239 2.150 1.681 2.135 2.361 0.938 1.389 2.027 3.112 2.555 2.271 3.304
ebe07d6 1.806 0.442 2.641 1.225 2.150 1.676 2.149 2.364 0.933 1.389 2.010 3.108 2.538 2.274 3.309
62d7c91 1.806 0.442 2.641 1.224 2.150 1.676 2.149 2.364 0.933 1.389 2.010 3.108 2.538 2.274 3.309
d33dbc9 1.806 0.442 2.641 1.226 2.150 1.676 2.149 2.364 0.931 1.389 2.010 3.108 2.538 2.274 3.309
ef7a7f8 1.806 0.442 2.641 1.229 2.150 1.676 2.149 2.364 0.933 1.389 2.010 3.108 2.538 2.274 3.309

@linjuanZ linjuanZ merged commit 1f23fd0 into master Mar 27, 2025
10 checks passed
@linjuanZ linjuanZ deleted the mmu-fix-0325 branch March 27, 2025 14:35
good-circle added a commit that referenced this pull request Mar 27, 2025
Similar to #4455, ppn_s1 has a width of 44 bits, ppn_s2 has a width of 38 bits, and both of them need to finally assign to a 36-bits signal `ppn(d)`.

The original code does not result in a functional error, but the designer should be aware of the bit-widths of these signals and whether they can be directly truncated during assignment. Therefore this PR was committed.
Tang-Haojin pushed a commit that referenced this pull request Mar 29, 2025
Similar to #4455, ppn_s1
has a width of 44 bits, ppn_s2 has a width of 38 bits, and both of them
need to finally assign to a 36-bits signal `ppn(d)`.

The original code does not result in a functional error, but the
designer should be aware of the bit-widths of these signals and whether
they can be directly truncated during assignment. Therefore this PR was
committed.
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.

3 participants