diff mbox

[2/2] tools: lkvm - Filter out cpu vendor string

Message ID 20130528115058.538288937@openvz.org (mailing list archive)
State New, archived
Headers show

Commit Message

Cyrill Gorcunov May 28, 2013, 11:49 a.m. UTC
If cpuvendor string is not filetered in case of host
amd machine we get unhandled msr reads

| [1709265.368464] kvm: 25706: cpu6 unhandled rdmsr: 0xc0010048
| [1709265.397161] kvm: 25706: cpu7 unhandled rdmsr: 0xc0010048
| [1709265.425774] kvm: 25706: cpu8 unhandled rdmsr: 0xc0010048

thus provide own string and kernel will use generic cpu init.

Reported-by: Ingo Molnar <mingo@kernel.org>
CC: Pekka Enberg <penberg@kernel.org>
CC: Sasha Levin <sasha.levin@oracle.com>
CC: Asias He <asias@redhat.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 tools/kvm/x86/cpuid.c |    8 ++++++++
 1 file changed, 8 insertions(+)


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Pekka Enberg June 6, 2013, 12:03 p.m. UTC | #1
On Tue, May 28, 2013 at 2:49 PM, Cyrill Gorcunov <gorcunov@openvz.org> wrote:
> If cpuvendor string is not filetered in case of host
> amd machine we get unhandled msr reads
>
> | [1709265.368464] kvm: 25706: cpu6 unhandled rdmsr: 0xc0010048
> | [1709265.397161] kvm: 25706: cpu7 unhandled rdmsr: 0xc0010048
> | [1709265.425774] kvm: 25706: cpu8 unhandled rdmsr: 0xc0010048
>
> thus provide own string and kernel will use generic cpu init.
>
> Reported-by: Ingo Molnar <mingo@kernel.org>
> CC: Pekka Enberg <penberg@kernel.org>
> CC: Sasha Levin <sasha.levin@oracle.com>
> CC: Asias He <asias@redhat.com>
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> ---
>  tools/kvm/x86/cpuid.c |    8 ++++++++
>  1 file changed, 8 insertions(+)
>
> 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
> @@ -12,6 +12,7 @@
>
>  static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid)
>  {
> +       unsigned int signature[3];
>         unsigned int i;
>
>         /*
> @@ -21,6 +22,13 @@ static void filter_cpuid(struct kvm_cpui
>                 struct kvm_cpuid_entry2 *entry = &kvm_cpuid->entries[i];
>
>                 switch (entry->function) {
> +               case 0:
> +                       /* Vendor name */
> +                       memcpy(signature, "LKVMLKVMLKVM", 12);
> +                       entry->ebx = signature[0];
> +                       entry->ecx = signature[1];
> +                       entry->edx = signature[2];
> +                       break;
>                 case 1:
>                         /* Set X86_FEATURE_HYPERVISOR */
>                         if (entry->index == 0)

Ping! Is there someone out there who has a AMD box they could test this on?
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Cyrill Gorcunov June 6, 2013, 12:06 p.m. UTC | #2
On Thu, Jun 06, 2013 at 03:03:03PM +0300, Pekka Enberg wrote:
> >                         /* Set X86_FEATURE_HYPERVISOR */
> >                         if (entry->index == 0)
> 
> Ping! Is there someone out there who has a AMD box they could test this on?

I don't have it, sorry :-(
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Asias He June 6, 2013, 1:39 p.m. UTC | #3
On Thu, Jun 6, 2013 at 8:03 PM, Pekka Enberg <penberg@kernel.org> wrote:
> On Tue, May 28, 2013 at 2:49 PM, Cyrill Gorcunov <gorcunov@openvz.org> wrote:
>> If cpuvendor string is not filetered in case of host
>> amd machine we get unhandled msr reads
>>
>> | [1709265.368464] kvm: 25706: cpu6 unhandled rdmsr: 0xc0010048
>> | [1709265.397161] kvm: 25706: cpu7 unhandled rdmsr: 0xc0010048
>> | [1709265.425774] kvm: 25706: cpu8 unhandled rdmsr: 0xc0010048
>>
>> thus provide own string and kernel will use generic cpu init.
>>
>> Reported-by: Ingo Molnar <mingo@kernel.org>
>> CC: Pekka Enberg <penberg@kernel.org>
>> CC: Sasha Levin <sasha.levin@oracle.com>
>> CC: Asias He <asias@redhat.com>
>> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
>> ---
>>  tools/kvm/x86/cpuid.c |    8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> 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
>> @@ -12,6 +12,7 @@
>>
>>  static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid)
>>  {
>> +       unsigned int signature[3];
>>         unsigned int i;
>>
>>         /*
>> @@ -21,6 +22,13 @@ static void filter_cpuid(struct kvm_cpui
>>                 struct kvm_cpuid_entry2 *entry = &kvm_cpuid->entries[i];
>>
>>                 switch (entry->function) {
>> +               case 0:
>> +                       /* Vendor name */
>> +                       memcpy(signature, "LKVMLKVMLKVM", 12);
>> +                       entry->ebx = signature[0];
>> +                       entry->ecx = signature[1];
>> +                       entry->edx = signature[2];
>> +                       break;
>>                 case 1:
>>                         /* Set X86_FEATURE_HYPERVISOR */
>>                         if (entry->index == 0)
>
> Ping! Is there someone out there who has a AMD box they could test this on?

I will try to find one.

--
Asias
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Asias He June 7, 2013, 8:17 a.m. UTC | #4
On Thu, Jun 6, 2013 at 8:03 PM, Pekka Enberg <penberg@kernel.org> wrote:
> On Tue, May 28, 2013 at 2:49 PM, Cyrill Gorcunov <gorcunov@openvz.org> wrote:
>> If cpuvendor string is not filetered in case of host
>> amd machine we get unhandled msr reads
>>
>> | [1709265.368464] kvm: 25706: cpu6 unhandled rdmsr: 0xc0010048
>> | [1709265.397161] kvm: 25706: cpu7 unhandled rdmsr: 0xc0010048
>> | [1709265.425774] kvm: 25706: cpu8 unhandled rdmsr: 0xc0010048
>>
>> thus provide own string and kernel will use generic cpu init.
>>
>> Reported-by: Ingo Molnar <mingo@kernel.org>
>> CC: Pekka Enberg <penberg@kernel.org>
>> CC: Sasha Levin <sasha.levin@oracle.com>
>> CC: Asias He <asias@redhat.com>
>> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
>> ---
>>  tools/kvm/x86/cpuid.c |    8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> 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
>> @@ -12,6 +12,7 @@
>>
>>  static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid)
>>  {
>> +       unsigned int signature[3];
>>         unsigned int i;
>>
>>         /*
>> @@ -21,6 +22,13 @@ static void filter_cpuid(struct kvm_cpui
>>                 struct kvm_cpuid_entry2 *entry = &kvm_cpuid->entries[i];
>>
>>                 switch (entry->function) {
>> +               case 0:
>> +                       /* Vendor name */
>> +                       memcpy(signature, "LKVMLKVMLKVM", 12);
>> +                       entry->ebx = signature[0];
>> +                       entry->ecx = signature[1];
>> +                       entry->edx = signature[2];
>> +                       break;
>>                 case 1:
>>                         /* Set X86_FEATURE_HYPERVISOR */
>>                         if (entry->index == 0)
>
> Ping! Is there someone out there who has a AMD box they could test this on?

I tested it on AMD box.  Guest boots with this patch, guest does not
boot without it.  I am not seeing the msr warning in both cases.

> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
Asias
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pekka Enberg June 7, 2013, 11:06 a.m. UTC | #5
On 06/07/2013 11:17 AM, Asias He wrote:
>> Ping! Is there someone out there who has a AMD box they could test this on?
>
> I tested it on AMD box.  Guest boots with this patch, guest does not
> boot without it.  I am not seeing the msr warning in both cases.

That's pretty interesting. Can you please provide your /proc/cpuinfo so 
I can include it in the changelog?

			Pekka

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Asias He June 7, 2013, 12:20 p.m. UTC | #6
On Fri, Jun 07, 2013 at 02:06:40PM +0300, Pekka Enberg wrote:
> On 06/07/2013 11:17 AM, Asias He wrote:
> >>Ping! Is there someone out there who has a AMD box they could test this on?
> >
> >I tested it on AMD box.  Guest boots with this patch, guest does not
> >boot without it.  I am not seeing the msr warning in both cases.
> 
> That's pretty interesting. Can you please provide your /proc/cpuinfo
> so I can include it in the changelog?

Indeed. Here you go:

processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 21
model           : 1
model name      : AMD Opteron(TM) Processor 6274
stepping        : 2
microcode       : 0x6000626
cpu MHz         : 2200.034
cache size      : 2048 KB
physical id     : 0
siblings        : 16
core id         : 0
cpu cores       : 8
apicid          : 32
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext
fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc
extd_apicid amd_dcm aperfmperf pni pclmulqdq monitor ssse3 cx16 sse4_1
sse4_2 popcnt aes xsave avx lahf_lm cmp_legacy svm extapic cr8_legacy
abm sse4a misalignsse 3dnowprefetch osvw ibs xop skinit wdt lwp fma4
nodeid_msr topoext perfctr_core perfctr_nb arat cpb hw_pstate npt lbrv
svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists
pausefilter pfthreshold
bogomips        : 4400.06
TLB size        : 1536 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 48 bits physical, 48 bits virtual
power management: ts ttp tm 100mhzsteps hwpstate cpb
Asias He June 7, 2013, 1:39 p.m. UTC | #7
On Fri, Jun 07, 2013 at 08:20:33PM +0800, Asias He wrote:
> On Fri, Jun 07, 2013 at 02:06:40PM +0300, Pekka Enberg wrote:
> > On 06/07/2013 11:17 AM, Asias He wrote:
> > >>Ping! Is there someone out there who has a AMD box they could test this on?
> > >
> > >I tested it on AMD box.  Guest boots with this patch, guest does not
> > >boot without it.  I am not seeing the msr warning in both cases.
> > 
> > That's pretty interesting. Can you please provide your /proc/cpuinfo
> > so I can include it in the changelog?
> 
> Indeed. Here you go:
> 
> processor       : 0
> vendor_id       : AuthenticAMD
> cpu family      : 21
> model           : 1
> model name      : AMD Opteron(TM) Processor 6274
> stepping        : 2
> microcode       : 0x6000626
> cpu MHz         : 2200.034
> cache size      : 2048 KB
> physical id     : 0
> siblings        : 16
> core id         : 0
> cpu cores       : 8
> apicid          : 32
> initial apicid  : 0
> fpu             : yes
> fpu_exception   : yes
> cpuid level     : 13
> wp              : yes
> flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
> mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext
> fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc
> extd_apicid amd_dcm aperfmperf pni pclmulqdq monitor ssse3 cx16 sse4_1
> sse4_2 popcnt aes xsave avx lahf_lm cmp_legacy svm extapic cr8_legacy
> abm sse4a misalignsse 3dnowprefetch osvw ibs xop skinit wdt lwp fma4
> nodeid_msr topoext perfctr_core perfctr_nb arat cpb hw_pstate npt lbrv
> svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists
> pausefilter pfthreshold
> bogomips        : 4400.06
> TLB size        : 1536 4K pages
> clflush size    : 64
> cache_alignment : 64
> address sizes   : 48 bits physical, 48 bits virtual
> power management: ts ttp tm 100mhzsteps hwpstate cpb

And in guest:

# cat /proc/cpuinfo 
processor	: 0
vendor_id	: LKVMLKVMLKVM
cpu family	: 21
model		: 1
model name	: 15/01
stepping	: 2
cpu MHz		: 0.000
cache size	: 0 KB
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt
pdpe1gb lm nopl pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 x2apic popcnt aes
xsave avx hypervisor lahf_lm cmp_legacy svm cr8_legacy abm sse4a
misalignsse 3dnowprefetch osvw xop fma4 npt nrip_save tsc_adjust
bogomips	: 1340.41
clflush size	: 64
cache_alignment	: 64
address sizes	: 48 bits physical, 48 bits virtual
power management:
Pekka Enberg June 8, 2013, 11:48 a.m. UTC | #8
Applied, thanks a lot!
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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
@@ -12,6 +12,7 @@ 
 
 static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid)
 {
+	unsigned int signature[3];
 	unsigned int i;
 
 	/*
@@ -21,6 +22,13 @@  static void filter_cpuid(struct kvm_cpui
 		struct kvm_cpuid_entry2 *entry = &kvm_cpuid->entries[i];
 
 		switch (entry->function) {
+		case 0:
+			/* Vendor name */
+			memcpy(signature, "LKVMLKVMLKVM", 12);
+			entry->ebx = signature[0];
+			entry->ecx = signature[1];
+			entry->edx = signature[2];
+			break;
 		case 1:
 			/* Set X86_FEATURE_HYPERVISOR */
 			if (entry->index == 0)