diff options
author | Myrtle Shah <gatecat@ds0.me> | 2022-01-20 15:33:37 +0000 |
---|---|---|
committer | Palmer Dabbelt <palmer@rivosinc.com> | 2022-02-04 11:11:07 -0800 |
commit | 3c04d84508b54fcf524093b0d4a718680ed67f0f (patch) | |
tree | d3f7053b90b2d64d9e40eb866427f25ee4e873d0 /arch/riscv/kernel | |
parent | 6a00ef4493706a23120057fafbc62379bcde11ec (diff) | |
download | linux-3c04d84508b54fcf524093b0d4a718680ed67f0f.tar.gz linux-3c04d84508b54fcf524093b0d4a718680ed67f0f.tar.bz2 linux-3c04d84508b54fcf524093b0d4a718680ed67f0f.zip |
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: f9ace4ede49b ("riscv: remove .text section size limitation for XIP")
Cc: stable@vger.kernel.org
Signed-off-by: Myrtle Shah <gatecat@ds0.me>
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'arch/riscv/kernel')
-rw-r--r-- | arch/riscv/kernel/head.S | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S index 2363b43312fc..ec07f991866a 100644 --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -22,14 +22,13 @@ add \reg, \reg, t0 .endm .macro XIP_FIXUP_FLASH_OFFSET reg - la t1, __data_loc - li t0, XIP_OFFSET_MASK - and t1, t1, t0 - li t1, XIP_OFFSET - sub t0, t0, t1 - sub \reg, \reg, t0 + la t0, __data_loc + REG_L t1, _xip_phys_offset + sub \reg, \reg, t1 + add \reg, \reg, t0 .endm _xip_fixup: .dword CONFIG_PHYS_RAM_BASE - CONFIG_XIP_PHYS_ADDR - XIP_OFFSET +_xip_phys_offset: .dword CONFIG_XIP_PHYS_ADDR + XIP_OFFSET #else .macro XIP_FIXUP_OFFSET reg .endm |