These are some initial patches to bugs I found attempting to get a XIP kernel working on hardware:
- 32-bit VexRiscv processor
- kernel in SPI flash, at 0x00200000
- 16MB of RAM at 0x10000000
- MMU enabled
I still have some more debugging to do, but these at least get the kernel as far as initialising the MMU, and I would appreciate feedback if anyone else is working on RISC-V XIP.
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH 1/2 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.
I believe this approach is more generic.
--- arch/riscv/kernel/head.S | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
arch/riscv/kernel/head.S +5 -6
@@ -21,14 +21,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
Signature · 1 line
2.34.1
PATCH 2/2 riscv/mm: Add some missing XIP_FIXUPs
In reply to Myrtle Shah--- arch/riscv/mm/init.c | 2 ++ 1 file changed, 2 insertions(+)
arch/riscv/mm/init.c +2 -0
@@ -41,6 +41,7 @@ phys_addr_t phys_ram_base __ro_after_init;EXPORT_SYMBOL (phys_ram_base);#ifdef CONFIG_XIP_KERNEL +#define phys_ram_base (*(phys_addr_t *)XIP_FIXUP(&phys_ram_base))extern char _xiprom[], _exiprom[], __data_loc;#endif
@@ -248,6 +249,7 @@ pgd_t early_pg_dir[PTRS_PER_PGD] __initdata __aligned(PAGE_SIZE);static pmd_t __maybe_unused early_dtb_pmd[PTRS_PER_PMD ]__initdata __aligned(PAGE_SIZE) ;#ifdef CONFIG_XIP_KERNEL +#define riscv_pfn_base (*(unsigned long *)XIP_FIXUP(&riscv_pfn_base))#define trampoline_pg_dir ((pgd_t *)XIP_FIXUP(trampoline_pg_dir))#define fixmap_pte ((pte_t *)XIP_FIXUP(fixmap_pte))#define early_pg_dir ((pgd_t *)XIP_FIXUP(early_pg_dir))
Signature · 7 lines
2.34.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Hey,
Quoted 11 lines · Myrtle Shah
These are some initial patches to bugs I found attempting to get a XIP kernel working on hardware:
- 32-bit VexRiscv processor
- kernel in SPI flash, at0x00200000
- 16MB of RAM at0x10000000
- MMU enabledI still have some more debugging to do, but these at least get the kernel as far as initialising the MMU, and I would appreciate feedback if anyone else is working on RISC-V XIP.
I'll try to support you as much as I can, unfortunately I don't have any 32-bit RISC-V around so I was rather thinking of extending the RISC-V XIP support to 64-bit non-MMU targets.
For now just please keep in mind that there might be some inherent assumptions that a target is 64 bit.
Best regards,
Vitaly
Quoted 5 lines
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 11 lines · Vitaly Wool
Hey,
Quoted 8 lines · Myrtle Shah
These are some initial patches to bugs I found attempting to get a XIP kernel working on hardware:
- 32-bit VexRiscv processor
- kernel in SPI flash, at0x00200000
- 16MB of RAM at0x10000000
- MMU enabled
Quoted 7 lines
Quoted 3 lines
I still have some more debugging to do, but these at least get the kernel as far as initialising the MMU, and I would appreciate feedback if anyone else is working on RISC-V XIP.
I'll try to support you as much as I can, unfortunately I don't have any 32-bit RISC-V around so I was rather thinking of extending the RISC-V XIP support to 64-bit non-MMU targets.
That would be great ! I am completing the buildroot patches for the K210. Got u-boot almost working for SD card boot too (fighting a problem with rootfs kernel mount on boot when using u-boot though).
Quoted 16 lines
For now just please keep in mind that there might be some inherent assumptions that a target is 64 bit.
Best regards,
VitalyQuoted 5 lines
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Signature · 2 lines
Damien Le Moal Western Digital Research
Palmer Dabbelt
maintainerQuoted 15 lines · On Thu, 20 Jan 2022 07:37:00 PST (-0800), [email protected] wrote:
Hey,
Quoted 11 lines · Myrtle Shah
These are some initial patches to bugs I found attempting to get a XIP kernel working on hardware:
- 32-bit VexRiscv processor
- kernel in SPI flash, at0x00200000
- 16MB of RAM at0x10000000
- MMU enabledI still have some more debugging to do, but these at least get the kernel as far as initialising the MMU, and I would appreciate feedback if anyone else is working on RISC-V XIP.
Quoted 5 lines
I'll try to support you as much as I can, unfortunately I don't have any 32-bit RISC-V around so I was rather thinking of extending the RISC-V XIP support to 64-bit non-MMU targets.
For now just please keep in mind that there might be some inherent assumptions that a target is 64 bit.
I don't test any of the XIP configs, but if you guys have something that's sane to run in QEMU I'm happy to do so. Given that there's now some folks finding boot bugs it's probably worth getting what does boot into a regression test so it's less likely to break moving forwards.
These are on fixes, with the second one split up so it's got a better chance of landing in the stable trees.
Thanks!
Quoted 9 lines
Best regards,
VitalyQuoted 5 lines
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv