Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Matt Redfearn <matt.redfearn@imgtec.com>
To: James Hogan <james@albanarts.com>,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	<linux-mips@linux-mips.org>
Subject: Re: [PATCH 6/9] MIPS: Call relocate_kernel if CONFIG_RELOCATABLE=y
Date: Fri, 4 Dec 2015 08:20:05 +0000	[thread overview]
Message-ID: <56614CB5.9020002@imgtec.com> (raw)
In-Reply-To: <BA73413A-D335-4692-85A4-9330D7ACAC03@albanarts.com>

Hi James,

On 03/12/15 18:54, James Hogan wrote:
> On 3 December 2015 17:46:14 GMT+00:00, Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> wrote:
>> On 12/03/2015 05:53 PM, Matt Redfearn wrote:
>>
>>>>> If CONFIG_RELOCATABLE is enabled, jump to relocate_kernel.
>>>>>
>>>>> This function will return the entry point of the relocated kernel
>> if
>>>>> copy/relocate is sucessful or the original entry point if not. The
>> stack
>>>>> pointer must then be pointed into the new image.
>>>>>
>>>>> Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
>>>>> ---
>>>>>    arch/mips/kernel/head.S | 20 ++++++++++++++++++++
>>>>>    1 file changed, 20 insertions(+)
>>>>>
>>>>> diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
>>>>> index 4e4cc5b9a771..7dc043349d66 100644
>>>>> --- a/arch/mips/kernel/head.S
>>>>> +++ b/arch/mips/kernel/head.S
>>>>> @@ -132,7 +132,27 @@ not_found:
>>>>>        set_saved_sp    sp, t0, t1
>>>>>        PTR_SUBU    sp, 4 * SZREG        # init stack pointer
>>>>>
>>>>> +#ifdef CONFIG_RELOCATABLE
>>>>> +    /* Copy kernel and apply the relocations */
>>>>> +    jal        relocate_kernel
>>>>> +
>>>>> +    /* Repoint the sp into the new kernel image */
>>>>> +    PTR_LI        sp, _THREAD_SIZE - 32 - PT_SIZE
>>>>> +    PTR_ADDU    sp, $28
>>>>     Can't you account for it in the previous PTR_LI?
>>> During relocate_kernel, $28, pointer to the current thread,
>> Ah, it's a register! I thought it was an immediate. Nevermind then. :-)
> Although, it could still be reduced:
> PTR_ADDU sp, gp, _THREAD_SIZE - 32 - PT_SIZE
>
> Assuming the immediate is in range of signed 16bit.

The immediate would be 32552, so in range of signed 16bit, but that 
would be brittle if either _THREAD_SIZE or PT_SIZE were to change in 
future....

Thanks,
Matt
>
> Cheers
> James
>
>> [...]
>>
>> MBR, Sergei
>

WARNING: multiple messages have this Message-ID (diff)
From: Matt Redfearn <matt.redfearn@imgtec.com>
To: James Hogan <james@albanarts.com>,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
	linux-mips@linux-mips.org
Subject: Re: [PATCH 6/9] MIPS: Call relocate_kernel if CONFIG_RELOCATABLE=y
Date: Fri, 4 Dec 2015 08:20:05 +0000	[thread overview]
Message-ID: <56614CB5.9020002@imgtec.com> (raw)
Message-ID: <20151204082005.UNvGKoUl-CNq3Duaea_dkgJOt5s2tci_w_xdpVu7abw@z> (raw)
In-Reply-To: <BA73413A-D335-4692-85A4-9330D7ACAC03@albanarts.com>

Hi James,

On 03/12/15 18:54, James Hogan wrote:
> On 3 December 2015 17:46:14 GMT+00:00, Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> wrote:
>> On 12/03/2015 05:53 PM, Matt Redfearn wrote:
>>
>>>>> If CONFIG_RELOCATABLE is enabled, jump to relocate_kernel.
>>>>>
>>>>> This function will return the entry point of the relocated kernel
>> if
>>>>> copy/relocate is sucessful or the original entry point if not. The
>> stack
>>>>> pointer must then be pointed into the new image.
>>>>>
>>>>> Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
>>>>> ---
>>>>>    arch/mips/kernel/head.S | 20 ++++++++++++++++++++
>>>>>    1 file changed, 20 insertions(+)
>>>>>
>>>>> diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
>>>>> index 4e4cc5b9a771..7dc043349d66 100644
>>>>> --- a/arch/mips/kernel/head.S
>>>>> +++ b/arch/mips/kernel/head.S
>>>>> @@ -132,7 +132,27 @@ not_found:
>>>>>        set_saved_sp    sp, t0, t1
>>>>>        PTR_SUBU    sp, 4 * SZREG        # init stack pointer
>>>>>
>>>>> +#ifdef CONFIG_RELOCATABLE
>>>>> +    /* Copy kernel and apply the relocations */
>>>>> +    jal        relocate_kernel
>>>>> +
>>>>> +    /* Repoint the sp into the new kernel image */
>>>>> +    PTR_LI        sp, _THREAD_SIZE - 32 - PT_SIZE
>>>>> +    PTR_ADDU    sp, $28
>>>>     Can't you account for it in the previous PTR_LI?
>>> During relocate_kernel, $28, pointer to the current thread,
>> Ah, it's a register! I thought it was an immediate. Nevermind then. :-)
> Although, it could still be reduced:
> PTR_ADDU sp, gp, _THREAD_SIZE - 32 - PT_SIZE
>
> Assuming the immediate is in range of signed 16bit.

The immediate would be 32552, so in range of signed 16bit, but that 
would be brittle if either _THREAD_SIZE or PT_SIZE were to change in 
future....

Thanks,
Matt
>
> Cheers
> James
>
>> [...]
>>
>> MBR, Sergei
>

  reply	other threads:[~2015-12-04  8:20 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-03 10:08 [PATCH 0/9] MIPS Relocatable kernel & KASLR Matt Redfearn
2015-12-03 10:08 ` Matt Redfearn
2015-12-03 10:08 ` [PATCH 1/9] MIPS: tools: Add relocs tool Matt Redfearn
2015-12-03 10:08   ` Matt Redfearn
2015-12-03 10:08 ` [PATCH 2/9] MIPS: tools: Build " Matt Redfearn
2015-12-03 10:08   ` Matt Redfearn
2015-12-03 10:08 ` [PATCH 3/9] MIPS: Reserve space for relocation table Matt Redfearn
2015-12-03 10:08   ` Matt Redfearn
2015-12-03 10:08 ` [PATCH 4/9] MIPS: Generate relocation table when CONFIG_RELOCATABLE Matt Redfearn
2015-12-03 10:08   ` Matt Redfearn
2015-12-03 10:08 ` [PATCH 5/9] MIPS: Kernel: Add relocate.c Matt Redfearn
2015-12-03 10:08   ` Matt Redfearn
2015-12-03 10:08 ` [PATCH 6/9] MIPS: Call relocate_kernel if CONFIG_RELOCATABLE=y Matt Redfearn
2015-12-03 10:08   ` Matt Redfearn
2015-12-03 14:24   ` Sergei Shtylyov
2015-12-03 14:53     ` Matt Redfearn
2015-12-03 14:53       ` Matt Redfearn
2015-12-03 17:46       ` Sergei Shtylyov
2015-12-03 18:54         ` James Hogan
2015-12-04  8:20           ` Matt Redfearn [this message]
2015-12-04  8:20             ` Matt Redfearn
2015-12-04 15:37             ` Ralf Baechle
2015-12-04 15:45               ` Matt Redfearn
2015-12-04 15:45                 ` Matt Redfearn
2015-12-03 10:08 ` [PATCH 7/9] MIPS: bootmem: When relocatable, free memory below kernel Matt Redfearn
2015-12-03 10:08   ` Matt Redfearn
2015-12-03 10:08 ` [PATCH 8/9] MIPS: Add CONFIG_RELOCATABLE Kconfig option Matt Redfearn
2015-12-03 10:08   ` Matt Redfearn
2015-12-03 10:08 ` [PATCH 9/9] MIPS: Kernel: Implement kASLR using CONFIG_RELOCATABLE Matt Redfearn
2015-12-03 10:08   ` Matt Redfearn
2015-12-03 22:23 ` [PATCH 0/9] MIPS Relocatable kernel & KASLR Joshua Kinard
2015-12-04  8:14   ` Matt Redfearn
2015-12-04  8:14     ` Matt Redfearn
2015-12-04 13:14     ` Joshua Kinard

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=56614CB5.9020002@imgtec.com \
    --to=matt.redfearn@imgtec.com \
    --cc=james@albanarts.com \
    --cc=linux-mips@linux-mips.org \
    --cc=sergei.shtylyov@cogentembedded.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