All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] board_f.c: Insure gd->new_bootstage alignment
@ 2020-01-07 12:07 Patrick DELAUNAY
  2020-01-09 17:23 ` Patrick DELAUNAY
  0 siblings, 1 reply; 9+ messages in thread
From: Patrick DELAUNAY @ 2020-01-07 12:07 UTC (permalink / raw)
  To: u-boot

Hi Patrice and Tom

> Sent: mercredi 18 décembre 2019 10:10
> 
> Hi Simon,
> 
> > From: Simon Glass <sjg@chromium.org>
> > Sent: mardi 17 décembre 2019 16:46
> >
> > Hi Patrice,
> >
> > On Wed, 27 Nov 2019 at 02:11, Patrice Chotard <patrice.chotard@st.com>
> wrote:
> > >
> > > In reserve_bootstage(), in case size is odd, gd->new_bootstage is
> > > not aligned. In bootstage_relocate(), the platform hangs when
> > > getting access to data->record[i].name.
> > > To avoid this issue, make gd->new_bootstage 16 byte aligned.
> > >
> > > To insure that new_bootstage is 16 byte aligned (at least needed for
> > > x86_64 and ARMv8) and new_bootstage starts down to get enough space,
> > > ALIGN_DOWN macro is used.
> > >
> > > Fixes: ac9cd4805c8b ("bootstage: Correct relocation algorithm")
> > >
> > > Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> > > Reviewed-by: Vikas MANOCHA <vikas.manocha@st.com>
> > > Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
> > > Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
> 
> For information, Patrice is absent for personal reason up to beginning next year.
> Don't wait a fast answer.
> 
> > For this patch I think it would be better to update reserve_fdt() to
> > keep things aligned, assuming that is the problem.
> 
> I don't sure that solve the issue,
> for me the problem is only for the bootstage struct (gd->bootstage) And
> reserve_fdt() already alligne size on 32 bytes
> 
> If I remember the Patrice analysis:
> 
> 1- bootstage_get_size return a odd value (or at least not 16 bytes aligned I don't
> remember).
> 
> 2- In reserve_bootstage()
> 	int size = bootstage_get_size();
> 	gd->start_addr_sp -= size
> 	=> it is a unaligned address even if gd->start_addr_sp is 32 bytes alligned
> 
> 	gd->new_bootstage = map_sysmem(gd->start_addr_sp, size);
> 	=> also unaligned
> 
> 3- Then during relocation, in reloc_bootstage()
> 	gd->bootstage = gd->new_bootstage;
> 
> 
> 4- crash occur because in next bootstage function beaucse the boostage address
> don't respect pointer to struct allignement...
> 
> 	struct bootstage_data *data = gd->bootstage
> 
> 
> > At some point we should also document that reservations must keep
> > things aligned.
> >
> > Perhaps this should be handled by a separate function called from all
> > these places, which subtracts gd->start_addr_sp and ensures 16-byte alignment.
> 
> Yes that can be a improvement,  but perhaps ia a second step / second serie....
> 
> Do you think about a function called in all reversed_ functions (when start_addr_sp
> is modified)...
> 
> static int reserved_allign_check(void)
> {
> 	/* make stack pointer 16-byte aligned */
> 	if (gd->start_addr_sp & 0xf) {
> 		gd->start_addr_sp -= 16;
> 		gd->start_addr_sp &= ~0xf;
> 	 }
> }
> 
> I prefer a function to reserved a size wich replace in any reserve_ function  the line
> :
> 	gd->start_addr_sp -= ...
> 
> /* reserve size and make stack pointer 16-byte aligned */
>  static int reserve(size_t size) {
> 	gd->start_addr_sp -= size;
> 	/* make stack pointer 16-byte aligned */
> 	gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp, 16);
> }
> 
> I think I will push it, when the patrice patch will be accepted.

I am preparing this patch.... 

Do you think it is ok to merge the Patrice v3 proposal first on master branch
for v2020.04 release (he just align the reserved memory for bootstage),
and after I make my patch (16-byte align all reserved area).

or it is better to make a more generic patch v4 to replace the Patrice one.

Regards
Patrick

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3] board_f.c: Insure gd->new_bootstage alignment
  2020-01-07 12:07 [PATCH v3] board_f.c: Insure gd->new_bootstage alignment Patrick DELAUNAY
@ 2020-01-09 17:23 ` Patrick DELAUNAY
  2020-01-21 23:18   ` Tom Rini
  0 siblings, 1 reply; 9+ messages in thread
From: Patrick DELAUNAY @ 2020-01-09 17:23 UTC (permalink / raw)
  To: u-boot

Hi,

> From: Patrick DELAUNAY
> Sent: mardi 7 janvier 2020 13:07
> 
> Hi Patrice and Tom
> 
> > Sent: mercredi 18 décembre 2019 10:10
> >
> > Hi Simon,
> >
> > > From: Simon Glass <sjg@chromium.org>
> > > Sent: mardi 17 décembre 2019 16:46
> > >
> > > Hi Patrice,
> > >
> > > On Wed, 27 Nov 2019 at 02:11, Patrice Chotard
> > > <patrice.chotard@st.com>
> > wrote:
> > > >
> > > > In reserve_bootstage(), in case size is odd, gd->new_bootstage is
> > > > not aligned. In bootstage_relocate(), the platform hangs when
> > > > getting access to data->record[i].name.
> > > > To avoid this issue, make gd->new_bootstage 16 byte aligned.
> > > >
> > > > To insure that new_bootstage is 16 byte aligned (at least needed
> > > > for
> > > > x86_64 and ARMv8) and new_bootstage starts down to get enough
> > > > space, ALIGN_DOWN macro is used.
> > > >
> > > > Fixes: ac9cd4805c8b ("bootstage: Correct relocation algorithm")
> > > >
> > > > Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> > > > Reviewed-by: Vikas MANOCHA <vikas.manocha@st.com>
> > > > Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
> > > > Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
> >
> > For information, Patrice is absent for personal reason up to beginning next year.
> > Don't wait a fast answer.
> >
> > > For this patch I think it would be better to update reserve_fdt() to
> > > keep things aligned, assuming that is the problem.
> >
> > I don't sure that solve the issue,
> > for me the problem is only for the bootstage struct (gd->bootstage)
> > And
> > reserve_fdt() already alligne size on 32 bytes
> >
> > If I remember the Patrice analysis:
> >
> > 1- bootstage_get_size return a odd value (or at least not 16 bytes
> > aligned I don't remember).
> >
> > 2- In reserve_bootstage()
> > 	int size = bootstage_get_size();
> > 	gd->start_addr_sp -= size
> > 	=> it is a unaligned address even if gd->start_addr_sp is 32 bytes
> > alligned
> >
> > 	gd->new_bootstage = map_sysmem(gd->start_addr_sp, size);
> > 	=> also unaligned
> >
> > 3- Then during relocation, in reloc_bootstage()
> > 	gd->bootstage = gd->new_bootstage;
> >
> >
> > 4- crash occur because in next bootstage function beaucse the boostage
> > address don't respect pointer to struct allignement...
> >
> > 	struct bootstage_data *data = gd->bootstage
> >
> >
> > > At some point we should also document that reservations must keep
> > > things aligned.
> > >
> > > Perhaps this should be handled by a separate function called from
> > > all these places, which subtracts gd->start_addr_sp and ensures 16-byte
> alignment.
> >
> > Yes that can be a improvement,  but perhaps ia a second step / second serie....
> >
> > Do you think about a function called in all reversed_ functions (when
> > start_addr_sp is modified)...
> >
> > static int reserved_allign_check(void) {
> > 	/* make stack pointer 16-byte aligned */
> > 	if (gd->start_addr_sp & 0xf) {
> > 		gd->start_addr_sp -= 16;
> > 		gd->start_addr_sp &= ~0xf;
> > 	 }
> > }
> >
> > I prefer a function to reserved a size wich replace in any reserve_
> > function  the line
> > :
> > 	gd->start_addr_sp -= ...
> >
> > /* reserve size and make stack pointer 16-byte aligned */  static int
> > reserve(size_t size) {
> > 	gd->start_addr_sp -= size;
> > 	/* make stack pointer 16-byte aligned */
> > 	gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp, 16); }
> >
> > I think I will push it, when the patrice patch will be accepted.
> 
> I am preparing this patch....
> 
> Do you think it is ok to merge the Patrice v3 proposal first on master branch for
> v2020.04 release (he just align the reserved memory for bootstage), and after I
> make my patch (16-byte align all reserved area).
> 
> or it is better to make a more generic patch v4 to replace the Patrice one.

I push a  serie, with my proposal:
[3/3] board_f.c: Insure 16 alignment of start_addr_sp and reserved memory

http://patchwork.ozlabs.org/project/uboot/list/?series=152226

As I found issue for ARM32 (I need to modify arch/arm/lib/crt0.S)
I think it is preferable that the Patrice Patch is merged in v2020.04, and my serie can live  independently.
But I can also squash of the 2 series.
 
Regards
Patrick

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3] board_f.c: Insure gd->new_bootstage alignment
  2020-01-09 17:23 ` Patrick DELAUNAY
