Messages in this thread | | | Subject | Re: [PATCH v8 15/15] KVM: xen: allow vcpu_info content to be 'safely' copied | From | David Woodhouse <> | Date | Tue, 21 Nov 2023 22:53:05 +0000 |
| |
On Tue, 2023-11-21 at 18:02 +0000, Paul Durrant wrote: > From: Paul Durrant <pdurrant@amazon.com> > > If the guest sets an explicit vcpu_info GPA then, for any of the first 32 > vCPUs, the content of the default vcpu_info in the shared_info page must be > copied into the new location. Because this copy may race with event > delivery (which updates the 'evtchn_pending_sel' field in vcpu_info) there > needs to be a way to defer that until the copy is complete. > Happily there is already a shadow of 'evtchn_pending_sel' in kvm_vcpu_xen > that is used in atomic context if the vcpu_info PFN cache has been > invalidated so that the update of vcpu_info can be deferred until the > cache can be refreshed (on vCPU thread's the way back into guest context). > > Also use this shadow if the vcpu_info cache has been *deactivated*, so that > the VMM can safely copy the vcpu_info content and then re-activate the > cache with the new GPA. To do this, stop considering an inactive vcpu_info > cache as a hard error in kvm_xen_set_evtchn_fast(). > > Signed-off-by: Paul Durrant <pdurrant@amazon.com> > Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
Wait, didn't we realise that this leaves the bits set in the shadow evtchn_pending_sel that get lost on migration?
The point in your previous patch which split out a shiny new set_shinfo_evtchn_pending() function was that you could then *call* that function to ensure that the corresponding index bit was set on the destination host after migration, if the bit in the shinfo is.
So we'd do that from kvm_xen_setup_evtchn(), kvm_xen_eventfd_assign(), and when setting KVM_XEN_VCPU_ATTR_TYPE_TIMER.
if (bit_is_set_in_shinfo) set_shinfo_evtchn_pending()
[unhandled content-type:application/pkcs7-signature] | |