* [PATCH v2] setup vwfi correctly on cpu0
@ 2017-03-31 22:37 Stefano Stabellini
2017-04-03 19:52 ` Julien Grall
0 siblings, 1 reply; 3+ messages in thread
From: Stefano Stabellini @ 2017-03-31 22:37 UTC (permalink / raw)
To: julien.grall; +Cc: sstabellini, xen-devel
parse_vwfi runs after init_traps on cpu0, potentially resulting in the
wrong HCR_EL2 for it. Secondary cpus boot after parse_vwfi, so in their
case init_traps will write the correct set of flags to HCR_EL2.
For cpu0, fix the issue by changing HCR_EL2 setting from a new
presmp_initcall.
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
---
This patch should be apply to 4.8, 4.7, 4.6, not to unstable (it will be
fixed differently there).
---
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 614501f..65b5397 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -115,6 +115,22 @@ static void __init parse_vwfi(const char *s)
}
custom_param("vwfi", parse_vwfi);
+static int __init vwfi_init(void)
+{
+ /*
+ * HCR_EL2 has already been set on cpu0, change the setting here, if
+ * needed. Other cpus haven't booted yet, init_traps will setup
+ * HCR_EL2 correctly.
+ */
+ if ( vwfi == NATIVE ) {
+ register_t hcr;
+ hcr = READ_SYSREG(HCR_EL2);
+ WRITE_SYSREG(hcr & ~(HCR_TWI|HCR_TWE), HCR_EL2);
+ }
+ return 0;
+}
+presmp_initcall(vwfi_init);
+
void init_traps(void)
{
/* Setup Hyp vector base */
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] setup vwfi correctly on cpu0
2017-03-31 22:37 [PATCH v2] setup vwfi correctly on cpu0 Stefano Stabellini
@ 2017-04-03 19:52 ` Julien Grall
2017-04-03 20:45 ` Stefano Stabellini
0 siblings, 1 reply; 3+ messages in thread
From: Julien Grall @ 2017-04-03 19:52 UTC (permalink / raw)
To: Stefano Stabellini; +Cc: xen-devel
Hi Stefano,
On 03/31/2017 11:37 PM, Stefano Stabellini wrote:
> parse_vwfi runs after init_traps on cpu0, potentially resulting in the
> wrong HCR_EL2 for it. Secondary cpus boot after parse_vwfi, so in their
> case init_traps will write the correct set of flags to HCR_EL2.
>
> For cpu0, fix the issue by changing HCR_EL2 setting from a new
> presmp_initcall.
>
> Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
>
> ---
> This patch should be apply to 4.8, 4.7, 4.6, not to unstable (it will be
> fixed differently there).
> ---
>
> diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
> index 614501f..65b5397 100644
> --- a/xen/arch/arm/traps.c
> +++ b/xen/arch/arm/traps.c
> @@ -115,6 +115,22 @@ static void __init parse_vwfi(const char *s)
> }
> custom_param("vwfi", parse_vwfi);
>
> +static int __init vwfi_init(void)
> +{
> + /*
> + * HCR_EL2 has already been set on cpu0, change the setting here, if
> + * needed. Other cpus haven't booted yet, init_traps will setup
> + * HCR_EL2 correctly.
> + */
> + if ( vwfi == NATIVE ) {
Coding style:
if ( ... )
{
> + register_t hcr;
NIT: newline here please.
> + hcr = READ_SYSREG(HCR_EL2);
> + WRITE_SYSREG(hcr & ~(HCR_TWI|HCR_TWE), HCR_EL2);
> + }
Ditto.
> + return 0;
> +}
> +presmp_initcall(vwfi_init);
> +
> void init_traps(void)
> {
> /* Setup Hyp vector base */
>
With that:
Reviewed-by: Julien Grall <julien.grall@arm.com>
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] setup vwfi correctly on cpu0
2017-04-03 19:52 ` Julien Grall
@ 2017-04-03 20:45 ` Stefano Stabellini
0 siblings, 0 replies; 3+ messages in thread
From: Stefano Stabellini @ 2017-04-03 20:45 UTC (permalink / raw)
To: Julien Grall; +Cc: Stefano Stabellini, Wei.Chen, xen-devel
On Mon, 3 Apr 2017, Julien Grall wrote:
> Hi Stefano,
>
> On 03/31/2017 11:37 PM, Stefano Stabellini wrote:
> > parse_vwfi runs after init_traps on cpu0, potentially resulting in the
> > wrong HCR_EL2 for it. Secondary cpus boot after parse_vwfi, so in their
> > case init_traps will write the correct set of flags to HCR_EL2.
> >
> > For cpu0, fix the issue by changing HCR_EL2 setting from a new
> > presmp_initcall.
> >
> > Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
> >
> > ---
> > This patch should be apply to 4.8, 4.7, 4.6, not to unstable (it will be
> > fixed differently there).
> > ---
> >
> > diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
> > index 614501f..65b5397 100644
> > --- a/xen/arch/arm/traps.c
> > +++ b/xen/arch/arm/traps.c
> > @@ -115,6 +115,22 @@ static void __init parse_vwfi(const char *s)
> > }
> > custom_param("vwfi", parse_vwfi);
> >
> > +static int __init vwfi_init(void)
> > +{
> > + /*
> > + * HCR_EL2 has already been set on cpu0, change the setting here, if
> > + * needed. Other cpus haven't booted yet, init_traps will setup
> > + * HCR_EL2 correctly.
> > + */
> > + if ( vwfi == NATIVE ) {
>
> Coding style:
>
> if ( ... )
> {
>
> > + register_t hcr;
>
> NIT: newline here please.
>
>
> > + hcr = READ_SYSREG(HCR_EL2);
> > + WRITE_SYSREG(hcr & ~(HCR_TWI|HCR_TWE), HCR_EL2);
> > + }
>
> Ditto.
>
> > + return 0;
> > +}
> > +presmp_initcall(vwfi_init);
> > +
> > void init_traps(void)
> > {
> > /* Setup Hyp vector base */
> >
>
> With that:
>
> Reviewed-by: Julien Grall <julien.grall@arm.com>
I committed the patch with your comments. However, because of the
backporting rules (only pushed-gated commits should be backported), I
only pushed it to staging for now.
I expect Wei Chen (CC'ed) to revert this patch completely or partially
as part of his series. Wei, to be clear, I committed this patch to fix a
bug on the stable trees where the vwfi option is not set correctly on
cpu0. With your series, this bug will be fixed in a much nicer way.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-04-03 20:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-31 22:37 [PATCH v2] setup vwfi correctly on cpu0 Stefano Stabellini
2017-04-03 19:52 ` Julien Grall
2017-04-03 20:45 ` Stefano Stabellini
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.