From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cyrill Gorcunov Subject: Re: [PATCH 1/2] kvm tools: set the HYPERVISOR flag in cpuid Date: Wed, 20 Jun 2012 11:37:39 +0400 Message-ID: <20120620073739.GA1950@moon> References: <1339760057-17969-1-git-send-email-levinsasha928@gmail.com> <20120615113846.GB2464@moon> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Sasha Levin , mingo@elte.hu, asias.hejun@gmail.com, kvm@vger.kernel.org To: Pekka Enberg Return-path: Received: from mail-lb0-f174.google.com ([209.85.217.174]:43964 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753275Ab2FTHho (ORCPT ); Wed, 20 Jun 2012 03:37:44 -0400 Received: by lbbgm6 with SMTP id gm6so224532lbb.19 for ; Wed, 20 Jun 2012 00:37:42 -0700 (PDT) Content-Disposition: inline In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Jun 20, 2012 at 10:23:06AM +0300, Pekka Enberg wrote: > On Fri, 15 Jun 2012, Cyrill Gorcunov wrote: > > > On Fri, Jun 15, 2012 at 01:34:16PM +0200, Sasha Levin wrote: > > > We need to set the HYPERVISOR flag to let the kernel know we're running > > > under a hypervisor. > > > > > > This makes the kernel enable all sorts of para-virtualization options > > > such as kvm-clock. > > > > > > Signed-off-by: Sasha Levin > > > > OK, looks good, but please Sasha, add a comment into the code > > itself about the bitflag enabled (or maybe Pekka would add at > > merge time). > > Sasha? I think it should be something like below Cyrill --- From: Sasha Levin Subject: [PATCH] kvm tools: set the HYPERVISOR flag in cpuid We need to set the HYPERVISOR flag to let the kernel know we're running under a hypervisor. This makes the kernel enable all sorts of para-virtualization options such as kvm-clock. Signed-off-by: Sasha Levin [gorcunov@: Add comments on bits] Signed-off-by: Cyrill Gorcunov --- tools/kvm/x86/cpuid.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) Index: linux-2.6.git/tools/kvm/x86/cpuid.c =================================================================== --- linux-2.6.git.orig/tools/kvm/x86/cpuid.c +++ linux-2.6.git/tools/kvm/x86/cpuid.c @@ -21,8 +21,13 @@ static void filter_cpuid(struct kvm_cpui struct kvm_cpuid_entry2 *entry = &kvm_cpuid->entries[i]; switch (entry->function) { + case 1: + /* Set X86_FEATURE_HYPERVISOR */ + if (entry->index == 0) + entry->ecx |= (1 << 31); + break; case 6: - /* Clear presence of IA32_ENERGY_PERF_BIAS */ + /* Clear X86_FEATURE_EPB */ entry->ecx = entry->ecx & ~(1 << 3); break; case CPUID_FUNC_PERFMON: