Theoretically this is supposed to be interchangeable with real
kernel code. Use kmem_alloc/free instead of some wily homerolled rump interfaces for memory allocation.
This commit is contained in:
parent
2c7914f588
commit
deeebf9713
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: auth.c,v 1.4 2008/01/02 18:15:14 pooka Exp $ */
|
||||
/* $NetBSD: auth.c,v 1.5 2008/01/03 02:48:02 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
@ -31,6 +31,7 @@
|
||||
#include <sys/param.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/kauth.h>
|
||||
#include <sys/kmem.h>
|
||||
|
||||
#include "rump.h"
|
||||
#include "rumpuser.h"
|
||||
@ -40,19 +41,16 @@ struct kauth_cred {
|
||||
gid_t cr_gid;
|
||||
|
||||
size_t cr_ngroups;
|
||||
gid_t cr_groups[0];
|
||||
gid_t cr_groups[NGROUPS];
|
||||
};
|
||||
|
||||
kauth_cred_t
|
||||
rump_cred_create(uid_t uid, gid_t gid, size_t ngroups, gid_t *groups)
|
||||
{
|
||||
kauth_cred_t cred;
|
||||
size_t credsize;
|
||||
|
||||
KASSERT(ngroups <= NGROUPS);
|
||||
|
||||
credsize = sizeof(struct kauth_cred) + ngroups * sizeof(gid_t);
|
||||
cred = rumpuser_malloc(credsize, 0);
|
||||
cred = kmem_alloc(sizeof(struct kauth_cred), KM_SLEEP);
|
||||
|
||||
cred->cr_uid = uid;
|
||||
cred->cr_gid = gid;
|
||||
@ -66,7 +64,7 @@ void
|
||||
rump_cred_destroy(kauth_cred_t cred)
|
||||
{
|
||||
|
||||
rumpuser_free(cred);
|
||||
kmem_free(cred, sizeof(struct kauth_cred));
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pool.c,v 1.5 2008/01/02 18:15:14 pooka Exp $ */
|
||||
/* $NetBSD: pool.c,v 1.6 2008/01/03 02:48:03 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
@ -113,7 +113,7 @@ pool_get(struct pool *pp, int flags)
|
||||
if (pp->pr_size == 0)
|
||||
panic("%s: pool unit size 0. not initialized?", __func__);
|
||||
|
||||
rv = rumpuser_malloc(pp->pr_size, 1);
|
||||
rv = kmem_alloc(pp->pr_size, KM_NOSLEEP);
|
||||
if (rv == NULL && (flags & PR_WAITOK && (flags & PR_LIMITFAIL) == 0))
|
||||
panic("%s: out of memory and PR_WAITOK", __func__);
|
||||
|
||||
@ -124,7 +124,7 @@ void
|
||||
pool_put(struct pool *pp, void *item)
|
||||
{
|
||||
|
||||
rumpuser_free(item);
|
||||
kmem_free(item, pp->pr_size);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rump.c,v 1.27 2008/01/02 18:15:14 pooka Exp $ */
|
||||
/* $NetBSD: rump.c,v 1.28 2008/01/03 02:48:03 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
@ -138,8 +138,7 @@ rump_mnt_init(struct vfsops *vfsops, int mntflags)
|
||||
{
|
||||
struct mount *mp;
|
||||
|
||||
mp = rumpuser_malloc(sizeof(struct mount), 0);
|
||||
memset(mp, 0, sizeof(struct mount));
|
||||
mp = kmem_zalloc(sizeof(struct mount), KM_SLEEP);
|
||||
|
||||
mp->mnt_op = vfsops;
|
||||
mp->mnt_flag = mntflags;
|
||||
@ -172,7 +171,7 @@ rump_mnt_destroy(struct mount *mp)
|
||||
{
|
||||
|
||||
mount_finispecific(mp);
|
||||
rumpuser_free(mp);
|
||||
kmem_free(mp, sizeof(*mp));
|
||||
}
|
||||
|
||||
struct componentname *
|
||||
@ -181,8 +180,7 @@ rump_makecn(u_long nameiop, u_long flags, const char *name, size_t namelen,
|
||||
{
|
||||
struct componentname *cnp;
|
||||
|
||||
cnp = rumpuser_malloc(sizeof(struct componentname), 0);
|
||||
memset(cnp, 0, sizeof(struct componentname));
|
||||
cnp = kmem_zalloc(sizeof(struct componentname), KM_SLEEP);
|
||||
|
||||
cnp->cn_nameiop = nameiop;
|
||||
cnp->cn_flags = flags;
|
||||
@ -210,7 +208,7 @@ rump_freecn(struct componentname *cnp, int flags)
|
||||
} else {
|
||||
PNBUF_PUT(cnp->cn_pnbuf);
|
||||
}
|
||||
rumpuser_free(cnp);
|
||||
kmem_free(cnp, sizeof(*cnp));
|
||||
}
|
||||
|
||||
int
|
||||
@ -250,7 +248,7 @@ rump_fakeblk_register(const char *path)
|
||||
if (rumpuser_realpath(path, buf, &error) == NULL)
|
||||
return error;
|
||||
|
||||
fblk = rumpuser_malloc(sizeof(struct fakeblk), 1);
|
||||
fblk = kmem_alloc(sizeof(struct fakeblk), KM_NOSLEEP);
|
||||
if (fblk == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
@ -277,7 +275,7 @@ rump_fakeblk_deregister(const char *path)
|
||||
return;
|
||||
|
||||
LIST_REMOVE(fblk, entries);
|
||||
rumpuser_free(fblk);
|
||||
kmem_free(fblk, sizeof(*fblk));
|
||||
}
|
||||
|
||||
void
|
||||
@ -314,7 +312,7 @@ rump_vattr_init()
|
||||
{
|
||||
struct vattr *vap;
|
||||
|
||||
vap = rumpuser_malloc(sizeof(struct vattr), 0);
|
||||
vap = kmem_alloc(sizeof(struct vattr), KM_SLEEP);
|
||||
vattr_null(vap);
|
||||
|
||||
return vap;
|
||||
@ -345,7 +343,7 @@ void
|
||||
rump_vattr_free(struct vattr *vap)
|
||||
{
|
||||
|
||||
rumpuser_free(vap);
|
||||
kmem_free(vap, sizeof(*vap));
|
||||
}
|
||||
|
||||
void
|
||||
@ -386,8 +384,8 @@ rump_uio_setup(void *buf, size_t bufsize, off_t offset, enum rump_uiorw rw)
|
||||
panic("%s: invalid rw %d", __func__, rw);
|
||||
}
|
||||
|
||||
uio = rumpuser_malloc(sizeof(struct uio), 0);
|
||||
uio->uio_iov = rumpuser_malloc(sizeof(struct iovec), 0);
|
||||
uio = kmem_alloc(sizeof(struct uio), KM_SLEEP);
|
||||
uio->uio_iov = kmem_alloc(sizeof(struct iovec), KM_SLEEP);
|
||||
|
||||
uio->uio_iov->iov_base = buf;
|
||||
uio->uio_iov->iov_len = bufsize;
|
||||
@ -421,8 +419,8 @@ rump_uio_free(struct uio *uio)
|
||||
size_t resid;
|
||||
|
||||
resid = uio->uio_resid;
|
||||
rumpuser_free(uio->uio_iov);
|
||||
rumpuser_free(uio);
|
||||
kmem_free(uio->uio_iov, sizeof(*uio->uio_iov));
|
||||
kmem_free(uio, sizeof(*uio));
|
||||
|
||||
return resid;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: specfs.c,v 1.15 2008/01/02 18:15:14 pooka Exp $ */
|
||||
/* $NetBSD: specfs.c,v 1.16 2008/01/03 02:48:03 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
@ -219,7 +219,7 @@ rump_specstrategy(void *v)
|
||||
if (bp->b_flags & B_ASYNC) {
|
||||
struct rumpuser_aio *rua;
|
||||
|
||||
rua = rumpuser_malloc(sizeof(struct rumpuser_aio), 0);
|
||||
rua = kmem_alloc(sizeof(struct rumpuser_aio), KM_SLEEP);
|
||||
rua->rua_fd = sp->rsp_fd;
|
||||
rua->rua_data = bp->b_data;
|
||||
rua->rua_dlen = bp->b_bcount;
|
||||
@ -239,7 +239,7 @@ rump_specstrategy(void *v)
|
||||
* so for now set N_AIOS high and FIXXXME some day.
|
||||
*/
|
||||
if ((rua_head+1) % N_AIOS == rua_tail) {
|
||||
rumpuser_free(rua);
|
||||
kmem_free(rua, sizeof(*rua));
|
||||
rumpuser_mutex_exit(&rua_mtx);
|
||||
goto syncfallback;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vfs.c,v 1.27 2008/01/03 02:44:05 pooka Exp $ */
|
||||
/* $NetBSD: vfs.c,v 1.28 2008/01/03 02:48:03 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
@ -84,8 +84,7 @@ getnewvnode(enum vtagtype tag, struct mount *mp, int (**vops)(void *),
|
||||
{
|
||||
struct vnode *vp;
|
||||
|
||||
vp = rumpuser_malloc(sizeof(struct vnode), 0);
|
||||
memset(vp, 0, sizeof(struct vnode));
|
||||
vp = kmem_zalloc(sizeof(struct vnode), KM_SLEEP);
|
||||
vp->v_mount = mp;
|
||||
vp->v_tag = tag;
|
||||
vp->v_op = vops;
|
||||
@ -110,9 +109,9 @@ rump_putnode(struct vnode *vp)
|
||||
{
|
||||
|
||||
if (vp->v_specinfo)
|
||||
rumpuser_free(vp->v_specinfo);
|
||||
kmem_free(vp->v_specinfo, sizeof(*vp->v_specinfo));
|
||||
UVM_OBJ_DESTROY(&vp->v_uobj);
|
||||
rumpuser_free(vp);
|
||||
kmem_free(vp, sizeof(*vp));
|
||||
}
|
||||
|
||||
void
|
||||
@ -307,7 +306,7 @@ makevnode(struct stat *sb, const char *path)
|
||||
struct vnode *vp;
|
||||
struct rump_specpriv *sp;
|
||||
|
||||
vp = rumpuser_malloc(sizeof(struct vnode), 0);
|
||||
vp = kmem_alloc(sizeof(struct vnode), KM_SLEEP);
|
||||
vp->v_size = vp->v_writesize = sb->st_size;
|
||||
vp->v_type = mode2vt(sb->st_mode);
|
||||
if (vp->v_type != VBLK)
|
||||
@ -317,9 +316,9 @@ makevnode(struct stat *sb, const char *path)
|
||||
if (vp->v_type != VBLK)
|
||||
panic("namei: only VBLK results supported currently");
|
||||
|
||||
vp->v_specinfo = rumpuser_malloc(sizeof(struct specinfo), 0);
|
||||
vp->v_specinfo = kmem_alloc(sizeof(struct specinfo), KM_SLEEP);
|
||||
vp->v_rdev = sb->st_dev;
|
||||
sp = rumpuser_malloc(sizeof(struct rump_specpriv), 0);
|
||||
sp = kmem_alloc(sizeof(struct rump_specpriv), KM_SLEEP);
|
||||
strcpy(sp->rsp_path, path);
|
||||
vp->v_data = sp;
|
||||
vp->v_op = spec_vnodeop_p;
|
||||
@ -443,7 +442,7 @@ checkalias(struct vnode *nvp, dev_t nvp_rdev, struct mount *mp)
|
||||
|
||||
/* Can this cause any funnies? */
|
||||
|
||||
nvp->v_specinfo = rumpuser_malloc(sizeof(struct specinfo), 0);
|
||||
nvp->v_specinfo = kmem_alloc(sizeof(struct specinfo), KM_SLEEP);
|
||||
nvp->v_rdev = nvp_rdev;
|
||||
return NULLVP;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: vm.c,v 1.26 2008/01/02 15:44:04 pooka Exp $ */
|
||||
/* $NetBSD: vm.c,v 1.27 2008/01/03 02:48:03 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
|
||||
@ -97,13 +97,11 @@ rumpvm_makepage(struct uvm_object *uobj, voff_t off)
|
||||
{
|
||||
struct vm_page *pg;
|
||||
|
||||
pg = rumpuser_malloc(sizeof(struct vm_page), 0);
|
||||
memset(pg, 0, sizeof(struct vm_page));
|
||||
pg = kmem_zalloc(sizeof(struct vm_page), KM_SLEEP);
|
||||
pg->offset = off;
|
||||
pg->uobject = uobj;
|
||||
|
||||
pg->uanon = (void *)rumpuser_malloc(PAGE_SIZE, 0);
|
||||
memset((void *)pg->uanon, 0, PAGE_SIZE);
|
||||
pg->uanon = (void *)kmem_zalloc(PAGE_SIZE, KM_SLEEP);
|
||||
pg->flags = PG_CLEAN|PG_BUSY|PG_FAKE;
|
||||
|
||||
TAILQ_INSERT_TAIL(&uobj->memq, pg, listq);
|
||||
@ -125,8 +123,8 @@ uvm_pagefree(struct vm_page *pg)
|
||||
wakeup(pg);
|
||||
|
||||
TAILQ_REMOVE(&uobj->memq, pg, listq);
|
||||
rumpuser_free((void *)pg->uanon);
|
||||
rumpuser_free(pg);
|
||||
kmem_free((void *)pg->uanon, PAGE_SIZE);
|
||||
kmem_free(pg, sizeof(*pg));
|
||||
}
|
||||
|
||||
struct rumpva {
|
||||
@ -143,7 +141,7 @@ rumpvm_enterva(vaddr_t addr, struct vm_page *pg)
|
||||
{
|
||||
struct rumpva *rva;
|
||||
|
||||
rva = rumpuser_malloc(sizeof(struct rumpva), 0);
|
||||
rva = kmem_alloc(sizeof(struct rumpva), KM_SLEEP);
|
||||
rva->addr = addr;
|
||||
rva->pg = pg;
|
||||
mutex_enter(&rvamtx);
|
||||
@ -159,7 +157,7 @@ rumpvm_flushva()
|
||||
mutex_enter(&rvamtx);
|
||||
while ((rva = LIST_FIRST(&rvahead)) != NULL) {
|
||||
LIST_REMOVE(rva, entries);
|
||||
rumpuser_free(rva);
|
||||
kmem_free(rva, sizeof(*rva));
|
||||
}
|
||||
mutex_exit(&rvamtx);
|
||||
}
|
||||
@ -252,8 +250,7 @@ uao_create(vsize_t size, int flags)
|
||||
{
|
||||
struct uvm_object *uobj;
|
||||
|
||||
uobj = rumpuser_malloc(sizeof(struct uvm_object), 0);
|
||||
memset(uobj, 0, sizeof(struct uvm_object));
|
||||
uobj = kmem_zalloc(sizeof(struct uvm_object), KM_SLEEP);
|
||||
uobj->pgops = &aobj_pager;
|
||||
TAILQ_INIT(&uobj->memq);
|
||||
mutex_init(&uobj->vmobjlock, MUTEX_DEFAULT, IPL_NONE);
|
||||
@ -266,7 +263,7 @@ uao_detach(struct uvm_object *uobj)
|
||||
{
|
||||
|
||||
ao_put(uobj, 0, 0, PGO_ALLPAGES | PGO_FREE);
|
||||
rumpuser_free(uobj);
|
||||
kmem_free(uobj, sizeof(*uobj));
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user