@ 2020-01-21 23:18   ` Tom Rini
  2020-01-22 13:57     ` Patrick DELAUNAY
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Rini @ 2020-01-21 23:18 UTC (permalink / raw)
  To: u-boot

On Thu, Jan 09, 2020 at 05:23:51PM +0000, Patrick DELAUNAY wrote:
> Hi,
> 
> > From: Patrick DELAUNAY
> > Sent: mardi 7 janvier 2020 13:07
> > 
> > Hi Patrice and Tom
> > 
> > > Sent: mercredi 18 décembre 2019 10:10
> > >
> > > Hi Simon,
> > >
> > > > From: Simon Glass <sjg@chromium.org>
> > > > Sent: mardi 17 décembre 2019 16:46
> > > >
> > > > Hi Patrice,
> > > >
> > > > On Wed, 27 Nov 2019 at 02:11, Patrice Chotard
> > > > <patrice.chotard@st.com>
> > > wrote:
> > > > >
> > > > > In reserve_bootstage(), in case size is odd, gd->new_bootstage is
> > > > > not aligned. In bootstage_relocate(), the platform hangs when
> > > > > getting access to data->record[i].name.
> > > > > To avoid this issue, make gd->new_bootstage 16 byte aligned.
> > > > >
> > > > > To insure that new_bootstage is 16 byte aligned (at least needed
> > > > > for
> > > > > x86_64 and ARMv8) and new_bootstage starts down to get enough
> > > > > space, ALIGN_DOWN macro is used.
> > > > >
> > > > > Fixes: ac9cd4805c8b ("bootstage: Correct relocation algorithm")
> > > > >
> > > > > Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> > > > > Reviewed-by: Vikas MANOCHA <vikas.manocha@st.com>
> > > > > Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
> > > > > Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
> > >
> > > For information, Patrice is absent for personal reason up to beginning next year.
> > > Don't wait a fast answer.
> > >
> > > > For this patch I think it would be better to update reserve_fdt() to
> > > > keep things aligned, assuming that is the problem.
> > >
> > > I don't sure that solve the issue,
> > > for me the problem is only for the bootstage struct (gd->bootstage)
> > > And
> > > reserve_fdt() already alligne size on 32 bytes
> > >
> > > If I remember the Patrice analysis:
> > >
> > > 1- bootstage_get_size return a odd value (or at least not 16 bytes
> > > aligned I don't remember).
> > >
> > > 2- In reserve_bootstage()
> > > 	int size = bootstage_get_size();
> > > 	gd->start_addr_sp -= size
> > > 	=> it is a unaligned address even if gd->start_addr_sp is 32 bytes
> > > alligned
> > >
> > > 	gd->new_bootstage = map_sysmem(gd->start_addr_sp, size);
> > > 	=> also unaligned
> > >
> > > 3- Then during relocation, in reloc_bootstage()
> > > 	gd->bootstage = gd->new_bootstage;
> > >
> > >
> > > 4- crash occur because in next bootstage function beaucse the boostage
> > > address don't respect pointer to struct allignement...
> > >
> > > 	struct bootstage_data *data = gd->bootstage
> > >
> > >
> > > > At some point we should also document that reservations must keep
> > > > things aligned.
> > > >
> > > > Perhaps this should be handled by a separate function called from
> > > > all these places, which subtracts gd->start_addr_sp and ensures 16-byte
> > alignment.
> > >
> > > Yes that can be a improvement,  but perhaps ia a second step / second serie....
> > >
> > > Do you think about a function called in all reversed_ functions (when
> > > start_addr_sp is modified)...
> > >
> > > static int reserved_allign_check(void) {
> > > 	/* make stack pointer 16-byte aligned */
> > > 	if (gd->start_addr_sp & 0xf) {
> > > 		gd->start_addr_sp -= 16;
> > > 		gd->start_addr_sp &= ~0xf;
> > > 	 }
> > > }
> > >
> > > I prefer a function to reserved a size wich replace in any reserve_
> > > function  the line
> > > :
> > > 	gd->start_addr_sp -= ...
> > >
> > > /* reserve size and make stack pointer 16-byte aligned */  static int
> > > reserve(size_t size) {
> > > 	gd->start_addr_sp -= size;
> > > 	/* make stack pointer 16-byte aligned */
> > > 	gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp, 16); }
> > >
> > > I think I will push it, when the patrice patch will be accepted.
> > 
> > I am preparing this patch....
> > 
> > Do you think it is ok to merge the Patrice v3 proposal first on master branch for
> > v2020.04 release (he just align the reserved memory for bootstage), and after I
> > make my patch (16-byte align all reserved area).
> > 
> > or it is better to make a more generic patch v4 to replace the Patrice one.
> 
> I push a  serie, with my proposal:
> [3/3] board_f.c: Insure 16 alignment of start_addr_sp and reserved memory
> 
> http://patchwork.ozlabs.org/project/uboot/list/?series=152226
> 
> As I found issue for ARM32 (I need to modify arch/arm/lib/crt0.S)
> I think it is preferable that the Patrice Patch is merged in v2020.04, and my serie can live  independently.
> But I can also squash of the 2 series.

