Remapping pages mapped to userspace (was: [PATCH 10 of 20] ipath - support for userspace apps using core driver)

From: Roland Dreier
Date: Thu Mar 16 2006 - 18:49:16 EST


[Err, sorry about the empty mail...]

Anyway, I'd like to hijack this thread slightly, since we are close to
a subject that I've been thinking about lately, and I'd like to take
advantage of the expert's attention...

My mthca driver (drivers/infiniband/hw/mthca) supports mapping some
MMIO registers into userspace via io_remap_pfn_range() in a .mmap
method. I think I have that pretty well under control.

However, on a hot unplug event, when the underlying PCI device is
going away, I would like to replace that mapping with a mapping (with
a mapping to the zero page?), so that userspace accesses after the
device is gone don't explode. What's the "right" way to do that?

Presumably it would be something like zeromap_page_range(), but that's
not exported to modules. Exporting that would be one option, but in a
way that's overkill for me: I only have a single page to deal with, so
I could also do something like

vm_insert_page(vma, addr, ZERO_PAGE(addr));

But do I have to do anything to kill the old mapping coming from
remap_pfn_range()? What's the exported API to do that?

I can keep a list of vmas that have registers mapped to userspace and
iterate through it on hot unplug. The only question is what to do
with those vmas.

Thanks,
Roland
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/