Skip to content

fix(PTW): Fix exception handle logic when both pf and af occur#4422

Merged
good-circle merged 1 commit intomasterfrom
mmu-excp
Mar 23, 2025
Merged

fix(PTW): Fix exception handle logic when both pf and af occur#4422
good-circle merged 1 commit intomasterfrom
mmu-excp

Conversation

@good-circle
Copy link
Contributor

@good-circle good-circle commented Mar 14, 2025

In the previous design, every time a page table entry was fetched from memory, a PMP check was performed on the physical address of the next-level page table. However, for cases requiring Stage-2 address translation or when a page fault occurs during the page table fetch, a PMP check is unnecessary. Performing a PMP check in these cases could lead to false access fault reports. This commit fixes the issue.

Future work: The current exception handling logic is messy and unsustainable. A complete refactor of this code is needed in the future, rather than continuing to add patches.

@good-circle good-circle added the note: do not merge (PR) For maintainer: do not merge this pull request yet label Mar 14, 2025
@good-circle
Copy link
Contributor Author

Please do not merge now

@XiangShanRobot
Copy link

[Generated by IPC robot]
commit: 4cdc2f9

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
4cdc2f9 1.806 0.442 2.641 1.233 2.150 1.676 2.149 2.364 0.933 1.389 2.010 3.108 2.538 2.274 3.309

master branch:

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
9245b52 1.676 0.933 3.309
15b6534 1.676 0.933 3.309
36e010a 1.806 0.442 2.641 1.231 2.150 1.676 2.149 2.364 0.933 1.389 2.010 3.108 2.538 2.274 3.309
a9115da 1.806 0.442 2.641 1.239 2.150 1.676 2.149 2.364 0.933 1.378 2.010 3.108 2.538 2.274 3.309
f242101 1.806 0.442 2.641 1.231 2.150 1.676 2.149 2.364 0.933 1.389 2.010 3.108 2.538 2.274 3.309
12931ef 1.806 0.442 2.641 1.230 2.150 1.676 2.149 2.364 0.933 1.389 2.010 3.108 2.538 2.274 3.309
39e2cc5 1.806 0.442 2.641 1.228 2.150 1.676 2.149 2.364 0.933 1.389 2.010 3.108 2.538 2.274 3.309
b9bfce8 1.806 0.442 2.641 1.237 2.150 1.676 2.149 2.364 0.933 1.389 2.010 3.108 2.538 2.274 3.309
6aa6d73 1.806 0.442 2.641 1.221 2.150 1.676 2.149 2.364 0.933 1.389 2.010 3.108 2.538 2.274 3.309
e542913 1.806 0.442 2.641 1.223 2.150 1.676 2.149 2.364 0.933 1.389 2.010 3.108 2.538 2.274 3.309

…ult occur

In the previous design, every time a page table entry was fetched from memory, a PMP check was performed on the physical address of the next-level page table. However, for cases requiring Stage-2 address translation or when a page fault occurs during the page table fetch, a PMP check is unnecessary. Performing a PMP check in these cases could lead to false access fault reports. This commit fixes the issue.

Future work: The current exception handling logic is messy and unsustainable. A complete refactor of this code is needed in the future, rather than continuing to add patches.
@good-circle good-circle removed the note: do not merge (PR) For maintainer: do not merge this pull request yet label Mar 21, 2025
@good-circle
Copy link
Contributor Author

Already tested kvm on simulator and can be merged now

Copy link
Member

@cebarobot cebarobot left a comment

Choose a reason for hiding this comment

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

Future work: The current exception handling logic is messy and unsustainable. A complete refactor of this code is needed in the future, rather than continuing to add patches.

I totally agree with this.

@XiangShanRobot
Copy link

[Generated by IPC robot]
commit: 3b2e882

commit astar copy_and_run coremark gcc gromacs hmmer-Vector lbm linux mcf microbench milc namd povray wrf xalancbmk
3b2e882 1.824 0.442 2.641 1.237 2.150 1.681 2.135 2.361 0.938 1.378 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
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
7eb878b 1.806 0.442 2.641 1.223 2.150 1.676 2.149 2.364 0.933 1.389 2.010 3.108 2.538 2.274 3.309
529b1cf 1.806 0.442 2.641 1.226 2.150 1.676 2.149 2.364 0.933 1.378 2.010 3.108 2.538 2.274 3.309

@good-circle good-circle changed the title fix(PTW): Fix exception handle logic when both Pagefault and Accessfa… fix(PTW): Fix exception handle logic when both pf and af occur Mar 23, 2025
@good-circle good-circle merged commit f8c4173 into master Mar 23, 2025
10 checks passed
@good-circle good-circle deleted the mmu-excp branch March 23, 2025 11:23
good-circle added a commit that referenced this pull request Apr 8, 2025
In #4422, For the virtualized allStage scenario, we attempt to suppress PMP checks until the G-stage translation result is returned. However, the approach used in #4422 is to try ignoring the `accessFault` result when `io.hptw.req.valid` is asserted.

In reality, the `accessFault` signal remains valid because it is implemented as a `RegEnable`. Therefore, we need to prevent `sent_to_pmp` from being asserted when sending the G-stage translation request to HPTW. To address this, we introduce the `vs_finish` signal. When `vs_finish` is `true.B`, `sent_to_pmp` will be false, thus avoiding false `accessFault` reports.
linjuanZ pushed a commit that referenced this pull request Apr 9, 2025
In #4422, For the
virtualized allStage scenario, we attempt to suppress PMP checks until
the G-stage translation result is returned. However, the approach used
in #4422 is to try
ignoring the `accessFault` result when `io.hptw.req.valid` is asserted.

In reality, the `accessFault` signal remains valid because it is
implemented as a `RegEnable`. Therefore, we need to prevent
`sent_to_pmp` from being asserted when sending the G-stage translation
request to HPTW. To address this, we introduce the `vs_finish` signal.
When `vs_finish` is `true.B`, `sent_to_pmp` will be false, thus avoiding
false `accessFault` reports.
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