Sorry for the delay.  Yes, please put together a single series that
takes care of everything.  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200121/12e6a0d7/attachment.sig>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3] board_f.c: Insure gd->new_bootstage alignment
  2020-01-21 23:18   ` Tom Rini
@ 2020-01-22 13:57     ` Patrick DELAUNAY
  0 siblings, 0 replies; 9+ messages in thread
From: Patrick DELAUNAY @ 2020-01-22 13:57 UTC (permalink / raw)
  To: u-boot

Hi Tom,

> From: Tom Rini <trini@konsulko.com>
> Sent: mercredi 22 janvier 2020 00:18
> 
> On Thu, Jan 09, 2020 at 05:23:51PM +0000, Patrick DELAUNAY wrote:
> > Hi,
> >
> > > From: Patrick DELAUNAY
> > > Sent: mardi 7 janvier 2020 13:07
> > >
> > > Hi Patrice and Tom
> > >
> > > > Sent: mercredi 18 décembre 2019 10:10
> > > >
> > > > Hi Simon,
> > > >
> > > > > From: Simon Glass <sjg@chromium.org>
> > > > > Sent: mardi 17 décembre 2019 16:46
> > > > >
> > > > > Hi Patrice,
> > > > >
> > > > > On Wed, 27 Nov 2019 at 02:11, Patrice Chotard
> > > > > <patrice.chotard@st.com>
> > > > wrote:
> > > > > >
> > > > > > In reserve_bootstage(), in case size is odd, gd->new_bootstage
> > > > > > is not aligned. In bootstage_relocate(), the platform hangs
> > > > > > when getting access to data->record[i].name.
> > > > > > To avoid this issue, make gd->new_bootstage 16 byte aligned.
> > > > > >
> > > > > > To insure that new_bootstage is 16 byte aligned (at least
> > > > > > needed for
> > > > > > x86_64 and ARMv8) and new_bootstage starts down to get enough
> > > > > > space, ALIGN_DOWN macro is used.
> > > > > >
> > > > > > Fixes: ac9cd4805c8b ("bootstage: Correct relocation
> > > > > > algorithm")
> > > > > >
> > > > > > Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> > > > > > Reviewed-by: Vikas MANOCHA <vikas.manocha@st.com>
> > > > > > Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
> > > > > > Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
> > > >
> > > > For information, Patrice is absent for personal reason up to beginning next
> year.
> > > > Don't wait a fast answer.
> > > >
> > > > > For this patch I think it would be better to update
> > > > > reserve_fdt() to keep things aligned, assuming that is the problem.
> > > >
> > > > I don't sure that solve the issue, for me the problem is only for
> > > > the bootstage struct (gd->bootstage) And
> > > > reserve_fdt() already alligne size on 32 bytes
> > > >
> > > > If I remember the Patrice analysis:
> > > >
> > > > 1- bootstage_get_size return a odd value (or at least not 16 bytes
> > > > aligned I don't remember).
> > > >
> > > > 2- In reserve_bootstage()
> > > > 	int size = bootstage_get_size();
> > > > 	gd->start_addr_sp -= size
> > > > 	=> it is a unaligned address even if gd->start_addr_sp is 32
> > > > bytes alligned
> > > >
> > > > 	gd->new_bootstage = map_sysmem(gd->start_addr_sp, size);
> > > > 	=> also unaligned
> > > >
> > > > 3- Then during relocation, in reloc_bootstage()
> > > > 	gd->bootstage = gd->new_bootstage;
> > > >
> > > >
> > > > 4- crash occur because in next bootstage function beaucse the
> > > > boostage address don't respect pointer to struct allignement...
> > > >
> > > > 	struct bootstage_data *data = gd->bootstage
> > > >
> > > >
> > > > > At some point we should also document that reservations must
> > > > > keep things aligned.
> > > > >
> > > > > Perhaps this should be handled by a separate function called
> > > > > from all these places, which subtracts gd->start_addr_sp and
> > > > > ensures 16-byte
> > > alignment.
> > > >
> > > > Yes that can be a improvement,  but perhaps ia a second step / second
> serie....
> > > >
> > > > Do you think about a function called in all reversed_ functions
> > > > (when start_addr_sp is modified)...
> > > >
> > > > static int reserved_allign_check(void) {
> > > > 	/* make stack pointer 16-byte aligned */
> > > > 	if (gd->start_addr_sp & 0xf) {
> > > > 		gd->start_addr_sp -= 16;
> > > > 		gd->start_addr_sp &= ~0xf;
> > > > 	 }
> > > > }
> > > >
> > > > I prefer a function to reserved a size wich replace in any
> > > > reserve_ function  the line
> > > > :
> > > > 	gd->start_addr_sp -= ...
> > > >
> > > > /* reserve size and make stack pointer 16-byte aligned */  static
> > > > int reserve(size_t size) {
> > > > 	gd->start_addr_sp -= size;
> > > > 	/* make stack pointer 16-byte aligned */
> > > > 	gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp, 16); }
> > > >
> > > > I think I will push it, when the patrice patch will be accepted.
> > >
> > > I am preparing this patch....
> > >
> > > Do you think it is ok to merge the Patrice v3 proposal first on
> > > master branch for
> > > v2020.04 release (he just align the reserved memory for bootstage),
> > > and after I make my patch (16-byte align all reserved area).
> > >
> > > or it is better to make a more generic patch v4 to replace the Patrice one.
> >
> > I push a  serie, with my proposal:
> > [3/3] board_f.c: Insure 16 alignment of start_addr_sp and reserved
> > memory
> >
> > http://patchwork.ozlabs.org/project/uboot/list/?series=152226
> >
> > As I found issue for ARM32 (I need to modify arch/arm/lib/crt0.S) I
> > think it is preferable that the Patrice Patch is merged in v2020.04, and my serie
> can live  independently.
> > But I can also squash of the 2 series.
> 
> Sorry for the delay.  Yes, please put together a single series that takes care of
> everything.  Thanks!

Done with serie = "Insure 16 alignment of reserved memory in board_f.c"

http://patchwork.ozlabs.org/project/uboot/list/?series=154685

I could merge the patches 1/4 and 4/4 if it is more clear.
 
Regards

Patrick

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3] board_f.c: Insure gd->new_bootstage alignment
  2019-12-17 15:46 ` Simon Glass
@ 2019-12-18  9:10   ` Patrick DELAUNAY
  0 siblings, 0 replies; 9+ messages in thread
From: Patrick DELAUNAY @ 2019-12-18  9:10 UTC (permalink / raw)
  To: u-boot

Hi Simon,

> From: Simon Glass <sjg@chromium.org>
> Sent: mardi 17 décembre 2019 16:46
> 
> Hi Patrice,
> 
> On Wed, 27 Nov 2019 at 02:11, Patrice Chotard <patrice.chotard@st.com> wrote:
> >
> > In reserve_bootstage(), in case size is odd, gd->new_bootstage is not
> > aligned. In bootstage_relocate(), the platform hangs when getting
> > access to data->record[i].name.
> > To avoid this issue, make gd->new_bootstage 16 byte aligned.
> >
> > To insure that new_bootstage is 16 byte aligned (at least needed for
> > x86_64 and ARMv8) and new_bootstage starts down to get enough space,
> > ALIGN_DOWN macro is used.
> >
> > Fixes: ac9cd4805c8b ("bootstage: Correct relocation algorithm")
> >
> > Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> > Reviewed-by: Vikas MANOCHA <vikas.manocha@st.com>
> > Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
> > Tested-by: Patrick Delaunay <patrick.delaunay@st.com>

For information, Patrice is absent for personal reason up to beginning next year.
Don't wait a fast answer.

> For this patch I think it would be better to update reserve_fdt() to keep things
> aligned, assuming that is the problem.

