From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Mosberger Date: Sat, 10 Jul 2004 05:28:15 +0000 Subject: serious performance regression due to NX patch Message-Id: <200407100528.i6A5SF8h020094@napali.hpl.hp.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: mingo@redhat.com, suresh.b.siddha@intel.com, jun.nakajima@intel.com, akpm@osdl.org, torvalds@osdl.org Cc: linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org The "No eXecute patch for x86" causes a serious exec() performance degradation on ia64 since it ends up incorrectly turning on the execute protection on all segments (since most ia64 binaries don't have a gnu_stack program-header). The patch below fixes the problem by turning on VM_EXEC and VM_MAYEXEC only if VM_DATA_DEFAULT_FLAGS mentions them. Note that on ia64, the value of VM_DATA_DEFAULT_FLAGS depends on the personality (to support x86 binaries) and hence I had to move the setting of "def_flags" down a bit to a point after SET_PERSONALITY() has been done. Please apply. --david === fs/binfmt_elf.c 1.78 vs edited ==--- 1.78/fs/binfmt_elf.c 2004-06-29 07:43:10 -07:00 +++ edited/fs/binfmt_elf.c 2004-07-09 21:53:05 -07:00 @@ -493,8 +493,8 @@ char passed_fileno[6]; struct files_struct *files; int executable_stack = EXSTACK_DEFAULT; - unsigned long def_flags = 0; - + unsigned long no_gnu_stack, def_flags = 0; + /* Get the exec-header */ elf_ex = *((struct elfhdr *) bprm->buf); @@ -627,8 +627,7 @@ executable_stack = EXSTACK_DISABLE_X; break; } - if (i = elf_ex.e_phnum) - def_flags |= VM_EXEC | VM_MAYEXEC; + no_gnu_stack = (i = elf_ex.e_phnum); /* Some simple consistency checks for the interpreter */ if (elf_interpreter) { @@ -662,6 +661,10 @@ /* Executables without an interpreter also need a personality */ SET_PERSONALITY(elf_ex, ibcs2_interpreter); } + + /* Now that personality is set, we can use VM_DATA_DEFAULT_FLAGS. */ + if (no_gnu_stack) + def_flags |= VM_DATA_DEFAULT_FLAGS & (VM_EXEC | VM_MAYEXEC); /* OK, we are done with that, now set up the arg stuff, and then start this sucker up */