Re: [q] fundamental thing I am still missing about put_user().

Tigran Aivazian (tigran@sco.COM)
Tue, 21 Dec 1999 10:12:10 +0000 (GMT)


btw (before I receive lots of advices), another way of doing what I wanted
is to add a refcount to struct vm_struct and increment it in vread()
and drop the spinlock (and set to 1 in get_vm_area()) and check if it is
not 1 in vfree()) but that would prevent us from coalescing the vm ranges
if we want to do so in the future. So I prefer to learn properly how to
kmap() user address ranges and do it that way (both here and in a couple
of other places I have my eyes upon).

Regards,
------
Tigran A. Aivazian | http://www.sco.com
Escalations Research Group | tel: +44-(0)1923-813796
Santa Cruz Operation Ltd | http://www.ocston.org/~tigran

On Tue, 21 Dec 1999, Tigran Aivazian wrote:

> forget about my original question - having thought a bit more I
> restructure my question thus:
>
> Given a user virtual address and a count I need to be able to get at each
> struct page * page that covers it. Then I can kmap() each page in a loop
> and generate very safe range (i.e. use __copy_to_user()) inside vread()),
> just like file_read_actor() does when called from do_generic_file_read().
>
> So I need something like uvirt_to_page() macro.
>
> Regards,
> ------
> Tigran A. Aivazian | http://www.sco.com
> Escalations Research Group | tel: +44-(0)1923-813796
> Santa Cruz Operation Ltd | http://www.ocston.org/~tigran
>
> On Tue, 21 Dec 1999, Tigran Aivazian wrote:
>
> > having thought of it for a minute, it is probably not the best design
> > though.
> >
> > I am going to try to change vread() interface to accept kernel addresses
> > and make temporary kernel buffers in read_kmem() and see what happens.
> >
> > Btw, Stephen mentioned kmapping user addresses but I still have not seen
> > any working examples of that - the stuff in mm/filemap.c only deals with a
> > page at a time...
> >
> > Regards,
> > Tigran.
> >
> > On Tue, 21 Dec 1999, Tigran Aivazian wrote:
> >
> > > Hi,
> > >
> > > I have a question about writing to userspace buffers. Can I do this in
> > > read_kmem() (read method of /dev/kmem):
> > >
> > > if (verify_area(VERIFY_WRITE, buf, count))
> > > return -EFAULT;
> > >
> > > lock_kernel();
> > > write to user buf without any worries, even taking spinlocks if needed.
> > > unlock_kernel();
> > >
> > > If I can do this then it is very useful because we could then hold a
> > > spinlock in mm/vmalloc.c:vread() which means vmlist can be protected by a
> > > simple spinlock which means vmalloc()/vfree()/ioremap() (i.e. really
> > > vfree() and get_vm_area()) can be made SMP safe, i.e. without forcing
> > > callers to have lock/unlock_kernel().
> > >
> > > Thank you for your patient explanation :)
> > > ------
> > > Tigran A. Aivazian | http://www.sco.com
> > > Escalations Research Group | tel: +44-(0)1923-813796
> > > Santa Cruz Operation Ltd | http://www.ocston.org/~tigran
> > >
> > >
> > >
> >
> >
> >
>
>
>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/