mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [Patch] X86_64 TASK_SIZE cleanup
@ 2005-04-16  1:34 Zou, Nanhai
  2005-04-18  9:06 ` [discuss] " Andi Kleen
  0 siblings, 1 reply; 6+ messages in thread
From: Zou, Nanhai @ 2005-04-16  1:34 UTC (permalink / raw)
  To: discuss, Andi Kleen; +Cc: linux-kernel, Siddha, Suresh B

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]


Hi,
   This patch will clean up the X86_64 compatibility mode TASK_SIZE
define thus fix some bugs found in X86_64 compatibility mode program.

Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com> 
Signed-off-by: Zou Nan hai <Nanhai.zou@intel.com>


[-- Attachment #2: x86_64-compat-tasksize-fix.patch --]
[-- Type: application/octet-stream, Size: 3123 bytes --]

diff -Nraup a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c
--- a/arch/x86_64/ia32/ia32_binfmt.c	2005-03-26 11:28:14.000000000 +0800
+++ b/arch/x86_64/ia32/ia32_binfmt.c	2005-04-12 00:59:09.000000000 +0800
@@ -46,7 +46,7 @@ struct elf_phdr; 
 
 #define IA32_EMULATOR 1
 
-#define ELF_ET_DYN_BASE		(TASK_UNMAPPED_32 + 0x1000000)
+#define ELF_ET_DYN_BASE		(TASK_UNMAPPED_BASE + 0x1000000)
 
 #undef ELF_ARCH
 #define ELF_ARCH EM_386
@@ -307,9 +307,6 @@ MODULE_AUTHOR("Eric Youngdale, Andi Klee
 
 #define elf_addr_t __u32
 
-#undef TASK_SIZE
-#define TASK_SIZE 0xffffffff
-
 static void elf32_init(struct pt_regs *);
 
 #include "../../../fs/binfmt_elf.c" 
diff -Nraup a/arch/x86_64/kernel/sys_x86_64.c b/arch/x86_64/kernel/sys_x86_64.c
--- a/arch/x86_64/kernel/sys_x86_64.c	2005-03-26 11:28:24.000000000 +0800
+++ b/arch/x86_64/kernel/sys_x86_64.c	2005-04-12 01:00:09.000000000 +0800
@@ -69,13 +69,7 @@ out:
 static void find_start_end(unsigned long flags, unsigned long *begin,
 			   unsigned long *end)
 {
-#ifdef CONFIG_IA32_EMULATION
-	if (test_thread_flag(TIF_IA32)) { 
-		*begin = TASK_UNMAPPED_32;
-		*end = IA32_PAGE_OFFSET; 
-	} else 
-#endif
-	if (flags & MAP_32BIT) { 
+	if (!test_thread_flag(TIF_IA32) && (flags & MAP_32BIT)) {
 		/* This is usually used needed to map code in small
 		   model, so it needs to be in the first 31bit. Limit
 		   it to that.  This means we need to move the
@@ -85,10 +79,10 @@ static void find_start_end(unsigned long
 		   of playground for now. -AK */ 
 		*begin = 0x40000000; 
 		*end = 0x80000000;		
-	} else { 
-		*begin = TASK_UNMAPPED_64; 
+	} else {
+		*begin = TASK_UNMAPPED_BASE;
 		*end = TASK_SIZE; 
-		}
+	}
 } 
 
 unsigned long
diff -Nraup a/include/asm-x86_64/a.out.h b/include/asm-x86_64/a.out.h
--- a/include/asm-x86_64/a.out.h	2005-03-26 11:28:19.000000000 +0800
+++ b/include/asm-x86_64/a.out.h	2005-04-12 00:59:09.000000000 +0800
@@ -21,7 +21,7 @@ struct exec
 
 #ifdef __KERNEL__
 #include <linux/thread_info.h>
-#define STACK_TOP (test_thread_flag(TIF_IA32) ? IA32_PAGE_OFFSET : TASK_SIZE)
+#define STACK_TOP TASK_SIZE
 #endif
 
 #endif /* __A_OUT_GNU_H__ */
diff -Nraup a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
--- a/include/asm-x86_64/processor.h	2005-03-26 11:28:38.000000000 +0800
+++ b/include/asm-x86_64/processor.h	2005-04-12 00:59:09.000000000 +0800
@@ -162,16 +162,15 @@ static inline void clear_in_cr4 (unsigne
 /*
  * User space process size. 47bits.
  */
-#define TASK_SIZE	(0x800000000000UL)
+
+#define TASK_SIZE64	(0x800000000000UL)
+#define TASK_SIZE (test_thread_flag(TIF_IA32) ? IA32_PAGE_OFFSET : TASK_SIZE64)
 
 /* This decides where the kernel will search for a free chunk of vm
  * space during mmap's.
  */
 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? 0xc0000000 : 0xFFFFe000)
-#define TASK_UNMAPPED_32 PAGE_ALIGN(IA32_PAGE_OFFSET/3)
-#define TASK_UNMAPPED_64 PAGE_ALIGN(TASK_SIZE/3) 
-#define TASK_UNMAPPED_BASE	\
-	(test_thread_flag(TIF_IA32) ? TASK_UNMAPPED_32 : TASK_UNMAPPED_64)  
+#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE/3)
 
 /*
  * Size of io_bitmap.

^ permalink raw reply	[flat|nested] 6+ messages in thread
* RE: [discuss] [Patch] X86_64 TASK_SIZE cleanup
@ 2005-04-18 16:37 Zou, Nanhai
  0 siblings, 0 replies; 6+ messages in thread
From: Zou, Nanhai @ 2005-04-18 16:37 UTC (permalink / raw)
  To: Andi Kleen; +Cc: discuss, linux-kernel, Siddha, Suresh B


When a 32bit program is mapping a lot of hugepage vm_areas, 
hugetlb_get_unmapped_area may search beyond 4G, then the program will
get a SIGFAULT instead of an errno of ENOMEM.
This patch will fix that.
I believe there are other inconsistent cases in generic code like mm and
fs.

Zou Nan hai

> -----Original Message-----
> From: Andi Kleen [mailto:ak@suse.de]
> Sent: Monday, April 18, 2005 5:06 PM
> To: Zou, Nanhai
> Cc: discuss@x86-64.org; Andi Kleen; linux-kernel@vger.kernel.org;
Siddha,
> Suresh B
> Subject: Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup
> 
> On Sat, Apr 16, 2005 at 09:34:25AM +0800, Zou, Nanhai wrote:
> >
> > Hi,
> >    This patch will clean up the X86_64 compatibility mode TASK_SIZE
> > define thus fix some bugs found in X86_64 compatibility mode
program.
> 
> Fix what bugs exactly?  Please a detailed description.
> 
> -Andi

^ permalink raw reply	[flat|nested] 6+ messages in thread
* RE: [discuss] [Patch] X86_64 TASK_SIZE cleanup
@ 2005-04-20 17:17 Zou, Nanhai
  2005-04-21 11:50 ` Andi Kleen
  0 siblings, 1 reply; 6+ messages in thread
