Subject: uvm_loan and passing large data structures to a syscall
To: None <>
From: Pete Yandell <>
List: tech-kern
Date: 07/02/2004 13:26:50
I'm writing a some networking related code (as an LKM) that looks up
incoming packets in large hash tables. What I'd like to do is build
these hash tables in a userland process and pass them into the kernel
via a syscall. I want to avoid having to copy the tables into kernel
space with copyin, so uvm_loan looks like what I need.

I don't know my way around UVM at all, so can anybody point me to some
documentation or sample code that shows how to do this? Say my syscall
handler looks very roughly like this:

set_hash_table (struct lwp* lwp, void* void_args, register_t* return_value)
    struct set_hash_table_args* args = void_args;
    void* hash_table = SCARG(args, hash_table);
    unsigned long table_size = SCARG(args, table_size);

    void* v = malloc (table_size / PAGE_SIZE * sizeof(int));

    /* How do I get the map argument to uvm_loan?
     * Are there locking issues?
     * Anything else that I'm missing? */
    uvm_loan (???, hash_table, table_size, v, UVM_LOAN_TOPAGE);

    return 0;


Pete Yandell