Skip to content

Commit 3863e94

Browse files
lyakhkv2019i
authored andcommitted
Don't convert ROM addresses to cached aliases
We don't include ROM sections into the output image. If conversion is applied to them, they end up in the SRAM address range, which then generates corrupted images. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 1e0a85b commit 3863e94

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/elf.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
static unsigned long uncache_to_cache(const struct image *image, unsigned long address)
1616
{
17-
return ((address & ~image->adsp->alias_mask) | image->adsp->alias_cached);
17+
return (address & ~image->adsp->alias_mask) | image->adsp->alias_cached;
1818
}
1919

2020
static int elf_read_sections(struct image *image, struct module *module,
@@ -25,6 +25,8 @@ static int elf_read_sections(struct image *image, struct module *module,
2525
size_t count;
2626
int i, ret;
2727
uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR);
28+
unsigned long rom_base = image->adsp->mem_zones[SOF_FW_BLK_TYPE_ROM].base;
29+
size_t rom_size = image->adsp->mem_zones[SOF_FW_BLK_TYPE_ROM].size;
2830

2931
/* read in section header */
3032
ret = fseek(module->fd, hdr->shoff, SEEK_SET);
@@ -115,7 +117,13 @@ static int elf_read_sections(struct image *image, struct module *module,
115117
continue;
116118
}
117119

118-
section[i].vaddr = uncache_to_cache(image, section[i].vaddr);
120+
/*
121+
* Don't convert ROM addresses, ROM sections aren't included in
122+
* the output image
123+
*/
124+
if (section[i].vaddr < rom_base || section[i].vaddr >= rom_base + rom_size)
125+
section[i].vaddr = uncache_to_cache(image, section[i].vaddr);
126+
119127
module->num_sections++;
120128

121129
if (!image->verbose)

0 commit comments

Comments
 (0)