-
Notifications
You must be signed in to change notification settings - Fork 104
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
Unify MMU translation APIs #533
Conversation
ff5d4d7
to
88f83c8
Compare
src/riscv.h
Outdated
* ifetch do not leverage this translation because basic block | ||
* might be retranslated and the corresponding PTE is NULL. | ||
*/ | ||
typedef riscv_word_t (*riscv_mem_trans)(riscv_t *rv, |
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.
Specify _t
suffix for typedef.
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.
I am not sure if riscv_mem_trans
is meaningful enough. How about mmu_translate_t
or mem_translate_t
?
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.
Specify
_t
suffix for typedef.
For only this one? What about the others?
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.
I am not sure if
riscv_mem_trans
is meaningful enough. How aboutmmu_translate_t
ormem_translate_t
?
Use riscv
prefix for consistency with others. I would go with riscv_mem_translate_t
, is it OK?
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.
Use
riscv
prefix for consistency with others. I would go withriscv_mem_translate_t
, is it OK?
It looks good.
The reason not to use "trans" is that it is an existing adjective which might not be intended to mean "translate." See https://dictionary.cambridge.org/dictionary/english/trans
To enable guest OS to run SDL applications using bidirectional queues, the VMM or system emulator must access the guest OS's virtual memory, as the queues are defined there. This requires MMU translation. In addition, the queues event data size likely larger than a word (maybe a page), thus the existing rv->io.mem_{read,write}_w do not sufficient for such memory manipulation. Export rv->io.mem_translate() to perform gVA2gPA translation. Unifying MMU translation logic by using rv->io.mem_translate(), eliminating redundant flows: mmu_walk -> check_pg_fault -> check_signal -> get_ppn_and_offset. Also, this interface allowing src/syscall_sdl.c to handle virtual memory by first translating the gVA2gPA, followed by memory_{read/write} the chunk of data at once. TODO: dTLB can be introduced in rv->io.mem_trans() to cache the gVA2gPA translation. See: sysprog21#310, sysprog21#510
88f83c8
to
dfab12e
Compare
Thank @ChinYikMing for contributing! |
To enable guest OS to run SDL applications using bidirectional queues, the VMM or system emulator must access the guest OS's virtual memory, as the queues are defined there. This requires MMU translation. In addition, the queues event data size likely larger than a word (maybe a page), thus the existing rv->io.mem_{read,write}_w do not sufficient for such memory manipulation.
Export rv->io.mem_translate() to perform gVA2gPA translation. Unifying MMU translation logic by using
rv->io.mem_translate(), eliminating redundant flows: mmu_walk -> check_pg_fault -> check_signal -> get_ppn_and_offset.
Also, this interface allowing src/syscall_sdl.c to handle virtual memory by first translating the gVA2gPA, followed by memory_{read/write} the chunk of data at once.
TODO: dTLB can be introduced in rv->io.mem_trans() to cache the gVA2gPA translation.
See: #310, #510