xen/m2p: use GNTTABOP_unmap_and_replace to reinstate the original mapping
commitee0726407feaf504dff304fb603652fb2d778b42
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>
Tue, 23 Jul 2013 17:23:54 +0000 (23 17:23 +0000)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tue, 20 Aug 2013 14:25:35 +0000 (20 10:25 -0400)
tree408473642b805ba2e56b94766f877fcb8518f24b
parent072b2064b88f709c53a83c6ec1f1cb17bf7c0abf
xen/m2p: use GNTTABOP_unmap_and_replace to reinstate the original mapping

GNTTABOP_unmap_grant_ref unmaps a grant and replaces it with a 0
mapping instead of reinstating the original mapping.
Doing so separately would be racy.

To unmap a grant and reinstate the original mapping atomically we use
GNTTABOP_unmap_and_replace.
GNTTABOP_unmap_and_replace doesn't work with GNTMAP_contains_pte, so
don't use it for kmaps.  GNTTABOP_unmap_and_replace zeroes the mapping
passed in new_addr so we have to reinstate it, however that is a
per-cpu mapping only used for balloon scratch pages, so we can be sure that
it's not going to be accessed while the mapping is not valid.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: alex@alex.org.uk
CC: dcrisan@flexiant.com
[v1: Konrad fixed up the conflicts]
Conflicts:
arch/x86/xen/p2m.c
arch/x86/xen/p2m.c
drivers/xen/gntdev.c