All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dan Maas" <dmaas@dcine.com>
To: <linux-kernel@vger.kernel.org>
Subject: Re: forcibly unmap pages in driver?
Date: Wed, 6 Jun 2001 23:46:05 -0400	[thread overview]
Message-ID: <044a01c0ef04$61559440$0701a8c0@morph> (raw)
In-Reply-To: <fa.fk487iv.1d2ksb0@ifi.uio.no> <fa.f3ckgov.ti0mb3@ifi.uio.no>

Just an update to my situation... I've implemented my idea of clearing the
associated PTE's when I need to free the DMA buffer, then re-filling them in
nopage(). This seems to work fine; if the user process tries anything fishy,
it gets a SIGBUS instead of accessing the old mapping.

I encountered two difficulties with the implementation:

1) zap_page_range(), flush_cache_range(), and flush_tlb_range() are not
exported to drivers. I basically copied the guts of zap_page_range() into my
driver, which seems to work OK on x86, but I know it will have trouble with
architectures that require special treatment of PTE manipulation...

2) the state of mm->mmap_sem is unknown when my file_operations->release()
function is called. If release() is called when the last FD closes, then
mm->mmap_sem is not taken. But if release() is called from do_munmap, then
mmap_sem has already been taken. So, it is risky to mess with vma's inside
of release()...

Regards,
Dan

> >> Later, the program calls the ioctl() again to set a smaller
> >> buffer size, or closes the file descriptor. At this point
> >> I'd like to shrink the buffer or free it completely. But I
> >> can't assume that the program will be nice and munmap() the
> >> region for me
>
> > Look at drivers/char/drm, for example.  At mmap time they allocate a
> > vm_ops to the address space.  With that you catch changes to the vma
> > structure initiated by a user mmap, munmap, etc.  You could also
> > dynamically map the pages in using the nopage method (optional).


       reply	other threads:[~2001-06-07  3:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fa.fk487iv.1d2ksb0@ifi.uio.no>
     [not found] ` <fa.f3ckgov.ti0mb3@ifi.uio.no>
2001-06-07  3:46   ` Dan Maas [this message]
2001-06-05  2:31 forcibly unmap pages in driver? Dan Maas
2001-06-05 22:21 ` Pete Wyckoff
2001-06-05 23:15   ` Dan Maas
2001-06-05 23:31     ` Pete Wyckoff
2001-06-06  0:13       ` Dan Maas
2001-06-06  8:07   ` Martin Diehl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='044a01c0ef04$61559440$0701a8c0@morph' \
    --to=dmaas@dcine.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.