Skip to contentSkip to conversation

Accessing an arbitrary user space from a module

DISCUSSION Durantez, Marc 2 participants 4 messages Apr 14, 1999

lore
Share & tools
lore
#0 lore raw

Hello,

I writing a module for an implementation of distributed shared memory on a group of computers over a LAN, but I still have not enought experience with the kernel.

My problem is that I don't know how to access an arbitrary user memory space from my module. Let us suppose I have a buffer in kernel space and I want to copy it in the memory space of process A at some virtual address.

First case: I am not at interrupt time but I am in the context of another process like a deamon or whatever.
I tried something using get_fs() and set_fs() but I don't really know what a mm_segment_t represents for an ultrasparc, I hoped it would work but it didn't (it wasn't a very rigourous test so may be it should work!)

Second case: At interrupt time, what can I do? I understand that provoquing a page falt is not an option so I got carefully the pte_t corresponding to the destination where I want to write, checked its validity with pte_present() but finally got a fault when accessing using paddr = (pte_page(*pte)|(addr&(~PAGE_MASK))+PAGE_OFFSET; where paddr should be the physical address. But I guess I will run into more trouble to mark the page as dirty or if the buffer I want to write is accross two or more pages.

Please, could you tell me where I am wrong and where should I look for more information on the web or in the source?

Thank you,

Marc

#1 lore raw

Date: Wed, 14 Apr 1999 11:44:41 +0900
From: "Durantez, Marc" <[email protected]>

First case: I am not at interrupt time but I am in the context of another process like a deamon or whatever.

copy_to_user(user_pointer, kernel_pointer, size);

Second case: At interrupt time, what can I do?

Allocate a kernel buffer in your driver beforehand, provide a device driver mmap() operation to let the user map this into his address space, at interrupt time copy into the kernel buffer and the data will magically appear into the user's mapping of it.

Later,
David S. Miller
[email protected]

#2 lore raw
In reply to Durantez, Marc
Quoted 5 lines

First case: I am not at interrupt time but I am in the context of another process like a deamon or whatever.

copy_to_user(user_pointer, kernel_pointer, size);

Should I understand that copy_to_user and the other functions of uaccess.h allow to access the memory of any user task? I thougth they accessed only the 'current' task's memory space... :-(