more RELOCATABLE + errata code model issues
Hey Alex,
LKP reported [1] some issues with relocatable kernels & code models. You didn't touch the commit that caused the issues, so you didn't see the failure report I guess, but Prabhakar is looking for some guidance on what he should do to resolve the problems. Copy-pasting from his mail:
Quoted 14 lines
Quoted 8 lines
All errors (new ones prefixed by >>):
Quoted 5 lines
Quoted 5 lines
ld.lld: error: relocation
R_RISCV_LO12_Icannot be used against symbol 'riscv_cbom_block_size'; recompile with -fPICQuoted 3 lines
defined in
vmlinux.a(arch/riscv/mm/cacheflush.o)
referenced byerrata.c
arch/riscv/errata/andes/errata.o:(andes_errata_patch_func) in archive vmlinux.aI did reproduce this issue locally. The andes errata is not compiled as medany. The config is RELOCATABLE + MEDLOW. I can see the cacheflush.o is compiled with medany flag. I can fix the build by adding a medany flag as below:
(quoted diff) +2
-0+#ifdef CONFIG_RISCV_ALTERNATIVE_EARLY +CFLAGS_errata.o := -mcmodel=medany#endif
Quoted 1 line
But I am not sure if this is correct approach. Any pointers on this?
The T-Head errata have something similar, so seems like fair game to me. Any thoughts?
Thanks,
Conor.
[1] - https://lore.kernel.org/all/[email protected]/
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 22 lines · Conor Dooley
Hey Alex,
LKP reported [1] some issues with relocatable kernels & code models. You didn't touch the commit that caused the issues, so you didn't see the failure report I guess, but Prabhakar is looking for some guidance on what he should do to resolve the problems. Copy-pasting from his mail:
Quoted 14 lines
Quoted 8 lines
All errors (new ones prefixed by >>):
Quoted 5 lines
Quoted 5 lines
ld.lld: error: relocation
R_RISCV_LO12_Icannot be used against symbol 'riscv_cbom_block_size'; recompile with -fPICQuoted 3 lines
defined in
vmlinux.a(arch/riscv/mm/cacheflush.o)
referenced byerrata.c
arch/riscv/errata/andes/errata.o:(andes_errata_patch_func) in archive vmlinux.aI did reproduce this issue locally. The andes errata is not compiled as medany. The config is RELOCATABLE + MEDLOW. I can see the cacheflush.o is compiled with medany flag. I can fix the build by adding a medany flag as below:
(quoted diff) +2
-0+#ifdef CONFIG_RISCV_ALTERNATIVE_EARLY +CFLAGS_errata.o := -mcmodel=medany#endif
Quoted 4 lines
Quoted 1 line
But I am not sure if this is correct approach. Any pointers on this?
The T-Head errata have something similar, so seems like fair game to me. Any thoughts?
We're using medany as a cheap way to get PIC, so anything that's pre-relocation will need medany. We don't really have a good way to check that, medany isn't supposed to be ABI (we're really just abusing it here for PIC). Thus none of this gets checked at build time, and I won't catch any errata pre-merge because I'm in QEMU. So this is all kind of fragile.
So maybe there's a better way to do all that, but for now just adding medany seems like the way to go.
Quoted 4 lines
Thanks,
Conor.
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Alexandre Ghiti
reviewerQuoted 23 lines · Palmer Dabbelt
Quoted 22 lines · Conor Dooley
Hey Alex,
LKP reported [1] some issues with relocatable kernels & code models. You didn't touch the commit that caused the issues, so you didn't see the failure report I guess, but Prabhakar is looking for some guidance on what he should do to resolve the problems. Copy-pasting from his mail:
Quoted 14 lines
Quoted 6 lines
All errors (new ones prefixed by >>):
Quoted 2 lines
Quoted 2 lines
Quoted 1 line
ld.lld: error: relocation
R_RISCV_LO12_Icannot be used againstsymbol '
riscv_cbom_block_size'; recompile with -fPIC>>> defined in
vmlinux.a(arch/riscv/mm/cacheflush.o)>>> referenced byerrata.c
>>> arch/riscv/errata/andes/errata.o:(andes_errata_patch_func)in archive vmlinux.a
Quoted 1 line
I did reproduce this issue locally. The andes errata is not
compiled as medany. The config is RELOCATABLE + MEDLOW. I can see the cacheflush.o is compiled with medany flag. I can fix the build by adding a medany flag as below:
(quoted diff) +2
-0+#ifdef CONFIG_RISCV_ALTERNATIVE_EARLY +CFLAGS_errata.o := -mcmodel=medany#endif
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
But I am not sure if this is correct approach. Any pointers on this?
The T-Head errata have something similar, so seems like fair game to me. Any thoughts?
We're using medany as a cheap way to get PIC, so anything that's pre-relocation will need medany. We don't really have a good way to check that, medany isn't supposed to be ABI (we're really just abusing it here for PIC). Thus none of this gets checked at build time, and I won't catch any errata pre-merge because I'm in QEMU. So this is all kind of fragile.
So maybe there's a better way to do all that, but for now just adding medany seems like the way to go.
There is the pre-mmu documentation now that gives hint about what to do for the very early code: https://elixir.bootlin.com/linux/v6.6-rc2/source/Documentation/riscv/boot.rst#L151 but admittedly, it does not state that it would result in compilation errors, maybe that can be added.
Quoted 10 lines
Quoted 5 lines
Thanks,
Conor._______________________________________________
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