From: Joe Lawrence <joe.lawrence@redhat.com>
To: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, hca@linux.ibm.com,
jpoimboe@kernel.org, gor@linux.ibm.com, iii@linux.ibm.com,
agordeev@linux.ibm.com, Joe Lawrence <joe.lawrence@redhat.com>
Subject: Re: [PATCH v2 0/4] s390: compile relocatable kernel with/without fPIE
Date: Fri, 21 Jun 2024 07:32:05 -0400 [thread overview]
Message-ID: <ed2152fe-dd0a-a230-c0ef-0d3a67b5e2ac@redhat.com> (raw)
In-Reply-To: <ZnUoRESborBG95aJ@li-2b55cdcc-350b-11b2-a85c-a78bff51fc11.ibm.com>
On 6/21/24 03:14, Sumanth Korikkar wrote:
> On Wed, Jun 19, 2024 at 02:23:49PM -0400, Joe Lawrence wrote:
>> On 6/19/24 13:01, Sumanth Korikkar wrote:
>>> On Tue, Jun 18, 2024 at 04:37:16PM -0400, Joe Lawrence wrote:
>>>> On Mon, Feb 19, 2024 at 02:27:30PM +0100, Sumanth Korikkar wrote:
>>>>> Hi All,
>>>>>
>>>>> This is a rebased version of Josh's patch series with a few fixups.
>>>>> https://git.kernel.org/pub/scm/linux/kernel/git/jpoimboe/linux.git/log/?h=s390
>>>>>
>>>>> This introduces the capability to compile the s390 relocatable kernel
>>>>> with and without the -fPIE option.
>>>>>
>>>>> When utilizing the kpatch functionality, it is advisable to compile the
>>>>> kernel without the -fPIE option. This is particularly important if the
>>>>> kernel is built with the -ffunction-sections and -fdata-sections flags.
>>>>> The linker imposes a restriction on the number of sections (limited to
>>>>> 64k), necessitating the omission of -fPIE.
>>>>>
>>>>> [1] https://gcc.gnu.org/pipermail/gcc-patches/2023-June/622872.html
>>>>> [2] https://gcc.gnu.org/pipermail/gcc-patches/2023-August/625986.html
>>>>>
>>>>> Gcc recently implemented an optimization [1] for loading symbols without
>>>>> explicit alignment, aligning with the IBM Z ELF ABI. This ABI mandates
>>>>> symbols to reside on a 2-byte boundary, enabling the use of the larl
>>>>> instruction. However, kernel linker scripts may still generate unaligned
>>>>> symbols. To address this, a new -munaligned-symbols option has been
>>>>> introduced [2] in recent gcc versions. This option has to be used with
>>>>> future gcc versions.
>>>>>
>>>>> Older Clang lacks support for handling unaligned symbols generated
>>>>> by kernel linker scripts when the kernel is built without -fPIE. However,
>>>>> future versions of Clang will include support for the -munaligned-symbols
>>>>> option. When the support is unavailable, compile the kernel with -fPIE
>>>>> to maintain the existing behavior.
>>>>>
>>>>> Patch 1 filters out -munaligned-symbol flag for vdso code. This is beneficial
>>>>> when compiling kernel with -fno-PIE and -munaligned-symbols combination.
>>>>>
>>>>> Patch 2 introduces the 'relocs' tool, which reads the vmlinux file and
>>>>> generates a vmlinux.relocs_64 section, containing offsets for all
>>>>> R_390_64 relocations.
>>>>>
>>>>> Patch 3 enables the compilation of a relocatable kernel with or without
>>>>> the -fPIE option. It allows for building the relocatable kernel without
>>>>> -fPIE. However, if compiler cannot handle unaligned symbols, the kernel
>>>>> is built with -fPIE.
>>>>>
>>>>> Patch 4 handles orphan .rela sections when kernel is built with
>>>>> -fno-PIE.
>>>>>
>>>>> kpatch tools changes:
>>>>> * -mno-pic-data-is-text-relative prevents relative addressing between
>>>>> code and data. This is needed to avoid relocation error when klp text
>>>>> and data are too far apart. kpatch already includes this flag.
>>>>> However, with these changes, ARCH_KFLAGS+="-fPIC" should be added to
>>>>> s390 kpatch tools, As -mno-pic-data-is-text-relative can be used only
>>>>> with -fPIC. The corresponding pull request will be sent to kpatch
>>>>> tools.
>>>>
>>>> Hi Sumanth,
>>>>
>>>> I noticed interesting compiler differences when adding -fPIC build
>>>> option and not. The difference in resulting output can confuse
>>>> kpatch-build when it tries to verify that its reference build (with the
>>>> mentioned options, plus --ffunction-sections and -fdata-sections),
>>>> doesn't line up closely enough with the original vmlinux source (sans
>>>> all these options).
>>>
>>> Hi Joe,
>>>
>>> kpatch for s390 already uses extra compiler flag -mno-pic-data-is-text-relative
>>> inorder to prevent relative addressing between code and data. Also,
>>> includes -ffunction-sections and -fdata-sections along with it to identify
>>> modified functions and its relocations.
>>>
>>> Both the source code and modified code are built with the same
>>> options during kpatch-build (-fPIC added to
>>> -mno-pic-data-is-text-relative). kpatch-build was able to identify
>>> modified functions and its associated relocations and include these
>>> changes in the final kpatch module.
>>>
>>> May be I am missing some info: Does this deviation cause confusion to kpatch?
>>>
>>
>> Hi Sumanth,
>>
>> Yes, in the example I provided, the __mmput() function is only inlined
>> in kpatch builds, but not the builds that create the target vmlinux.
>> Here is a reproducer tarball that you can try against a local
>> create-diff-object binary:
>>
>> https://file.rdu.redhat.com/~jolawren/repro-s390x-shadow-newpid.tar.gz
>>
>> create-diff-object: ERROR: fork.ORIG.o: find_local_syms: 222: couldn't
>> find matching fork.c local symbols in vmlinux symbol table.
>
> Hi Joe,
>
> I tried to download the tarball and rhel config. Both are unreachable.
> Failed to resolve 'file.rdu.redhat.com' (Name or service not known)
>
> Could you please provide alternative link to it?
>
D'oh, I uploaded them to our internal filespace. Try these links, they
should be visible to everyone:
https://people.redhat.com/~jolawren/kernel-s390x-rhel.config
https://people.redhat.com/~jolawren/repro-s390x-special-static.tar.gz
--
Joe
next prev parent reply other threads:[~2024-06-21 11:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-19 13:27 [PATCH v2 0/4] s390: compile relocatable kernel with/without fPIE Sumanth Korikkar
2024-02-19 13:27 ` [PATCH v2 1/4] s390/vdso64: filter out munaligned-symbols flag for vdso Sumanth Korikkar
2024-02-19 13:27 ` [PATCH v2 2/4] s390: Add relocs tool Sumanth Korikkar
2024-02-19 16:11 ` Heiko Carstens
2024-02-19 13:27 ` [PATCH v2 3/4] s390: Compile relocatable kernel without -fPIE Sumanth Korikkar
2024-02-19 13:27 ` [PATCH v2 4/4] s390/kernel: vmlinux.lds.S: handle orphan .rela sections Sumanth Korikkar
2024-02-19 16:12 ` [PATCH v2 0/4] s390: compile relocatable kernel with/without fPIE Heiko Carstens
2024-06-18 20:37 ` Joe Lawrence
2024-06-19 17:01 ` Sumanth Korikkar
2024-06-19 18:23 ` Joe Lawrence
2024-06-21 7:14 ` Sumanth Korikkar
2024-06-21 11:32 ` Joe Lawrence [this message]
2024-06-21 16:59 ` Joe Lawrence
2024-06-24 9:59 ` Sumanth Korikkar
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=ed2152fe-dd0a-a230-c0ef-0d3a67b5e2ac@redhat.com \
--to=joe.lawrence@redhat.com \
--cc=agordeev@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=jpoimboe@kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=sumanthk@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox