x86/hvm: Fix HVMOP_get_param when skipping creating the default ioreq server
PATCH 1/2 x86/hvm: Fix HVMOP_get_param when skipping creating the default ioreq server
c/s e7dabe5 "x86/hvm: don't unconditionally create a default ioreq server" added a break statement, but the logic previously depended on falling through into the default case to fill in the value the caller asked for.
This causes the sending migration code to put a junk PARAM into the stream, and the receiving side to fail to zero the IOREQ pages, causing QEMU to object when it finds stale requests while starting up.
Reorder the code so it more clearly falls through into the default case.
---
CC: Jan Beulich <[email protected]>
CC: Paul Durrant <[email protected]>
CC: Boris Ostrovsky <[email protected]>
--- xen/arch/x86/hvm/hvm.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
xen/arch/x86/hvm/hvm.c +9 -11
@@ -5275,9 +5275,6 @@ static int hvmop_get_param(case HVM_PARAM_IOREQ_PFN :case HVM_PARAM_BUFIOREQ_PFN :case HVM_PARAM_BUFIOREQ_EVTCHN : - { -domid_t domid; -/* * It may be necessary to create a default ioreq server here, * because legacy versions of QEMU are not aware of the new API for
@@ -5285,15 +5282,16 @@ static int hvmop_get_param(* under construction then it will not be QEMU querying the * parameters and thus the query should not have that side-effect. */ -if ( d->creation_finished ) -break ; +if ( !d->creation_finished ) + { +domid_t domid = d->arch.hvm_domain.params[HVM_PARAM_DM_DOMAIN ]; + + rc =hvm_create_ioreq_server (d, domid,1 , +HVM_IOREQSRV_BUFIOREQ_LEGACY ,NULL ); +if ( rc !=0 && rc != -EEXIST ) + goto out; + } - domid = d->arch.hvm_domain.params[HVM_PARAM_DM_DOMAIN ]; - rc =hvm_create_ioreq_server (d, domid,1 , -HVM_IOREQSRV_BUFIOREQ_LEGACY ,NULL ); -if ( rc !=0 && rc != -EEXIST ) - goto out; - }/*FALLTHRU*/ default : a.value = d->arch.hvm_domain.params[a.index];
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/2 xen: Fix determining when domain creation is complete
d->creation_finished is used in several places alter behaviour depending on whether the domain is being created, or is already running.
However, there is a latent bug if a toolstack component makes a pair of pause/unpause calls, where creation will be considered finished prematurely.
---
CC: Jan Beulich <[email protected]>
CC: Paul Durrant <[email protected]>
CC: Boris Ostrovsky <[email protected]>
This is probably a backport candidate, as creation_finished was introduced in 4.8
--- xen/common/domain.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
xen/common/domain.c +14 -7
@@ -1004,13 +1004,6 @@ int domain_unpause_by_systemcontroller(struct domain *d) {int old, new, prev = d->controller_pause_count; -/* -* We record this information here for populate_physmap to figure out -* that the domain has finished being created. In fact, we're only -* allowed to set the MEMF_no_tlbflush flag during VM creation. -*/ - d->creation_finished = true; - do { old = prev;
@@ -1022,6 +1015,20 @@ int domain_unpause_by_systemcontroller(struct domain *d) prev =cmpxchg (&d->controller_pause_count, old, new); }while ( prev != old ); +/* +* d->controller_pause_count is initialised to 1, and the toolstack is +* responsible for making one unpause hypercall when it wishes the guest +* to start running. +* +* All other toolstack operations should make a pair of pause/unpause +* calls and rely on the reference counting here. +* +* Creation is considered finished when the controller reference count +* first drops to 0. +*/ +if ( new ==0 ) + d->creation_finished = true; +domain_unpause (d);return 0 ;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH 2/2] xen: Fix determining when domain creation is complete
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 12.12.16 at 19:29, <[email protected]> wrote:
d->creation_finishedis used in several places alter behaviour depending on whether the domain is being created, or is already running.However, there is a latent bug if a toolstack component makes a pair of pause/unpause calls, where creation will be considered finished prematurely.
Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/2] xen: Fix determining when domain creation is complete
In reply to Andrew CooperQuoted 12 lines
-----Original Message-----
From: Andrew Cooper [mailto:[email protected]]
Sent: 12 December 2016 18:30
To: Xen-devel <[email protected]>
Cc: Andrew Cooper <[email protected]>; Jan Beulich <[email protected]>; Paul Durrant <[email protected]>; Boris Ostrovsky <[email protected]>
Subject: [PATCH 2/2] xen: Fix determining when domain creation is complete
d->creation_finishedis used in several places alter behaviour depending on whether the domain is being created, or is already running.
Quoted 8 lines
However, there is a latent bug if a toolstack component makes a pair of pause/unpause calls, where creation will be considered finished prematurely.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Paul Durrant <[email protected]>
I tested this on initial boot and restore.
Quoted 49 lines
CC Boris Ostrovsky <[email protected]>This is probably a backport candidate, as
creation_finishedwas introduced in 4.8--- xen/common/domain.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)xen/common/domain.c +0
-7@@ -1004,13 +1004,6 @@ int domain_unpause_by_systemcontroller(struct domain *d) {int old, new, prev = d->controller_pause_count; -/* -* We record this information here for populate_physmap to figure out -* that the domain has finished being created. In fact, we're only -* allowed to set the MEMF_no_tlbflush flag during VM creation. -*/ - d->creation_finished = true; - do {old = prev;xen/common/domain.c +14
-0@@ -1022,6 +1015,20 @@ int domain_unpause_by_systemcontroller(struct domain *d) prev =cmpxchg (&d->controller_pause_count, old, new); }while ( prev != old ); +/* +* d->controller_pause_count is initialised to 1, and the toolstack is +* responsible for making one unpause hypercall when it wishes the guest +* to start running. +* +* All other toolstack operations should make a pair of pause/unpause +* calls and rely on the reference counting here. +* +* Creation is considered finished when the controller reference count +* first drops to 0. +*/ +if ( new ==0 ) + d->creation_finished = true; +domain_unpause (d);return 0;
Quoted 2 lines
--
2.1.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/2] xen: Fix determining when domain creation is complete
In reply to Andrew CooperQuoted 7 lines
Quoted 1 line
Quoted 1 line · On 12.12.16 at 19:29, <[email protected]> wrote:
d->creation_finishedis used in several places alter behaviour depending on whether the domain is being created, or is already running.However, there is a latent bug if a toolstack component makes a pair of pause/unpause calls, where creation will be considered finished prematurely.
Quoted 8 lines
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Paul Durrant <[email protected]>
CC: Boris Ostrovsky <[email protected]>This is probably a backport candidate, as
creation_finishedwas introduced in 4.8
Yes. I actually mean to take the combination of Paul's original change and your 1/2, too.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 12.12.16 at 19:29, <[email protected]> wrote:
c/s e7dabe5 "x86/hvm: don't unconditionally create a default ioreq server" added a break statement, but the logic previously depended on falling through into the default case to fill in the value the caller asked for.
Quoted 7 lines
This causes the sending migration code to put a junk PARAM into the stream, and the receiving side to fail to zero the IOREQ pages, causing QEMU to object when it finds stale requests while starting up.
Reorder the code so it more clearly falls through into the default case.
Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 10 lines
-----Original Message-----
From: Andrew Cooper [mailto:[email protected]]
Sent: 12 December 2016 18:30
To: Xen-devel <[email protected]>
Cc: Andrew Cooper <[email protected]>; Jan Beulich <[email protected]>; Paul Durrant <[email protected]>; Boris Ostrovsky <[email protected]>
Subject: [PATCH 1/2] x86/hvm: FixHVMOP_get_paramwhen skipping creating the default ioreq server
Quoted 5 lines
c/s e7dabe5 "x86/hvm: don't unconditionally create a default ioreq server" added a break statement, but the logic previously depended on falling through
into the default case to fill in the value the caller asked for.
Yes, I mistakenly thought I was breaking out of an inner switch. Thanks for fixing this up.
Quoted 56 lines
This causes the sending migration code to put a junk PARAM into the stream, and the receiving side to fail to zero the IOREQ pages, causing QEMU to object
when it finds stale requests while starting up.Reorder the code so it more clearly falls through into the default case.
Signed-off-by Andrew Cooper <[email protected]>---
CC: Jan Beulich <[email protected]>
CC: Paul Durrant <[email protected]>
CC: Boris Ostrovsky <[email protected]>--- xen/arch/x86/hvm/hvm.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)xen/arch/x86/hvm/hvm.c +9
-11@@ -5275,9 +5275,6 @@ static int hvmop_get_param(case HVM_PARAM_IOREQ_PFN :case HVM_PARAM_BUFIOREQ_PFN :case HVM_PARAM_BUFIOREQ_EVTCHN : - { -domid_t domid; -/* * It may be necessary to create a default ioreq server here, * because legacy versions of QEMU are not aware of the new API for @@ -5285,15 +5282,16 @@ static int hvmop_get_param(* under construction then it will not be QEMU querying the * parameters and thus the query should not have that side-effect. */ -if ( d->creation_finished ) -break ; +if ( !d->creation_finished ) + { +domid_t domid = d- >arch.hvm_domain.params[HVM_PARAM_DM_DOMAIN]; + + rc =hvm_create_ioreq_server (d, domid,1 , +HVM_IOREQSRV_BUFIOREQ_LEGACY ,NULL ); +if ( rc !=0 && rc != -EEXIST ) + goto out; + } - domid = d->arch.hvm_domain.params[HVM_PARAM_DM_DOMAIN ]; - rc =hvm_create_ioreq_server (d, domid,1 , -HVM_IOREQSRV_BUFIOREQ_LEGACY ,NULL ); -if ( rc !=0 && rc != -EEXIST ) - goto out; - }/*FALLTHRU*/ default :a.value = d->arch.hvm_domain.params[a.index];
Quoted 2 lines
--
2.1.4
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel