All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Ghiti <alex@ghiti.fr>
To: Palmer Dabbelt <palmer@rivosinc.com>,
	Conor Dooley <conor.dooley@microchip.com>
Cc: prabhakar.mahadev-lad.rj@bp.renesas.com, linux-riscv@lists.infradead.org
Subject: Re: more RELOCATABLE + errata code model issues
Date: Mon, 18 Sep 2023 18:59:37 +0200	[thread overview]
Message-ID: <419c17bb-9d5e-dedf-01bf-8db9db405a39@ghiti.fr> (raw)
In-Reply-To: <mhng-ffed6e42-d66a-47c8-b652-cd5d9fced9ab@palmer-ri-x1c9>


On 18/09/2023 17:15, Palmer Dabbelt wrote:
> On Mon, 18 Sep 2023 03:36:03 PDT (-0700), Conor Dooley wrote:
>>
>> 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:
>>> > All errors (new ones prefixed by >>):
>>> > > >> ld.lld: error: relocation R_RISCV_LO12_I cannot be used against
>>> > >> symbol 'riscv_cbom_block_size'; recompile with -fPIC
>>> >    >>> defined in vmlinux.a(arch/riscv/mm/cacheflush.o)
>>> >    >>> referenced by errata.c
>>> >    >>> arch/riscv/errata/andes/errata.o:(andes_errata_patch_func) 
>>> in archive vmlinux.a
>>> > 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:
>>> +#ifdef CONFIG_RISCV_ALTERNATIVE_EARLY
>>> +CFLAGS_errata.o := -mcmodel=medany
>>> #endif
>>>
>>> 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.


>
>> Thanks,
>> Conor.
>>
>> [1] - https://lore.kernel.org/all/202309111311.8tcq3KVc-lkp@intel.com/
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

      reply	other threads:[~2023-09-18 16:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18 10:36 more RELOCATABLE + errata code model issues Conor Dooley
2023-09-18 15:15 ` Palmer Dabbelt
2023-09-18 16:59   ` Alexandre Ghiti [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=419c17bb-9d5e-dedf-01bf-8db9db405a39@ghiti.fr \
    --to=alex@ghiti.fr \
    --cc=conor.dooley@microchip.com \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@rivosinc.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.