-
Notifications
You must be signed in to change notification settings - Fork 353
target/riscv: add is_virtual parameter to memory access method #1241
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
Open
fk-sc
wants to merge
2
commits into
riscv-collab:riscv
Choose a base branch
from
fk-sc:fk-sc/is-virtual
base: riscv
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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
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
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
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
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
Oops, something went wrong.
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.
Could you please double-check this line.
If
mmu_enabled
is false, shouldn'tis_virtual
be false as well?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.
Addressed
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.
@fk-sc can we discuss this design once again?
I don't like the suggested approach because riscv_rw_memory should always operate on virtual addresses by design. The decision on how the actual address translation is performed should be decided by lower level functions - that is I would expect for
r->access_memory()
to be called withis_virutual = true
. The fact that in some execution context virtual address is equal to physical is irrelevant at this level of abstraction.if there is a necessity to provide additional layer to simplify page-crossing translations - we can do it here and establish a contract that
r->access_memory
should access non-page crossing memory regions.please rename
mmu_enabled
tosatp_translation_required
.mmu_enabled
is too broad term that can confuse the reader (it definitely confuses me)@JanMatCodasip sorry for the mess, most likely we @fk-sc , @en-sc and me should have yet another round of internal discussion related to the above bulllets. Please consider this MR as a draft for now. You inputs are as always are very welcome, so please do share concerns/questions/suggestions regarding the matter (if you have any)
Uh oh!
There was an error while loading. Please reload this page.
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.
No problem at all. Thank you for letting me know.
Sounds good to me.
In that case, if you like, you can also make the code more clear by doing this:
riscv_rw_memory()
toriscv_rw_virt_memory()
riscv_rw_phys_memory()
(a thin wrapper overr->access_memory(args, /* is_virtual = */ false)
)virt2phys_mode
is set toSW
?I agree that
mmu_enabled
is not a clear name. It could also be calledmanual_satp_translation_needed
. The word "manual" is IMO important here as it means that OpenOCD must do the translation work (as opposed to the hardware).Furthermore, I am concerned about the
riscv_mmu()
itself. Ifvirt2phys
mode is set toHW
, thenriscv_mmu()
returns False, which looks incorrect. As a result:riscv_virt2phys()
function (and the TCL commandvirt2phys
) will return 1:1 mapping instead of correctly translated addresses.target_alloc_working_area_try()
will allocate the work area in the physical address range (-work-area-phys
) instead of virtual (-work-area-virt
).Should the initial check in riscv_mmu() be fixed this way?