From owner-freebsd-questions@FreeBSD.ORG Thu Mar 17 22:15:13 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C3CEB106564A for ; Thu, 17 Mar 2011 22:15:13 +0000 (UTC) (envelope-from dteske@vicor.com) Received: from postoffice.vicor.com (postoffice.vicor.com [69.26.56.53]) by mx1.freebsd.org (Postfix) with ESMTP id A715C8FC1E for ; Thu, 17 Mar 2011 22:15:13 +0000 (UTC) Received: from [192.82.228.128] (port=58849) by postoffice.vicor.com with esmtpsa (SSLv3:AES256-SHA:256) (Exim 4.74) (envelope-from ) id 1Q0LTa-0008Ug-N3; Thu, 17 Mar 2011 15:15:28 -0700 From: Devin Teske To: Tait In-Reply-To: <20110317213336.GF10069@ece.pdx.edu> References: <20110317213336.GF10069@ece.pdx.edu> Organization: VICOR, Inc. Date: Thu, 17 Mar 2011 22:14:54 +0000 Message-ID: <1300400094.47040.53.camel@dt.vicor.com> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 X-Scan-Signature: 272b9303b28efa3124132325680605ff X-Scan-Host: postoffice.vicor.com Content-Type: text/plain; charset="cp1252" Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-questions@freebsd.org Subject: Re: How to tell whether CPU supports x64? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Mar 2011 22:15:13 -0000 On Thu, 2011-03-17 at 14:33 -0700, Tait wrote: > I have a remote server, and I'd like to know if it will support > 64-bit instructions. I wrote this for the job (please, suggestions/comments very welcome): ############################################################ BEGIN FILE /* -*- tab-width: 4 -*- ;; Emacs */ /* vi: set tabstop=4 :: Vi/ViM */ /* Devin Teske (c)2010, July 26, 11:42:38. All Rights Reserved. */ /* system includes */ #include /* printf(3) */ #include /* EXIT_SUCCESS exit(3) */ #include /* strncmp(3) */ #include /* u_int/register_t (for machine/cpufunc.h) */ #include /* read_e/rflags() write_e/rflags() * do_cpuid() */ #include /* PSL_ID */ #include /* AMDID_LM */ /* Preprocessor Macros */ #ifndef AMDID_LM #define AMDID_LM 0x20000000 #endif int main (int argc, char *argv[]) { int has_lm = 0; char *cpu_vendor; int vendor[3]; #ifdef __amd64__ register_t rflags; #else u_int eflags; #endif u_int regs[4]; /* Check for presence of "cpuid". */ #ifdef __amd64__ rflags = read_rflags(); write_rflags(rflags ^ PSL_ID); if (((rflags ^ read_rflags()) & PSL_ID) != 0) #else eflags = read_eflags(); write_eflags(eflags ^ PSL_ID); if (((eflags ^ read_eflags()) & PSL_ID) != 0) #endif { /* Fetch the vendor string. */ do_cpuid(0, regs); vendor[0] = regs[1]; vendor[1] = regs[3]; vendor[2] = regs[2]; cpu_vendor = (char *)vendor; /* check for vendors that support AMD features. */ if (strncmp(cpu_vendor, "GenuineIntel", 12) == 0 || strncmp(cpu_vendor, "AuthenticAMD", 12) == 0) { /* Has to support AMD features. */ do_cpuid(0x80000000, regs); has_lm = (regs[3] & AMDID_LM); } } printf("x86_64 support: %s\n", has_lm ? "YES" : "NO" ); exit(EXIT_SUCCESS); } ############################################################ END FILE Save the text above into a file named "x86_64.c" and then execute "make x86_64" without arguments (or, if you prefer to have a static binary, instead execute "cc -static -Wall -O -pipe -I. x86_64.c -o x86_64". After you've compiled the utility, execute "./x86_64" and the results will be either: x86_64 support: YES or x86_64 support: NO -- Devin (full sig at bottom) > Is there some way I can tell? It's running 32-bit > FreeBSD right now. > > >From dmesg.boot: > Timecounter "i8254" frequency 1193182 Hz quality 0 > CPU: Intel(R) Xeon(TM) CPU 2.40GHz (2387.76-MHz 686-class CPU) > Origin = "GenuineIntel" Id = 0xf29 Stepping = 9 > Features=0xbfebfbff > Features2=0x4400> > Logical CPUs per core: 2 > real memory = 1073676288 (1023 MB) > avail memory = 1041502208 (993 MB) > ACPI APIC Table: > FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs > cpu0 (BSP): APIC ID: 0 > cpu1 (AP): APIC ID: 1 > > I've had no luck trying to search for the id/stepping. Would the > feature list show x64 support? > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" -- Cheers, Devin Teske -> FUN STUFF <- -----BEGIN GEEK CODE BLOCK----- Version 3.12 GAT/CS/B/CC/E/IT/MC/M/MU/P/S/TW d+(++) s: a- C+++@$ UB++++$ P++++@$ L ++++$ E- W+++ N? o? K? w@ O M++$ V- PS+>++ PE@ Y+ PGP-> t(+) 5? X(+) R(-) tv+ b +>++ DI+ D+(++) G++ e>++++ h r+++ z+++ ------END GEEK CODE BLOCK------ Learn about the "Geek Code": http://www.geekcode.com/ -> LEGAL DISCLAIMER <- This message contains confidential and proprietary information of the sender, and is intended only for the person(s) to whom it is addressed. Any use, distribution, copying or disclosure by any other person is strictly prohibited. If you have received this message in error, please notify the e-mail sender immediately, and delete the original message without making a copy. -> END TRANSMISSION <-