Skip to content

Commit 3c04d84

Browse files
gatecatpalmer-dabbelt
authored andcommitted
riscv: Fix XIP_FIXUP_FLASH_OFFSET
There were several problems with the calculation. Not only was an 'and' being computed into t1 but thrown away; but the 'and' itself would cause problems if the granularity of the XIP physical address was less than XIP_OFFSET - in my case I had the kernel image at 2MB in SPI flash. Fixes: f9ace4e ("riscv: remove .text section size limitation for XIP") Cc: [email protected] Signed-off-by: Myrtle Shah <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 6a00ef4 commit 3c04d84

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

arch/riscv/kernel/head.S

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@
2222
add \reg, \reg, t0
2323
.endm
2424
.macro XIP_FIXUP_FLASH_OFFSET reg
25-
la t1, __data_loc
26-
li t0, XIP_OFFSET_MASK
27-
and t1, t1, t0
28-
li t1, XIP_OFFSET
29-
sub t0, t0, t1
30-
sub \reg, \reg, t0
25+
la t0, __data_loc
26+
REG_L t1, _xip_phys_offset
27+
sub \reg, \reg, t1
28+
add \reg, \reg, t0
3129
.endm
3230
_xip_fixup: .dword CONFIG_PHYS_RAM_BASE - CONFIG_XIP_PHYS_ADDR - XIP_OFFSET
31+
_xip_phys_offset: .dword CONFIG_XIP_PHYS_ADDR + XIP_OFFSET
3332
#else
3433
.macro XIP_FIXUP_OFFSET reg
3534
.endm

0 commit comments

Comments
 (0)