x86: i486: stub out init-arch logic

Message ID 1439285278-22006-1-git-send-email-vapier@gentoo.org
State Not applicable
Headers

Commit Message

Mike Frysinger Aug. 11, 2015, 9:27 a.m. UTC
  The common x86 init-arch logic hardcodes the usage of cpuid which breaks
running on i486 and older systems.  Rather than add more checking to the
common case only for old cpus, stub it out for i486 systems entirely.

Reported-by: Daniel Goertzen <daniel.goertzen@gmail.com>
URL: https://bugs.gentoo.org/523830

2015-08-11  Mike Frysinger  <vapier@gentoo.org>

	* sysdeps/unix/sysv/linux/i386/i486/init-arch.c: New file.
---
 sysdeps/unix/sysv/linux/i386/i486/init-arch.c | 44 +++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/i386/i486/init-arch.c
  

Comments

H.J. Lu Aug. 11, 2015, 10:42 a.m. UTC | #1
On Tue, Aug 11, 2015 at 2:27 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> The common x86 init-arch logic hardcodes the usage of cpuid which breaks
> running on i486 and older systems.  Rather than add more checking to the
> common case only for old cpus, stub it out for i486 systems entirely.

cpuid is added to i486 and glibc no longer supports i386.  cpuid can be
used on x86 without checking and i486 glibc should use cpuid on i686.

> Reported-by: Daniel Goertzen <daniel.goertzen@gmail.com>
> URL: https://bugs.gentoo.org/523830
>
> 2015-08-11  Mike Frysinger  <vapier@gentoo.org>
>
>         * sysdeps/unix/sysv/linux/i386/i486/init-arch.c: New file.

BTW, I am rewriting init-arch support on hjl/cpuid/master branch.
If you wan to make changes to init-arch, please do it on hjl/cpuid/master
branch.
  
Matt Turner Aug. 11, 2015, 7:19 p.m. UTC | #2
On Tue, Aug 11, 2015 at 3:42 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Aug 11, 2015 at 2:27 AM, Mike Frysinger <vapier@gentoo.org> wrote:
>> The common x86 init-arch logic hardcodes the usage of cpuid which breaks
>> running on i486 and older systems.  Rather than add more checking to the
>> common case only for old cpus, stub it out for i486 systems entirely.
>
> cpuid is added to i486 and glibc no longer supports i386.  cpuid can be
> used on x86 without checking and i486 glibc should use cpuid on i686.

There are apparently some non-Intel 486-compatible CPUs without the
CPUID instruction -- see the Gentoo bug report.

>> Reported-by: Daniel Goertzen <daniel.goertzen@gmail.com>
>> URL: https://bugs.gentoo.org/523830
  
H.J. Lu Aug. 11, 2015, 7:29 p.m. UTC | #3
On Tue, Aug 11, 2015 at 12:19 PM, Matt Turner <mattst88@gmail.com> wrote:
> On Tue, Aug 11, 2015 at 3:42 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Tue, Aug 11, 2015 at 2:27 AM, Mike Frysinger <vapier@gentoo.org> wrote:
>>> The common x86 init-arch logic hardcodes the usage of cpuid which breaks
>>> running on i486 and older systems.  Rather than add more checking to the
>>> common case only for old cpus, stub it out for i486 systems entirely.
>>
>> cpuid is added to i486 and glibc no longer supports i386.  cpuid can be
>> used on x86 without checking and i486 glibc should use cpuid on i686.
>
> There are apparently some non-Intel 486-compatible CPUs without the
> CPUID instruction -- see the Gentoo bug report.
>

Please check out  hjl/cpuid/master branch.  It should work.
  
Mike Frysinger Aug. 12, 2015, 3:45 a.m. UTC | #4
On 11 Aug 2015 12:29, H.J. Lu wrote:
> On Tue, Aug 11, 2015 at 12:19 PM, Matt Turner <mattst88@gmail.com> wrote:
> > On Tue, Aug 11, 2015 at 3:42 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> >> On Tue, Aug 11, 2015 at 2:27 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> >>> The common x86 init-arch logic hardcodes the usage of cpuid which breaks
> >>> running on i486 and older systems.  Rather than add more checking to the
> >>> common case only for old cpus, stub it out for i486 systems entirely.
> >>
> >> cpuid is added to i486 and glibc no longer supports i386.  cpuid can be
> >> used on x86 without checking and i486 glibc should use cpuid on i686.
> >
> > There are apparently some non-Intel 486-compatible CPUs without the
> > CPUID instruction -- see the Gentoo bug report.
> 
> Please check out  hjl/cpuid/master branch.  It should work.

as long as it doesn't require cpuid and is merged for 2.23, sounds fine
-mike
  

Patch

diff --git a/sysdeps/unix/sysv/linux/i386/i486/init-arch.c b/sysdeps/unix/sysv/linux/i386/i486/init-arch.c
new file mode 100644
index 0000000..c95979d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/i386/i486/init-arch.c
@@ -0,0 +1,44 @@ 
+/* Initialize CPU feature data.
+   This file is part of the GNU C Library.
+   Copyright (C) 2015 Free Software Foundation, Inc.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <atomic.h>
+#include "init-arch.h"
+
+
+struct cpu_features __cpu_features attribute_hidden;
+
+
+void
+__init_cpu_features (void)
+{
+  __cpu_features.family = 0;
+  __cpu_features.model = 0;
+  atomic_write_barrier ();
+  __cpu_features.kind = arch_kind_other;
+}
+
+#undef __get_cpu_features
+
+const struct cpu_features *
+__get_cpu_features (void)
+{
+  if (__cpu_features.kind == arch_kind_unknown)
+    __init_cpu_features ();
+
+  return &__cpu_features;
+}