2008-02-01 00:42:18

by Pavel Machek

[permalink] [raw]
Subject: how to tell i386 from x86-64 kernel

Hi!

Quiz: on a booted system, how do you tell 32bit from 64bit kernel?

A1: zcat /proc/config.gz | grep CONFIG_64

...but config.gz is optional

A2: cat /proc/meminfo | grep High

...but i386 kernel could have highmem disabled

What is _your_ answer? ;-)>
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


2008-02-01 00:47:19

by Ray Lee

[permalink] [raw]
Subject: Re: how to tell i386 from x86-64 kernel

On Jan 31, 2008 4:42 PM, Pavel Machek <[email protected]> wrote:
> Quiz: on a booted system, how do you tell 32bit from 64bit kernel?

Uhm, is this a trick question? What's wrong with uname(2)?

2008-02-01 00:59:25

by Jan Engelhardt

[permalink] [raw]
Subject: Re: how to tell i386 from x86-64 kernel


On Jan 31 2008 16:46, Ray Lee wrote:
>On Jan 31, 2008 4:42 PM, Pavel Machek <[email protected]> wrote:
>> Quiz: on a booted system, how do you tell 32bit from 64bit kernel?
>
>Uhm, is this a trick question? What's wrong with uname(2)?

# uname -m
I won't tell you.
# linux32 uname -m
i686

Now what? :-)

Well, the answer is simple, a 64-bit kernel will allow you
(minus selinux voodoo) to load 64-bit binaries.

2008-02-01 01:03:19

by Pavel Machek

[permalink] [raw]
Subject: Re: how to tell i386 from x86-64 kernel

On Thu 2008-01-31 16:46:57, Ray Lee wrote:
> On Jan 31, 2008 4:42 PM, Pavel Machek <[email protected]> wrote:
> > Quiz: on a booted system, how do you tell 32bit from 64bit kernel?
>
> Uhm, is this a trick question? What's wrong with uname(2)?

No, it is a tricky question. You are right, uname -a tells me. Sorry.

Still, it would be nice to print it as a first message of dmesg, so
that it automatically gets included with problem reports... on
easy-to-see place.

Pavel

Linux version 2.6.24-rc8 (pavel@amd) (gcc version 4.1.3 20071209 (prerelease) (Debian 4.1.2-18)) #65 SMP Thu Jan 31 00:02:37 CET 2008
BIOS-provided physical RAM map:


--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2008-02-01 01:37:22

by Jan Engelhardt

[permalink] [raw]
Subject: Re: how to tell i386 from x86-64 kernel


don't strip Ccs, thanks. (and try not to tofu either.)

On Jan 31 2008 17:01, Justin Banks wrote:
>
>uname -a will tell you, though.

No. uname is generally not a reliable source to tell you the bitness (or
more precisely, the arch). It may even happen that you cannot find out
at all if access permissions are set 'correctly'.
You may find ELF64 files flying around in the filesystem, and while that
is a strong indication of a 64-bit kernel being running, it is not a
definite Yes.


02:31 ccgmbh:~ > uname -a
Linux ccgmbh 2.6.23.10-ccj62-regular #1 SMP 2007/10/26 14:17:15 UTC i686
athlon i386 GNU/Linux

02:32 ccgmbh:~ > file `which uname`
/bin/uname: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for
GNU/Linux 2.6.4, dynamically linked (uses shared libs), stripped

2008-02-01 05:03:44

by H. Peter Anvin

[permalink] [raw]
Subject: Re: how to tell i386 from x86-64 kernel

Pavel Machek wrote:
> Hi!
>
> Quiz: on a booted system, how do you tell 32bit from 64bit kernel?
>
> A1: zcat /proc/config.gz | grep CONFIG_64
>
> ...but config.gz is optional
>
> A2: cat /proc/meminfo | grep High
>
> ...but i386 kernel could have highmem disabled
>
> What is _your_ answer? ;-)>
> Pavel

uname -m

-hpa

2008-02-01 10:07:27

by Jiri Kosina

[permalink] [raw]
Subject: Re: how to tell i386 from x86-64 kernel

On Thu, 31 Jan 2008, H. Peter Anvin wrote:

> > Quiz: on a booted system, how do you tell 32bit from 64bit kernel?
> uname -m

I think that the real point here is that there is no general way how to
determine whether the kernel is 32bit or 64bit from full dmesg output,
which could sometimes make debugging user-reported bugs a little bit
harder.

--
Jiri Kosina
SUSE Labs

2008-02-01 10:47:46

by Rik Bobbaers

[permalink] [raw]
Subject: Re: how to tell i386 from x86-64 kernel

hi there,

since i'm not on the list... how about:

tail /proc/1/smaps and check the address size...
on 32 bit: ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]

on 64 bit: ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0
[vdso]

there you can clearly see that your address space is double... so
there's your 32 bit vs 64 bit

as a normal user, you can do the same but with your own processes

greetings,

