mbox series

[v2,0/2] deal with GOT stuff for RISC-V

Message ID cover.1678970065.git.oleksii.kurochko@gmail.com (mailing list archive)
Headers show
Series deal with GOT stuff for RISC-V | expand

Message

Oleksii Kurochko March 16, 2023, 1:22 p.m. UTC
The patch series introduces things to deal with GOT stuff whichwas faced
during the work on [1].

Initially, the issue was with 'la' pseudo instruction, which transformed to
'aupic/l{w|d} GOT' instead of 'auipc/addi'.
The transformation dependson .option {nopic, pic} directive or compiler flags.

Right now, 'la' transforms to 'auipc/l{w|d}', which in case of cpu0_boot_stack[]
will lead to the usage of _GLOBAL_OFFSET_TABLE_and addresses inside GOT
sections will be relative to linker time addresses.

At least there are two reasons for that:
1. GCC compiler used in RISCV64 container is compiled with
  --enable-default-pie flag.
2. GCC spec file for the RISC-V architecture by default enabled -fpic:
   [user@49295ae49cbe build]$ riscv64-linux-gnu-gcc -dumpspecs | grep -i pic
    --traditional-format %(subtarget_asm_debugging_spec) %{fno-pie|fno- PIE|fno-pic|fno-PIC:;:-fpic} %{march=*} %{mabi=*} %{mno-relax} %{mbig- endian} %{mlittle-endian} %(subtarget_asm_spec)%{misa-spec=*}
  which means that -fpic is enabled if none of the following options are
  present on the command line: fno-pie, -fno-PIE, -fno-pic, -fno-PIC

To resolve that, it was added EMBEDDED_EXTRA_CFLAGS to RISCV's CFLAGS as it was
done for other architecture.

To catch use cases when GOT things will be produced by something was createthe
second patch of the patch series:
[xen/riscv: add explicit check that.got{.plt} is empty] which add .got&.got.plt
sections to xen.lds.S and alsoadds asserts to check that the mentioned sections
are empty otherwise, it will be produced a compilation error with the message
that the sections aren't empty.

[1]:
https://lore.kernel.org/xen-devel/22c46432-e940-914e-53c2-2913607be3e2@suse.com/T/#t

---
Changes in V2:
 * The patch [1] was refactored and lead to the patch [xen/riscv: add
   EMBEDDED_EXTRA_CFLAGS to CFLAGS].
 * In addition to the patch [1] was created another patch [xen/riscv: add explicit
   check that .got{.plt} is empty] to be sure that .got{.plt} sections
   weren't produced.
---
Oleksii Kurochko (2):
  xen/riscv: add EMBEDDED_EXTRA_CFLAGS to CFLAGS
  xen/riscv: add explicit check that .got{.plt} is empty

 xen/arch/riscv/arch.mk   |  2 ++
 xen/arch/riscv/xen.lds.S | 13 +++++++++++++
 2 files changed, 15 insertions(+)

Comments

Andrew Cooper March 16, 2023, 1:59 p.m. UTC | #1
On 16/03/2023 1:22 pm, Oleksii Kurochko wrote:
> Oleksii Kurochko (2):
>   xen/riscv: add EMBEDDED_EXTRA_CFLAGS to CFLAGS
>   xen/riscv: add explicit check that .got{.plt} is empty

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Jan Beulich April 17, 2023, 2:12 p.m. UTC | #2
On 16.03.2023 14:22, Oleksii Kurochko wrote:
> Oleksii Kurochko (2):
>   xen/riscv: add EMBEDDED_EXTRA_CFLAGS to CFLAGS
>   xen/riscv: add explicit check that .got{.plt} is empty
> 
>  xen/arch/riscv/arch.mk   |  2 ++
>  xen/arch/riscv/xen.lds.S | 13 +++++++++++++
>  2 files changed, 15 insertions(+)

Just to mention it in case you aren't aware: Hunting down the necessary acks
is your responsibility, not one of the committers. You may want to ping Bob
and Alistair (unless this response of mine is already enough of a ping).
Provided of course the patches still apply as-is ...

Jan
Jan Beulich April 18, 2023, 6:30 a.m. UTC | #3
On 16.03.2023 14:59, Andrew Cooper wrote:
> On 16/03/2023 1:22 pm, Oleksii Kurochko wrote:
>> Oleksii Kurochko (2):
>>   xen/riscv: add EMBEDDED_EXTRA_CFLAGS to CFLAGS
>>   xen/riscv: add explicit check that .got{.plt} is empty
> 
> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>

I'm sorry, I failed to apply this ack while committing.

Jan
Andrew Cooper April 18, 2023, 6:35 a.m. UTC | #4
On 18/04/2023 7:30 am, Jan Beulich wrote:
> On 16.03.2023 14:59, Andrew Cooper wrote:
>> On 16/03/2023 1:22 pm, Oleksii Kurochko wrote:
>>> Oleksii Kurochko (2):
>>>   xen/riscv: add EMBEDDED_EXTRA_CFLAGS to CFLAGS
>>>   xen/riscv: add explicit check that .got{.plt} is empty
>> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
> I'm sorry, I failed to apply this ack while committing.

Oh well.  The important thing is that it's in now.

~Andrew
Oleksii Kurochko April 18, 2023, 12:03 p.m. UTC | #5
On Mon, 2023-04-17 at 16:12 +0200, Jan Beulich wrote:
> On 16.03.2023 14:22, Oleksii Kurochko wrote:
> > Oleksii Kurochko (2):
> >   xen/riscv: add EMBEDDED_EXTRA_CFLAGS to CFLAGS
> >   xen/riscv: add explicit check that .got{.plt} is empty
> > 
> >  xen/arch/riscv/arch.mk   |  2 ++
> >  xen/arch/riscv/xen.lds.S | 13 +++++++++++++
> >  2 files changed, 15 insertions(+)
> 
> Just to mention it in case you aren't aware: Hunting down the
> necessary acks
> is your responsibility, not one of the committers. You may want to
> ping Bob
> and Alistair (unless this response of mine is already enough of a
> ping).
> Provided of course the patches still apply as-is ...
> 
Thanks. I'll take that into account.

I thought the only option I have wait for a response from a maintainer.

~ Oleksii
Jan Beulich April 19, 2023, 6:02 a.m. UTC | #6
On 18.04.2023 14:03, Oleksii wrote:
> On Mon, 2023-04-17 at 16:12 +0200, Jan Beulich wrote:
>> On 16.03.2023 14:22, Oleksii Kurochko wrote:
>>> Oleksii Kurochko (2):
>>>   xen/riscv: add EMBEDDED_EXTRA_CFLAGS to CFLAGS
>>>   xen/riscv: add explicit check that .got{.plt} is empty
>>>
>>>  xen/arch/riscv/arch.mk   |  2 ++
>>>  xen/arch/riscv/xen.lds.S | 13 +++++++++++++
>>>  2 files changed, 15 insertions(+)
>>
>> Just to mention it in case you aren't aware: Hunting down the
>> necessary acks
>> is your responsibility, not one of the committers. You may want to
>> ping Bob
>> and Alistair (unless this response of mine is already enough of a
>> ping).
>> Provided of course the patches still apply as-is ...
>>
> Thanks. I'll take that into account.
> 
> I thought the only option I have wait for a response from a maintainer.

Well, in principle yes. But pinging is appropriate after a reasonable
amount of time (rule of thumb: a week, maybe two, depending on e.g.
complexity).

Jan