From: Zou, Nanhai @ 2005-04-20 17:17 UTC (permalink / raw)
  To: Andi Kleen; +Cc: discuss, linux-kernel, Siddha, Suresh B

Hi Andi,
   What is your comment on this patch?
Here is another example bug this patch will fix.
The following piece of code will get a success mmap even if compiled
with -m32. 
   
   int *p;
   p = mmap((void *)(0xFFFFE000UL), 0x10000UL, PROT_READ|PROT_WRITE,
                MAP_FIXED|MAP_PRIVATE|MAP_ANON, 0, 0);

I believe there are other kind of corner case bugs around mm and fs. 
e.g in mremap and munmap.
Those bugs will be fixed by this patch. 

Zou Nan hai
> -----Original Message-----
> From: Zou, Nanhai
> Sent: Tuesday, April 19, 2005 12:37 AM
> To: 'Andi Kleen'
> Cc: discuss@x86-64.org; linux-kernel@vger.kernel.org; Siddha, Suresh B
> Subject: RE: [discuss] [Patch] X86_64 TASK_SIZE cleanup
> 
> 
> When a 32bit program is mapping a lot of hugepage vm_areas,
> hugetlb_get_unmapped_area may search beyond 4G, then the program will
get a
> SIGFAULT instead of an errno of ENOMEM.
> This patch will fix that.
> I believe there are other inconsistent cases in generic code like mm
and fs.
> 
> Zou Nan hai
> 
> > -----Original Message-----
> > From: Andi Kleen [mailto:ak@suse.de]
> > Sent: Monday, April 18, 2005 5:06 PM
> > To: Zou, Nanhai
> > Cc: discuss@x86-64.org; Andi Kleen; linux-kernel@vger.kernel.org;
Siddha,
> > Suresh B
> > Subject: Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup
> >
> > On Sat, Apr 16, 2005 at 09:34:25AM +0800, Zou, Nanhai wrote:
> > >
> > > Hi,
> > >    This patch will clean up the X86_64 compatibility mode
TASK_SIZE
> > > define thus fix some bugs found in X86_64 compatibility mode
program.
> >
> > Fix what bugs exactly?  Please a detailed description.
> >
> > -Andi

^ permalink raw reply	[flat|nested] 6+ messages in thread
* RE: [discuss] [Patch] X86_64 TASK_SIZE cleanup
@ 2005-04-21 15:43 Zou, Nanhai
  0 siblings, 0 replies; 6+ messages in thread
From: Zou, Nanhai @ 2005-04-21 15:43 UTC (permalink / raw)
  To: Andi Kleen; +Cc: discuss, linux-kernel, Siddha, Suresh B


Isn't that a 
!test_thread_flag(TIF_IA32) && (flags & MAP_32BIT)
in my patch?

Zou Nan hai

> -----Original Message-----
> From: Andi Kleen [mailto:ak@suse.de]
> Sent: Thursday, April 21, 2005 7:51 PM
> To: Zou, Nanhai
> Cc: Andi Kleen; discuss@x86-64.org; linux-kernel@vger.kernel.org;
Siddha,
> Suresh B
> Subject: Re: [discuss] [Patch] X86_64 TASK_SIZE cleanup
> 
> On Thu, Apr 21, 2005 at 01:17:40AM +0800, Zou, Nanhai wrote:
> > Hi Andi,
> >    What is your comment on this patch?
> 
> There is at least one wrong change in there, you have a check
> for test_thread_flag(TIF_IA32) && (flags & MAP_32BIT)
> 
> and that is wrong because MAP_32BIT is used from 64bit code
> 
> -Andi

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-04-21 15:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-16  1:34 [Patch] X86_64 TASK_SIZE cleanup Zou, Nanhai
2005-04-18  9:06 ` [discuss] " Andi Kleen
2005-04-18 16:37 Zou, Nanhai
2005-04-20 17:17 Zou, Nanhai
2005-04-21 11:50 ` Andi Kleen
2005-04-21 15:43 Zou, Nanhai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®