Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: David Daney <ddaney@caviumnetworks.com>
To: Harvey Hunt <harvey.hunt@imgtec.com>
Cc: Joshua Kinard <kumba@gentoo.org>, <linux-mips@linux-mips.org>,
	<ralf@linux-mips.org>, David Daney <david.daney@cavium.com>,
	Paul Burton <paul.burton@imgtec.com>,
	James Hogan <james.hogan@imgtec.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] MIPS: Always page align TASK_SIZE
Date: Mon, 8 Feb 2016 14:08:17 -0800	[thread overview]
Message-ID: <56B911D1.2090402@caviumnetworks.com> (raw)
In-Reply-To: <56B90D30.5020904@imgtec.com>

On 02/08/2016 01:48 PM, Harvey Hunt wrote:
> Hi Joshua,
>
> On 02/08/2016 01:35 PM, Joshua Kinard wrote:
>> On 02/08/2016 13:15, Harvey Hunt wrote:
>>> Hi David,
>>>
>>> On 02/08/2016 10:11 AM, David Daney wrote:
>>>> On 02/08/2016 10:05 AM, Harvey Hunt wrote:
>>>>> STACK_TOP_MAX is aligned on a 32k boundary. When __bprm_mm_init()
>>>>> creates an
>>>>> initial stack for a process, it does so using STACK_TOP_MAX as the end
>>>>> of the
>>>>> vma. A process's arguments and environment information are placed on
>>>>> the stack
>>>>> and then the stack is relocated and aligned on a page boundary. When
>>>>> using a 32
>>>>> bit kernel with 64k pages, the relocated stack has the process's args
>>>>> erroneously stored in the middle of the stack. This means that
>>>>> processes
>>>>> receive no arguments or environment variables, preventing them from
>>>>> running
>>>>> correctly.
>>>>>
>>>>> Fix this by aligning TASK_SIZE on a page boundary.
>>>>>
>>>>> Signed-off-by: Harvey Hunt <harvey.hunt@imgtec.com>
>>>>> Cc: David Daney <david.daney@cavium.com>
>>>>> Cc: Paul Burton <paul.burton@imgtec.com>
>>>>> Cc: James Hogan <james.hogan@imgtec.com>
>>>>> Cc: linux-kernel@vger.kernel.org
>>>>> ---
>>>>>    arch/mips/include/asm/processor.h | 6 +++---
>>>>>    1 file changed, 3 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/arch/mips/include/asm/processor.h
>>>>> b/arch/mips/include/asm/processor.h
>>>>> index 3f832c3..b618b40 100644
>>>>> --- a/arch/mips/include/asm/processor.h
>>>>> +++ b/arch/mips/include/asm/processor.h
>>>>> @@ -39,13 +39,13 @@ extern unsigned int vced_count, vcei_count;
>>>>>    #ifdef CONFIG_32BIT
>>>>>    #ifdef CONFIG_KVM_GUEST
>>>>>    /* User space process size is limited to 1GB in KVM Guest Mode */
>>>>> -#define TASK_SIZE    0x3fff8000UL
>>>>> +#define TASK_SIZE    (0x40000000UL - PAGE_SIZE)
>>>>>    #else
>>>>>    /*
>>>>>     * User space process size: 2GB. This is hardcoded into a few
>>>>> places,
>>>>>     * so don't change it unless you know what you are doing.
>>>>>     */
>>>>> -#define TASK_SIZE    0x7fff8000UL
>>>>> +#define TASK_SIZE    (0x7fff8000UL & PAGE_SIZE)
>>>>
>>>> Can you check your math here.  This doesn't seem correct.
>>>
>>> Thanks for spotting that - it should have been:
>>>
>>> (0x7fff8000UL & PAGE_MASK)
>>>
>>> I'll do a v2 now.
>>>
>>
>> FYI, TASK_SIZE was recently changed to 0x80000000UL in commit
>> 7f8ca9cb1ed3 on
>> the linux-mips.org tree.
>
> Thanks, I'll rebase.

You may find that in rebasing, suddenly you have a completely empty patch!


>
>>
>>
>>>>
>>>>>    #endif
>>>>>
>>>>>    #define STACK_TOP_MAX    TASK_SIZE
>>>>> @@ -62,7 +62,7 @@ extern unsigned int vced_count, vcei_count;
>>>>>     * support 16TB; the architectural reserve for future expansion is
>>>>>     * 8192EB ...
>>>>>     */
>>>>> -#define TASK_SIZE32    0x7fff8000UL
>>>>> +#define TASK_SIZE32    (0x7fff8000UL & PAGE_SIZE)
>>>>
>>>> Same here.
>>>
>>> As above.
>>>
>>>>
>>>>>    #define TASK_SIZE64    0x10000000000UL
>>>>>    #define TASK_SIZE (test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 :
>>>>> TASK_SIZE64)
>>>>>    #define STACK_TOP_MAX    TASK_SIZE64
>>>>>
>>>>
>>>
>>> Thanks,
>>>
>>> Harvey
>>>
>>>
>>
>>

WARNING: multiple messages have this Message-ID (diff)
From: David Daney <ddaney@caviumnetworks.com>
To: Harvey Hunt <harvey.hunt@imgtec.com>
Cc: Joshua Kinard <kumba@gentoo.org>,
	linux-mips@linux-mips.org, ralf@linux-mips.org,
	David Daney <david.daney@cavium.com>,
	Paul Burton <paul.burton@imgtec.com>,
	James Hogan <james.hogan@imgtec.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] MIPS: Always page align TASK_SIZE
Date: Mon, 8 Feb 2016 14:08:17 -0800	[thread overview]
Message-ID: <56B911D1.2090402@caviumnetworks.com> (raw)
Message-ID: <20160208220817.4lYBGM_JL_KzqjLSzSI97MVnad5u3PA-TrdRpPvwy0I@z> (raw)
In-Reply-To: <56B90D30.5020904@imgtec.com>

On 02/08/2016 01:48 PM, Harvey Hunt wrote:
> Hi Joshua,
>
> On 02/08/2016 01:35 PM, Joshua Kinard wrote:
>> On 02/08/2016 13:15, Harvey Hunt wrote:
>>> Hi David,
>>>
>>> On 02/08/2016 10:11 AM, David Daney wrote:
>>>> On 02/08/2016 10:05 AM, Harvey Hunt wrote:
>>>>> STACK_TOP_MAX is aligned on a 32k boundary. When __bprm_mm_init()
>>>>> creates an
>>>>> initial stack for a process, it does so using STACK_TOP_MAX as the end
>>>>> of the
>>>>> vma. A process's arguments and environment information are placed on
>>>>> the stack
>>>>> and then the stack is relocated and aligned on a page boundary. When
>>>>> using a 32
>>>>> bit kernel with 64k pages, the relocated stack has the process's args
>>>>> erroneously stored in the middle of the stack. This means that
>>>>> processes
>>>>> receive no arguments or environment variables, preventing them from
>>>>> running
>>>>> correctly.
>>>>>
>>>>> Fix this by aligning TASK_SIZE on a page boundary.
>>>>>
>>>>> Signed-off-by: Harvey Hunt <harvey.hunt@imgtec.com>
>>>>> Cc: David Daney <david.daney@cavium.com>
>>>>> Cc: Paul Burton <paul.burton@imgtec.com>
>>>>> Cc: James Hogan <james.hogan@imgtec.com>
>>>>> Cc: linux-kernel@vger.kernel.org
>>>>> ---
>>>>>    arch/mips/include/asm/processor.h | 6 +++---
>>>>>    1 file changed, 3 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/arch/mips/include/asm/processor.h
>>>>> b/arch/mips/include/asm/processor.h
>>>>> index 3f832c3..b618b40 100644
>>>>> --- a/arch/mips/include/asm/processor.h
>>>>> +++ b/arch/mips/include/asm/processor.h
>>>>> @@ -39,13 +39,13 @@ extern unsigned int vced_count, vcei_count;
>>>>>    #ifdef CONFIG_32BIT
>>>>>    #ifdef CONFIG_KVM_GUEST
>>>>>    /* User space process size is limited to 1GB in KVM Guest Mode */
>>>>> -#define TASK_SIZE    0x3fff8000UL
>>>>> +#define TASK_SIZE    (0x40000000UL - PAGE_SIZE)
>>>>>    #else
>>>>>    /*
>>>>>     * User space process size: 2GB. This is hardcoded into a few
>>>>> places,
>>>>>     * so don't change it unless you know what you are doing.
>>>>>     */
>>>>> -#define TASK_SIZE    0x7fff8000UL
>>>>> +#define TASK_SIZE    (0x7fff8000UL & PAGE_SIZE)
>>>>
>>>> Can you check your math here.  This doesn't seem correct.
>>>
>>> Thanks for spotting that - it should have been:
>>>
>>> (0x7fff8000UL & PAGE_MASK)
>>>
>>> I'll do a v2 now.
>>>
>>
>> FYI, TASK_SIZE was recently changed to 0x80000000UL in commit
>> 7f8ca9cb1ed3 on
>> the linux-mips.org tree.
>
> Thanks, I'll rebase.

You may find that in rebasing, suddenly you have a completely empty patch!


>
>>
>>
>>>>
>>>>>    #endif
>>>>>
>>>>>    #define STACK_TOP_MAX    TASK_SIZE
>>>>> @@ -62,7 +62,7 @@ extern unsigned int vced_count, vcei_count;
>>>>>     * support 16TB; the architectural reserve for future expansion is
>>>>>     * 8192EB ...
>>>>>     */
>>>>> -#define TASK_SIZE32    0x7fff8000UL
>>>>> +#define TASK_SIZE32    (0x7fff8000UL & PAGE_SIZE)
>>>>
>>>> Same here.
>>>
>>> As above.
>>>
>>>>
>>>>>    #define TASK_SIZE64    0x10000000000UL
>>>>>    #define TASK_SIZE (test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 :
>>>>> TASK_SIZE64)
>>>>>    #define STACK_TOP_MAX    TASK_SIZE64
>>>>>
>>>>
>>>
>>> Thanks,
>>>
>>> Harvey
>>>
>>>
>>
>>

  parent reply	other threads:[~2016-02-08 22:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-08 18:05 [PATCH] MIPS: Always page align TASK_SIZE Harvey Hunt
2016-02-08 18:05 ` Harvey Hunt
2016-02-08 18:11 ` David Daney
2016-02-08 18:11   ` David Daney
2016-02-08 18:15   ` Harvey Hunt
2016-02-08 18:15     ` Harvey Hunt
2016-02-08 18:24     ` David Daney
2016-02-08 21:35     ` Joshua Kinard
2016-02-08 21:48       ` Harvey Hunt
2016-02-08 21:48         ` Harvey Hunt
2016-02-08 22:08         ` David Daney [this message]
2016-02-08 22:08           ` David Daney
2016-02-08 22:26           ` Harvey Hunt
2016-02-08 22:26             ` Harvey Hunt

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=56B911D1.2090402@caviumnetworks.com \
    --to=ddaney@caviumnetworks.com \
    --cc=david.daney@cavium.com \
    --cc=harvey.hunt@imgtec.com \
    --cc=james.hogan@imgtec.com \
    --cc=kumba@gentoo.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=paul.burton@imgtec.com \
    --cc=ralf@linux-mips.org \
    /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