MIPS: Loongson: Salvage the full count from the constant timer#20
Closed
Rongronggg9 wants to merge 2 commits intoAOSC-Tracking:aosc/v6.18.7from
Closed
MIPS: Loongson: Salvage the full count from the constant timer#20Rongronggg9 wants to merge 2 commits intoAOSC-Tracking:aosc/v6.18.7from
Rongronggg9 wants to merge 2 commits intoAOSC-Tracking:aosc/v6.18.7from
Conversation
HWR $30 (Loongson64 constant timer) is 64 bits wide. However, vDSO uses `unsigned long' to read the timer count, which leads to frozen time (delta ~= 3s) when O32/N32 userspace programs request HRES time. For N32, using `u64' instead of `unsigned long' fixes the issue. The issue becomes trickier on O32. RDHWR never sign-extends the timer count before copying it into a GPR, as the kernel always sets Status.UX=1 even in O32 userspace. Aside from the frozen time, the "shadow" on the upper half also breaks subsequent logical/branch instructions relying on the GPR. Thankfully, Status.UX==1 also means that we have the full timer count available and can use 64-bit instructions to salvage it into a pair of GPR to comply with O32 ABI. Utilize (abuse?) this fact to salvage the full timer count in O32 vDSO. Fixes: "AOSCOS: MIPS: Loongson: Add constant timer support" Signed-off-by: Rong Zhang <i@rong.moe>
…timer" This reverts commit 1e094a6. With the full timer count salvaged, we can safely use RDHWR to read the timer count from Loongson64 constant timer in O32 vDSO. Signed-off-by: Rong Zhang <i@rong.moe>
|
Picked to aosc/v6.18.8, thanks! |
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.
HWR $30 (Loongson64 constant timer) is 64 bits wide. However, vDSO uses `unsigned long' to read the timer count, which leads to frozen time (delta ~= 3s) when O32/N32 userspace programs request HRES time.
For N32, using `u64' instead of `unsigned long' fixes the issue.
The issue becomes trickier on O32. RDHWR never sign-extends the timer count before copying it into a GPR, as the kernel always sets Status.UX=1 even in O32 userspace. Aside from the frozen time, the "shadow" on the upper half also breaks subsequent logical/branch instructions relying on
the GPR.
Thankfully, Status.UX==1 also means that we have the full timer count available and can use 64-bit instructions to salvage it into a pair of GPR to comply with O32 ABI.
Utilize (abuse?) this fact to salvage the full timer count in O32 vDSO.