lmb: handle more than one DRAM BANK
Subsystems (3)
PATCH 1/1 lmb: handle more than one DRAM BANK
This fixes the automatic lmb initialization and reservation for boards with more than one DRAM bank.
This fixes the CVE-2018-18439 and -18440 fixes that only allowed to load files into the firs DRAM bank from fs and via tftp.
---
common/bootm.c | 4 ++-- fs/fs.c | 3 +-- include/lmb.h | 7 +++++-- lib/lmb.c | 37 ++++++++++++++++++++++++++++++++----- net/tftp.c | 3 +-- 5 files changed, 41 insertions(+), 13 deletions(-)
common/bootm.c +2 -2
@@ -59,8 +59,8 @@ static void boot_start_lmb(bootm_headers_t *images) mem_start =env_get_bootm_low (); mem_size =env_get_bootm_size (); -lmb_init_and_reserve (&images->lmb, (phys_addr_t )mem_start, mem_size, - NULL); +lmb_init_and_reserve_range (&images->lmb, (phys_addr_t )mem_start, + mem_size, NULL); }#else #define lmb_reserve (lmb, base, size)
fs/fs.c +1 -2
@@ -453,8 +453,7 @@ static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset,if (len && len < read_len) read_len = len; -lmb_init_and_reserve (&lmb, gd->bd->bi_dram[0 ].start, - gd->bd->bi_dram[0 ].size, (void *)gd->fdt_blob); +lmb_init_and_reserve (&lmb, gd->bd, (void *)gd->fdt_blob);lmb_dump_all (&lmb);if (lmb_alloc_addr (&lmb, addr, read_len) == addr)
include/lmb.h +5 -2
@@ -4,6 +4,8 @@#ifdef __KERNEL__#include <asm/types.h> +#include <asm/u-boot.h> +/* * Logical memory blocks. *
@@ -29,8 +31,9 @@ struct lmb { };extern void lmb_init (struct lmb *lmb); -extern void lmb_init_and_reserve (struct lmb *lmb,phys_addr_t base, -phys_size_t size,void *fdt_blob); +extern void lmb_init_and_reserve (struct lmb *lmb,bd_t *bd,void *fdt_blob); +extern void lmb_init_and_reserve_range (struct lmb *lmb,phys_addr_t base, +phys_size_t size,void *fdt_blob);extern long lmb_add (struct lmb *lmb,phys_addr_t base,phys_size_t size);extern long lmb_reserve (struct lmb *lmb,phys_addr_t base,phys_size_t size);extern phys_addr_t lmb_alloc (struct lmb *lmb,phys_size_t size,ulong align);
lib/lmb.c +32 -5
@@ -98,12 +98,8 @@ void lmb_init(struct lmb *lmb) lmb->reserved.size =0 ; } -/* Initialize the struct, add memory and call arch/board reserve functions */ -void lmb_init_and_reserve (struct lmb *lmb,phys_addr_t base,phys_size_t size, -void *fdt_blob) +static void lmb_reserve_common (struct lmb *lmb,void *fdt_blob) { -lmb_init (lmb); -lmb_add (lmb, base, size);arch_lmb_reserve (lmb);board_lmb_reserve (lmb);
@@ -111,6 +107,37 @@ void lmb_init_and_reserve(struct lmb *lmb, phys_addr_t base, phys_size_t size,boot_fdt_add_mem_rsv_regions (lmb, fdt_blob); } +/* Initialize the struct, add memory and call arch/board reserve functions */ +void lmb_init_and_reserve (struct lmb *lmb,bd_t *bd,void *fdt_blob) +{ +#ifdef CONFIG_NR_DRAM_BANKS +int i; +#endif + +lmb_init (lmb); +#ifdef CONFIG_NR_DRAM_BANKS +for (i =0 ; i <CONFIG_NR_DRAM_BANKS ; i++) { +if (bd->bi_dram[i].size) { +lmb_add (lmb, bd->bi_dram[i].start, + bd->bi_dram[i].size); + } + } +#else +if (bd->bi_memsize) +lmb_add (lmb, bd->bi_memstart, bd->bi_memsize); +#endif +lmb_reserve_common (lmb, fdt_blob); +} + +/* Initialize the struct, add memory and call arch/board reserve functions */ +void lmb_init_and_reserve_range (struct lmb *lmb,phys_addr_t base, +phys_size_t size,void *fdt_blob) +{ +lmb_init (lmb); +lmb_add (lmb, base, size); +lmb_reserve_common (lmb, fdt_blob); +} +/* This routine called with relocation disabled. */ static long lmb_add_region (struct lmb_region *rgn,phys_addr_t base,phys_size_t size) {
net/tftp.c +1 -2
@@ -606,8 +606,7 @@ static int tftp_init_load_addr(void)struct lmb lmb;phys_size_t max_size; -lmb_init_and_reserve (&lmb, gd->bd->bi_dram[0 ].start, - gd->bd->bi_dram[0 ].size, (void *)gd->fdt_blob); +lmb_init_and_reserve (&lmb, gd->bd, (void *)gd->fdt_blob); max_size =lmb_get_unreserved_size (&lmb, load_addr);if (!max_size)
Signature · 1 line
2.17.1
PATCH 1/1 lmb: handle more than one DRAM BANK
Quoted 8 lines · Simon Goldschmidt
This fixes the automatic lmb initialization and reservation for boards with more than one DRAM bank.
This fixes the CVE-2018-18439 and -18440 fixes that only allowed to load files into the firs DRAM bank from fs and via tftp.
Signed-off-by Simon Goldschmidt <[email protected]>
Thanks for the patch.
With the patch tftp to $loadaddr is possible on vexpress_ca15_tc2. Loading to an address outside DRAM is forbidden.
So for vexpress_ca15_tc2
PATCH 1/1 lmb: handle more than one DRAM BANK
Quoted 10 lines · Heinrich Schuchardt
Quoted 8 lines · Simon Goldschmidt
This fixes the automatic lmb initialization and reservation for boards with more than one DRAM bank.
This fixes the CVE-2018-18439 and -18440 fixes that only allowed to load files into the firs DRAM bank from fs and via tftp.
Signed-off-by Simon Goldschmidt <[email protected]>
Quoted 9 lines
Thanks for the patch.
With the patch tftp to $loadaddr is possible on
vexpress_ca15_tc2. Loading to an address outside DRAM is forbidden.So for
vexpress_ca15_tc2Tested-by Heinrich Schuchardt <[email protected]>
I ran this patch through Travis CI together with the efi-next queue and no error occurred.
https://travis-ci.org/xypron2/u-boot/builds/484859383
https://github.com/xypron2/u-boot/commits/21ea2188022313cac9db0f27d46a9dbcad0f2c19
Best regards
Heinrich
PATCH 1/1 lmb: handle more than one DRAM BANK
In reply to Simon GoldschmidtHi Simon,
Quoted 9 lines · Simon Goldschmidt
This fixes the automatic lmb initialization and reservation for boards with more than one DRAM bank.
This fixes the CVE-2018-18439 and -18440 fixes that only allowed to load files into the firs DRAM bank from fs and via tftp.
Signed-off-by Simon Goldschmidt <[email protected]>
Quoted 8 lines
---
common/bootm.c | 4 ++-- fs/fs.c | 3 +-- include/lmb.h | 7 +++++-- lib/lmb.c | 37 ++++++++++++++++++++++++++++++++----- net/tftp.c | 3 +-- 5 files changed, 41 insertions(+), 13 deletions(-)
Do we need a test update to cover this?
- Simon
PATCH 1/1 lmb: handle more than one DRAM BANK
Quoted 22 lines · Simon Glass
Hi Simon,
Quoted 9 lines · Simon Goldschmidt
This fixes the automatic lmb initialization and reservation for boards with more than one DRAM bank.
This fixes the CVE-2018-18439 and -18440 fixes that only allowed to load files into the firs DRAM bank from fs and via tftp.
Signed-off-by Simon Goldschmidt <[email protected]>Quoted 8 lines
---
common/bootm.c | 4 ++-- fs/fs.c | 3 +-- include/lmb.h | 7 +++++-- lib/lmb.c | 37 ++++++++++++++++++++++++++++++++----- net/tftp.c | 3 +-- 5 files changed, 41 insertions(+), 13 deletions(-)
Quoted 7 lines
Reviewed-by Simon Glass <[email protected]>Do we need a test update to cover this?
- Simon
Currently in Travis we only check that loading to allowable regions works. This is where I experienced trouble that led to this patch.
A test checking that loading to disallowed regions fails is not yet available. Unfortunately such a test would have to be board specific. Maybe we should just do a sandbox test.
It would be helpful for such a test if the sandbox were using multiple DRAM banks.
Currently the sandbox shows only a single DRAM bank of *zero* size:
=> bdinfoboot_params = 0x0000000000000000
DRAM bank = 0x0000000000000000 -> start = 0x0000000000000000 -> size = 0x0000000008000000 ethaddr = 00:00:11:22:33:44 IP addr = 1.2.3.4
@Simon
Is this a display bug?
Best regards
Heinrich
PATCH 1/1 lmb: handle more than one DRAM BANK
Quoted 41 lines · Heinrich Schuchardt
Quoted 22 lines · Simon Glass
Hi Simon,
Quoted 9 lines · Simon Goldschmidt
This fixes the automatic lmb initialization and reservation for boards with more than one DRAM bank.
This fixes the CVE-2018-18439 and -18440 fixes that only allowed to load files into the firs DRAM bank from fs and via tftp.
Signed-off-by Simon Goldschmidt <[email protected]>Quoted 8 lines
---
common/bootm.c | 4 ++-- fs/fs.c | 3 +-- include/lmb.h | 7 +++++-- lib/lmb.c | 37 ++++++++++++++++++++++++++++++++----- net/tftp.c | 3 +-- 5 files changed, 41 insertions(+), 13 deletions(-)Quoted 7 lines
Reviewed-by Simon Glass <[email protected]>Do we need a test update to cover this?
- Simon
Currently in Travis we only check that loading to allowable regions works. This is where I experienced trouble that led to this patch.
A test checking that loading to disallowed regions fails is not yet available. Unfortunately such a test would have to be board specific. Maybe we should just do a sandbox test.
It would be helpful for such a test if the sandbox were using multiple DRAM banks.
Quoted 7 lines
Currently the sandbox shows only a single DRAM bank of *zero* size:
=> bdinfo
boot_params=0x0000000000000000DRAM bank = 0x0000000000000000 -> start = 0x0000000000000000 -> size = 0x0000000008000000
But size is *not* zero here?
Quoted 4 lines
ethaddr = 00:00:11:22:33:44
IP addr = 1.2.3.4@Simon
Which Simon? ;-)
Regards,
Simon
Quoted 5 lines
Is this a display bug?
Best regards
Heinrich
Quoted 10 lines · Simon Goldschmidt
This fixes the automatic lmb initialization and reservation for boards with more than one DRAM bank.
This fixes the CVE-2018-18439 and -18440 fixes that only allowed to load files into the firs DRAM bank from fs and via tftp.
Signed-off-by Simon Goldschmidt <[email protected]>Tested-by Heinrich Schuchardt <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190202/30b5f375/attachment.sig>