]> xenbits.xensource.com Git - xen.git/commit
x86/svm: do not try to handle recalc NPT faults immediately
authorIgor Druzhinin <igor.druzhinin@citrix.com>
Fri, 5 Jun 2020 15:12:11 +0000 (17:12 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 5 Jun 2020 15:12:11 +0000 (17:12 +0200)
commit51ca66c37371b10b378513af126646de22eddb17
tree551373450a1b3c57d09815b460e034e2838c99b3
parent81da3f2b4fa9ccbbdcd135275ee62f0817bcab26
x86/svm: do not try to handle recalc NPT faults immediately

A recalculation NPT fault doesn't always require additional handling
in hvm_hap_nested_page_fault(), moreover in general case if there is no
explicit handling done there - the fault is wrongly considered fatal.

This covers a specific case of migration with vGPU assigned which
uses direct MMIO mappings made by XEN_DOMCTL_memory_mapping hypercall:
at a moment log-dirty is enabled globally, recalculation is requested
for the whole guest memory including those mapped MMIO regions
which causes a page fault being raised at the first access to them;
but due to MMIO P2M type not having any explicit handling in
hvm_hap_nested_page_fault() a domain is erroneously crashed with unhandled
SVM violation.

Instead of trying to be opportunistic - use safer approach and handle
P2M recalculation in a separate NPT fault by attempting to retry after
making the necessary adjustments. This is aligned with Intel behavior
where there are separate VMEXITs for recalculation and EPT violations
(faults) and only faults are handled in hvm_hap_nested_page_fault().
Do it by also unifying do_recalc return code with Intel implementation
where returning 1 means P2M was actually changed.

Since there was no case previously where p2m_pt_handle_deferred_changes()
could return a positive value - it's safe to replace ">= 0" with just "== 0"
in VMEXIT_NPF handler. finish_type_change() is also not affected by the
change as being able to deal with >0 return value of p2m->recalc from
EPT implementation.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Paul Durrant <paul@xen.org>
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/mm/p2m-pt.c
xen/arch/x86/mm/p2m.c