I don't sure that solve the issue, 
for me the problem is only for the bootstage struct (gd->bootstage)
And reserve_fdt() already alligne size on 32 bytes

If I remember the Patrice analysis:

1- bootstage_get_size return a odd value (or at least not 16 bytes aligned I don't remember).

2- In reserve_bootstage()
	int size = bootstage_get_size();
	gd->start_addr_sp -= size
	=> it is a unaligned address even if gd->start_addr_sp is 32 bytes alligned

	gd->new_bootstage = map_sysmem(gd->start_addr_sp, size);
	=> also unaligned

3- Then during relocation, in reloc_bootstage()
	gd->bootstage = gd->new_bootstage;


4- crash occur because in next bootstage function beaucse the boostage address don't respect pointer to struct allignement...

	struct bootstage_data *data = gd->bootstage


> At some point we should also document that reservations must keep things
> aligned.
> 
> Perhaps this should be handled by a separate function called from all these
> places, which subtracts gd->start_addr_sp and ensures 16-byte alignment.

Yes that can be a improvement,  but perhaps ia a second step / second serie....

Do you think about a function called in all reversed_ functions (when start_addr_sp is modified)...

static int reserved_allign_check(void)
{
	/* make stack pointer 16-byte aligned */
	if (gd->start_addr_sp & 0xf) {
		gd->start_addr_sp -= 16;
		gd->start_addr_sp &= ~0xf;
	 }
}

I prefer a function to reserved a size wich replace in any reserve_ function  the line : 
	gd->start_addr_sp -= ...

/* reserve size and make stack pointer 16-byte aligned */
static int reserve(size_t size)
{
	gd->start_addr_sp -= size;
	/* make stack pointer 16-byte aligned */
	gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp, 16);
}

