memory: restrict XENMEM_remove_from_physmap to translated guests
authorJan Beulich <jbeulich@suse.com>
Mon, 13 May 2019 15:49:39 +0000 (17:49 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 13 May 2019 15:49:39 +0000 (17:49 +0200)
commitf3694f3acba92d46479e2455fd74b32799a9eb02
treea0c167207f4679c2c8c42a03f69781307e50457a
parent738faba9d74736dc8e5d7c5d3be53776097f6af1
memory: restrict XENMEM_remove_from_physmap to translated guests

The commit re-introducing it (14eb3b41d0 ["xen: reinstate previously
unused XENMEM_remove_from_physmap hypercall"]) as well as the one having
originally introduced it (d818f3cb7c ["hvm: Use main memory for video
memory"]) and the one then purging it again (78c3097e4f ["Remove unused
XENMEM_remove_from_physmap"]) make clear that this operation is intended
for use on HVM (i.e. translated) guests only. Restrict it at least as
much, because for PV guests documentation (in the public header) does
not even match the implementation: It talks about GPFN as input, but
get_page_from_gfn() assumes a GMFN in the non-translated case (and hands
back the value passed in).

Also lift the check in XENMEM_add_to_physmap{,_batch} handling up
directly into top level hypercall handling, and clarify things in the
public header accordingly.

Take the liberty and also replace a pointless use of "current" with a
more efficient use of an existing local variable (or function parameter
to be precise).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
xen/arch/x86/mm.c
xen/common/memory.c
xen/include/public/memory.h