fix(TLB): avoid freeze when GPF occurs #3964
Merged
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.
L1TLB does not store gpaddr, but gpaddr is needed when a guest page fault occurs. In that situation, L1TLB needs to send a PTW request to get the gpaddr, which we called it getGpa. The getGpa mechanism could only handle one GPF TLB request (the first one) and expects the corresponding TLB entry is still in L1TLB.
L1TLB replacement uses PLRU (Pseudo-LRU) algorithm, which may replace intems that are not necessarily the least recently used. We found an case that L1TLB replace that GPF TLB entry, although that GPF TLB entry is accessed recently. This results in a deadlock in getGpa mechanism, which eventually causes the entire core to freeze. To solve this problem, we decides to prevent any unrelated ptw refills when getGpa mechanism is working (need_gpa).
After solve such problem, we identified that under certain conditions, as other PTW response is never refilled, other TLB requests keep replying which trigger PTW requests and occupy the L2TLB request path, preventing the GPF PTW request from responding, ultimately leading to a processor freeze. To resolve this, we decides to prevent any unrelated ptw request when need_gpa.
This patch also changes the code style of some combinational logic signals. Using when/otherwise is clearer and easier to understand than complex logical expression.