Hi,

I am using openbsd 6.8 on a raspberry pi 4. I have a problem and wonder if
this is an arm
or arm64 specific bug.

In my code I am creating an uvm_object and mapping it in kernel memory
using uvm_map.

uvm_map returns an address which is not aligned with PAGE_SIZE and later
when I call
uvm_unmap it panics because uvm_unmap checks for memory to be page aligned.

This is a summary of the code that creates the map:

struct uvm_object * the_uvm_object = uao_create(memory_size, 0);
uao_reference(the_uvm_object);
uvm_map(kernel_map, (vaddr_t *)&memory, round_page(memory_size),
the_uvm_object,
    0, 0, UVM_MAPFLAG(PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE,
    MAP_INHERIT_SHARED, MADV_NORMAL, 0));

memory now points to an address which has 0x004 in its lower 12 bits! Later
I do this:

uvm_unmap(kernel_map, memory, memory + memory_size);

And uvm_unmap panics. Note: memory_size is a multiple of PAGE_SIZE in my
code.

I have seen similar code patterns around in the kernel code, so I am a bit
surprised that
my code receives a non aligned address from uvm_map and all the other
instances do.

Am I missing something or is this a bug?

Thanks,
Alessandro

Reply via email to