I think I will push it, when the patrice patch will be accepted.

> Regards,
> Simon

Regards
Patrick

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3] board_f.c: Insure gd->new_bootstage alignment
  2019-12-17 12:52   ` Tom Rini
@ 2019-12-18  8:26     ` Patrick DELAUNAY
  0 siblings, 0 replies; 9+ messages in thread
From: Patrick DELAUNAY @ 2019-12-18  8:26 UTC (permalink / raw)
  To: u-boot

Hi Tom,

> From: Tom Rini <trini@konsulko.com>
> Sent: mardi 17 décembre 2019 13:52
> 
> On Mon, Dec 16, 2019 at 11:53:48AM +0000, Patrick DELAUNAY wrote:
> > Hi Tom,
> >
> > > From: Patrice CHOTARD <patrice.chotard@st.com>
> > > Sent: mercredi 27 novembre 2019 10:12
> > >
> > > In reserve_bootstage(), in case size is odd, gd->new_bootstage is
> > > not aligned. In bootstage_relocate(), the platform hangs when
> > > getting access to data-
> > > >record[i].name.
> > > To avoid this issue, make gd->new_bootstage 16 byte aligned.
> > >
> > > To insure that new_bootstage is 16 byte aligned (at least needed for
> > > x86_64 and ARMv8) and new_bootstage starts down to get enough space,
> > > ALIGN_DOWN macro is used.
> > >
> > > Fixes: ac9cd4805c8b ("bootstage: Correct relocation algorithm")
> > >
> > > Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> > > Reviewed-by: Vikas MANOCHA <vikas.manocha@st.com>
> > > Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
> > > Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
> > >
> >
> > Do you plan to merge this fixe for the next rc for v2020.01 ?
> > Or do you expect some change / review.
> >
> > This patch is mandatory for stm32mp1 (ARM plaform with bootstage
> > feature activated).
> > Without this patch, the boot failed (at least for v2020.01-rc3 : crash
> > has struct pointer new_bootstage is not aligned).
> >
> > Or I will deactivate the BOOTSTAGE feature...
> 
> I think at this point I would prefer dropping BOOTSTAGE from those boards for
> the release.  There's already been more than one "I think this is safe" followed by
> "this broke ..." changes I've tried.  Sorry!

