VMX virtual-apic: Update the p2m mapping alongside the control bit
PATCH 1/1 VMX virtual-apic: Update the p2m mapping alongside the control bit
Otherwise a VM migrated from a system which supports the feature to one which doesn't ends up with a data page where its vlapic should be.
# HG changeset patch
# User Tim Deegan <[email protected]>
# Date 1274798185 -3600
# Node ID fef1e7dc74e64cf25d817991dc2594579abf5bd0
# Parent 10ad9b50b4ca85d4ff19d87ffb6e66b0472c4926
VMX virtual-apic: Update the p2m mapping alongside the control bit. Otherwise a VM migrated from a system which supports the feature to one which doesn't ends up with a data page where its vlapic should be.
xen/arch/x86/hvm/vmx/vmx.c +9 -3
@@ -1904,8 +1904,6 @@if ( apic_va ==NULL )return -ENOMEM ;share_xen_page_with_guest (virt_to_page (apic_va), d, XENSHARE_writable); -set_mmio_p2m_entry ( - d,paddr_to_pfn (APIC_DEFAULT_PHYS_BASE ),_mfn (virt_to_mfn (apic_va))); d->arch.hvm_domain.vmx.apic_access_mfn =virt_to_mfn (apic_va);return 0 ;
@@ -1945,10 +1943,18 @@vmx_vmcs_enter (v); ctl =__vmread (SECONDARY_VM_EXEC_CONTROL ); - ctl &= ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES ;if ( !vlapic_hw_disabled (vlapic) && (vlapic_base_address (vlapic) ==APIC_DEFAULT_PHYS_BASE ) ) + { ctl |=SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES ; +set_mmio_p2m_entry (v->domain,paddr_to_pfn (APIC_DEFAULT_PHYS_BASE ), +_mfn (v->domain->arch.hvm_domain.vmx.apic_access_mfn)); + } +else + { + ctl &= ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES ; +clear_mmio_p2m_entry (v->domain,paddr_to_pfn (APIC_DEFAULT_PHYS_BASE )); + }__vmwrite (SECONDARY_VM_EXEC_CONTROL , ctl);vmx_vmcs_exit (v); }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 2 lines · Tim Deegan
Otherwise a VM migrated from a system which supports the feature to one which doesn't ends up with a data page where its vlapic should be.
I don't see that this problem exists, let alone that this patch would fix it if it did.
The dummy data page should not be migrated because it has p2m type mmio_direct, which will fail the p2m_is_ram() check in mod_l1_entry() when dom0 attempts to map the page to save/migrate it.
Even if that weren't the case, the dummy page will be mapped into the guest's p2m unless the apic is disabled or relocated from its default physaddr location. Neither of these is especially likely to be true during save/migration.
The only thing I can see is this patch avoids a dummy page hanging around in the p2m when HW APIC virt is disabled. But the dummy page is pretty benign in this situation, so I don't see that we care.
-- Keir
Quoted 3 lines
Signed-off-by Tim Deegan <[email protected]>
Quoted 6 lines · Keir Fraser
Quoted 2 lines · Tim Deegan
Otherwise a VM migrated from a system which supports the feature to one which doesn't ends up with a data page where its vlapic should be.
I don't see that this problem exists, let alone that this patch would fix it if it did.
I've seen it happen, if that helps. :)
Quoted 3 lines
The dummy data page should not be migrated because it has p2m type
mmio_direct, which will fail thep2m_is_ram()check inmod_l1_entry()when dom0 attempts to map the page to save/migrate it.
Ah, so it will; I hadn't seen that. The full failure mode is actually on migrating from Xen 3.3 (where mod_l1_entry() didn't have that check) to a newer Xen on a machine where the HW APIC virt isn't supported. The sender sends the contents of the dummy page (incorrectly) and the receiver doesn't do anything (assuming that there'll be a hole in the p2m where the APIC should be).
There might be a more correcter thing to do (maybe detect the RAM page and explicitly free it back to Xen?). Or, of course, we could finally get round to explicitly registering all mmio_dm areas...
Sorry for the confusion - I'm trying to tidy up patches from our product patchqueue and some of them have been around for a while. :|
Cheers,
Tim.
Signature · 3 lines
Tim Deegan <[email protected]> Principal Software Engineer, XenServer Engineering Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)
Quoted 10 lines · Tim Deegan
Quoted 3 lines
The dummy data page should not be migrated because it has p2m type
mmio_direct, which will fail thep2m_is_ram()check inmod_l1_entry()when dom0 attempts to map the page to save/migrate it.Ah, so it will; I hadn't seen that. The full failure mode is actually on migrating from Xen 3.3 (where
mod_l1_entry()didn't have that check) to a newer Xen on a machine where the HW APIC virt isn't supported. The sender sends the contents of the dummy page (incorrectly) and the receiver doesn't do anything (assuming that there'll be a hole in the p2m where the APIC should be).
Well, even so, the patch would still appear to only clear the p2m entry if the APIC is disabled or relocated. Why would either be the case during save/migrate?
Anyway, somewhat academic given we agree it's not needed at all in 3.4+
-- Keir
Quoted 13 lines · Keir Fraser
Quoted 10 lines · Tim Deegan
Quoted 3 lines
The dummy data page should not be migrated because it has p2m type
mmio_direct, which will fail thep2m_is_ram()check inmod_l1_entry()when dom0 attempts to map the page to save/migrate it.Ah, so it will; I hadn't seen that. The full failure mode is actually on migrating from Xen 3.3 (where
mod_l1_entry()didn't have that check) to a newer Xen on a machine where the HW APIC virt isn't supported. The sender sends the contents of the dummy page (incorrectly) and the receiver doesn't do anything (assuming that there'll be a hole in the p2m where the APIC should be).
Quoted 3 lines
Well, even so, the patch would still appear to only clear the p2m entry if the APIC is disabled or relocated. Why would either be the case during save/migrate?
Eh, good point. But it also re-sets the mmio-dm p2m entry in the case where the HW support _is_ available, which, now that I think of it, would also be broken. :)
Quoted 1 line
Anyway, somewhat academic given we agree it's not needed at all in 3.4+
Well, forward compatibility for save files would be nice (and indeed is needed in XenServer for live upgrade of a server pool to a new version) but since 3.4 -> 4.0 works, I'm happy to let it go.
Cheers,
Tim.
Signature · 3 lines
Tim Deegan <[email protected]> Principal Software Engineer, XenServer Engineering Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)