From owner-freebsd-stable@FreeBSD.ORG Fri Aug 27 20:16:14 2010 Return-Path: Delivered-To: freebsd-stable@FreeBSD.org Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by hub.freebsd.org (Postfix) with ESMTP id 3261D1065674; Fri, 27 Aug 2010 20:16:14 +0000 (UTC) (envelope-from jkim@FreeBSD.org) From: Jung-uk Kim To: Andriy Gapon Date: Fri, 27 Aug 2010 16:15:55 -0400 User-Agent: KMail/1.6.2 References: <201007141414.o6EEEUx9014690@lurza.secnetix.de> <201008271536.08773.jkim@FreeBSD.org> <4C781640.8010909@icyb.net.ua> In-Reply-To: <4C781640.8010909@icyb.net.ua> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201008271615.58056.jkim@FreeBSD.org> Cc: freebsd-stable@FreeBSD.org Subject: Re: 8.1-PRERELEASE: CPU packages not detected correctly X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Aug 2010 20:16:15 -0000 On Friday 27 August 2010 03:47 pm, Andriy Gapon wrote: > on 27/08/2010 22:36 Jung-uk Kim said the following: > > Now, back to my original question. My point was, we should never > > trust any CPUIDs on emulated CPU if they are translated. What > > should happen if you have four physical cores and you "assign" > > just one for VirtualBox, for example? What should we "announce" > > if you are emulating two cores on UP host? How do we know > > whether it is "the" real BSP or not? Is it really bound to a > > CPU? Is "CPUID leaf 11" emulated properly? If not, is it an > > emulator bug or a guest OS bug? Do we really care about "physical > > topology" in these cases? IMHO, the answer is no, we don't, and > > we should say "all cores are independent". If anyone really > > cares and wants prettier printing, we may say "N virtual cores", > > though. > > Thanks a lot for the rest of the info that I snipped, very > interesting and useful! > > To this issue - I'd say let the developers of virtual machines > worry that their machines look like real hardware, not us. > More specifically, in this thread we saw that current FreeBSD code > (without the patch) and Intel's code detect the same topology and > that topology looks reasonable for the person who started the > thread. With the patch though, detected topology looks different. > So I'd rather not worry about the general case of virtual machines > right now. Let's first see more evidence of whether we should trust > them or not. I quickly looked over Xen sources. It seems the CPUID instruction is translated by this code: http://lxr.xensource.com/lxr/source/tools/libxc/xc_cpuid_x86.c For HVM case, this is how the CPUID_HTT_CORES is set: 185 case 0x00000001: 186 /* 187 * EBX[23:16] is Maximum Logical Processors Per Package. 188 * Update to reflect vLAPIC_ID = vCPU_ID * 2. 189 */ 190 regs[1] = (regs[1] & 0x0000ffffu) | ((regs[1] & 0x007f0000u) << 1); But CPUID 0x0b is not handled and falls here: 265 default: 266 regs[0] = regs[1] = regs[2] = regs[3] = 0; 267 break; I am not a Xen developer, so please don't shoot me. ;-) Jung-uk Kim