]> xenbits.xensource.com Git - xen.git/commit
x86/ept: limit calls to memory_type_changed()
authorRoger Pau Monné <roger.pau@citrix.com>
Thu, 29 Sep 2022 12:44:10 +0000 (14:44 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 29 Sep 2022 12:44:10 +0000 (14:44 +0200)
commitc4e5cc2ccc5b8274d02f7855c4769839989bb349
tree0dc8ac7c1b82f68ef6d4e80e1219b8729ef170ca
parent9982fe275ba4ee1a749b6dde5602a5a79e42b543
x86/ept: limit calls to memory_type_changed()

memory_type_changed() is currently only implemented for Intel EPT, and
results in the invalidation of EMT attributes on all the entries in
the EPT page tables.  Such invalidation causes EPT_MISCONFIG vmexits
when the guest tries to access any gfns for the first time, which
results in the recalculation of the EMT for the accessed page.  The
vmexit and the recalculations are expensive, and as such should be
avoided when possible.

Remove the call to memory_type_changed() from
XEN_DOMCTL_memory_mapping: there are no modifications of the
iomem_caps ranges anymore that could alter the return of
cache_flush_permitted() from that domctl.

Encapsulate calls to memory_type_changed() resulting from changes to
the domain iomem_caps or ioport_caps ranges in the helpers themselves
(io{ports,mem}_{permit,deny}_access()), and add a note in
epte_get_entry_emt() to remind that changes to the logic there likely
need to be propagaed to the IO capabilities helpers.

Note changes to the IO ports or memory ranges are not very common
during guest runtime, but Citrix Hypervisor has an use case for them
related to device passthrough.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/domctl.c
xen/arch/x86/include/asm/iocap.h
xen/arch/x86/mm/p2m-ept.c
xen/common/domctl.c
xen/include/xen/iocap.h