Re: [kvm-devel] [RFC] Expose host cpuid to guest

2007-11-22 Thread Mike Lampard
On Fri, 23 Nov 2007 12:00:00 am Avi Kivity wrote:
> Mike Lampard wrote:
> > With current kvm-git (commit 51727a110220681f6f43b005d069e28c58f5d151)
> > (userspace is current to commit 6a385c9539f9746d7ff51ef34c064c3eba86448b)
> > and the userspace portion of this patch I cannot boot a 64 bit guest
> > (Mandriva 2008 x64) on my AMD x2 without -cpu host.  The guest kernel
> > says "Your CPU does not support long mode.  Use a 32bit distribution.". 
> > Works fine without the userspace portion of the patch.

erm.. sorry, seems the patch mis-applied @ my end, I just re-applied the 
userspace patch and the above problem is no longer, 1 down, 1 to go:

> >
> > With -cpu host, the 64bit kernel starts to boot then panics almost
> > immediately:
> > Code: 0f 30 e9 ed fc ff ff b8 66 00 00 00 f0 0f ab 45 08 e9 e2 fa
> > RIP [ identify_cpu+0x609/0x700
> >  RSP 
> > Kernel panic - not syncing: Attempted to kill the idle task!
> >
> > In the host log I see: cpu0 unhandled wrmsr: 0xc0010015, which might not
> > have anything to do with this patch of course :)
>
> A listing/disassembly of the function will help show where the problem is.

yes, of course.. I'll post it as soon as I can.

Thanks for the help
Mike

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC] Expose host cpuid to guest

2007-11-22 Thread Dan Kenigsberg
On Thu, Nov 22, 2007 at 11:50:14PM +1030, Mike Lampard wrote:
> On Thu, 22 Nov 2007 11:31:18 pm Dan Kenigsberg wrote:
> > On Thu, Nov 22, 2007 at 10:12:04AM +1030, Mike Lampard wrote:
> > > On Wed, 21 Nov 2007 09:36:31 pm Dan Kenigsberg wrote:
> > > > These patches expose host CPU features (that are known to work under
> > > > KVM) to guests. It makes a couple of benchmarks run faster, and
> > > > generally gives kvm's user better info on its host.
> > > >
> > > > The kernel-space patch adds KVM_GET_SUPPORTED_CPUID ioctl to obtain the
> > > > table of cpuid functions supported by the host. The user-space patch
> > > > allows fine-tuning this table from the command-line.
> > > >
> > > > I had to define struct kvm_cpuid2, KVM_SET_CPUID2 etc., because cpuid
> > > > functions are a little more complex than just function-value pairs.
> > > >
> > > > Dan.
> > >
> > > With current kvm-git (commit 51727a110220681f6f43b005d069e28c58f5d151)
> > > (userspace is current to commit 6a385c9539f9746d7ff51ef34c064c3eba86448b)
> > > and the userspace portion of this patch I cannot boot a 64 bit guest
> > > (Mandriva 2008 x64) on my AMD x2 without -cpu host.  The guest kernel
> > > says "Your CPU does not support long mode.  Use a 32bit distribution.". 
> > > Works fine without the userspace portion of the patch.
> >
> > Thanks for your report. I'm probably not exposing one(?) of AMD's x86_64
> > required cpuid features. However, I fail to reproduce this on Dual-Core
> > AMD Opteron(tm) Processor 2210 running 2.6.18-8.1.15.el5. What is your
> > host?
> 
> 64bit 2.6.23.8 on an AMD Athlon X2 4400.
> cpuid 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 rdtscp lm 
> 3dnowext 3dnow rep_good pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy 
> misalignsse
> 
> If you need further info, just yell. I didnt want to clutter up the 
> mailinglist with the full output of cpuid, but will if it helps you.

Since I'm currently out of ideas, would you try it with -no-kvm?
Since current Qemu cvs has a -cpu userspace patch, it might be
worthwhile to test that, too.

Dan.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC] Expose host cpuid to guest