I know the number of issue with  "it should work".... and I understood.
I sill push a patch to deactivate bootstatge (remove 2 "imply" in fact) and a new pull request.


> --
> Tom

BR
Patrick

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3] board_f.c: Insure gd->new_bootstage alignment
  2019-11-27  9:11 [U-Boot] " Patrice Chotard
  2019-12-16 11:53 ` Patrick DELAUNAY
@ 2019-12-17 15:46 ` Simon Glass
  2019-12-18  9:10   ` Patrick DELAUNAY
  1 sibling, 1 reply; 9+ messages in thread
From: Simon Glass @ 2019-12-17 15:46 UTC (permalink / raw)
  To: u-boot

Hi Patrice,

On Wed, 27 Nov 2019 at 02:11, Patrice Chotard <patrice.chotard@st.com> wrote:
>
> In reserve_bootstage(), in case size is odd, gd->new_bootstage
> is not aligned. In bootstage_relocate(), the platform hangs when
> getting access to data->record[i].name.
> To avoid this issue, make gd->new_bootstage 16 byte aligned.
>
> To insure that new_bootstage is 16 byte aligned (at least needed for
> x86_64 and ARMv8) and new_bootstage starts down to get enough space,
> ALIGN_DOWN macro is used.
>
> Fixes: ac9cd4805c8b ("bootstage: Correct relocation algorithm")
>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> Reviewed-by: Vikas MANOCHA <vikas.manocha@st.com>
> Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
> Tested-by: Patrick Delaunay <patrick.delaunay@st.com>

For this patch I think it would be better to update reserve_fdt() to
keep things aligned, assuming that is the problem.

At some point we should also document that reservations must keep
things aligned.

Perhaps this should be handled by a separate function called from all
these places, which subtracts gd->start_addr_sp and ensures 16-byte
alignment.

Regards,
Simon

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3] board_f.c: Insure gd->new_bootstage alignment
  2019-12-16 11:53 ` Patrick DELAUNAY
@ 2019-12-17 12:52   ` Tom Rini
  2019-12-18  8:26     ` Patrick DELAUNAY
  0 siblings, 1 reply; 9+ messages in thread
From: Tom Rini @ 2019-12-17 12:52 UTC (permalink / raw)
  To: u-boot

On Mon, Dec 16, 2019 at 11:53:48AM +0000, Patrick DELAUNAY wrote:
> Hi Tom,
> 
> > From: Patrice CHOTARD <patrice.chotard@st.com>
> > Sent: mercredi 27 novembre 2019 10:12
> > 
> > In reserve_bootstage(), in case size is odd, gd->new_bootstage is not aligned. In
> > bootstage_relocate(), the platform hangs when getting access to data-
> > >record[i].name.
> > To avoid this issue, make gd->new_bootstage 16 byte aligned.
> > 
> > To insure that new_bootstage is 16 byte aligned (at least needed for
> > x86_64 and ARMv8) and new_bootstage starts down to get enough space,
> > ALIGN_DOWN macro is used.
> > 
> > Fixes: ac9cd4805c8b ("bootstage: Correct relocation algorithm")
> > 
> > Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> > Reviewed-by: Vikas MANOCHA <vikas.manocha@st.com>
> > Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
> > Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
> > 
> 
> Do you plan to merge this fixe for the next rc for v2020.01 ?
> Or do you expect some change / review.
>
> This patch is mandatory for stm32mp1 (ARM plaform with bootstage
> feature activated).
> Without this patch, the boot failed (at least for v2020.01-rc3 : crash
> has struct pointer new_bootstage is not aligned).
> 
> Or I will deactivate the BOOTSTAGE feature...
 
