lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <mhng-517c0318-c8fb-4c4a-aa0e-0d08f8d34d78@palmer-ri-x1c9>
Date: Wed, 26 Mar 2025 15:47:45 -0700 (PDT)
From: Palmer Dabbelt <palmer@...belt.com>
To: samuel.holland@...ive.com
CC: linux-kernel@...r.kernel.org, linux-riscv@...ts.infradead.org,
  akpm@...ux-foundation.org, Arnd Bergmann <arnd@...db.de>, alexghiti@...osinc.com
Subject:     Re: [PATCH 0/6] riscv: Relocatable NOMMU kernels

On Wed, 26 Feb 2025 07:22:51 PST (-0800), samuel.holland@...ive.com wrote:
> Hi Palmer,
>
> On 2025-02-13 8:17 AM, Palmer Dabbelt wrote:
>> On Sat, 26 Oct 2024 10:13:52 PDT (-0700), samuel.holland@...ive.com wrote:
>>> Currently, RISC-V NOMMU kernels are linked at CONFIG_PAGE_OFFSET, and
>>> since they are not relocatable, must be loaded at this address as well.
>>> CONFIG_PAGE_OFFSET is not a user-visible Kconfig option, so its value is
>>> not obvious, and users must patch the kernel source if they want to load
>>> it at a different address.
>>>
>>> Make NOMMU kernels more portable by making them relocatable by default.
>>> This allows a single kernel binary to work when loaded at any address.
>>>
>>>
>>> Samuel Holland (6):
>>>   riscv: Remove duplicate CONFIG_PAGE_OFFSET definition
>>>   riscv: Allow NOMMU kernels to access all of RAM
>>>   riscv: Support CONFIG_RELOCATABLE on NOMMU
>>>   asm-generic: Always define Elf_Rel and Elf_Rela
>>>   riscv: Support CONFIG_RELOCATABLE on riscv32
>>>   riscv: Remove CONFIG_PAGE_OFFSET
>>>
>>>  arch/riscv/Kconfig               | 10 +---
>>>  arch/riscv/Makefile              |  1 -
>>>  arch/riscv/include/asm/page.h    | 27 ++++-----
>>>  arch/riscv/include/asm/pgtable.h |  6 +-
>>>  arch/riscv/mm/init.c             | 97 ++++++++++++++++----------------
>>>  include/asm-generic/module.h     |  8 ---
>>>  6 files changed, 68 insertions(+), 81 deletions(-)
>>
>> I'm getting some build failures
>>
>> riscv64-unknown-linux-gnu-ld: arch/riscv/errata/sifive/errata.o: relocation
>> R_RISCV_HI20 against `tlb_flush_all_threshold' can not be used when making a
>> shared object; recompile with -fPIC
>> riscv64-unknown-linux-gnu-ld: arch/riscv/errata/thead/errata.o: relocation
>> R_RISCV_HI20 against `riscv_cbom_block_size' can not be used when making a
>> shared object; recompile with -fPIC
>
> What toolchain and config do you see failures with? I have tried building this
> series on top of v6.14-rc4 with GCC 14.2.1 and
>  * defconfig
>  * defconfig + NOMMU + S-mode
>  * defconfig + NOMMU + M-mode
>  * defconfig + 32-bit
>  * defconfig + 32-bit + NOMMU + S-mode
>  * defconfig + 32-bit + NOMMU + M-Mode
>  * nommu_k210_defconfig
>  * nommu_k210_sdcard_defconfig
>  * nommu_virt_defconfig
> and all succeed.

rv32 allmodconfig does it.

I don't actually know what's going on, but it seems that something in 
Kconfig land has flipped over and ended up building medlow with these.  
The erata handling can't be proper PIC (see 8dc2a7e8027f ("riscv: Fix 
relocatable kernels with early alternatives using -fno-pie")), but that 
one was just wrong -- they need to be medany, otherwise they're 
very-non-relocatable.

I feel like it's possible to construct Kconfigs that break this without 
your patch set, but not 100% sure there.  Either way I sent a patch
<https://lore.kernel.org/all/20250326224506.27165-2-palmer@rivosinc.com/>

>
> Regards,
> Samuel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