2007-11-22 Thread Avi Kivity
Mike Lampard wrote:
> With current kvm-git (commit 51727a110220681f6f43b005d069e28c58f5d151) 
> (userspace is current to commit 6a385c9539f9746d7ff51ef34c064c3eba86448b) and 
> the userspace portion of this patch I cannot boot a 64 bit guest (Mandriva 
> 2008 x64) on my AMD x2 without -cpu host.  The guest kernel says "Your CPU 
> does not support long mode.  Use a 32bit distribution.".  Works fine without 
> the userspace portion of the patch.  
>
> With -cpu host, the 64bit kernel starts to boot then panics almost 
> immediately:
> Code: 0f 30 e9 ed fc ff ff b8 66 00 00 00 f0 0f ab 45 08 e9 e2 fa
> RIP [ identify_cpu+0x609/0x700
>  RSP 
> Kernel panic - not syncing: Attempted to kill the idle task!
>
> In the host log I see: cpu0 unhandled wrmsr: 0xc0010015, which might not have 
> anything to do with this patch of course :)
>   

A listing/disassembly of the function will help show where the problem is.

-- 
error compiling committee.c: too many arguments to function


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC] Expose host cpuid to guest

2007-11-22 Thread Mike Lampard
On Thu, 22 Nov 2007 11:31:18 pm Dan Kenigsberg wrote:
> On Thu, Nov 22, 2007 at 10:12:04AM +1030, Mike Lampard wrote:
> > On Wed, 21 Nov 2007 09:36:31 pm Dan Kenigsberg wrote:
> > > These patches expose host CPU features (that are known to work under
> > > KVM) to guests. It makes a couple of benchmarks run faster, and
> > > generally gives kvm's user better info on its host.
> > >
> > > The kernel-space patch adds KVM_GET_SUPPORTED_CPUID ioctl to obtain the
> > > table of cpuid functions supported by the host. The user-space patch
> > > allows fine-tuning this table from the command-line.
> > >
> > > I had to define struct kvm_cpuid2, KVM_SET_CPUID2 etc., because cpuid
> > > functions are a little more complex than just function-value pairs.
> > >
> > > Dan.
> >
> > With current kvm-git (commit 51727a110220681f6f43b005d069e28c58f5d151)
> > (userspace is current to commit 6a385c9539f9746d7ff51ef34c064c3eba86448b)
> > and the userspace portion of this patch I cannot boot a 64 bit guest
> > (Mandriva 2008 x64) on my AMD x2 without -cpu host.  The guest kernel
> > says "Your CPU does not support long mode.  Use a 32bit distribution.". 
> > Works fine without the userspace portion of the patch.
>
> Thanks for your report. I'm probably not exposing one(?) of AMD's x86_64
> required cpuid features. However, I fail to reproduce this on Dual-Core
> AMD Opteron(tm) Processor 2210 running 2.6.18-8.1.15.el5. What is your
> host?

64bit 2.6.23.8 on an AMD Athlon X2 4400.
cpuid 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 rdtscp lm 
3dnowext 3dnow rep_good pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy 
misalignsse

If you need further info, just yell. I didnt want to clutter up the 
mailinglist with the full output of cpuid, but will if it helps you.

Mike

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC] Expose host cpuid to guest

2007-11-22 Thread Dan Kenigsberg
On Thu, Nov 22, 2007 at 10:12:04AM +1030, Mike Lampard wrote:
> On Wed, 21 Nov 2007 09:36:31 pm Dan Kenigsberg wrote:
> > These patches expose host CPU features (that are known to work under
> > KVM) to guests. It makes a couple of benchmarks run faster, and
> > generally gives kvm's user better info on its host.
> >
> > The kernel-space patch adds KVM_GET_SUPPORTED_CPUID ioctl to obtain the
> > table of cpuid functions supported by the host. The user-space patch
> > allows fine-tuning this table from the command-line.
> >
> > I had to define struct kvm_cpuid2, KVM_SET_CPUID2 etc., because cpuid
> > functions are a little more complex than just function-value pairs.
> >
> > Dan.
> 
> With current kvm-git (commit 51727a110220681f6f43b005d069e28c58f5d151) 
> (userspace is current to commit 6a385c9539f9746d7ff51ef34c064c3eba86448b) and 
> the userspace portion of this patch I cannot boot a 64 bit guest (Mandriva 
> 2008 x64) on my AMD x2 without -cpu host.  The guest kernel says "Your CPU 
> does not support long mode.  Use a 32bit distribution.".  Works fine without 
> the userspace portion of the patch.  

