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

Oleksii Kurochko posted 2 patches 1 year, 1 month ago
Test gitlab-ci passed
Failed in applying to current master (apply log)
xen/arch/riscv/arch.mk   |  2 ++
xen/arch/riscv/xen.lds.S | 13 +++++++++++++
2 files changed, 15 insertions(+)
[PATCH v2 0/2] deal with GOT stuff for RISC-V
Posted by Oleksii Kurochko 1 year, 1 month ago
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(+)

-- 
2.39.2
Re: [PATCH v2 0/2] deal with GOT stuff for RISC-V
Posted by Jan Beulich 1 year ago
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
Re: [PATCH v2 0/2] deal with GOT stuff for RISC-V
Posted by Oleksii 1 year ago
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
Re: [PATCH v2 0/2] deal with GOT stuff for RISC-V
Posted by Jan Beulich 1 year ago
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

Re: [PATCH v2 0/2] deal with GOT stuff for RISC-V
Posted by Andrew Cooper 1 year, 1 month ago
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>
Re: [PATCH v2 0/2] deal with GOT stuff for RISC-V
Posted by Jan Beulich 1 year ago
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
Re: [PATCH v2 0/2] deal with GOT stuff for RISC-V
Posted by Andrew Cooper 1 year ago
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