Repository navigation
sys/cpu: Use cntvct_el0 instead of cntpct_el0 on aarch64 - #712
Open
hotline1337 wants to merge 1 commit into
Open
hotline1337 wants to merge 1 commit into
hotline1337 wants to merge 1 commit into
Conversation
Signed-off-by: hotline1337 <denuvo at tuta dot io>
This branch has not been deployed
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.
Summary
CNTPCT_EL0) to the virtual counter (CNTVCT_EL0) incommon/sys/cpu.handchecks/payloads/limine/arch_aarch64.c.Background & Problem
Per the ARM Architecture Reference Manual for A-profile architecture (
ARM DDI 0487),CNTPCT_EL0reads the physical counter, whereasCNTVCT_EL0reads the virtual counter, i.e. the physical count minusCNTVOFF_EL2(treated as zero when EL2 is absent or disabled). Access from lower exception levels may be trapped by the hypervisor.CNTHCTL_EL2.EL1PCTENis cleared, accessingCNTPCT_EL0from EL1 traps to EL2. Depending on hypervisor configuration, this either incurs costly VM-exit emulation overhead on every timer poll or triggers an unhandled synchronous exception.CNTVCT_EL0is intended for EL1/EL0 consumers, executes natively in hardware without trapping to EL2 under standard virtualisation setups, and provides a consistent monotonic counter on both bare metal and virtualised guests.Changes
common/sys/cpu.h: Updatedrdtsc()on AArch64 to readcntvct_el0instead ofcntpct_el0.checks/payloads/limine/arch_aarch64.c: Updatedarch_counter()in the Limine test payload to readcntvct_el0instead ofcntpct_el0.Verification & Testing
-Werrorwith 0 warnings and 0 errors.CNTVCT_EL0cleanly without exceptions.