Thanks for your report. I'm probably not exposing one(?) of AMD's x86_64
required cpuid features. However, I fail to reproduce this on Dual-Core
AMD Opteron(tm) Processor 2210 running 2.6.18-8.1.15.el5. What is your
host?

Dan.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC] Expose host cpuid to guest

2007-11-21 Thread Mike Lampard
On Wed, 21 Nov 2007 09:36:31 pm Dan Kenigsberg wrote:
> These patches expose host CPU features (that are known to work under
> KVM) to guests. It makes a couple of benchmarks run faster, and
> generally gives kvm's user better info on its host.
>
> The kernel-space patch adds KVM_GET_SUPPORTED_CPUID ioctl to obtain the
> table of cpuid functions supported by the host. The user-space patch
> allows fine-tuning this table from the command-line.
>
> I had to define struct kvm_cpuid2, KVM_SET_CPUID2 etc., because cpuid
> functions are a little more complex than just function-value pairs.
>
> Dan.

With current kvm-git (commit 51727a110220681f6f43b005d069e28c58f5d151) 
(userspace is current to commit 6a385c9539f9746d7ff51ef34c064c3eba86448b) and 
the userspace portion of this patch I cannot boot a 64 bit guest (Mandriva 
2008 x64) on my AMD x2 without -cpu host.  The guest kernel says "Your CPU 
does not support long mode.  Use a 32bit distribution.".  Works fine without 
the userspace portion of the patch.  

With -cpu host, the 64bit kernel starts to boot then panics almost 
immediately:
Code: 0f 30 e9 ed fc ff ff b8 66 00 00 00 f0 0f ab 45 08 e9 e2 fa
RIP [ identify_cpu+0x609/0x700
 RSP 
Kernel panic - not syncing: Attempted to kill the idle task!

In the host log I see: cpu0 unhandled wrmsr: 0xc0010015, which might not have 
anything to do with this patch of course :)

Mike

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC] Expose host cpuid to guest

2007-11-21 Thread Avi Kivity
Dan Kenigsberg wrote:
> On Wed, Nov 21, 2007 at 01:52:15PM +0200, Avi Kivity wrote:
>   
>> Dan Kenigsberg wrote:
>> 
>>> These patches expose host CPU features (that are known to work under
>>> KVM) to guests. It makes a couple of benchmarks run faster, and
>>> generally gives kvm's user better info on its host.
>>>
>>> The kernel-space patch adds KVM_GET_SUPPORTED_CPUID ioctl to obtain the
>>> table of cpuid functions supported by the host. The user-space patch
>>> allows fine-tuning this table from the command-line.
>>>
>>> I had to define struct kvm_cpuid2, KVM_SET_CPUID2 etc., because cpuid
>>> functions are a little more complex than just function-value pairs.
>>>   commit e9775d0a16097cfb71779cb2fb985fb3e5040dc8
>>> Author: Dan Kenigsberg <[EMAIL PROTECTED]>
>>> Date:   Sun Nov 18 13:55:26 2007 +0200
>>>
>>> Support -cpu host option. Negotiate cpuid table with userspace.
>>>   
>
> I believe the attached two patches apply all your comments.
>
>   
Applied kernel patch.  Will wait with userspace until next qemu merge 
(which is pending qemu-cvs regressions).

-- 
error compiling committee.c: too many arguments to function


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC] Expose host cpuid to guest

