From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LWar1-0004sW-4E for qemu-devel@nongnu.org; Mon, 09 Feb 2009 13:27:35 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LWaqz-0004rq-JR for qemu-devel@nongnu.org; Mon, 09 Feb 2009 13:27:34 -0500 Received: from [199.232.76.173] (port=57760 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LWaqz-0004rl-EJ for qemu-devel@nongnu.org; Mon, 09 Feb 2009 13:27:33 -0500 Received: from mx2.redhat.com ([66.187.237.31]:59894) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LWaqy-00075v-Lg for qemu-devel@nongnu.org; Mon, 09 Feb 2009 13:27:33 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n19IRVFd023477 for ; Mon, 9 Feb 2009 13:27:31 -0500 Message-ID: <499075AC.6070104@redhat.com> Date: Mon, 09 Feb 2009 20:27:56 +0200 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [6567] KVM: Get all cpuid values from function 2 (Amit Shah) References: <4990548C.60706@redhat.com> <49905DE1.7070808@codemonkey.ws> In-Reply-To: <49905DE1.7070808@codemonkey.ws> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Anthony Liguori wrote: >> >> Note that if we are rescheduled on another cpu, or if another process >> calls cpuid 2 during the loop on the same cpu, this will break. > > That's unfortunate. If cpuid values can differ for individual > processors, than I don't see a great way to avoid this problem in > general. The problem is not mismatched cpus, it's hidden state within the cpu. If you look at the code, it just calls cpuid(2) repeatedly, and expects different results for the same inputs. That means the cpuid code in the cpu looks something like this: if (function == 2) { switch (hidden_function_2_state++) { // return different results } } this hidden state is of course not maintained across context switches. Only the kernel can extract this information reliably. Note that we also need save this hidden state as part of savevm. The word "unfortunate" doesn't even begin to describe it, even if one favors understatements. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.