xen: modify kernel mappings corresponding to granted pages
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>
Thu, 29 Sep 2011 10:57:56 +0000 (11:57 +0100)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Thu, 29 Sep 2011 14:32:58 +0000 (10:32 -0400)
commit0930bba674e248b921ea659b036ff02564e5a5f4
tree52df16f477e1e63b034ee2e28f2d5c916bb53097
parent693394b8c3dcee1a3baa52e30fdc3323d88cd579
xen: modify kernel mappings corresponding to granted pages

If we want to use granted pages for AIO, changing the mappings of a user
vma and the corresponding p2m is not enough, we also need to update the
kernel mappings accordingly.
Currently this is only needed for pages that are created for user usages
through /dev/xen/gntdev. As in, pages that have been in use by the
kernel and use the P2M will not need this special mapping.
However there are no guarantees that in the future the kernel won't
start accessing pages through the 1:1 even for internal usage.

In order to avoid the complexity of dealing with highmem, we allocated
the pages lowmem.
We issue a HYPERVISOR_grant_table_op right away in
m2p_add_override and we remove the mappings using another
HYPERVISOR_grant_table_op in m2p_remove_override.
Considering that m2p_add_override and m2p_remove_override are called
once per page we use multicalls and hypercall batching.

Use the kmap_op pointer directly as argument to do the mapping as it is
guaranteed to be present up until the unmapping is done.
Before issuing any unmapping multicalls, we need to make sure that the
mapping has already being done, because we need the kmap->handle to be
set correctly.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
[v1: Removed GRANT_FRAME_BIT usage]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
arch/x86/include/asm/xen/page.h
arch/x86/xen/p2m.c
drivers/block/xen-blkback/blkback.c
drivers/xen/gntdev.c
drivers/xen/grant-table.c
include/xen/grant_table.h