* [Qemu-devel] [PATCH 1/8] target-i386: kvm_cpu_fill_host(): Kill unused code
2013-11-24 19:55 [Qemu-devel] [PATCH 0/8] target-i386: Simplify kvm_cpu_fill_host() and kvm_check_features_against_host() Eduardo Habkost
@ 2013-11-24 19:55 ` Eduardo Habkost
2013-11-24 19:55 ` [Qemu-devel] [PATCH 2/8] target-i386: kvm_cpu_fill_host(): No need to check level Eduardo Habkost
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Eduardo Habkost @ 2013-11-24 19:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Igor Mammedov, Andreas Färber
Those host_cpuid() calls are useless. They are leftovers from when the
old code using host_cpuid() was removed.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 864c80e..5796c6d 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1181,12 +1181,10 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
/* Call Centaur's CPUID instruction. */
if (!strcmp(x86_cpu_def->vendor, CPUID_VENDOR_VIA)) {
- host_cpuid(0xC0000000, 0, &eax, &ebx, &ecx, &edx);
eax = kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
if (eax >= 0xC0000001) {
/* Support VIA max extended level */
x86_cpu_def->xlevel2 = eax;
- host_cpuid(0xC0000001, 0, &eax, &ebx, &ecx, &edx);
x86_cpu_def->features[FEAT_C000_0001_EDX] =
kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 2/8] target-i386: kvm_cpu_fill_host(): No need to check level
2013-11-24 19:55 [Qemu-devel] [PATCH 0/8] target-i386: Simplify kvm_cpu_fill_host() and kvm_check_features_against_host() Eduardo Habkost
2013-11-24 19:55 ` [Qemu-devel] [PATCH 1/8] target-i386: kvm_cpu_fill_host(): Kill unused code Eduardo Habkost
@ 2013-11-24 19:55 ` Eduardo Habkost
2013-11-24 19:55 ` [Qemu-devel] [PATCH 3/8] target-i386: kvm_cpu_fill_host(): No need to check CPU vendor Eduardo Habkost
` (6 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Eduardo Habkost @ 2013-11-24 19:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Igor Mammedov, Andreas Färber
There's no need to check level (CPUID[0].EAX) before calling
kvm_arch_get_supported_cpuid(s, 0x7, 0, R_EBX), because:
* The kernel won't return any entry for CPUID 7 if CPUID[0].EAX is < 7
(See kvm_dev_ioctl_get_supported_cpuid() on the kernel code);
* kvm_arch_get_supported_cpuid() will return 0 if no entry is returned
by the kernel for the requested leaf.
This will simplify the kvm_cpu_fill_host() code a little.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 5796c6d..f659a3b 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1164,12 +1164,8 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
x86_cpu_def->features[FEAT_1_ECX] =
kvm_arch_get_supported_cpuid(s, 0x1, 0, R_ECX);
- if (x86_cpu_def->level >= 7) {
- x86_cpu_def->features[FEAT_7_0_EBX] =
- kvm_arch_get_supported_cpuid(s, 0x7, 0, R_EBX);
- } else {
- x86_cpu_def->features[FEAT_7_0_EBX] = 0;
- }
+ x86_cpu_def->features[FEAT_7_0_EBX] =
+ kvm_arch_get_supported_cpuid(s, 0x7, 0, R_EBX);
x86_cpu_def->xlevel = kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);
x86_cpu_def->features[FEAT_8000_0001_EDX] =
--
1.8.3.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 3/8] target-i386: kvm_cpu_fill_host(): No need to check CPU vendor
2013-11-24 19:55 [Qemu-devel] [PATCH 0/8] target-i386: Simplify kvm_cpu_fill_host() and kvm_check_features_against_host() Eduardo Habkost
2013-11-24 19:55 ` [Qemu-devel] [PATCH 1/8] target-i386: kvm_cpu_fill_host(): Kill unused code Eduardo Habkost
2013-11-24 19:55 ` [Qemu-devel] [PATCH 2/8] target-i386: kvm_cpu_fill_host(): No need to check level Eduardo Habkost
@ 2013-11-24 19:55 ` Eduardo Habkost
2013-11-24 19:55 ` [Qemu-devel] [PATCH 4/8] target-i386: kvm_cpu_fill_host(): No need to check xlevel2 Eduardo Habkost
` (5 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Eduardo Habkost @ 2013-11-24 19:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Igor Mammedov, Andreas Färber
There's no need to check CPU vendor before calling
kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX), because:
* The kernel won't return any entry for 0xC0000000 if host CPU vendor
is not Centaur (See kvm_dev_ioctl_get_supported_cpuid() on the kernel
code);
* kvm_arch_get_supported_cpuid() will return 0 if no entry is returned
by the kernel for the requested leaf.
This will simplify the kvm_cpu_fill_host() code a little.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index f659a3b..41726f8 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1176,14 +1176,12 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
cpu_x86_fill_model_id(x86_cpu_def->model_id);
/* Call Centaur's CPUID instruction. */
- if (!strcmp(x86_cpu_def->vendor, CPUID_VENDOR_VIA)) {
- eax = kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
- if (eax >= 0xC0000001) {
- /* Support VIA max extended level */
- x86_cpu_def->xlevel2 = eax;
- x86_cpu_def->features[FEAT_C000_0001_EDX] =
- kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);
- }
+ eax = kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
+ if (eax >= 0xC0000001) {
+ /* Support VIA max extended level */
+ x86_cpu_def->xlevel2 = eax;
+ x86_cpu_def->features[FEAT_C000_0001_EDX] =
+ kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);
}
/* Other KVM-specific feature fields: */
--
1.8.3.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 4/8] target-i386: kvm_cpu_fill_host(): No need to check xlevel2
2013-11-24 19:55 [Qemu-devel] [PATCH 0/8] target-i386: Simplify kvm_cpu_fill_host() and kvm_check_features_against_host() Eduardo Habkost
` (2 preceding siblings ...)
2013-11-24 19:55 ` [Qemu-devel] [PATCH 3/8] target-i386: kvm_cpu_fill_host(): No need to check CPU vendor Eduardo Habkost
@ 2013-11-24 19:55 ` Eduardo Habkost
2014-01-20 21:10 ` Andreas Färber
2013-11-24 19:55 ` [Qemu-devel] [PATCH 5/8] target-i386: kvm_cpu_fill_host(): Set all feature words at end of function Eduardo Habkost
` (4 subsequent siblings)
8 siblings, 1 reply; 11+ messages in thread
From: Eduardo Habkost @ 2013-11-24 19:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Igor Mammedov, Andreas Färber
There's no need to check CPU xlevel2 before calling
kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX), because:
* The kernel won't return any entry for 0xC0000000 if host CPU vendor
is not Centaur (See kvm_dev_ioctl_get_supported_cpuid() on the kernel
code)
* Similarly, the kernel won't return any entry for 0xC0000001 if
CPUID[0xC0000000].EAX is < 0xC0000001
* kvm_arch_get_supported_cpuid() will return 0 if no entry is returned
by the kernel for the requested leaf
For similar reasons, we can simply set x86_cpu_def->xlevel2 directly
instead of making it conditional, because it will be set to 0 CPU vendor
is not Centaur.
This will simplify the kvm_cpu_fill_host() code a little.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 41726f8..9731493 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1176,13 +1176,11 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
cpu_x86_fill_model_id(x86_cpu_def->model_id);
/* Call Centaur's CPUID instruction. */
- eax = kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
- if (eax >= 0xC0000001) {
- /* Support VIA max extended level */
- x86_cpu_def->xlevel2 = eax;
- x86_cpu_def->features[FEAT_C000_0001_EDX] =
- kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);
- }
+ x86_cpu_def->xlevel2 =
+ kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
+ /* Support VIA max extended level */
+ x86_cpu_def->features[FEAT_C000_0001_EDX] =
+ kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);
/* Other KVM-specific feature fields: */
x86_cpu_def->features[FEAT_SVM] =
--
1.8.3.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 4/8] target-i386: kvm_cpu_fill_host(): No need to check xlevel2
2013-11-24 19:55 ` [Qemu-devel] [PATCH 4/8] target-i386: kvm_cpu_fill_host(): No need to check xlevel2 Eduardo Habkost
@ 2014-01-20 21:10 ` Andreas Färber
0 siblings, 0 replies; 11+ messages in thread
From: Andreas Färber @ 2014-01-20 21:10 UTC (permalink / raw)
To: Eduardo Habkost, qemu-devel; +Cc: Igor Mammedov
Am 24.11.2013 20:55, schrieb Eduardo Habkost:
> There's no need to check CPU xlevel2 before calling
> kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX), because:
>
> * The kernel won't return any entry for 0xC0000000 if host CPU vendor
> is not Centaur (See kvm_dev_ioctl_get_supported_cpuid() on the kernel
> code)
> * Similarly, the kernel won't return any entry for 0xC0000001 if
> CPUID[0xC0000000].EAX is < 0xC0000001
> * kvm_arch_get_supported_cpuid() will return 0 if no entry is returned
> by the kernel for the requested leaf
>
> For similar reasons, we can simply set x86_cpu_def->xlevel2 directly
> instead of making it conditional, because it will be set to 0 CPU vendor
> is not Centaur.
"... if CPU vendor is not ..." I guess. :)
>
> This will simplify the kvm_cpu_fill_host() code a little.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> target-i386/cpu.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 41726f8..9731493 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -1176,13 +1176,11 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
> cpu_x86_fill_model_id(x86_cpu_def->model_id);
>
> /* Call Centaur's CPUID instruction. */
> - eax = kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
> - if (eax >= 0xC0000001) {
> - /* Support VIA max extended level */
> - x86_cpu_def->xlevel2 = eax;
> - x86_cpu_def->features[FEAT_C000_0001_EDX] =
> - kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);
> - }
> + x86_cpu_def->xlevel2 =
> + kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
> + /* Support VIA max extended level */
> + x86_cpu_def->features[FEAT_C000_0001_EDX] =
> + kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);
>
> /* Other KVM-specific feature fields: */
> x86_cpu_def->features[FEAT_SVM] =
Sounds okay otherwise.
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 5/8] target-i386: kvm_cpu_fill_host(): Set all feature words at end of function
2013-11-24 19:55 [Qemu-devel] [PATCH 0/8] target-i386: Simplify kvm_cpu_fill_host() and kvm_check_features_against_host() Eduardo Habkost
` (3 preceding siblings ...)
2013-11-24 19:55 ` [Qemu-devel] [PATCH 4/8] target-i386: kvm_cpu_fill_host(): No need to check xlevel2 Eduardo Habkost
@ 2013-11-24 19:55 ` Eduardo Habkost
2013-11-24 19:55 ` [Qemu-devel] [PATCH 6/8] target-i386: kvm_cpu_fill_host(): Fill feature words in a loop Eduardo Habkost
` (3 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Eduardo Habkost @ 2013-11-24 19:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Igor Mammedov, Andreas Färber
Reorder the code so all the code that sets x86_cpu_def->features is at
the end of the function.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 9731493..57bec6c 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1159,30 +1159,24 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
x86_cpu_def->stepping = eax & 0x0F;
x86_cpu_def->level = kvm_arch_get_supported_cpuid(s, 0x0, 0, R_EAX);
+ x86_cpu_def->xlevel = kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);
+ x86_cpu_def->xlevel2 =
+ kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
+
+ cpu_x86_fill_model_id(x86_cpu_def->model_id);
+
x86_cpu_def->features[FEAT_1_EDX] =
kvm_arch_get_supported_cpuid(s, 0x1, 0, R_EDX);
x86_cpu_def->features[FEAT_1_ECX] =
kvm_arch_get_supported_cpuid(s, 0x1, 0, R_ECX);
-
x86_cpu_def->features[FEAT_7_0_EBX] =
- kvm_arch_get_supported_cpuid(s, 0x7, 0, R_EBX);
-
- x86_cpu_def->xlevel = kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);
+ kvm_arch_get_supported_cpuid(s, 0x7, 0, R_EBX);
x86_cpu_def->features[FEAT_8000_0001_EDX] =
- kvm_arch_get_supported_cpuid(s, 0x80000001, 0, R_EDX);
+ kvm_arch_get_supported_cpuid(s, 0x80000001, 0, R_EDX);
x86_cpu_def->features[FEAT_8000_0001_ECX] =
- kvm_arch_get_supported_cpuid(s, 0x80000001, 0, R_ECX);
-
- cpu_x86_fill_model_id(x86_cpu_def->model_id);
-
- /* Call Centaur's CPUID instruction. */
- x86_cpu_def->xlevel2 =
- kvm_arch_get_supported_cpuid(s, 0xC0000000, 0, R_EAX);
- /* Support VIA max extended level */
+ kvm_arch_get_supported_cpuid(s, 0x80000001, 0, R_ECX);
x86_cpu_def->features[FEAT_C000_0001_EDX] =
kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);
-
- /* Other KVM-specific feature fields: */
x86_cpu_def->features[FEAT_SVM] =
kvm_arch_get_supported_cpuid(s, 0x8000000A, 0, R_EDX);
x86_cpu_def->features[FEAT_KVM] =
--
1.8.3.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 6/8] target-i386: kvm_cpu_fill_host(): Fill feature words in a loop
2013-11-24 19:55 [Qemu-devel] [PATCH 0/8] target-i386: Simplify kvm_cpu_fill_host() and kvm_check_features_against_host() Eduardo Habkost
` (4 preceding siblings ...)
2013-11-24 19:55 ` [Qemu-devel] [PATCH 5/8] target-i386: kvm_cpu_fill_host(): Set all feature words at end of function Eduardo Habkost
@ 2013-11-24 19:55 ` Eduardo Habkost
2013-11-24 19:55 ` [Qemu-devel] [PATCH 7/8] target-i386: kvm_check_features_against_host(): Kill feature word array Eduardo Habkost
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Eduardo Habkost @ 2013-11-24 19:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Igor Mammedov, Andreas Färber
Now that the kvm_cpu_fill_host() code is simplified, we can simply set
the feature word array using a simple loop.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 57bec6c..9fc8500 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1165,22 +1165,13 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
cpu_x86_fill_model_id(x86_cpu_def->model_id);
- x86_cpu_def->features[FEAT_1_EDX] =
- kvm_arch_get_supported_cpuid(s, 0x1, 0, R_EDX);
- x86_cpu_def->features[FEAT_1_ECX] =
- kvm_arch_get_supported_cpuid(s, 0x1, 0, R_ECX);
- x86_cpu_def->features[FEAT_7_0_EBX] =
- kvm_arch_get_supported_cpuid(s, 0x7, 0, R_EBX);
- x86_cpu_def->features[FEAT_8000_0001_EDX] =
- kvm_arch_get_supported_cpuid(s, 0x80000001, 0, R_EDX);
- x86_cpu_def->features[FEAT_8000_0001_ECX] =
- kvm_arch_get_supported_cpuid(s, 0x80000001, 0, R_ECX);
- x86_cpu_def->features[FEAT_C000_0001_EDX] =
- kvm_arch_get_supported_cpuid(s, 0xC0000001, 0, R_EDX);
- x86_cpu_def->features[FEAT_SVM] =
- kvm_arch_get_supported_cpuid(s, 0x8000000A, 0, R_EDX);
- x86_cpu_def->features[FEAT_KVM] =
- kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX);
+ FeatureWord w;
+ for (w = 0; w < FEATURE_WORDS; w++) {
+ FeatureWordInfo *wi = &feature_word_info[w];
+ x86_cpu_def->features[w] =
+ kvm_arch_get_supported_cpuid(s, wi->cpuid_eax, wi->cpuid_ecx,
+ wi->cpuid_reg);
+ }
#endif /* CONFIG_KVM */
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 7/8] target-i386: kvm_check_features_against_host(): Kill feature word array
2013-11-24 19:55 [Qemu-devel] [PATCH 0/8] target-i386: Simplify kvm_cpu_fill_host() and kvm_check_features_against_host() Eduardo Habkost
` (5 preceding siblings ...)
2013-11-24 19:55 ` [Qemu-devel] [PATCH 6/8] target-i386: kvm_cpu_fill_host(): Fill feature words in a loop Eduardo Habkost
@ 2013-11-24 19:55 ` Eduardo Habkost
2013-11-24 19:55 ` [Qemu-devel] [PATCH 8/8] target-i386: kvm_check_features_against_host(): Don't use kvm_cpu_fill_host() Eduardo Habkost
2013-12-11 16:07 ` [Qemu-devel] [PATCH 0/8] target-i386: Simplify kvm_cpu_fill_host() and kvm_check_features_against_host() Eduardo Habkost
8 siblings, 0 replies; 11+ messages in thread
From: Eduardo Habkost @ 2013-11-24 19:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Igor Mammedov, Andreas Färber
We don't need the ft[] array on kvm_check_features_against_host()
anymore, as we can simply use the feature_word_info[] array, that has
everything we need.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu.c | 41 ++++++++---------------------------------
1 file changed, 8 insertions(+), 33 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 9fc8500..6c540c6 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1204,44 +1204,19 @@ static int kvm_check_features_against_host(X86CPU *cpu)
{
CPUX86State *env = &cpu->env;
x86_def_t host_def;
- uint32_t mask;
- int rv, i;
- struct model_features_t ft[] = {
- {&env->features[FEAT_1_EDX],
- &host_def.features[FEAT_1_EDX],
- FEAT_1_EDX },
- {&env->features[FEAT_1_ECX],
- &host_def.features[FEAT_1_ECX],
- FEAT_1_ECX },
- {&env->features[FEAT_8000_0001_EDX],
- &host_def.features[FEAT_8000_0001_EDX],
- FEAT_8000_0001_EDX },
- {&env->features[FEAT_8000_0001_ECX],
- &host_def.features[FEAT_8000_0001_ECX],
- FEAT_8000_0001_ECX },
- {&env->features[FEAT_C000_0001_EDX],
- &host_def.features[FEAT_C000_0001_EDX],
- FEAT_C000_0001_EDX },
- {&env->features[FEAT_7_0_EBX],
- &host_def.features[FEAT_7_0_EBX],
- FEAT_7_0_EBX },
- {&env->features[FEAT_SVM],
- &host_def.features[FEAT_SVM],
- FEAT_SVM },
- {&env->features[FEAT_KVM],
- &host_def.features[FEAT_KVM],
- FEAT_KVM },
- };
+ int rv = 0;
+ FeatureWord w;
assert(kvm_enabled());
-
kvm_cpu_fill_host(&host_def);
- for (rv = 0, i = 0; i < ARRAY_SIZE(ft); ++i) {
- FeatureWord w = ft[i].feat_word;
+
+ for (w = 0; w < FEATURE_WORDS; w++) {
FeatureWordInfo *wi = &feature_word_info[w];
+ uint32_t guest_feat = env->features[w];
+ uint32_t host_feat = host_def.features[w];
+ uint32_t mask;
for (mask = 1; mask; mask <<= 1) {
- if (*ft[i].guest_feat & mask &&
- !(*ft[i].host_feat & mask)) {
+ if (guest_feat & mask && !(host_feat & mask)) {
unavailable_host_feature(wi, mask);
rv = 1;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH 8/8] target-i386: kvm_check_features_against_host(): Don't use kvm_cpu_fill_host()
2013-11-24 19:55 [Qemu-devel] [PATCH 0/8] target-i386: Simplify kvm_cpu_fill_host() and kvm_check_features_against_host() Eduardo Habkost
` (6 preceding siblings ...)
2013-11-24 19:55 ` [Qemu-devel] [PATCH 7/8] target-i386: kvm_check_features_against_host(): Kill feature word array Eduardo Habkost
@ 2013-11-24 19:55 ` Eduardo Habkost
2013-12-11 16:07 ` [Qemu-devel] [PATCH 0/8] target-i386: Simplify kvm_cpu_fill_host() and kvm_check_features_against_host() Eduardo Habkost
8 siblings, 0 replies; 11+ messages in thread
From: Eduardo Habkost @ 2013-11-24 19:55 UTC (permalink / raw)
To: qemu-devel; +Cc: Igor Mammedov, Andreas Färber
As now kvm_cpu_fill_host() will simply fill the x86_def_t.features array
with the results of kvm_arch_get_supported_cpuid() calls, we can simply
call kvm_arch_get_supported_cpuid() directly.
Note how kvm_check_features_against_host() and filter_features_for_kvm()
are getting very similar. Eventually they should become a single
function.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
target-i386/cpu.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 6c540c6..048d87f 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1200,20 +1200,20 @@ static int unavailable_host_feature(FeatureWordInfo *f, uint32_t mask)
*
* This function may be called only if KVM is enabled.
*/
-static int kvm_check_features_against_host(X86CPU *cpu)
+static int kvm_check_features_against_host(KVMState *s, X86CPU *cpu)
{
CPUX86State *env = &cpu->env;
- x86_def_t host_def;
int rv = 0;
FeatureWord w;
assert(kvm_enabled());
- kvm_cpu_fill_host(&host_def);
for (w = 0; w < FEATURE_WORDS; w++) {
FeatureWordInfo *wi = &feature_word_info[w];
uint32_t guest_feat = env->features[w];
- uint32_t host_feat = host_def.features[w];
+ uint32_t host_feat = kvm_arch_get_supported_cpuid(s, wi->cpuid_eax,
+ wi->cpuid_ecx,
+ wi->cpuid_reg);
uint32_t mask;
for (mask = 1; mask; mask <<= 1) {
if (guest_feat & mask && !(host_feat & mask)) {
@@ -2516,7 +2516,8 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
env->features[FEAT_8000_0001_ECX] &= TCG_EXT3_FEATURES;
env->features[FEAT_SVM] &= TCG_SVM_FEATURES;
} else {
- if (check_cpuid && kvm_check_features_against_host(cpu)
+ KVMState *s = kvm_state;
+ if (check_cpuid && kvm_check_features_against_host(s, cpu)
&& enforce_cpuid) {
error_setg(&local_err,
"Host's CPU doesn't support requested features");
--
1.8.3.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH 0/8] target-i386: Simplify kvm_cpu_fill_host() and kvm_check_features_against_host()
2013-11-24 19:55 [Qemu-devel] [PATCH 0/8] target-i386: Simplify kvm_cpu_fill_host() and kvm_check_features_against_host() Eduardo Habkost
` (7 preceding siblings ...)
2013-11-24 19:55 ` [Qemu-devel] [PATCH 8/8] target-i386: kvm_check_features_against_host(): Don't use kvm_cpu_fill_host() Eduardo Habkost
@ 2013-12-11 16:07 ` Eduardo Habkost
8 siblings, 0 replies; 11+ messages in thread
From: Eduardo Habkost @ 2013-12-11 16:07 UTC (permalink / raw)
To: qemu-devel; +Cc: Igor Mammedov, Andreas Färber
Ping? Any comments?
On Sun, Nov 24, 2013 at 05:55:32PM -0200, Eduardo Habkost wrote:
> This series simplifies kvm_cpu_fill_host() and
> kvm_check_features_against_host() to simply use FeatureWord & feature_word_info
> loops to fill/check feature words.
>
> The initial motivation for this was to avoid hacks involving the "host" CPU
> class on the forthcoming conversion of CPU models to be X86CPU subclasses.
> Instead of requiring the kvm_arch_get_supported_cpuid() results to be stored in
> the class struct for "host" (thus requiring KVM initialization hacks).
>
> Eduardo Habkost (8):
> target-i386: kvm_cpu_fill_host(): Kill unused code
> target-i386: kvm_cpu_fill_host(): No need to check level
> target-i386: kvm_cpu_fill_host(): No need to check CPU vendor
> target-i386: kvm_cpu_fill_host(): No need to check xlevel2
> target-i386: kvm_cpu_fill_host(): Set all feature words at end of
> function
> target-i386: kvm_cpu_fill_host(): Fill feature words in a loop
> target-i386: kvm_check_features_against_host(): Kill feature word
> array
> target-i386: kvm_check_features_against_host(): Don't use
> kvm_cpu_fill_host()
>
> target-i386/cpu.c | 89 +++++++++++++------------------------------------------
> 1 file changed, 20 insertions(+), 69 deletions(-)
>
> --
> 1.8.3.1
>
>
--
Eduardo
^ permalink raw reply [flat|nested] 11+ messages in thread