Message ID | 1477585631-18574-3-git-send-email-ard.biesheuvel@linaro.org |
---|---|
State | New |
Headers | show |
Ard Biesheuvel <ard.biesheuvel@linaro.org> writes: > diff --git a/arch/powerpc/relocs_check.sh b/arch/powerpc/relocs_check.sh > index ec2d5c835170..2f510fbc87da 100755 > --- a/arch/powerpc/relocs_check.sh > +++ b/arch/powerpc/relocs_check.sh > @@ -43,7 +43,8 @@ R_PPC_ADDR16_HA > R_PPC_RELATIVE > R_PPC_NONE' | > grep -E -v '\<R_PPC64_ADDR64[[:space:]]+mach_' | > - grep -E -v '\<R_PPC64_ADDR64[[:space:]]+__crc_' > + grep -E -v '\<R_PPC64_ADDR64[[:space:]]+__crc_' | > + grep -E -v '\<R_PPC64_ADDR32[[:space:]]+\*ABS\*' I'm still getting: WARNING: 24 bad relocations c000000000d307c4 R_PPC64_ADDR32 __crc___arch_hweight16 c000000000d307c8 R_PPC64_ADDR32 __crc___arch_hweight32 c000000000d307cc R_PPC64_ADDR32 __crc___arch_hweight64 c000000000d307d0 R_PPC64_ADDR32 __crc___arch_hweight8 c000000000d30848 R_PPC64_ADDR32 __crc___bswapdi2 c000000000d30854 R_PPC64_ADDR32 __crc___clear_user c000000000d30868 R_PPC64_ADDR32 __crc___copy_tofrom_user c000000000d30d4c R_PPC64_ADDR32 __crc__mcount c000000000d31344 R_PPC64_ADDR32 __crc_copy_page c000000000d3141c R_PPC64_ADDR32 __crc_current_stack_pointer c000000000d31840 R_PPC64_ADDR32 __crc_empty_zero_page c000000000d31a7c R_PPC64_ADDR32 __crc_flush_dcache_range c000000000d31a84 R_PPC64_ADDR32 __crc_flush_icache_range c000000000d32608 R_PPC64_ADDR32 __crc_load_fp_state c000000000d32614 R_PPC64_ADDR32 __crc_load_vr_state c000000000d32828 R_PPC64_ADDR32 __crc_memchr c000000000d32830 R_PPC64_ADDR32 __crc_memcmp c000000000d32834 R_PPC64_ADDR32 __crc_memcpy c000000000d32840 R_PPC64_ADDR32 __crc_memmove c000000000d32888 R_PPC64_ADDR32 __crc_memset c000000000d33c9c R_PPC64_ADDR32 __crc_store_fp_state c000000000d33ca0 R_PPC64_ADDR32 __crc_store_vr_state c000000000d33cf0 R_PPC64_ADDR32 __crc_strncmp c000000000d33cf4 R_PPC64_ADDR32 __crc_strncpy If I just add those to the whitelist it builds, but then things aren't happy at boot: [ 7.607687] kvm: disagrees about version of symbol module_layout [ 7.846799] virtio: disagrees about version of symbol module_layout [ 22.012615] crc32c_vpmsum: disagrees about version of symbol module_layout [ 22.012959] libcrc32c: disagrees about version of symbol module_layout cheers
Ard Biesheuvel <ard.biesheuvel@linaro.org> writes: > On 25 November 2016 at 11:29, Michael Ellerman <mpe@ellerman.id.au> wrote: >> Ard Biesheuvel <ard.biesheuvel@linaro.org> writes: >> >> [ 7.607687] kvm: disagrees about version of symbol module_layout >> [ 7.846799] virtio: disagrees about version of symbol module_layout >> [ 22.012615] crc32c_vpmsum: disagrees about version of symbol module_layout >> [ 22.012959] libcrc32c: disagrees about version of symbol module_layout >> > > Sigh. I suppose your modversions fixes are queued for v4.10? It's > probably best to revisit this after the v4.10 merge window closes > then, just to make sure I'm not aiming for a moving target. Actually they were merged into 4.9-rc7 ish. But I'm still seeing the same as above with this series rebased on top of that, and I'm a bit short on time to debug it ATM. So during the 4.10 cycle is probably the best we can hope for, sorry. cheers
On 1 December 2016 at 09:39, Michael Ellerman <mpe@ellerman.id.au> wrote: > Ard Biesheuvel <ard.biesheuvel@linaro.org> writes: >> On 25 November 2016 at 11:29, Michael Ellerman <mpe@ellerman.id.au> wrote: >>> Ard Biesheuvel <ard.biesheuvel@linaro.org> writes: >>> >>> [ 7.607687] kvm: disagrees about version of symbol module_layout >>> [ 7.846799] virtio: disagrees about version of symbol module_layout >>> [ 22.012615] crc32c_vpmsum: disagrees about version of symbol module_layout >>> [ 22.012959] libcrc32c: disagrees about version of symbol module_layout >>> >> >> Sigh. I suppose your modversions fixes are queued for v4.10? It's >> probably best to revisit this after the v4.10 merge window closes >> then, just to make sure I'm not aiming for a moving target. > > Actually they were merged into 4.9-rc7 ish. > > But I'm still seeing the same as above with this series rebased on top > of that, and I'm a bit short on time to debug it ATM. > > So during the 4.10 cycle is probably the best we can hope for, sorry. > Not a problem. The only question is whether 1/3 of this series fixes an actual bug or not, given that the CONFIG_RELOCATABLE workaround has been made ppc64 only. But for the remaining patches, I'm happy to respin after the v4.10 merge window closes, and get something queued for v4.11 -- Ard.
On 1 December 2016 at 09:45, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote: > On 1 December 2016 at 09:39, Michael Ellerman <mpe@ellerman.id.au> wrote: >> Ard Biesheuvel <ard.biesheuvel@linaro.org> writes: >>> On 25 November 2016 at 11:29, Michael Ellerman <mpe@ellerman.id.au> wrote: >>>> Ard Biesheuvel <ard.biesheuvel@linaro.org> writes: >>>> >>>> [ 7.607687] kvm: disagrees about version of symbol module_layout >>>> [ 7.846799] virtio: disagrees about version of symbol module_layout >>>> [ 22.012615] crc32c_vpmsum: disagrees about version of symbol module_layout >>>> [ 22.012959] libcrc32c: disagrees about version of symbol module_layout >>>> >>> >>> Sigh. I suppose your modversions fixes are queued for v4.10? It's >>> probably best to revisit this after the v4.10 merge window closes >>> then, just to make sure I'm not aiming for a moving target. >> >> Actually they were merged into 4.9-rc7 ish. >> >> But I'm still seeing the same as above with this series rebased on top >> of that, and I'm a bit short on time to debug it ATM. >> >> So during the 4.10 cycle is probably the best we can hope for, sorry. >> > > Not a problem. The only question is whether 1/3 of this series fixes > an actual bug or not, given that the CONFIG_RELOCATABLE workaround has > been made ppc64 only. > > But for the remaining patches, I'm happy to respin after the v4.10 > merge window closes, and get something queued for v4.11 > Actually, given the uncertain fate of modversions in general, we may no longer have to bother by the time the v4.11 merge window opens ...
diff --git a/arch/powerpc/kernel/reloc_64.S b/arch/powerpc/kernel/reloc_64.S index d88736fbece6..7927e00be746 100644 --- a/arch/powerpc/kernel/reloc_64.S +++ b/arch/powerpc/kernel/reloc_64.S @@ -14,6 +14,7 @@ RELA = 7 RELACOUNT = 0x6ffffff9 R_PPC64_RELATIVE = 22 +R_PPC64_ADDR32 = 1 /* * r3 = desired final address of kernel @@ -66,10 +67,10 @@ _GLOBAL(relocate) /* * Run through the list of relocations and process the - * R_PPC64_RELATIVE ones. + * R_PPC64_RELATIVE and R_PPC64_ADDR32 ones. */ mtctr r8 -5: ld r0,8(9) /* ELF64_R_TYPE(reloc->r_info) */ +5: ld r0,8(9) /* reloc->r_info (type *and* symbol index) */ cmpdi r0,R_PPC64_RELATIVE bne 6f ld r6,0(r9) /* reloc->r_offset */ @@ -77,9 +78,22 @@ _GLOBAL(relocate) add r0,r0,r3 stdx r0,r7,r6 addi r9,r9,24 - bdnz 5b + b 7f + + /* + * CRCs of exported symbols are emitted as 32-bit relocations against + * the NULL .dynsym entry, with the CRC value recorded in the addend. + */ +6: cmpdi r0,R_PPC64_ADDR32 + bne 7f + ld r6,0(r9) /* reloc->r_offset */ + ld r0,16(r9) /* reloc->r_addend */ + stwx r0,r7,r6 + addi r9,r9,24 + +7: bdnz 5b + blr -6: blr .balign 8 p_dyn: .llong __dynamic_start - 0b diff --git a/arch/powerpc/relocs_check.sh b/arch/powerpc/relocs_check.sh index ec2d5c835170..2f510fbc87da 100755 --- a/arch/powerpc/relocs_check.sh +++ b/arch/powerpc/relocs_check.sh @@ -43,7 +43,8 @@ R_PPC_ADDR16_HA R_PPC_RELATIVE R_PPC_NONE' | grep -E -v '\<R_PPC64_ADDR64[[:space:]]+mach_' | - grep -E -v '\<R_PPC64_ADDR64[[:space:]]+__crc_' + grep -E -v '\<R_PPC64_ADDR64[[:space:]]+__crc_' | + grep -E -v '\<R_PPC64_ADDR32[[:space:]]+\*ABS\*' ) if [ -z "$bad_relocs" ]; then
In preparation of modifying the core modversions code to emit the CRCs as 32-bit quantities, ensure that 64-bit PowerPC will be able to deal with this when CONFIG_RELOCATABLE=y, in which case the CRCs will be emitted into the final ELF binary as R_PPC64_ADDR32 relocations. Since 32-bit relocations cannot be used to relocate memory addresses on 64-bit architectures, and since the CRC pseudo-symbol references are emitted as anonymous relocations (i.e., against the NULL symbol in the .dynsym section) with the final value recorded in the addend (*), we can disregard any relocations where the symbol index != 0. * Note that unsatisfied CRC pseudo-symbol references are emitted as R_PPC64_ADDR32 relocations against named symbols that are typed as weak undefined in the .dynsym symbol table. These can simply be ignored (as before), considering that zero CRCs are interpreted as missing, and the module code deals with that accordingly. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- arch/powerpc/kernel/reloc_64.S | 22 ++++++++++++++++---- arch/powerpc/relocs_check.sh | 3 ++- 2 files changed, 20 insertions(+), 5 deletions(-) -- 2.7.4