linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Youling Tang <tangyouling@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>, Huacai Chen <chenhuacai@kernel.org>
Cc: linux-kernel@vger.kernel.org, loongarch@lists.linux.dev,
	Xuerui Wang <kernel@xen0n.name>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	Jinyang He <hejinyang@loongson.cn>
Subject: Re: [PATCH 1/3] LoongArch: tools: Add relocs tool support
Date: Sat, 3 Sep 2022 09:57:04 +0800	[thread overview]
Message-ID: <f0e77716-9533-724a-2ea9-86bc5b52066c@loongson.cn> (raw)
In-Reply-To: <4df8a26c49a35c1fce36d80c370f738fa71a2bef.camel@xry111.site>

Hi, Ruoyao

On 09/02/2022 07:27 PM, Xi Ruoyao wrote:
> On Fri, 2022-09-02 at 19:10 +0800, Xi Ruoyao wrote:
>> Hi Youling,
>>
>> On Fri, 2022-09-02 at 18:08 +0800, Youling Tang wrote:
>>> This tool is based on the arch/mips/boot/tools/relocs tool.
>>
>> I've dig some history of MIPS relocatable kernel
>> (https://lwn.net/Articles/682020/):
>>
>>    * Kernel is compiled & statically linked as normal, with no position
>>      independent code. MIPS before R6 only has limited relative jump
>>      instructions so the vast majority of jumps are absolute. To compile
>>      the kernel position independent would introduce a highly undesireable
>>      overhead. Relocating the static binary gives a small startup time
>>      penalty but the kernel otherwise perforns normally.
>>
>> Unlike (pre-r6) MIPS, LoongArch has a complete support for PIC, and
>> currently LoongArch toolchain always produces PIC (except, if -Wa,-mla-
>> {local,global}-with-abs or la.abs macros are used explicitly).
>>
>> So would it be easier to review and correct the uses of "la.abs" in the
>> code, and make the main kernel image a real PIE?  Then we can load it
>> everywhere w/o any need to do relocation at load time.

At the beginning I also wanted to make the main kernel image a real PIE
and tried it, some of the "la.abs" can be modified, but I encountered
difficulties in modifying the  exception handling code part, the kernel
will not  boot after modification :(, I will continue to work hard try.

I would be grateful if you all have better suggestions and ideas :).

>
> Arrgh, doing so will need to get rid of GOT (the GCC patch for this is
> still under review) or we still need to relocate the GOT at least :(.

Yes, now all global variable access is via got (la.got) in the new
toolchain, so we need to relocate the GOT in relocate.c. However there
is no need to relocate it in the old toolchain as it is accessed
via la.pcrel.

Thanks,
Youling

>
>


  reply	other threads:[~2022-09-03  1:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02 10:08 [PATCH 0/3] Add kernel relocation and KASLR support Youling Tang
2022-09-02 10:08 ` [PATCH 1/3] LoongArch: tools: Add relocs tool support Youling Tang
2022-09-02 11:10   ` Xi Ruoyao
2022-09-02 11:27     ` Xi Ruoyao
2022-09-03  1:57       ` Youling Tang [this message]
2022-09-03 10:49         ` Xi Ruoyao
2022-09-03 16:23           ` Jinyang He
2022-09-03 16:53             ` Xi Ruoyao
2022-09-05  2:52               ` Youling Tang
2022-09-06  2:16                 ` Youling Tang
2022-09-06  5:17                   ` Xi Ruoyao
2022-09-07 10:19                     ` Youling Tang
2022-09-08  2:44                       ` Youling Tang
2022-09-08  8:01                         ` Youling Tang
2022-09-22 11:19                           ` Xi Ruoyao
2022-09-23  9:56                             ` Youling Tang
2022-09-05  1:52             ` Youling Tang
2022-09-02 10:08 ` [PATCH 2/3] LoongArch: Add support for kernel relocation Youling Tang
2022-09-02 10:08 ` [PATCH 3/3] LoongArch: Add support for kernel address space layout randomization (KASLR) Youling Tang

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=f0e77716-9533-724a-2ea9-86bc5b52066c@loongson.cn \
    --to=tangyouling@loongson.cn \
    --cc=chenhuacai@kernel.org \
    --cc=hejinyang@loongson.cn \
    --cc=jiaxun.yang@flygoat.com \
    --cc=kernel@xen0n.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=xry111@xry111.site \
    /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;
as well as URLs for NNTP newsgroup(s).