> Hi!
>
> Quiz: on a booted system, how do you tell 32bit from 64bit kernel?
>
> A1: zcat /proc/config.gz | grep CONFIG_64
> ...but config.gz is optional
>
> A2: cat /proc/meminfo | grep High
> ...but i386 kernel could have highmem disabled
>
> What is _your_ answer? ;-)>

--
harry
aka Rik Bobbaers

K.U.Leuven - LUDIT -=- Tel: +32 485 52 71 50
[email protected] -=- http://harry.enzoverder.be

Don't steal - the government hates competition.



Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

Subject: Re: how to tell i386 from x86-64 kernel

El Fri, 1 Feb 2008 01:59:03 +0100 (CET)
Jan Engelhardt <[email protected]> escribió:


>
> # uname -m
> I won't tell you.
> # linux32 uname -m
> i686

Ubuntu 7.10 64 bit userland 2.6.24

$ uname -m
x86_64
$ linux32 uname -m
i686



>
> Now what? :-)
>
> Well, the answer is simple, a 64-bit kernel will allow you
> (minus selinux voodoo) to load 64-bit binaries.

2008-02-02 11:06:47

by Pavel Machek

[permalink] [raw]
Subject: Re: how to tell i386 from x86-64 kernel

On Fri 2008-02-01 11:47:29, Rik Bobbaers wrote:
> hi there,
>
> since i'm not on the list... how about:
>
> tail /proc/1/smaps and check the address size...
> on 32 bit: ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]
>
> on 64 bit: ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0
> [vdso]
>
> there you can clearly see that your address space is double... so
> there's your 32 bit vs 64 bit
>
> as a normal user, you can do the same but with your own processes

That tells you if _init_ is 32 or 64 bit, not kernel.

I'm running 32-bit distro on 64-bit kernel here. It works fine (as it
should).

Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2008-02-09 20:13:53

by Jan Engelhardt

[permalink] [raw]
Subject: Re: how to tell i386 from x86-64 kernel


On Feb 1 2008 12:53, Alejandro Riveira Fernández wrote:
>>
>> # uname -m
>> I won't tell you.
>> # linux32 uname -m
>> i686
>
> Ubuntu 7.10 64 bit userland 2.6.24
>
>$ uname -m
>x86_64
>$ linux32 uname -m
>i686

What I am saying is that uname(2) does not reliably tell you whether you
have a 64-bit kernel underneath unless you have other sources of
information.

2008-02-09 22:34:55

by Arjan van de Ven

[permalink] [raw]
Subject: Re: how to tell i386 from x86-64 kernel

On Sat, 9 Feb 2008 21:13:43 +0100 (CET)
Jan Engelhardt <[email protected]> wrote:

>
> On Feb 1 2008 12:53, Alejandro Riveira Fernández wrote:
> >>
> >> # uname -m
> >> I won't tell you.
> >> # linux32 uname -m
> >> i686
> >
> > Ubuntu 7.10 64 bit userland 2.6.24
> >
> >$ uname -m
> >x86_64
> >$ linux32 uname -m
> >i686
>
> What I am saying is that uname(2) does not reliably tell you whether
> you have a 64-bit kernel underneath unless you have other sources of
> information.

that's sort of a rabbit-and-the-frog problem. The 32 bit emulator tries to
look EXACTLY like the 32 bit kernel, and it really should.
If someone wants a method to detect even that... we would really want
to know the exact usecase.. because very likely it's the wrong answer
to some other problem ;-)

--
If you want to reach me at my work email, use [email protected]
For development, discussion and tips for power savings,
visit http://www.lesswatts.org

2008-02-10 01:27:47

by Pavel Machek

[permalink] [raw]
Subject: Re: how to tell i386 from x86-64 kernel

On Sat 2008-02-09 14:34:30, Arjan van de Ven wrote:
> On Sat, 9 Feb 2008 21:13:43 +0100 (CET)
> Jan Engelhardt <[email protected]> wrote:
>
> >
> > On Feb 1 2008 12:53, Alejandro Riveira Fern?ndez wrote:
> > >>
> > >> # uname -m
> > >> I won't tell you.
> > >> # linux32 uname -m
> > >> i686
> > >
> > > Ubuntu 7.10 64 bit userland 2.6.24
> > >
> > >$ uname -m
> > >x86_64
> > >$ linux32 uname -m
> > >i686
> >
> > What I am saying is that uname(2) does not reliably tell you whether
> > you have a 64-bit kernel underneath unless you have other sources of
> > information.
>
> that's sort of a rabbit-and-the-frog problem. The 32 bit emulator tries to
> look EXACTLY like the 32 bit kernel, and it really should.
> If someone wants a method to detect even that... we would really want
> to know the exact usecase.. because very likely it's the wrong answer
> to some other problem ;-)

dmesg should really really tell you 32 vs. 64 bit, at the first line
where it prints versions... so you easily know what you are dealing
with when someone sends a bugreport.

Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html