From mboxrd@z Thu Jan 1 00:00:00 1970 Received: with ECARTIS (v1.0.0; list linux-mips); Mon, 08 Feb 2016 19:15:23 +0100 (CET) Received: from mailapp01.imgtec.com ([195.59.15.196]:8349 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S27012049AbcBHSPU5lVaY (ORCPT ); Mon, 8 Feb 2016 19:15:20 +0100 Received: from hhmail02.hh.imgtec.org (unknown [10.100.10.20]) by Websense Email Security Gateway with ESMTPS id C0E7F5C08422B; Mon, 8 Feb 2016 18:15:11 +0000 (GMT) Received: from LEMAIL01.le.imgtec.org (192.168.152.62) by hhmail02.hh.imgtec.org (10.100.10.20) with Microsoft SMTP Server (TLS) id 14.3.266.1; Mon, 8 Feb 2016 18:15:14 +0000 Received: from [10.20.79.140] (10.20.79.140) by LEMAIL01.le.imgtec.org (192.168.152.62) with Microsoft SMTP Server (TLS) id 14.3.210.2; Mon, 8 Feb 2016 18:15:14 +0000 Subject: Re: [PATCH] MIPS: Always page align TASK_SIZE To: David Daney References: <1454954723-24887-1-git-send-email-harvey.hunt@imgtec.com> <56B8DA56.9020108@caviumnetworks.com> CC: , , David Daney , Paul Burton , James Hogan , From: Harvey Hunt Message-ID: <56B8DB2D.3070604@imgtec.com> Date: Mon, 8 Feb 2016 10:15:09 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <56B8DA56.9020108@caviumnetworks.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.20.79.140] Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 51862 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: harvey.hunt@imgtec.com Precedence: bulk List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: linux-mips X-List-ID: linux-mips List-subscribe: List-owner: List-post: List-archive: X-list: linux-mips 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 >> Cc: David Daney >> Cc: Paul Burton >> Cc: James Hogan >> 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailapp01.imgtec.com ([195.59.15.196]:8349 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S27012049AbcBHSPU5lVaY (ORCPT ); Mon, 8 Feb 2016 19:15:20 +0100 Subject: Re: [PATCH] MIPS: Always page align TASK_SIZE References: <1454954723-24887-1-git-send-email-harvey.hunt@imgtec.com> <56B8DA56.9020108@caviumnetworks.com> From: Harvey Hunt Message-ID: <56B8DB2D.3070604@imgtec.com> Date: Mon, 8 Feb 2016 10:15:09 -0800 MIME-Version: 1.0 In-Reply-To: <56B8DA56.9020108@caviumnetworks.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit Return-Path: Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-subscribe: List-owner: List-post: List-archive: To: David Daney Cc: linux-mips@linux-mips.org, ralf@linux-mips.org, David Daney , Paul Burton , James Hogan , linux-kernel@vger.kernel.org Message-ID: <20160208181509.iw59-b_pwGcXOOTMZORCOIoyzjBSYC-b5_eikXxCy3M@z> 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 >> Cc: David Daney >> Cc: Paul Burton >> Cc: James Hogan >> 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