]> xenbits.xensource.com Git - xen.git/commit
x86/svm: do not try to handle recalc NPT faults immediately
authorIgor Druzhinin <igor.druzhinin@citrix.com>
Wed, 24 Jun 2020 14:45:59 +0000 (16:45 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 24 Jun 2020 14:45:59 +0000 (16:45 +0200)
commit11ea967c99b90011f371e64ec063bb6e38bd2b6c
tree668aad6f2c434bda73eaf9837b69cd4f87c4da2e
parent53bafb59e94041c1f46f979e0ce75c69f05564e8
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>
master commit: 51ca66c37371b10b378513af126646de22eddb17
master date: 2020-06-05 17:12:11 +0200
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/mm/p2m-pt.c
xen/arch/x86/mm/p2m.c