xen: Fix BUFIOREQ evtchn init for a stubdom.
PATCH 1/1 xen: Fix BUFIOREQ evtchn init for a stubdom.
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 fix the initialization of QEMU inside the stubdomain.
--- xen/arch/x86/hvm/hvm.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
xen/arch/x86/hvm/hvm.c +16 -0
@@ -3788,6 +3788,22 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg)/* 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); + +if ( v->vcpu_id ==0 ) + { + new_port =alloc_unbound_xen_event_channel ( + v, a.value,NULL ); +if ( new_port <0 ) + { + rc = new_port; +break ; + } + old_port =xchg ( + &v->domain->arch.hvm_domain.params[HVM_PARAM_BUFIOREQ_EVTCHN ], + 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;
Signature · 1 line
Anthony PERARD
Quoted 7 lines · Anthony PERARD
This is a missing part from the previous patch that add the
BUFIOREQ_EVTCHNparameter. This patch changes the ownership of the buifioreq event channel to the stubdom (whenHVM_PARAM_DM_DOMAINis set within the stubdom).This fix the initialization of QEMU inside the stubdomain.
Signed-off-by Anthony PERARD <[email protected]>
This fixes stub domains for me, thanks.
The user of this field (hvm_buffered_io_send) takes iorp->lock so we probably want to put the update inside that too, just like for the non-buffered case?
It would be nice to extract the alloc&replace functionality into a helper.
Ian.
Quoted 31 lines
--- xen/arch/x86/hvm/hvm.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)xen/arch/x86/hvm/hvm.c +16
-0@@ -3788,6 +3788,22 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE(void) arg)/* 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); + +if ( v->vcpu_id ==0 ) + { + new_port =alloc_unbound_xen_event_channel ( + v, a.value,NULL ); +if ( new_port <0 ) + { + rc = new_port; +break ; + } + old_port =xchg ( + &v->domain->arch.hvm_domain.params[HVM_PARAM_BUFIOREQ_EVTCHN ], + 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;
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Anthony PERARD
This is a missing part from the previous patch that add the
BUFIOREQ_EVTCHNparameter. This patch changes the ownership of the buifioreq event channel to the stubdom (whenHVM_PARAM_DM_DOMAINis set within the stubdom).This fix the initialization of QEMU inside the stubdomain.
Quoted 7 lines
Quoted 1 line
Signed-off-by Anthony PERARD <[email protected]>This fixes stub domains for me, thanks.
The user of this field (
hvm_buffered_io_send) takesiorp->lockso we probably want to put the update inside that too, just like for the non-buffered case?
Will do.
Quoted 2 lines
It would be nice to extract the alloc&replace functionality into a helper.
I tried but it does not work well.xen_port is an it (non-buffer case) and params[bufioreq...] is an uint64_t. Both should be argument of the helper, as a pointer to be pass to xchg().
The prototype of the not working helper:
static int hvm_replace_event_channel(struct vcpu *v, uint64_t remote_domid, int *port)
So unless there is another way to create this helper, there won't be any.
Signature · 1 line
Anthony PERARD
Quoted 26 lines · Anthony PERARD
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Anthony PERARD
This is a missing part from the previous patch that add the
BUFIOREQ_EVTCHNparameter. This patch changes the ownership of the buifioreq event channel to the stubdom (whenHVM_PARAM_DM_DOMAINis set within the stubdom).This fix the initialization of QEMU inside the stubdomain.
Quoted 7 lines
Quoted 1 line
Signed-off-by Anthony PERARD <[email protected]>This fixes stub domains for me, thanks.
The user of this field (
hvm_buffered_io_send) takesiorp->lockso we probably want to put the update inside that too, just like for the non-buffered case?Will do.
Quoted 2 lines
It would be nice to extract the alloc&replace functionality into a helper.
I tried but it does not work well.
xen_portis an it (non-buffer case) and params[bufioreq...] is anuint64_t. Both should be argument of the helper, as a pointer to be pass toxchg().
Quoted 5 lines
The prototype of the not working helper:
static inthvm_replace_event_channel(struct vcpu *v, uint64_t remote_domid, int *port)So unless there is another way to create this helper, there won't be any.
Although params[...] are generally uint64_t the params[BUFIOREQ_EVTCHN] is really an int (or more properly an evtchn_port_t, although this is only used in include/public). Perhaps a cast is appropriate in this case?
Ian.
Quoted 31 lines · Ian Campbell
Quoted 30 lines · Anthony PERARD
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Anthony PERARD
This is a missing part from the previous patch that add the
BUFIOREQ_EVTCHNparameter. This patch changes the ownership of the buifioreq event channel to the stubdom (whenHVM_PARAM_DM_DOMAINis set within the stubdom).This fix the initialization of QEMU inside the stubdomain.
Quoted 7 lines
Quoted 1 line
Signed-off-by Anthony PERARD <[email protected]>This fixes stub domains for me, thanks.
The user of this field (
hvm_buffered_io_send) takesiorp->lockso we probably want to put the update inside that too, just like for the non-buffered case?Will do.
Quoted 2 lines
It would be nice to extract the alloc&replace functionality into a helper.
I tried but it does not work well.
xen_portis an it (non-buffer case) and params[bufioreq...] is anuint64_t. Both should be argument of the helper, as a pointer to be pass toxchg().The prototype of the not working helper:
static inthvm_replace_event_channel(struct vcpu *v, uint64_t remote_domid, int *port)
Quoted 6 lines
Quoted 1 line
So unless there is another way to create this helper, there won't be any.
Although params[...] are generally
uint64_tthe params[BUFIOREQ_EVTCHN] is really an int (or more properly anevtchn_port_t, although this is only used ininclude/public). Perhaps a cast is appropriate in this case?
All right, I will cast.
Signature · 1 line
Anthony PERARD