From: "J.A. Magallon" <jamagallon@able.es>
To: Marcelo Tosatti <marcelo@conectiva.com.br>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] correct AT_PLATFORM for HT cpus
Date: Sun, 31 Aug 2003 11:21:27 +0200 [thread overview]
Message-ID: <20030831092127.GA21970@werewolf.able.es> (raw)
In-Reply-To: <Pine.LNX.4.55L.0308301220020.31588@freak.distro.conectiva>; from marcelo@conectiva.com.br on Sat, Aug 30, 2003 at 17:48:22 +0200
On 08.30, Marcelo Tosatti wrote:
>
> Hello,
>
> Here goes -pre2. It contains an USB update, PPC merge, m68k merge, IDE
> changes from Alan, network drivers update from Jeff, amongst other fixes
> and updates.
>
In shortest: Pentium4 with HT do not realize they are themselves an i686.
Even, they do not know what they are. This makes P4HT select i386 libraries
at runtime, instead of i686 ones.
In short: binfmt_elf::create_elf_tables() copies the AT_PLATFORM in the
place pointed by u_platform, and then copies the pointer to elf tables.
But, in the HT case, u_platform gets changed in the middle, beacuse it
is also used as the beginning of the stack, that is shifted for HT
processors to avoid cache collisions. So then
it puts a pointer to garbage in the elf tables:
if (k_platform) {
platform_len = strlen(k_platform) + 1;
u_platform = p - platform_len;
__copy_to_user(u_platform, k_platform, platform_len);
} else
u_platform = p;
...
if(smp_num_siblings > 1)
u_platform = u_platform - ((current->pid % 64) << 7);
...
if (k_platform) {
sp -= 2;
NEW_AUX_ENT(0, AT_PLATFORM, (elf_addr_t)(unsigned long) u_platform);
}
Solution is to use separate variables to store u_platform and the stack_top:
--- linux/fs/binfmt_elf.c.orig 2002-12-28 00:12:32.000000000 +0100
+++ linux/fs/binfmt_elf.c 2002-12-28 00:32:37.000000000 +0100
@@ -116,11 +116,14 @@
elf_caddr_t *argv;
elf_caddr_t *envp;
elf_addr_t *sp, *csp;
+ char *stack_top;
char *k_platform, *u_platform;
long hwcap;
size_t platform_len = 0;
size_t len;
+ stack_top = p;
+
/*
* Get hold of platform and hardware capabilities masks for
* the machine we are running on. In some cases (Sparc),
@@ -135,8 +138,8 @@
platform_len = strlen(k_platform) + 1;
u_platform = p - platform_len;
__copy_to_user(u_platform, k_platform, platform_len);
- } else
- u_platform = p;
+ stack_top = u_platform;
+ }
#if defined(__i386__) && defined(CONFIG_SMP)
/*
@@ -149,15 +152,14 @@
* processors. This keeps Mr Marcelo Person happier but should be
* removed for 2.5
*/
-
if(smp_num_siblings > 1)
- u_platform = u_platform - ((current->pid % 64) << 7);
+ stack_top -= ((current->pid % 64) << 7);
#endif
/*
* Force 16 byte _final_ alignment here for generality.
*/
- sp = (elf_addr_t *)(~15UL & (unsigned long)(u_platform));
+ sp = (elf_addr_t *)(~15UL & (unsigned long)(stack_top));
csp = sp;
csp -= (1+DLINFO_ITEMS)*2 + (k_platform ? 2 : 0);
#ifdef DLINFO_ARCH_ITEMS
As other patches, tested by myself. And Mandrake kernel includes it.
Comments ?
--
J.A. Magallon <jamagallon@able.es> \ Software is like sex:
werewolf.able.es \ It's better when it's free
Mandrake Linux release 9.2 (Cooker) for i586
Linux 2.4.22-jam1m (gcc 3.3.1 (Mandrake Linux 9.2 3.3.1-1mdk))
next prev parent reply other threads:[~2003-08-31 9:21 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-30 15:48 Linux 2.4.23-pre2 Marcelo Tosatti
2003-08-30 16:22 ` Dave Bentham
2003-08-30 19:35 ` system_lists
2003-08-30 22:05 ` [PATCH] check_gcc for i386 J.A. Magallon
2003-08-30 22:58 ` Marcelo Tosatti
2003-08-30 23:20 ` Norberto BENSA
2003-08-31 2:39 ` Marcelo Tosatti
2003-08-30 23:31 ` J.A. Magallon
2003-08-30 23:37 ` Alan Cox
2003-08-31 0:47 ` Jeff Garzik
2003-08-31 0:59 ` Kurt Wall
2003-08-31 3:03 ` Marcelo Tosatti
2003-09-01 19:14 ` Marcelo Tosatti
2003-08-30 23:01 ` Andre Tomt
2003-08-30 23:11 ` Linux 2.4.23-pre2 - airo.c compile failure Eyal Lebedinsky
2003-09-03 15:56 ` [patch] fix airo.c compile failure with gcc 2.95 Adrian Bunk
2003-09-03 16:33 ` Jeff Garzik
2003-08-31 9:21 ` J.A. Magallon [this message]
2003-09-02 15:18 ` [patch] 2.4.23-pre2: fix rocket.c compilation Adrian Bunk
2003-09-02 16:49 ` 2.4.23-pre2: 3c515.c doesn't compile non-modular Adrian Bunk
2003-09-02 17:47 ` [PATCH] " Jeff Garzik
2003-10-15 17:32 ` airo regression with Linux 2.4.23-pre2 Udo A. Steinberg
2003-10-15 19:47 ` Celso González
2003-10-15 21:27 ` Javier Achirica
2003-10-16 13:51 ` Udo A. Steinberg
2003-10-16 14:52 ` Marc Giger
2003-10-19 15:19 ` Joseph Pingenot
2003-10-20 10:33 ` Javier Achirica
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=20030831092127.GA21970@werewolf.able.es \
--to=jamagallon@able.es \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
/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