mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 10:40:03 +01:00
x86/svm: Always sync guest CR2 on VMExit
Under SVM, there are two copies of guest CR2. One is v->arch.hvm.guest_cr[2]
and one is in the VMCB.
Xen doesn't intercept CR2 accesses, so this mostly goes unnoticed; hardware
loads and saves the guest CR2 in the VMCB across VMRUN/VMExit.
For HAP guests (where #PF is not intercepted, and therefore we don't typically
inject #PF either), this causes the guest CR2 value to be lost on migrate. As
migration is cooperative and not done from the #PF handler, this also goes
unnoticed by guests.
It also means that an emulated MOV-from-CR2 reads a stale value.
Reported-by: Stefano Stabellini <sstabellini@kernel.org>
Fixes: d1bd157fbc ("Big merge the HVM full-virtualisation abstractions.")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
acfd2631b9
commit
3e6bca616b
1 file changed
+1
@@ -2505,6 +2505,7 @@ void asmlinkage svm_vmexit_handler(void)
|
||||
hvm_sanitize_regs_fields(
|
||||
regs, !(vmcb_get_efer(vmcb) & EFER_LMA) || !(vmcb->cs.l));
|
||||
|
||||
v->arch.hvm.guest_cr[2] = vmcb_get_cr2(vmcb);
|
||||
if ( paging_mode_hap(v->domain) )
|
||||
v->arch.hvm.guest_cr[3] = v->arch.hvm.hw_cr[3] = vmcb_get_cr3(vmcb);
|
||||
|
||||
|
||||