mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-24 06:24:17 +00:00
cmd: fix loads, saves on sandbox
The loads and saves commands crash on the sandbox due to illegal memory access. For command line arguments the sandbox uses a virtual address space which does not equal the addresses of the memory allocated with memmap(). Add the missing address translations for the loads and saves commands. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
76e1607617
commit
338b67f76c
1 changed files with 12 additions and 4 deletions
14
cmd/load.c
14
cmd/load.c
|
@ -181,13 +181,17 @@ static ulong load_serial(long offset)
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
void *dst;
|
||||||
|
|
||||||
ret = lmb_reserve(&lmb, store_addr, binlen);
|
ret = lmb_reserve(&lmb, store_addr, binlen);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("\nCannot overwrite reserved area (%08lx..%08lx)\n",
|
printf("\nCannot overwrite reserved area (%08lx..%08lx)\n",
|
||||||
store_addr, store_addr + binlen);
|
store_addr, store_addr + binlen);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
memcpy((char *)(store_addr), binbuf, binlen);
|
dst = map_sysmem(store_addr, binlen);
|
||||||
|
memcpy(dst, binbuf, binlen);
|
||||||
|
unmap_sysmem(dst);
|
||||||
lmb_free(&lmb, store_addr, binlen);
|
lmb_free(&lmb, store_addr, binlen);
|
||||||
}
|
}
|
||||||
if ((store_addr) < start_addr)
|
if ((store_addr) < start_addr)
|
||||||
|
@ -350,8 +354,11 @@ static int save_serial(ulong address, ulong count)
|
||||||
if(write_record(SREC3_START)) /* write the header */
|
if(write_record(SREC3_START)) /* write the header */
|
||||||
return (-1);
|
return (-1);
|
||||||
do {
|
do {
|
||||||
if(count) { /* collect hex data in the buffer */
|
volatile uchar *src;
|
||||||
c = *(volatile uchar*)(address + reclen); /* get one byte */
|
|
||||||
|
src = map_sysmem(address, count);
|
||||||
|
if (count) { /* collect hex data in the buffer */
|
||||||
|
c = src[reclen]; /* get one byte */
|
||||||
checksum += c; /* accumulate checksum */
|
checksum += c; /* accumulate checksum */
|
||||||
data[2*reclen] = hex[(c>>4)&0x0f];
|
data[2*reclen] = hex[(c>>4)&0x0f];
|
||||||
data[2*reclen+1] = hex[c & 0x0f];
|
data[2*reclen+1] = hex[c & 0x0f];
|
||||||
|
@ -359,6 +366,7 @@ static int save_serial(ulong address, ulong count)
|
||||||
++reclen;
|
++reclen;
|
||||||
--count;
|
--count;
|
||||||
}
|
}
|
||||||
|
unmap_sysmem((void *)src);
|
||||||
if(reclen == SREC_BYTES_PER_RECORD || count == 0) {
|
if(reclen == SREC_BYTES_PER_RECORD || count == 0) {
|
||||||
/* enough data collected for one record: dump it */
|
/* enough data collected for one record: dump it */
|
||||||
if(reclen) { /* build & write a data record: */
|
if(reclen) { /* build & write a data record: */
|
||||||
|
|
Loading…
Add table
Reference in a new issue