Try to force heap allocation of vmaps

上级 909c7ad2
...@@ -69,13 +69,12 @@ struct vmap { ...@@ -69,13 +69,12 @@ struct vmap {
struct radix rx; struct radix rx;
#endif #endif
static vmap* alloc();
atomic<u64> ref; atomic<u64> ref;
pgmap *const pml4; // Page table pgmap *const pml4; // Page table
char *const kshared; char *const kshared;
vmap();
~vmap();
bool replace_vma(vma *a, vma *b); bool replace_vma(vma *a, vma *b);
void decref(); void decref();
...@@ -88,11 +87,15 @@ struct vmap { ...@@ -88,11 +87,15 @@ struct vmap {
int copyout(uptr va, void *p, u64 len); int copyout(uptr va, void *p, u64 len);
int sbrk(ssize_t n, uptr *addr); int sbrk(ssize_t n, uptr *addr);
NEW_DELETE_OPS(vmap)
uptr brk_; // Top of heap uptr brk_; // Top of heap
private: private:
vmap();
vmap(const vmap&);
vmap& operator=(const vmap&);
~vmap();
NEW_DELETE_OPS(vmap)
int pagefault_wcow(vma *m); int pagefault_wcow(vma *m);
struct spinlock brklock_; struct spinlock brklock_;
}; };
...@@ -168,7 +168,7 @@ exec(const char *path, char **argv) ...@@ -168,7 +168,7 @@ exec(const char *path, char **argv)
if(elf.magic != ELF_MAGIC) if(elf.magic != ELF_MAGIC)
goto bad; goto bad;
if((vmp = new vmap()) == 0) if((vmp = vmap::alloc()) == 0)
goto bad; goto bad;
// Arguments for work queue // Arguments for work queue
......
...@@ -243,7 +243,7 @@ inituser(void) ...@@ -243,7 +243,7 @@ inituser(void)
if (p->ftable == nullptr) if (p->ftable == nullptr)
panic("userinit: new filetable"); panic("userinit: new filetable");
bootproc = p; bootproc = p;
if((p->vmap = new vmap()) == 0) if((p->vmap = vmap::alloc()) == 0)
panic("userinit: out of vmaps?"); panic("userinit: out of vmaps?");
vmnode *vmn = new vmnode(PGROUNDUP(_initcode_size) / PGSIZE); vmnode *vmn = new vmnode(PGROUNDUP(_initcode_size) / PGSIZE);
if(vmn == 0) if(vmn == 0)
...@@ -481,7 +481,7 @@ threadalloc(void (*fn)(void *), void *arg) ...@@ -481,7 +481,7 @@ threadalloc(void (*fn)(void *), void *arg)
if (p == nullptr) if (p == nullptr)
return 0; return 0;
p->vmap = new vmap(); p->vmap = vmap::alloc();
if (p->vmap == nullptr) { if (p->vmap == nullptr) {
freeproc(p); freeproc(p);
return 0; return 0;
......
...@@ -138,6 +138,12 @@ vma::~vma() ...@@ -138,6 +138,12 @@ vma::~vma()
* vmap * vmap
*/ */
vmap*
vmap::alloc(void)
{
return new vmap();
}
vmap::vmap() : vmap::vmap() :
#if VM_CRANGE #if VM_CRANGE
cr(10), cr(10),
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论