I think at this point I would prefer dropping BOOTSTAGE from those
boards for the release.  There's already been more than one "I think
this is safe" followed by "this broke ..." changes I've tried.  Sorry!

-- 
Tom

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3] board_f.c: Insure gd->new_bootstage alignment
  2019-11-27  9:11 [U-Boot] " Patrice Chotard
@ 2019-12-16 11:53 ` Patrick DELAUNAY
  2019-12-17 12:52   ` Tom Rini
  2019-12-17 15:46 ` Simon Glass
  1 sibling, 1 reply; 9+ messages in thread
From: Patrick DELAUNAY @ 2019-12-16 11:53 UTC (permalink / raw)
  To: u-boot

Hi Tom,

> From: Patrice CHOTARD <patrice.chotard@st.com>
> Sent: mercredi 27 novembre 2019 10:12
> 
> In reserve_bootstage(), in case size is odd, gd->new_bootstage is not aligned. In
> bootstage_relocate(), the platform hangs when getting access to data-
> >record[i].name.
> To avoid this issue, make gd->new_bootstage 16 byte aligned.
> 
> To insure that new_bootstage is 16 byte aligned (at least needed for
> x86_64 and ARMv8) and new_bootstage starts down to get enough space,
> ALIGN_DOWN macro is used.
> 
> Fixes: ac9cd4805c8b ("bootstage: Correct relocation algorithm")
> 
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
> Reviewed-by: Vikas MANOCHA <vikas.manocha@st.com>
> Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
> Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
> 

Do you plan to merge this fixe for the next rc for v2020.01 ?
Or do you expect some change / review.

This patch is mandatory for stm32mp1 (ARM plaform with bootstage feature activated).
Without this patch, the boot failed (at least for v2020.01-rc3 : crash has struct pointer new_bootstage is not aligned).

Or I will deactivate the BOOTSTAGE feature...

Thanks 

Patrick

> ---
> 
> Changes in v3:
>   - Add Patrick Reviewed-by and Tested-by.
> 
> Changes in v2:
>   - Update comment to explain the ALIGN_DOWN() usage.
> 
>  common/board_f.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/common/board_f.c b/common/board_f.c index e3591cbaeb..d367f6b044
> 100644
> --- a/common/board_f.c
> +++ b/common/board_f.c
> @@ -559,6 +559,11 @@ static int reserve_bootstage(void)
>  	int size = bootstage_get_size();
> 
>  	gd->start_addr_sp -= size;
> +	/*
> +	 * Insure that start_addr_sp is aligned down to reserve enough
> +	 * space for new_bootstage
> +	 */
> +	gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp, 16);
>  	gd->new_bootstage = map_sysmem(gd->start_addr_sp, size);
>  	debug("Reserving %#x Bytes for bootstage at: %08lx\n", size,
>  	      gd->start_addr_sp);
> --
> 2.17.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-01-22 13:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07 12:07 [PATCH v3] board_f.c: Insure gd->new_bootstage alignment Patrick DELAUNAY
2020-01-09 17:23 ` Patrick DELAUNAY
2020-01-21 23:18   ` Tom Rini
2020-01-22 13:57     ` Patrick DELAUNAY
  -- strict thread matches above, loose matches on Subject: below --
2019-11-27  9:11 [U-Boot] " Patrice Chotard
2019-12-16 11:53 ` Patrick DELAUNAY
2019-12-17 12:52   ` Tom Rini
2019-12-18  8:26     ` Patrick DELAUNAY
2019-12-17 15:46 ` Simon Glass
2019-12-18  9:10   ` Patrick DELAUNAY

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.