-
Notifications
You must be signed in to change notification settings - Fork 84
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
Add TLB to bypass the second stage translation(GPA to HPA) #179
base: master
Are you sure you want to change the base?
Conversation
src/isa/riscv64/system/priv.c
Outdated
@@ -801,24 +804,24 @@ static word_t priv_instr(uint32_t op, const rtlreg_t *src) { | |||
if(cpu.v) longjmp_exception(EX_VI); | |||
if(cpu.mode == MODE_U) longjmp_exception(EX_II); | |||
if(!(cpu.mode == MODE_M || (cpu.mode == MODE_S && !cpu.v))) longjmp_exception(EX_II); | |||
mmu_tlb_flush(*src); | |||
mmu_vmtlb_flush(*src); |
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.
Read the function of "hfence.vvma" in the RISC-V Instruction Set Manual
Volume II: Privileged Architecture
src/isa/riscv64/system/priv.c
Outdated
break; | ||
#ifdef CONFIG_RV_SVINVAL | ||
case 0x13: // hinval.vvma | ||
if(cpu.v) longjmp_exception(EX_VI); | ||
if(cpu.mode == MODE_U) longjmp_exception(EX_II); | ||
mmu_tlb_flush(*src); | ||
mmu_vmtlb_flush(*src); |
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.
Read the function of "hinval.vvma" in the RISC-V Instruction Set Manual
Volume II: Privileged Architecture
src/memory/host-tlb.c
Outdated
e->offset = guest_to_host(paddr) - vaddr; | ||
e->gvpn = hosttlb_vpn(vaddr); | ||
hosttlb_insert(vaddr, paddr, type); | ||
hosttlb_insert(vaddr, paddr, type); |
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.
insert tlb twice?
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.
Maybe the problem about merging, I have fixed it.
src/memory/host-tlb.c
Outdated
extern bool has_two_stage_translation(); | ||
if(has_two_stage_translation()){ | ||
if (has_two_stage_translation()) { |
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.
The reason why I put two stage translation in this place is to skip tlb translation when NEMU don't have tlb for the second stage. If you add the second stage tlb to NEMU, you should change these codes.
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.
But I only add the TLB for the second stage, which means it still need to skip previous host tlb lookup(va -> pa).
P.S.
Maybe I can add a TLB mapping GVA to GPA. However, this cannot avoid adding judgement here. And I don't think adding this will effectively improve the performance because there will be another large table to be flushed.
The origin 2-stage translation do not utilize TLB but walk the whole translation path, which consume a lot. I add a HOSTVMTLB for the translation from GPA to HPA.
Otherwise, I also add a TLB mapping GVA to PA.
The effect of acceleration depends on how long the VM stays. By test, it accelerates xvisor workload by 300%, and keep almost the same speed under KVM workload.