board_f.c: Insure gd->new_bootstage alignment
PATCH v3 1/1 board_f.c: Insure gd->new_bootstage alignment
Hi Patrice and Tom
Quoted 85 lines
Sent: mercredi 18 décembre 2019 10:10
Hi Simon,
Quoted 6 lines
From: Simon Glass <[email protected]>
Sent: mardi 17 décembre 2019 16:46Hi Patrice,
On Wed, 27 Nov 2019 at 02:11, Patrice Chotard <[email protected]>
Quoted 10 lines · wrote:
Quoted 10 lines
In
reserve_bootstage(), in case size is odd,gd->new_bootstageis not aligned. Inbootstage_relocate(), the platform hangs when getting access to data->record[i].name.
To avoid this issue, makegd->new_bootstage16 byte aligned.To insure that
new_bootstageis 16 byte aligned (at least needed forx86_64and ARMv8) andnew_bootstagestarts down to get enough space,ALIGN_DOWNmacro is used.Quoted 6 lines
Quoted 6 lines
Fixes ac9cd4805c8b ("bootstage: Correct relocation algorithm")Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Vikas MANOCHA <[email protected]>Reviewed-by Patrick Delaunay <[email protected]>Tested-by Patrick Delaunay <[email protected]>For information, Patrice is absent for personal reason up to beginning next year. Don't wait a fast answer.
Quoted 2 lines
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) Andreserve_fdt()already alligne size on 32 bytesIf I remember the Patrice analysis:
1-
bootstage_get_sizereturn 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 unaligned3- 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->bootstageQuoted 5 lines
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_spand 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 (whenstart_addr_spis 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 -= ...
Quoted 8 lines
/* 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
PATCH v3 1/1 board_f.c: Insure gd->new_bootstage alignment
Hi,
Quoted 103 lines
From: Patrick DELAUNAY
Sent: mardi 7 janvier 2020 13:07Hi Patrice and Tom
Quoted 55 lines
Sent: mercredi 18 décembre 2019 10:10
Hi Simon,
Quoted 7 lines
From: Simon Glass <[email protected]>
Sent: mardi 17 décembre 2019 16:46Hi Patrice,
On Wed, 27 Nov 2019 at 02:11, Patrice Chotard
<[email protected]>Quoted 11 lines · wrote:
Quoted 11 lines
In
reserve_bootstage(), in case size is odd,gd->new_bootstageis not aligned. Inbootstage_relocate(), the platform hangs when getting access to data->record[i].name.
To avoid this issue, makegd->new_bootstage16 byte aligned.To insure that
new_bootstageis 16 byte aligned (at least needed forx86_64and ARMv8) andnew_bootstagestarts down to get enough space,ALIGN_DOWNmacro is used.Quoted 6 lines
Quoted 6 lines
Fixes ac9cd4805c8b ("bootstage: Correct relocation algorithm")Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Vikas MANOCHA <[email protected]>Reviewed-by Patrick Delaunay <[email protected]>Tested-by Patrick Delaunay <[email protected]>For information, Patrice is absent for personal reason up to beginning next year. Don't wait a fast answer.
Quoted 2 lines
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) Andreserve_fdt()already alligne size on 32 bytesIf I remember the Patrice analysis:
1-
bootstage_get_sizereturn 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 bytesalligned
gd->new_bootstage = map_sysmem(gd->start_addr_sp, size); => also unalignedQuoted 15 lines
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->bootstageQuoted 5 lines
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_spand ensures 16-bytealignment.
Quoted 19 lines
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 (whenstart_addr_spis 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 -= ...Quoted 7 lines
/* 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.
Quoted 7 lines
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
PATCH v3 1/1 board_f.c: Insure gd->new_bootstage alignment
Quoted 113 lines · Patrick DELAUNAY
Hi,
Quoted 103 lines
From: Patrick DELAUNAY
Sent: mardi 7 janvier 2020 13:07Hi Patrice and Tom
Quoted 55 lines
Sent: mercredi 18 décembre 2019 10:10
Hi Simon,
Quoted 7 lines
From: Simon Glass <[email protected]>
Sent: mardi 17 décembre 2019 16:46Hi Patrice,
On Wed, 27 Nov 2019 at 02:11, Patrice Chotard
<[email protected]>Quoted 11 lines · wrote:
Quoted 11 lines
In
reserve_bootstage(), in case size is odd,gd->new_bootstageis not aligned. Inbootstage_relocate(), the platform hangs when getting access to data->record[i].name.
To avoid this issue, makegd->new_bootstage16 byte aligned.To insure that
new_bootstageis 16 byte aligned (at least needed forx86_64and ARMv8) andnew_bootstagestarts down to get enough space,ALIGN_DOWNmacro is used.Quoted 6 lines
Quoted 6 lines
Fixes ac9cd4805c8b ("bootstage: Correct relocation algorithm")Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Vikas MANOCHA <[email protected]>Reviewed-by Patrick Delaunay <[email protected]>Tested-by Patrick Delaunay <[email protected]>For information, Patrice is absent for personal reason up to beginning next year. Don't wait a fast answer.
Quoted 2 lines
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) Andreserve_fdt()already alligne size on 32 bytesIf I remember the Patrice analysis:
1-
bootstage_get_sizereturn 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 bytesalligned
gd->new_bootstage = map_sysmem(gd->start_addr_sp, size); => also unalignedQuoted 15 lines
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->bootstageQuoted 5 lines
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_spand ensures 16-bytealignment.
Quoted 19 lines
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 (whenstart_addr_spis 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 -= ...Quoted 7 lines
/* 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.
Quoted 7 lines
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.
Quoted 8 lines
I push a serie, with my proposal:
[3/3]board_f.c: Insure 16 alignment ofstart_addr_spand reserved memoryhttp://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!
Signature · 8 lines
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>
PATCH v3 1/1 board_f.c: Insure gd->new_bootstage alignment
Hi Tom,
Quoted 127 lines
From: Tom Rini <[email protected]>
Sent: mercredi 22 janvier 2020 00:18Quoted 39 lines · Patrick DELAUNAY
Hi,
Quoted 37 lines
From: Patrick DELAUNAY
Sent: mardi 7 janvier 2020 13:07Hi Patrice and Tom
Quoted 32 lines
Sent: mercredi 18 décembre 2019 10:10
Hi Simon,
Quoted 7 lines
From: Simon Glass <[email protected]>
Sent: mardi 17 décembre 2019 16:46Hi Patrice,
On Wed, 27 Nov 2019 at 02:11, Patrice Chotard
<[email protected]>Quoted 11 lines · wrote:
Quoted 11 lines
In
reserve_bootstage(), in case size is odd,gd->new_bootstageis not aligned. Inbootstage_relocate(), the platform hangs when getting access to data->record[i].name.
To avoid this issue, makegd->new_bootstage16 byte aligned.To insure that
new_bootstageis 16 byte aligned (at least needed forx86_64and ARMv8) andnew_bootstagestarts down to get enough space,ALIGN_DOWNmacro is used.Quoted 7 lines
Quoted 7 lines
Fixes ac9cd4805c8b ("bootstage: Correct relocationalgorithm")
Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Vikas MANOCHA <[email protected]>Reviewed-by Patrick Delaunay <[email protected]>Tested-by Patrick Delaunay <[email protected]>For information, Patrice is absent for personal reason up to beginning next
year.
Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
Don't wait a fast answer.
Quoted 2 lines
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) Andreserve_fdt()already alligne size on 32 bytesIf I remember the Patrice analysis:
1-
bootstage_get_sizereturn 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 32bytes alligned
gd->new_bootstage = map_sysmem(gd->start_addr_sp, size); => also unaligned3- 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->bootstageQuoted 3 lines
At some point we should also document that reservations must keep things aligned.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Perhaps this should be handled by a separate function called from all these places, which subtracts
gd->start_addr_spand ensures 16-bytealignment.
Quoted 2 lines
Yes that can be a improvement, but perhaps ia a second step / second
serie....
Quoted 40 lines
Quoted 25 lines
Quoted 17 lines
Do you think about a function called in all
reversed_functions (whenstart_addr_spis 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 -= ...Quoted 7 lines
/* 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.
Quoted 8 lines
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 ofstart_addr_spand reserved memoryhttp://patchwork.ozlabs.org/project/uboot/list/?series=152226
Quoted 7 lines
Quoted 2 lines
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 seriecan live independently.
Quoted 1 line
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