13.7.09

64 bits: Check and Double-check

"I am not accustomed to saying anything with certainty after only one or two observations." -- Andreas Vesalius
In my last post I described how to determine if a processor is 64-bit in Linux using the information in 'cpuinfo'. Of course, if you really want to know for sure then you have to get the same answer from multiple sources looking at the same information.

Enter cpuid, a cross-platform utility that is a little more transparent than the information displayed from your OS. The bad news is that it appears the Linux version of this utility hasn't been updated since 2002, but the good news is that it shows the raw output from the queries to your processor and with a little research you can pretty much decipher it yourself, if the information you're looking for isn't already displayed in human underneath.

To focus on checking whether or not your process is 64-bit, you need to look at the raw output from the processor. Again, from my handy-dandy Pentium 4 desktop:

 eax in    eax      ebx      ecx      edx
00000000 00000005 756e6547 6c65746e 49656e69
00000001 00000f49 00020800 0000641d bfebfbff
00000002 605b5001 00000000 00000000 007c7040
00000003 00000000 00000000 00000000 00000000
00000004 00004121 01c0003f 0000001f 00000000
00000005 00000040 00000040 00000000 00000000
80000000 80000008 00000000 00000000 00000000
80000001 00000000 00000000 00000001 20000000
80000002 20202020 20202020 20202020 6e492020
80000003 286c6574 50202952 69746e65 52286d75
80000004 20342029 20555043 30302e33 007a4847
80000005 00000000 00000000 00000000 00000000
80000006 00000000 00000000 04006040 00000000
80000007 00000000 00000000 00000000 00000000
80000008 00003024 00000000 00000000 00000000
Doesn't make much sense to me either. But the important line is the one highlighted. Don't ask me anything about assembly language. I couldn't even figure out how to do this on my Commodore 64.

According to the CPU ID specification, an EAX input of 0x80000001 will set bit 29 of the EDX output if long mode is available -- in other words, if your processor is 64-bit capable. The EDX output is 0x20000000, which in binary is [ 0010 0000 0000 0000 0000 0000 0000 0000 ]. Counting from zero at the right towards the left, yup, that's bit 29 all right.

8.7.09

Am I 64-bit ready?

"You will never come up against a greater adversary than your own potential." -- Star Trek: The Next Generation 'Evolution'

I recently had to determine if a server running SUSE Linux had 64-bit processors or not. I did the usual stuff -- check the machine specs, which just said Xeon processor without explicitly stating 64-bit, then checked the kernel version, which listed itself as running on i686 rather than x86_64.

There had to be some way of either getting the specific processor model or some information about the hardware that would tell me for sure. After much Googling and gnashing of teeth, I found it.

At your command line enter cat /proc/cpuinfo and this will dump information for each core of each physical processor. The line to look at is "flags". As an example, the flags for my desktop Intel Pentium 4 list these:

fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe lm constant_tsc pebs bts pni dtes64 monitor ds_cpl cid cx16 xtpr lahf_lm

The "lm" flag I've highlighted stands for "long mode" as basically means that the processor is 64-bit. The complete set of flags is included in the cpufeature.h file in the Linux kernel headers.

6.7.09

A few things to get started

"The beautiful thing about learning is nobody can take it away from you." -- B. B. King

I am hopefully going to use this blog to share the occasional golden nuggets of information I come across during my IT escapades. May times I find that I have to do an awful lot of research for a particular issue, and then think to myself, Wouldn't it be nice to have this all compiled neatly together so that it's easy to find again? Not to mention someone else might need it...

Let's be honest. One thing the IT world isn't necessarily good at is documentation, unless you have a large department with loads of resources at your disposal. Granted there are good resources out there, but sometimes you either have an obscure problem or you have to get things from multiple sources and put them together to get all of the information you need. Hopefully I can put all of this in one place as I go, but we'll see how things work out. Sometimes the vision you start with isn't as clear as you think.

As I work in a very heterogeneous environment I come across some unique problems, particularly getting Windows and Linux to play nicely together. I won't tip my hand as to who my favourite is yet, suffice to say that one of them is more work but makes a lot more sense, whereas the other wants you to trust that they'll do things for you.

We'll see what is to come.