* [PATCH] xen/arm: Fix dom0 boot following c/s 580c45869
@ 2018-08-31 18:01 Andrew Cooper
2018-09-03 10:43 ` Julien Grall
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Cooper @ 2018-08-31 18:01 UTC (permalink / raw)
To: Xen-devel
Cc: Stefano Stabellini, Wei Liu, Andrew Cooper, Julien Grall,
Jan Beulich, Roger Pau Monné
c/s 580c45869 "Call arch_domain_create() as early as possible in
domain_create()" overlooked the fact that ARM uses is_hardware_domain() in at
least two places during arch_domain_create().
The bug manifests as:
(XEN) Freed 292kB init memory.
(XEN) traps.c:2017:d0v0 HSR=0x938c0007 pc=0xc0639d08 gva=0xe0800004 gpa=0x00000010481004
when dom0 tries to use the vuart. Judging by other uses of
is_hardware_domain(), I expect the x86 PVH dom0 boot is similarly broken.
Reposition the code which sets up hardware_domain so that the
is_hardware_domain() predicate works correctly all the way through domain
creation.
While moving it, leave a related comment explaining the positioning of the
is_priv assignment, which in hindsight should have been part of c/s ef765ec98
when exactly the same problem was discovered for the is_control_domain()
predicate.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
Thanks to Julien for helping debug this after OSSTest gave me an error I
didn't understand, and sorry for breaking it!
I've got some other cleanup I'd like to do to the general hardware_domain
infrastrucutre, but I'll leave that to a later change so as to unduly block
staging.
---
xen/common/domain.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/xen/common/domain.c b/xen/common/domain.c
index f64ad5f..256c59a 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -273,8 +273,22 @@ struct domain *domain_create(domid_t domid,
return ERR_PTR(-ENOMEM);
d->domain_id = domid;
+
+ /* Sort out our idea of is_control_domain(). */
d->is_privileged = is_priv;
+ /* Sort out our idea of is_hardware_domain(). */
+ if ( domid == 0 || domid == hardware_domid )
+ {
+ if ( hardware_domid < 0 || hardware_domid >= DOMID_FIRST_RESERVED )
+ panic("The value of hardware_dom must be a valid domain ID");
+
+ d->is_pinned = opt_dom0_vcpus_pin;
+ d->disable_migrate = 1;
+ old_hwdom = hardware_domain;
+ hardware_domain = d;
+ }
+
/* Debug sanity. */
ASSERT(is_system_domain(d) ? config == NULL : config != NULL);
@@ -354,16 +368,6 @@ struct domain *domain_create(domid_t domid,
watchdog_domain_init(d);
init_status |= INIT_watchdog;
- if ( domid == 0 || domid == hardware_domid )
- {
- if ( hardware_domid < 0 || hardware_domid >= DOMID_FIRST_RESERVED )
- panic("The value of hardware_dom must be a valid domain ID");
- d->is_pinned = opt_dom0_vcpus_pin;
- d->disable_migrate = 1;
- old_hwdom = hardware_domain;
- hardware_domain = d;
- }
-
if ( config->flags & XEN_DOMCTL_CDF_xs_domain )
{
d->is_xenstore = 1;
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xen/arm: Fix dom0 boot following c/s 580c45869
2018-08-31 18:01 [PATCH] xen/arm: Fix dom0 boot following c/s 580c45869 Andrew Cooper
@ 2018-09-03 10:43 ` Julien Grall
0 siblings, 0 replies; 2+ messages in thread
From: Julien Grall @ 2018-09-03 10:43 UTC (permalink / raw)
To: Andrew Cooper, Xen-devel
Cc: Stefano Stabellini, Wei Liu, Jan Beulich, Roger Pau Monné
Hi Andrew,
On 31/08/18 19:01, Andrew Cooper wrote:
> c/s 580c45869 "Call arch_domain_create() as early as possible in
> domain_create()" overlooked the fact that ARM uses is_hardware_domain() in at
> least two places during arch_domain_create().
>
> The bug manifests as:
>
> (XEN) Freed 292kB init memory.
> (XEN) traps.c:2017:d0v0 HSR=0x938c0007 pc=0xc0639d08 gva=0xe0800004 gpa=0x00000010481004
>
> when dom0 tries to use the vuart. Judging by other uses of
> is_hardware_domain(), I expect the x86 PVH dom0 boot is similarly broken.
>
> Reposition the code which sets up hardware_domain so that the
> is_hardware_domain() predicate works correctly all the way through domain
> creation.
>
> While moving it, leave a related comment explaining the positioning of the
> is_priv assignment, which in hindsight should have been part of c/s ef765ec98
> when exactly the same problem was discovered for the is_control_domain()
> predicate.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
Tested-by: Julien Grall <julien.grall@arm.com>
I will commit it now.
Cheers,
> ---
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien.grall@arm.com>
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Roger Pau Monné <roger.pau@citrix.com>
>
> Thanks to Julien for helping debug this after OSSTest gave me an error I
> didn't understand, and sorry for breaking it!
>
> I've got some other cleanup I'd like to do to the general hardware_domain
> infrastrucutre, but I'll leave that to a later change so as to unduly block
> staging.
> ---
> xen/common/domain.c | 24 ++++++++++++++----------
> 1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/xen/common/domain.c b/xen/common/domain.c
> index f64ad5f..256c59a 100644
> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -273,8 +273,22 @@ struct domain *domain_create(domid_t domid,
> return ERR_PTR(-ENOMEM);
>
> d->domain_id = domid;
> +
> + /* Sort out our idea of is_control_domain(). */
> d->is_privileged = is_priv;
>
> + /* Sort out our idea of is_hardware_domain(). */
> + if ( domid == 0 || domid == hardware_domid )
> + {
> + if ( hardware_domid < 0 || hardware_domid >= DOMID_FIRST_RESERVED )
> + panic("The value of hardware_dom must be a valid domain ID");
> +
> + d->is_pinned = opt_dom0_vcpus_pin;
> + d->disable_migrate = 1;
> + old_hwdom = hardware_domain;
> + hardware_domain = d;
> + }
> +
> /* Debug sanity. */
> ASSERT(is_system_domain(d) ? config == NULL : config != NULL);
>
> @@ -354,16 +368,6 @@ struct domain *domain_create(domid_t domid,
> watchdog_domain_init(d);
> init_status |= INIT_watchdog;
>
> - if ( domid == 0 || domid == hardware_domid )
> - {
> - if ( hardware_domid < 0 || hardware_domid >= DOMID_FIRST_RESERVED )
> - panic("The value of hardware_dom must be a valid domain ID");
> - d->is_pinned = opt_dom0_vcpus_pin;
> - d->disable_migrate = 1;
> - old_hwdom = hardware_domain;
> - hardware_domain = d;
> - }
> -
> if ( config->flags & XEN_DOMCTL_CDF_xs_domain )
> {
> d->is_xenstore = 1;
>
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-03 10:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-31 18:01 [PATCH] xen/arm: Fix dom0 boot following c/s 580c45869 Andrew Cooper
2018-09-03 10:43 ` Julien Grall
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.