From: Ian Campbell Subject: Re: [PATCH V2] xen: Fix BUFIOREQ evtchn init for a stubdom. Date: Fri, 29 Jun 2012 09:26:53 +0100 Message-ID: <1340958413.10942.81.camel@zakaz.uk.xensource.com> References: <1340724087-7814-1-git-send-email-anthony.perard@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1340724087-7814-1-git-send-email-anthony.perard@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Anthony PERARD Cc: Stefano Stabellini , Keir Fraser , Jan Beulich , Xen Devel List-Id: xen-devel@lists.xenproject.org On Tue, 2012-06-26 at 16:21 +0100, Anthony PERARD wrote: > This is a missing part from the previous patch that add the BUFIOREQ_EVTCHN > parameter. This patch changes the ownership of the buifioreq event channel to > the stubdom (when HVM_PARAM_DM_DOMAIN is set within the stubdom). > > This patch introduces an helper to replace a xen port. > > This fix the initialization of QEMU inside the stubdomain. > > Signed-off-by: Anthony PERARD Thought I'd already acked this but apparently not. This fixes stub domains for me. Acked-by: Ian Campbell Tested-by: Ian Campbell CCing Hypervisor maintainers... > --- > Change: > - an helper > - the replacement of the buferioreq evtchn is inside iorp->lock now. > > xen/arch/x86/hvm/hvm.c | 37 ++++++++++++++++++++++++++++--------- > 1 files changed, 28 insertions(+), 9 deletions(-) > > diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c > index e0d495d..e8e86c0 100644 > --- a/xen/arch/x86/hvm/hvm.c > +++ b/xen/arch/x86/hvm/hvm.c > @@ -3664,6 +3664,21 @@ static int hvmop_flush_tlb_all(void) > return 0; > } > > +static int hvm_replace_event_channel(struct vcpu *v, uint64_t remote_domid, > + int *port) > +{ > + int old_port, new_port; > + > + new_port = alloc_unbound_xen_event_channel(v, remote_domid, NULL); > + if ( new_port < 0 ) > + return new_port; > + > + /* xchg() ensures that only we free_xen_event_channel() */ > + old_port = xchg(port, new_port); > + free_xen_event_channel(v, old_port); > + return 0; > +} > + > long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg) > > { > @@ -3777,17 +3792,21 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg) > iorp = &d->arch.hvm_domain.ioreq; > for_each_vcpu ( d, v ) > { > - int old_port, new_port; > - new_port = alloc_unbound_xen_event_channel( > - v, a.value, NULL); > - if ( new_port < 0 ) > - { > - rc = new_port; > + rc = hvm_replace_event_channel(v, a.value, > + &v->arch.hvm_vcpu.xen_port); > + if ( rc ) > break; > + > + if ( v->vcpu_id == 0 ) > + { > + spin_lock(&iorp->lock); > + rc = hvm_replace_event_channel(v, a.value, > + (int*)&v->domain->arch.hvm_domain.params[HVM_PARAM_BUFIOREQ_EVTCHN]); > + spin_unlock(&iorp->lock); > + if ( rc ) > + break; > } > - /* xchg() ensures that only we free_xen_event_channel() */ > - old_port = xchg(&v->arch.hvm_vcpu.xen_port, new_port); > - free_xen_event_channel(v, old_port); > + > spin_lock(&iorp->lock); > if ( iorp->va != NULL ) > get_ioreq(v)->vp_eport = v->arch.hvm_vcpu.xen_port;