x86/altp2m: hypercall to set altp2m view visibility
authorAlexandru Isaila <aisaila@bitdefender.com>
Tue, 14 Apr 2020 09:38:48 +0000 (11:38 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 14 Apr 2020 09:38:48 +0000 (11:38 +0200)
commit3fd3e9303ec4b1bc9d5271b9c089177e82c16dbb
treef14f9abe4078703d291ca680840dd87b253c3abd
parent7372466b21c3b6c96bb7a52754e432bac883a1e3
x86/altp2m: hypercall to set altp2m view visibility

At this moment a guest can call vmfunc to change the altp2m view. This
should be limited in order to avoid any unwanted view switch.

The new xc_altp2m_set_visibility() solves this by making views invisible
to vmfunc.
This is done by having a separate arch.altp2m_working_eptp that is
populated and made invalid in the same places as altp2m_eptp. This is
written to EPTP_LIST_ADDR.
The views are made in/visible by marking them with INVALID_MFN or
copying them back from altp2m_eptp.
To have consistency the visibility also applies to
p2m_switch_domain_altp2m_by_id().

The usage of this hypercall is aimed at dom0 having a logic with a number of views
created and at some time there is a need to be sure that only some of the views
can be switched, saving the rest and making them visible when the time
is right.

Note: If altp2m mode is set to mixed the guest is able to change the view
visibility and then call vmfunc.

Signed-off-by: Alexandru Isaila <aisaila@bitdefender.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Wei Liu <wl@xen.org>
tools/libxc/include/xenctrl.h
tools/libxc/xc_altp2m.c
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/vmx/vmx.c
xen/arch/x86/mm/hap/hap.c
xen/arch/x86/mm/p2m-ept.c
xen/arch/x86/mm/p2m.c
xen/include/asm-x86/domain.h
xen/include/asm-x86/p2m.h
xen/include/public/hvm/hvm_op.h