Skip to content

Commit

Permalink
fix(aarch32): use lvl 1 as the shared level for vm install
Browse files Browse the repository at this point in the history
The level of page table where entries are shared for aarch32 is lvl 1.
By resharing the lvl 0 pte, this was causing erroneous mappings on
secondary cores.

Signed-off-by: Jose Martins <[email protected]>
  • Loading branch information
josecm committed Mar 24, 2024
1 parent a7ff83a commit 7189a89
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/arch/armv8/armv8-a/aarch32/inc/arch/bao.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define BAO_VAS_TOP (0x80000000)
#define PAGE_SIZE (0x1000)
#define STACK_SIZE (PAGE_SIZE)
#define VM_SHARED_PT_LVL (1)

#define GPR(N) "r" #N

Expand Down
1 change: 1 addition & 0 deletions src/arch/armv8/armv8-a/aarch64/inc/arch/bao.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define BAO_VAS_TOP (0xff0000000000)
#define PAGE_SIZE (0x1000)
#define STACK_SIZE (PAGE_SIZE)
#define VM_SHARED_PT_LVL (0)

#define GPR(N) "x" #N

Expand Down
1 change: 1 addition & 0 deletions src/arch/riscv/inc/arch/bao.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#define PAGE_SIZE (0x1000)
#define STACK_SIZE (PAGE_SIZE)
#define VM_SHARED_PT_LVL (0)

#ifndef __ASSEMBLER__

Expand Down
4 changes: 2 additions & 2 deletions src/core/mmu/vmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ struct vm_install_info vmm_get_vm_install_info(struct vm_allocation* vm_alloc)
{
struct vm_install_info info = {
.base = vm_alloc->base,
.vm_section_pte = *pt_get_pte(&cpu()->as.pt, 0, vm_alloc->base),
.vm_section_pte = *pt_get_pte(&cpu()->as.pt, VM_SHARED_PT_LVL, vm_alloc->base),
};
return info;
}

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_t* pte = pt_get_pte(&cpu()->as.pt, VM_SHARED_PT_LVL, (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.
Expand Down

0 comments on commit 7189a89

Please sign in to comment.