Skip to content

Commit

Permalink
fix(core/vmm): fixe use of fences on VMM install
Browse files Browse the repository at this point in the history
First a fence was required to enforce the dependency on
`install_info_ready` being set calling vmm_vm_install as there is no
real data dependency.

Second, we move the write fence which ensures the write to the page
table is visible to within the install function. It is it responsibility
to ensure it returns with its effects visible.

Signed-off-by: Jose Martins <josemartins90@gmail.com>
  • Loading branch information
josecm committed Dec 10, 2023
1 parent e98c20a commit 2da121f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/core/mmu/vmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ void vmm_vm_install(struct vm_install_info* install_info)
{
pte_t* pte = pt_get_pte(&cpu()->as.pt, 0, (vaddr_t)install_info->base);
*pte = install_info->vm_section_pte;
// We don't invalidate the TLB as we know there was no previous mapping or accesses to the
// addresses in the VM section. Just make sure the write commited before leaving.
fence_ord_write();
}
2 changes: 1 addition & 1 deletion src/core/vmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ static struct vm_allocation* vmm_alloc_install_vm(vmid_t vm_id, bool master)
vm_assign[vm_id].install_info_ready = true;
} else {
while (!vm_assign[vm_id].install_info_ready) { }
fence_ord_read();
vmm_vm_install(&vm_assign[vm_id].vm_install_info);
fence_sync_write();
}

return vm_alloc;
Expand Down

0 comments on commit 2da121f

Please sign in to comment.