Messages in this thread | | | Date | Tue, 31 Oct 2023 16:58:53 -0700 | Subject | Re: [PATCH v7 11/11] KVM: xen: allow vcpu_info content to be 'safely' copied | From | Sean Christopherson <> |
| |
On Mon, Oct 02, 2023, 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) we > need a way to defer that until the copy is complete.
Nit, add a blank link between paragraphs.
> 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). > So let's 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, all we need to do > is stop considering an inactive vcpu_info cache as a hard error in > kvm_xen_set_evtchn_fast().
Please, please try to write changelogs that adhere to the preferred style. I get that the preferred style likely doesn't align with what you're used to, but the preferred style really doesn't help me get through reviews quicker.
> diff --git a/arch/x86/kvm/xen.c b/arch/x86/kvm/xen.c > index aafc794940e4..e645066217bb 100644 > --- a/arch/x86/kvm/xen.c > +++ b/arch/x86/kvm/xen.c > @@ -1606,9 +1606,6 @@ int kvm_xen_set_evtchn_fast(struct kvm_xen_evtchn *xe, struct kvm *kvm) > WRITE_ONCE(xe->vcpu_idx, vcpu->vcpu_idx); > } > > - if (!vcpu->arch.xen.vcpu_info_cache.active) > - return -EINVAL; > -
Hmm, maybe move this check after the "hard" error checks and explicitly do:
return -EWOULDBLOCK
That way it's much more obvious that this patch is safe. Alternatively, briefly explain what happens if the cache is invalid in the changelog.
> if (xe->port >= max_evtchn_port(kvm)) > return -EINVAL; > > -- > 2.39.2 >
| |