xen/x86: hap: Clean-up and harden hap_enable()
authorJulien Grall <jgrall@amazon.com>
Mon, 3 Feb 2020 23:57:05 +0000 (23:57 +0000)
committerJulien Grall <julien@xen.org>
Thu, 5 Mar 2020 12:59:46 +0000 (12:59 +0000)
commita47ae19672fce8e377277f23336692f9eab4fca1
tree4db849ac254dc8c2d4d7d2d5f1665feb4616b8ba
parent523a15a701baf01beb616238637be8be5d737d10
xen/x86: hap: Clean-up and harden hap_enable()

Unlike shadow_enable(), hap_enable() can only be called once during
domain creation and with the mode equal to
PG_external | PG_translate | PG_refcounts.

If it were called twice, then we might have some interesting problems
as the p2m tables would be re-allocated (and therefore all the mappings
would be lost).

Add code to sanity check the mode and that the function is only called
once. Take the opportunity to an if checking that PG_translate is set.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/mm/hap/hap.c