2007-11-21 Thread Dan Kenigsberg
On Wed, Nov 21, 2007 at 01:52:15PM +0200, Avi Kivity wrote:
> Dan Kenigsberg wrote:
>> These patches expose host CPU features (that are known to work under
>> KVM) to guests. It makes a couple of benchmarks run faster, and
>> generally gives kvm's user better info on its host.
>>
>> The kernel-space patch adds KVM_GET_SUPPORTED_CPUID ioctl to obtain the
>> table of cpuid functions supported by the host. The user-space patch
>> allows fine-tuning this table from the command-line.
>>
>> I had to define struct kvm_cpuid2, KVM_SET_CPUID2 etc., because cpuid
>> functions are a little more complex than just function-value pairs.
>>   commit e9775d0a16097cfb71779cb2fb985fb3e5040dc8
>> Author: Dan Kenigsberg <[EMAIL PROTECTED]>
>> Date:   Sun Nov 18 13:55:26 2007 +0200
>>
>> Support -cpu host option. Negotiate cpuid table with userspace.

I believe the attached two patches apply all your comments.

Dan.
commit 53c12a2602642ed01488ae382d23d350e5464a71
Author: Dan Kenigsberg <[EMAIL PROTECTED]>
Date:   Wed Nov 21 16:03:55 2007 +0200

Expose host CPU features to guests. a new KVM_GET_SUPPORTED_CPUID ioctl is 
used
to obtain the table of cpuid functions supported by the host & kvm. The
user-space may fine-tune this table and use the KVM_SET_CPUID2 ioctl to set 
the
table seen by guests.

This patch exposes CPU features that are hitherto hidden (e.g. SSE, cache
structure) and makes a couple of benchmarks faster.

The table of cpuid entries and kvm_emulate_cpuid() had to be changed because
for a couple of cpuid functions, edx - and not only eax - is significant.
Worse, function 2 is stateful; its value may change between consequtive 
calls.

Signed-off-by: Dan Kenigsberg <[EMAIL PROTECTED]>

diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index b42c9d4..c14967a 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -626,6 +626,7 @@ int kvm_dev_ioctl_check_extension(long ext)
case KVM_CAP_MMU_SHADOW_CACHE_CONTROL:
case KVM_CAP_USER_MEMORY:
case KVM_CAP_SET_TSS_ADDR:
+   case KVM_CAP_EXT_CPUID:
r = 1;
break;
default:
@@ -688,13 +689,18 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
kvm_put_guest_fpu(vcpu);
 }
 
+static int is_efer_nx(void) {
+   u64 efer;
+
+   rdmsrl(MSR_EFER, efer);
+   return efer & EFER_NX;
+}
+
 static void cpuid_fix_nx_cap(struct kvm_vcpu *vcpu)
 {
-   u64 efer;
int i;
-   struct kvm_cpuid_entry *e, *entry;
+   struct kvm_cpuid_entry2 *e, *entry;
 
-   rdmsrl(MSR_EFER, efer);
entry = NULL;
for (i = 0; i < vcpu->cpuid_nent; ++i) {
e = &vcpu->cpuid_entries[i];
@@ -703,16 +709,56 @@ static void cpuid_fix_nx_cap(struct kvm_vcpu *vcpu)
break;
}
}
-   if (entry && (entry->edx & (1 << 20)) && !(efer & EFER_NX)) {
+   if (entry && (entry->edx & (1 << 20)) && !is_efer_nx()) {
entry->edx &= ~(1 << 20);
printk(KERN_INFO "kvm: guest NX capability removed\n");
}
 }
 
+/* when an old userspace process fills a new kernel module */
 static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,
