Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1329448 > unrolled thread

[PATCH] MIPS: Always page align TASK_SIZE

Started byHarvey Hunt <harvey.hunt@imgtec.com>
First post2016-02-08 19:10 +0100
Last post2016-02-08 19:20 +0100
Articles 8 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] MIPS: Always page align TASK_SIZE Harvey Hunt <harvey.hunt@imgtec.com> - 2016-02-08 19:10 +0100
    Re: [PATCH] MIPS: Always page align TASK_SIZE Harvey Hunt <harvey.hunt@imgtec.com> - 2016-02-08 19:20 +0100
      Re: [PATCH] MIPS: Always page align TASK_SIZE David Daney <ddaney.cavm@gmail.com> - 2016-02-08 19:30 +0100
      Re: [PATCH] MIPS: Always page align TASK_SIZE Joshua Kinard <kumba@gentoo.org> - 2016-02-08 22:40 +0100
        Re: [PATCH] MIPS: Always page align TASK_SIZE Harvey Hunt <harvey.hunt@imgtec.com> - 2016-02-08 22:50 +0100
          Re: [PATCH] MIPS: Always page align TASK_SIZE David Daney <ddaney@caviumnetworks.com> - 2016-02-08 23:10 +0100
            Re: [PATCH] MIPS: Always page align TASK_SIZE Harvey Hunt <harvey.hunt@imgtec.com> - 2016-02-08 23:30 +0100
    Re: [PATCH] MIPS: Always page align TASK_SIZE David Daney <ddaney@caviumnetworks.com> - 2016-02-08 19:20 +0100

#1329448 — [PATCH] MIPS: Always page align TASK_SIZE

FromHarvey Hunt <harvey.hunt@imgtec.com>
Date2016-02-08 19:10 +0100
Subject[PATCH] MIPS: Always page align TASK_SIZE
Message-ID<qZYq9-qH-67@gated-at.bofh.it>
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)
 #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)
 #define TASK_SIZE64	0x10000000000UL
 #define TASK_SIZE (test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE64)
 #define STACK_TOP_MAX	TASK_SIZE64
-- 
2.7.1

[toc] | [next] | [standalone]


#1329452

FromHarvey Hunt <harvey.hunt@imgtec.com>
Date2016-02-08 19:20 +0100
Message-ID<qZYzM-v9-15@gated-at.bofh.it>
In reply to#1329448
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.

>
>>   #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

[toc] | [prev] | [next] | [standalone]


#1329459

FromDavid Daney <ddaney.cavm@gmail.com>
Date2016-02-08 19:30 +0100
Message-ID<qZYJs-zh-19@gated-at.bofh.it>
In reply to#1329452
On 02/08/2016 10:15 AM, 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)

This brings up an interesting point.  How was this tested?  Please note 
that in the change log.

Also look at the definition of PAGE_MASK in page.h

Is that correct?  Most of the other related symbols have an "_AC(1,UL)" 
in them.  Why is this not also appropriate for PAGE_MASK?

It may also be a good idea to prepare and test a patch that defines 
PAGE_MASK much in the same way HPAGE_MASK is defined.

David Daney


>
> I'll do a v2 now.
>
>>
>>>   #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

[toc] | [prev] | [next] | [standalone]


#1329596

FromJoshua Kinard <kumba@gentoo.org>
Date2016-02-08 22:40 +0100
Message-ID<r01Hm-2vO-39@gated-at.bofh.it>
In reply to#1329452
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.


>>
>>>   #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
> 
> 


-- 
Joshua Kinard
Gentoo/MIPS
kumba@gentoo.org
6144R/F5C6C943 2015-04-27
177C 1972 1FB8 F254 BAD0 3E72 5C63 F4E3 F5C6 C943

"The past tempts us, the present confuses us, the future frightens us.  And our
lives slip away, moment by moment, lost in that vast, terrible in-between."

--Emperor Turhan, Centauri Republic

[toc] | [prev] | [next] | [standalone]


#1329600

FromHarvey Hunt <harvey.hunt@imgtec.com>
Date2016-02-08 22:50 +0100
Message-ID<r01R0-2zw-19@gated-at.bofh.it>
In reply to#1329596
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.

>
>
>>>
>>>>    #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
>>
>>
>
>

[toc] | [prev] | [next] | [standalone]


#1329618

FromDavid Daney <ddaney@caviumnetworks.com>
Date2016-02-08 23:10 +0100
Message-ID<r02am-2VY-7@gated-at.bofh.it>
In reply to#1329600
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
>>>
>>>
>>
>>

[toc] | [prev] | [next] | [standalone]


#1329644

FromHarvey Hunt <harvey.hunt@imgtec.com>
Date2016-02-08 23:30 +0100
Message-ID<r02tI-33a-5@gated-at.bofh.it>
In reply to#1329618

On 02/08/2016 02:08 PM, David Daney wrote:
> 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!
>

Yeah, I noticed that. I'll just drop this patch...

Thanks,

Harvey

>
>>
>>>
>>>
>>>>>
>>>>>>    #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
>>>>
>>>>
>>>
>>>
>

[toc] | [prev] | [next] | [standalone]


#1329456

FromDavid Daney <ddaney@caviumnetworks.com>
Date2016-02-08 19:20 +0100
Message-ID<qZYzM-v9-17@gated-at.bofh.it>
In reply to#1329448
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.

>   #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.

>   #define TASK_SIZE64	0x10000000000UL
>   #define TASK_SIZE (test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE64)
>   #define STACK_TOP_MAX	TASK_SIZE64
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web