-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arm: init CNTVOFF #2052
Merged
Merged
arm: init CNTVOFF #2052
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -335,6 +335,38 @@ UNWIND( .fnstart) | |
cps #CPSR_MODE_MON | ||
/* Point just beyond sm_ctx.sec */ | ||
sub sp, r0, #(SM_CTX_SIZE - SM_CTX_NSEC) | ||
|
||
#ifdef CFG_INIT_CNTVOFF | ||
read_scr r0 | ||
orr r0, r0, #SCR_NS /* Set NS bit in SCR */ | ||
write_scr r0 | ||
isb | ||
|
||
/* | ||
* Accessing CNTVOFF: | ||
* If the implementation includes the Virtualization Extensions | ||
* this is a RW register, accessible from Hyp mode, and | ||
* from Monitor mode when SCR.NS is set to 1. | ||
* If the implementation includes the Security Extensions | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here replace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comments are directly from ARM architecture reference mannual. So keep Security extensions. |
||
* but not the Virtualization Extensions, an MCRR or MRRC to | ||
* the CNTVOFF encoding is UNPREDICTABLE if executed in Monitor | ||
* mode, regardless of the value of SCR.NS. | ||
*/ | ||
read_idpfr1 r2 | ||
mov r3, r2 | ||
ands r3, r3, #IDPFR1_GENTIMER_MASK | ||
beq .no_gentimer | ||
ands r2, r2, #IDPFR1_VIRT_MASK | ||
beq .no_gentimer | ||
mov r2, #0 | ||
write_cntvoff r2, r2 | ||
|
||
.no_gentimer: | ||
bic r0, r0, #SCR_NS /* Clr NS bit in SCR */ | ||
write_scr r0 | ||
isb | ||
#endif | ||
|
||
msr cpsr, r1 | ||
|
||
#ifdef CFG_CORE_WORKAROUND_SPECTRE_BP | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need an ISB after setting (and clearing) SCR[NS]?
Also, maybe use a sequence where we switch in non secure only if CNTVOFF is accessed. Yet, this is not a big issue: we're booting, no perf penalty...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ISB is needed. I'll add it.