struct kvm_cpuid *cpuid,
struct kvm_cpuid_entry __user *entries)
 {
+   int r, i;
+   struct kvm_cpuid_entry *cpuid_entries;
+
+   r = -E2BIG;
+   if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
+   goto out;
+   r = -ENOMEM;
+   cpuid_entries = vmalloc(sizeof(struct kvm_cpuid_entry) * cpuid->nent);
+   if (!cpuid_entries)
+   goto out;
+   r = -EFAULT;
+   if (copy_from_user(cpuid_entries, entries,
+  cpuid->nent * sizeof(struct kvm_cpuid_entry)))
+   goto out_free;
+   for (i = 0; i < cpuid->nent; i++) {
+   vcpu->cpuid_entries[i].function = cpuid_entries[i].function;
+   vcpu->cpuid_entries[i].eax = cpuid_entries[i].eax;
+   vcpu->cpuid_entries[i].ebx = cpuid_entries[i].ebx;
+   vcpu->cpuid_entries[i].ecx = cpuid_entries[i].ecx;
+   vcpu->cpuid_entries[i].edx = cpuid_entries[i].edx;
+   vcpu->cpuid_entries[i].index = 0;
+   vcpu->cpuid_entries[i].flags = 0;
+   vcpu->cpuid_entries[i].padding[0] = 0;
+   vcpu->cpuid_entries[i].padding[1] = 0;
+   vcpu->cpuid_entries[i].padding[2] = 0;
+   }
+   vcpu->cpuid_nent = cpuid->nent;
+   r = 0;
+
+out_free:
+   vfree(cpuid_entries);
+out:
+   return r;
+}
+
+static int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
+   struct kvm_cpuid2 *cpuid,
+   struct kvm_cpuid_entry2 __user *entries)
+{
int r;
 
r = -E2BIG;
@@ -720,7 +766,7 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,
g

Re: [kvm-devel] [RFC] Expose host cpuid to guest

2007-11-21 Thread Avi Kivity
Dan Kenigsberg wrote:
> These patches expose host CPU features (that are known to work under
> KVM) to guests. It makes a couple of benchmarks run faster, and
> generally gives kvm's user better info on its host.
>
> The kernel-space patch adds KVM_GET_SUPPORTED_CPUID ioctl to obtain the
> table of cpuid functions supported by the host. The user-space patch
> allows fine-tuning this table from the command-line.
>
> I had to define struct kvm_cpuid2, KVM_SET_CPUID2 etc., because cpuid
> functions are a little more complex than just function-value pairs.
>   
> commit e9775d0a16097cfb71779cb2fb985fb3e5040dc8
> Author: Dan Kenigsberg <[EMAIL PROTECTED]>
> Date:   Sun Nov 18 13:55:26 2007 +0200
>
> Support -cpu host option. Negotiate cpuid table with userspace.
>   

The kernel doesn't have a -cpu option.  The description needs to be more 
descriptive (motivation, special cases in cpuid).

> 
>  
> +static int is_efer_nx(void) {
> + u64 efer;
>   

blank line

> + rdmsrl(MSR_EFER, efer);
> + return efer & EFER_NX;
> +}
> +
>   

>  
> +static int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
> + struct kvm_cpuid2 *cpuid,
> + struct kvm_cpuid_entry2 __user *entries)
> +{
> + int r;
> +
> + r = -E2BIG;
> + if (cpuid->nent < vcpu->cpuid_nent)
> + goto out;
> + r = -EFAULT;
> + if (copy_to_user(entries, &vcpu->cpuid_entries,
> +vcpu->cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
> + goto out;
> + return 0;
> +
> +out:
> +cpuid->nent = vcpu->cpuid_nent;
>   

whitespace damage here

> + return r;
> +
> +static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
> +  u32 index, int *nent, int maxnent)
> +{
> + const __u32 kvm_supported_word0_x86_features = bit(X86_FEATURE_FPU) |
> + bit(X86_FEATURE_VME) | bit(X86_FEATURE_DE) |
> + bit(X86_FEATURE_PSE) | bit(X86_FEATURE_TSC) |
> + bit(X86_FEATURE_MSR) | bit(X86_FEATURE_PAE) |
> + bit(X86_FEATURE_CX8) | bit(X86_FEATURE_APIC) |
> + bit(X86_FEATURE_SEP) | bit(X86_FEATURE_PGE) |
> + bit(X86_FEATURE_CMOV) | bit(X86_FEATURE_PSE36) |
> + bit(X86_FEATURE_CLFLSH) | bit(X86_FEATURE_MMX) |
> + bit(X86_FEATURE_FXSR) | bit(X86_FEATURE_XMM) |
> + bit(X86_FEATURE_XMM2) | bit(X86_FEATURE_SELFSNOOP);
>   

u32, not __u32.

> + const __u32 kvm_supported_word1_x86_features = bit(X86_FEATURE_FPU) |
> + bit(X86_FEATURE_VME) | bit(X86_FEATURE_DE) |
> + bit(X86_FEATURE_PSE) | bit(X86_FEATURE_TSC) |
> + bit(X86_FEATURE_MSR) | bit(X86_FEATURE_PAE) |
> + bit(X86_FEATURE_CX8) | bit(X86_FEATURE_APIC) |
> + bit(X86_FEATURE_PGE) |
> + bit(X86_FEATURE_CMOV) | bit(X86_FEATURE_PSE36) |
> + bit(X86_FEATURE_MMX) | bit(X86_FEATURE_FXSR) |
> + bit(X86_FEATURE_SYSCALL) |
> + (bit(X86_FEATURE_NX) && is_efer_nx()) |
> +#ifdef CONFIG_X86_64
> + bit(X86_FEATURE_LM) |
> +#endif
> + /* TODO: make sure the following features are
> +  * safe for SVM guests */
> + bit(X86_FEATURE_MMXEXT) |
> + bit(X86_FEATURE_RDTSCP) | bit(X86_FEATURE_3DNOWEXT) |
> + bit(X86_FEATURE_3DNOW);
>   

rdtscp isn't,   I believe.

> + const __u32 kvm_supported_word3_x86_features =
> + bit(X86_FEATURE_XMM3) | bit(X86_FEATURE_CX16);
> + const __u32 kvm_supported_word6_x86_features =
> + bit(X86_FEATURE_LAHF_LM) | bit(X86_FEATURE_CMP_LEGACY);
> +
> + /* all func 2 cpuid_count() should be called on the same cpu */
> + if (function==2)
> + get_cpu();
>   

Avoid the special case, just to it unconditionally.

> + do_cpuid_1_ent(entry, function, index);
> + ++*nent;
> +
> + switch (function) {
> + case 0:
> + entry->eax = min(entry->eax, (u32)0xb);
> + break;
> + case 1:
> + entry->edx &= kvm_supported_word0_x86_features;
> + entry->ecx &= kvm_supported_word3_x86_features;
> + break;
> + /* function 2 entries are STATEFUL. That is, repeated cpuid commands
> +  * may return different values. This forces us to get_cpu() before
> +  * issuing the first command, and also to emulate this annoying behavior
> +  * in kvm_emulate_cpuid() using KVM_CPUID_FLAG_STATE_READ_NEXT */
> + case 2: {
> + int t, times = entry->eax & 0xff;
>   

Indent this normally relative to other entries.

> +
> + entry->flags |= KVM_CPUID_FLAG_STATEFUL_FUNC;
> + for (t = 1; t < times && *nent < maxnent; ++t) {
> + do_cpuid_1_ent(&entry[t], function, 0);
> + entry[t].flags |= KVM_CPUID_FLAG_STATEFUL_FUNC;
> +  

Re: [kvm-devel] [RFC] Expose host cpuid to guest

2007-11-21 Thread Amit Shah
* Dan Kenigsberg wrote:
> These patches expose host CPU features (that are known to work under
> KVM) to guests. It makes a couple of benchmarks run faster, and
> generally gives kvm's user better info on its host.
>
> The kernel-space patch adds KVM_GET_SUPPORTED_CPUID ioctl to obtain the
> table of cpuid functions supported by the host. The user-space patch
> allows fine-tuning this table from the command-line.
>
> I had to define struct kvm_cpuid2, KVM_SET_CPUID2 etc., because cpuid
> functions are a little more complex than just function-value pairs.
>
> Dan.

Hey Dan, were those amd-specific things sorted out?

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel