diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-09-14 12:47:03 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-09-14 12:47:03 -0700 |
commit | 6fb355c58c23e932309829b6d57f17e91d93b018 (patch) | |
tree | 98badf6e427c86b1c3f577fccdf85dba4a82dfbd /pk | |
parent | 4a37572381acc146da66720f1f8073772f2c9119 (diff) | |
download | pk-6fb355c58c23e932309829b6d57f17e91d93b018.zip pk-6fb355c58c23e932309829b6d57f17e91d93b018.tar.gz pk-6fb355c58c23e932309829b6d57f17e91d93b018.tar.bz2 |
Increase VMR limit for SPEC
Diffstat (limited to 'pk')
-rw-r--r-- | pk/vm.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -14,9 +14,9 @@ typedef struct { int prot; } vmr_t; -#define MAX_VMR 32 +#define MAX_VMR (RISCV_PGSIZE / sizeof(vmr_t)) spinlock_t vm_lock = SPINLOCK_INIT; -static vmr_t vmrs[MAX_VMR]; +static vmr_t* vmrs; pte_t* root_page_table; static uintptr_t first_free_page; @@ -34,10 +34,15 @@ static uintptr_t __page_alloc() static vmr_t* __vmr_alloc(uintptr_t addr, size_t length, file_t* file, size_t offset, unsigned refcnt, int prot) { - for (vmr_t* v = vmrs; v < vmrs + MAX_VMR; v++) - { - if (v->refcnt == 0) - { + if (!vmrs) { + spinlock_lock(&vm_lock); + if (!vmrs) + vmrs = (vmr_t*)__page_alloc(); + spinlock_unlock(&vm_lock); + } + + for (vmr_t* v = vmrs; v < vmrs + MAX_VMR; v++) { + if (v->refcnt == 0) { if (file) file_incref(file); v->addr = addr; |