* [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
@ 2013-08-18 18:23 Liu, Jinsong
2013-08-18 18:37 ` Stefan Weil
2013-08-19 9:22 ` Paolo Bonzini
0 siblings, 2 replies; 9+ messages in thread
From: Liu, Jinsong @ 2013-08-18 18:23 UTC (permalink / raw)
To: Gleb Natapov, Marcelo Tosatti, qemu-devel@nongnu.org, kvm
[-- Attachment #1: Type: text/plain, Size: 2749 bytes --]
>From 1273f8b2e5464ec987facf9942fd3ccc0b69087e Mon Sep 17 00:00:00 2001
From: Liu Jinsong <jinsong.liu@intel.com>
Date: Mon, 19 Aug 2013 09:33:30 +0800
Subject: [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
This patch is to fix the bug https://bugs.launchpad.net/qemu-kvm/+bug/1207623
IA32_FEATURE_CONTROL is pointless if not expose VMX or SMX bits to
cpuid.1.ecx of vcpu. Current qemu-kvm will error return when kvm_put_msrs
or kvm_get_msrs.
Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
---
target-i386/kvm.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 84ac00a..7facbfe 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -65,6 +65,7 @@ static bool has_msr_star;
static bool has_msr_hsave_pa;
static bool has_msr_tsc_adjust;
static bool has_msr_tsc_deadline;
+static bool has_msr_feature_control;
static bool has_msr_async_pf_en;
static bool has_msr_pv_eoi_en;
static bool has_msr_misc_enable;
@@ -644,6 +645,11 @@ int kvm_arch_init_vcpu(CPUState *cs)
qemu_add_vm_change_state_handler(cpu_update_state, env);
+ c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0);
+ if (c)
+ has_msr_feature_control = !!(c->ecx & CPUID_EXT_VMX) |
+ !!(c->ecx & CPUID_EXT_SMX);
+
cpuid_data.cpuid.padding = 0;
r = kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data);
if (r) {
@@ -1121,7 +1127,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
if (hyperv_vapic_recommended()) {
kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0);
}
- kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL, env->msr_ia32_feature_control);
+ if (has_msr_feature_control) {
+ kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL,
+ env->msr_ia32_feature_control);
+ }
}
if (env->mcg_cap) {
int i;
@@ -1346,7 +1355,9 @@ static int kvm_get_msrs(X86CPU *cpu)
if (has_msr_misc_enable) {
msrs[n++].index = MSR_IA32_MISC_ENABLE;
}
- msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
+ if (has_msr_feature_control) {
+ msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
+ }
if (!env->tsc_valid) {
msrs[n++].index = MSR_IA32_TSC;
@@ -1447,6 +1458,7 @@ static int kvm_get_msrs(X86CPU *cpu)
break;
case MSR_IA32_FEATURE_CONTROL:
env->msr_ia32_feature_control = msrs[i].data;
+ break;
default:
if (msrs[i].index >= MSR_MC0_CTL &&
msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) {
--
1.7.1
[-- Attachment #2: 0001-qemu-kvm-bugfix-for-IA32_FEATURE_CONTROL.patch --]
[-- Type: application/octet-stream, Size: 2676 bytes --]
From 1273f8b2e5464ec987facf9942fd3ccc0b69087e Mon Sep 17 00:00:00 2001
From: Liu Jinsong <jinsong.liu@intel.com>
Date: Mon, 19 Aug 2013 09:33:30 +0800
Subject: [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
This patch is to fix the bug https://bugs.launchpad.net/qemu-kvm/+bug/1207623
IA32_FEATURE_CONTROL is pointless if not expose VMX or SMX bits to
cpuid.1.ecx of vcpu. Current qemu-kvm will error return when kvm_put_msrs
or kvm_get_msrs.
Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
---
target-i386/kvm.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 84ac00a..7facbfe 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -65,6 +65,7 @@ static bool has_msr_star;
static bool has_msr_hsave_pa;
static bool has_msr_tsc_adjust;
static bool has_msr_tsc_deadline;
+static bool has_msr_feature_control;
static bool has_msr_async_pf_en;
static bool has_msr_pv_eoi_en;
static bool has_msr_misc_enable;
@@ -644,6 +645,11 @@ int kvm_arch_init_vcpu(CPUState *cs)
qemu_add_vm_change_state_handler(cpu_update_state, env);
+ c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0);
+ if (c)
+ has_msr_feature_control = !!(c->ecx & CPUID_EXT_VMX) |
+ !!(c->ecx & CPUID_EXT_SMX);
+
cpuid_data.cpuid.padding = 0;
r = kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data);
if (r) {
@@ -1121,7 +1127,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
if (hyperv_vapic_recommended()) {
kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0);
}
- kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL, env->msr_ia32_feature_control);
+ if (has_msr_feature_control) {
+ kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL,
+ env->msr_ia32_feature_control);
+ }
}
if (env->mcg_cap) {
int i;
@@ -1346,7 +1355,9 @@ static int kvm_get_msrs(X86CPU *cpu)
if (has_msr_misc_enable) {
msrs[n++].index = MSR_IA32_MISC_ENABLE;
}
- msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
+ if (has_msr_feature_control) {
+ msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
+ }
if (!env->tsc_valid) {
msrs[n++].index = MSR_IA32_TSC;
@@ -1447,6 +1458,7 @@ static int kvm_get_msrs(X86CPU *cpu)
break;
case MSR_IA32_FEATURE_CONTROL:
env->msr_ia32_feature_control = msrs[i].data;
+ break;
default:
if (msrs[i].index >= MSR_MC0_CTL &&
msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) {
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
2013-08-18 18:23 [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL Liu, Jinsong
@ 2013-08-18 18:37 ` Stefan Weil
2013-08-19 9:22 ` Paolo Bonzini
1 sibling, 0 replies; 9+ messages in thread
From: Stefan Weil @ 2013-08-18 18:37 UTC (permalink / raw)
To: Liu, Jinsong; +Cc: Marcelo Tosatti, qemu-devel@nongnu.org, Gleb Natapov, kvm
Am 18.08.2013 20:23, schrieb Liu, Jinsong:
> From 1273f8b2e5464ec987facf9942fd3ccc0b69087e Mon Sep 17 00:00:00 2001
> From: Liu Jinsong <jinsong.liu@intel.com>
> Date: Mon, 19 Aug 2013 09:33:30 +0800
> Subject: [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
>
> This patch is to fix the bug https://bugs.launchpad.net/qemu-kvm/+bug/1207623
>
> IA32_FEATURE_CONTROL is pointless if not expose VMX or SMX bits to
> cpuid.1.ecx of vcpu. Current qemu-kvm will error return when kvm_put_msrs
> or kvm_get_msrs.
>
> Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
> ---
> target-i386/kvm.c | 16 ++++++++++++++--
> 1 files changed, 14 insertions(+), 2 deletions(-)
>
Hello,
please check your patch with scripts/checkpatch.pl
before sending it to the list.
For boolean operands, the boolean or (||) is better than
the bitwise or (|).
Regards,
Stefan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
2013-08-18 18:23 [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL Liu, Jinsong
2013-08-18 18:37 ` Stefan Weil
@ 2013-08-19 9:22 ` Paolo Bonzini
2013-08-19 14:31 ` Liu, Jinsong
1 sibling, 1 reply; 9+ messages in thread
From: Paolo Bonzini @ 2013-08-19 9:22 UTC (permalink / raw)
To: Liu, Jinsong; +Cc: Marcelo Tosatti, qemu-devel@nongnu.org, Gleb Natapov, kvm
Il 18/08/2013 20:23, Liu, Jinsong ha scritto:
> From 1273f8b2e5464ec987facf9942fd3ccc0b69087e Mon Sep 17 00:00:00 2001
> From: Liu Jinsong <jinsong.liu@intel.com>
> Date: Mon, 19 Aug 2013 09:33:30 +0800
> Subject: [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
>
> This patch is to fix the bug https://bugs.launchpad.net/qemu-kvm/+bug/1207623
>
> IA32_FEATURE_CONTROL is pointless if not expose VMX or SMX bits to
> cpuid.1.ecx of vcpu. Current qemu-kvm will error return when kvm_put_msrs
> or kvm_get_msrs.
>
> Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
> ---
> target-i386/kvm.c | 16 ++++++++++++++--
> 1 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 84ac00a..7facbfe 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -65,6 +65,7 @@ static bool has_msr_star;
> static bool has_msr_hsave_pa;
> static bool has_msr_tsc_adjust;
> static bool has_msr_tsc_deadline;
> +static bool has_msr_feature_control;
> static bool has_msr_async_pf_en;
> static bool has_msr_pv_eoi_en;
> static bool has_msr_misc_enable;
> @@ -644,6 +645,11 @@ int kvm_arch_init_vcpu(CPUState *cs)
>
> qemu_add_vm_change_state_handler(cpu_update_state, env);
>
> + c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0);
> + if (c)
> + has_msr_feature_control = !!(c->ecx & CPUID_EXT_VMX) |
> + !!(c->ecx & CPUID_EXT_SMX);
> +
> cpuid_data.cpuid.padding = 0;
> r = kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data);
> if (r) {
> @@ -1121,7 +1127,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
> if (hyperv_vapic_recommended()) {
> kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0);
> }
> - kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL, env->msr_ia32_feature_control);
> + if (has_msr_feature_control) {
> + kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL,
> + env->msr_ia32_feature_control);
> + }
> }
> if (env->mcg_cap) {
> int i;
> @@ -1346,7 +1355,9 @@ static int kvm_get_msrs(X86CPU *cpu)
> if (has_msr_misc_enable) {
> msrs[n++].index = MSR_IA32_MISC_ENABLE;
> }
> - msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
> + if (has_msr_feature_control) {
> + msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
> + }
>
> if (!env->tsc_valid) {
> msrs[n++].index = MSR_IA32_TSC;
> @@ -1447,6 +1458,7 @@ static int kvm_get_msrs(X86CPU *cpu)
> break;
> case MSR_IA32_FEATURE_CONTROL:
> env->msr_ia32_feature_control = msrs[i].data;
> + break;
> default:
> if (msrs[i].index >= MSR_MC0_CTL &&
> msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) {
>
The patch looks good. Please repost it with checkpatch.pl failures fixed.
Paolo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
2013-08-19 9:22 ` Paolo Bonzini
@ 2013-08-19 14:31 ` Liu, Jinsong
2013-08-19 14:59 ` Andreas Färber
0 siblings, 1 reply; 9+ messages in thread
From: Liu, Jinsong @ 2013-08-19 14:31 UTC (permalink / raw)
To: Paolo Bonzini, Stefan Weil
Cc: Marcelo Tosatti, qemu-devel@nongnu.org, Gleb Natapov, kvm
[-- Attachment #1: Type: text/plain, Size: 2974 bytes --]
Paolo Bonzini wrote:
>
> The patch looks good. Please repost it with checkpatch.pl failures
> fixed.
>
> Paolo
Thanks Stefan and Paolo! Updated patch attached.
Regards,
Jinsong
===============
>From a0ddf948d40e42de862543157a5668a1c12faae6 Mon Sep 17 00:00:00 2001
From: Liu Jinsong <jinsong.liu@intel.com>
Date: Mon, 19 Aug 2013 09:33:30 +0800
Subject: [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
This patch is to fix the bug https://bugs.launchpad.net/qemu-kvm/+bug/1207623
IA32_FEATURE_CONTROL is pointless if not expose VMX or SMX bits to
cpuid.1.ecx of vcpu. Current qemu-kvm will error return when kvm_put_msrs
or kvm_get_msrs.
Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
---
target-i386/kvm.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 84ac00a..5adeb03 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -65,6 +65,7 @@ static bool has_msr_star;
static bool has_msr_hsave_pa;
static bool has_msr_tsc_adjust;
static bool has_msr_tsc_deadline;
+static bool has_msr_feature_control;
static bool has_msr_async_pf_en;
static bool has_msr_pv_eoi_en;
static bool has_msr_misc_enable;
@@ -644,6 +645,12 @@ int kvm_arch_init_vcpu(CPUState *cs)
qemu_add_vm_change_state_handler(cpu_update_state, env);
+ c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0);
+ if (c) {
+ has_msr_feature_control = !!(c->ecx & CPUID_EXT_VMX) ||
+ !!(c->ecx & CPUID_EXT_SMX);
+ }
+
cpuid_data.cpuid.padding = 0;
r = kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data);
if (r) {
@@ -1121,7 +1128,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
if (hyperv_vapic_recommended()) {
kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0);
}
- kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL, env->msr_ia32_feature_control);
+ if (has_msr_feature_control) {
+ kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL,
+ env->msr_ia32_feature_control);
+ }
}
if (env->mcg_cap) {
int i;
@@ -1346,7 +1356,9 @@ static int kvm_get_msrs(X86CPU *cpu)
if (has_msr_misc_enable) {
msrs[n++].index = MSR_IA32_MISC_ENABLE;
}
- msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
+ if (has_msr_feature_control) {
+ msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
+ }
if (!env->tsc_valid) {
msrs[n++].index = MSR_IA32_TSC;
@@ -1447,6 +1459,7 @@ static int kvm_get_msrs(X86CPU *cpu)
break;
case MSR_IA32_FEATURE_CONTROL:
env->msr_ia32_feature_control = msrs[i].data;
+ break;
default:
if (msrs[i].index >= MSR_MC0_CTL &&
msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) {
--
1.7.1
[-- Attachment #2: 0001-qemu-kvm-bugfix-for-IA32_FEATURE_CONTROL.patch --]
[-- Type: application/octet-stream, Size: 2687 bytes --]
From a0ddf948d40e42de862543157a5668a1c12faae6 Mon Sep 17 00:00:00 2001
From: Liu Jinsong <jinsong.liu@intel.com>
Date: Mon, 19 Aug 2013 09:33:30 +0800
Subject: [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
This patch is to fix the bug https://bugs.launchpad.net/qemu-kvm/+bug/1207623
IA32_FEATURE_CONTROL is pointless if not expose VMX or SMX bits to
cpuid.1.ecx of vcpu. Current qemu-kvm will error return when kvm_put_msrs
or kvm_get_msrs.
Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
---
target-i386/kvm.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 84ac00a..5adeb03 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -65,6 +65,7 @@ static bool has_msr_star;
static bool has_msr_hsave_pa;
static bool has_msr_tsc_adjust;
static bool has_msr_tsc_deadline;
+static bool has_msr_feature_control;
static bool has_msr_async_pf_en;
static bool has_msr_pv_eoi_en;
static bool has_msr_misc_enable;
@@ -644,6 +645,12 @@ int kvm_arch_init_vcpu(CPUState *cs)
qemu_add_vm_change_state_handler(cpu_update_state, env);
+ c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0);
+ if (c) {
+ has_msr_feature_control = !!(c->ecx & CPUID_EXT_VMX) ||
+ !!(c->ecx & CPUID_EXT_SMX);
+ }
+
cpuid_data.cpuid.padding = 0;
r = kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data);
if (r) {
@@ -1121,7 +1128,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
if (hyperv_vapic_recommended()) {
kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0);
}
- kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL, env->msr_ia32_feature_control);
+ if (has_msr_feature_control) {
+ kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL,
+ env->msr_ia32_feature_control);
+ }
}
if (env->mcg_cap) {
int i;
@@ -1346,7 +1356,9 @@ static int kvm_get_msrs(X86CPU *cpu)
if (has_msr_misc_enable) {
msrs[n++].index = MSR_IA32_MISC_ENABLE;
}
- msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
+ if (has_msr_feature_control) {
+ msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
+ }
if (!env->tsc_valid) {
msrs[n++].index = MSR_IA32_TSC;
@@ -1447,6 +1459,7 @@ static int kvm_get_msrs(X86CPU *cpu)
break;
case MSR_IA32_FEATURE_CONTROL:
env->msr_ia32_feature_control = msrs[i].data;
+ break;
default:
if (msrs[i].index >= MSR_MC0_CTL &&
msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) {
--
1.7.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
2013-08-19 14:31 ` Liu, Jinsong
@ 2013-08-19 14:59 ` Andreas Färber
2013-08-19 15:20 ` Paolo Bonzini
2013-08-20 3:33 ` Liu, Jinsong
0 siblings, 2 replies; 9+ messages in thread
From: Andreas Färber @ 2013-08-19 14:59 UTC (permalink / raw)
To: Liu, Jinsong
Cc: Gleb Natapov, kvm, Stefan Weil, Marcelo Tosatti,
qemu-devel@nongnu.org, Paolo Bonzini
Am 19.08.2013 16:31, schrieb Liu, Jinsong:
> Paolo Bonzini wrote:
>>
>> The patch looks good. Please repost it with checkpatch.pl failures
>> fixed.
>>
>> Paolo
>
> Thanks Stefan and Paolo! Updated patch attached.
>
> Regards,
> Jinsong
>
> ===============
> From a0ddf948d40e42de862543157a5668a1c12faae6 Mon Sep 17 00:00:00 2001
> From: Liu Jinsong <jinsong.liu@intel.com>
> Date: Mon, 19 Aug 2013 09:33:30 +0800
> Subject: [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
>
> This patch is to fix the bug https://bugs.launchpad.net/qemu-kvm/+bug/1207623
>
> IA32_FEATURE_CONTROL is pointless if not expose VMX or SMX bits to
> cpuid.1.ecx of vcpu. Current qemu-kvm will error return when kvm_put_msrs
> or kvm_get_msrs.
>
> Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
Jinsong, if this is for upstream QEMU, then the commit message needs
some small improvements:
qemu-kvm is no longer maintained since 1.3 so it should not be occurring
any more.
Please use a prefix of "target-i386: " (the directory name) to signal
where you are changing code, i.e. x86 only.
"bugfix" is not a very telling description of what a patch is doing.
(Up to Paolo and Gleb whether they'll fix it or whether they require a
resend.)
Also please use git-send-email to submit patches and use "PATCH v2" etc.
for submission as top-level patch:
http://wiki.qemu.org/Contribute/SubmitAPatch
One question inline...
> ---
> target-i386/kvm.c | 17 +++++++++++++++--
> 1 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 84ac00a..5adeb03 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -65,6 +65,7 @@ static bool has_msr_star;
> static bool has_msr_hsave_pa;
> static bool has_msr_tsc_adjust;
> static bool has_msr_tsc_deadline;
> +static bool has_msr_feature_control;
> static bool has_msr_async_pf_en;
> static bool has_msr_pv_eoi_en;
> static bool has_msr_misc_enable;
> @@ -644,6 +645,12 @@ int kvm_arch_init_vcpu(CPUState *cs)
>
> qemu_add_vm_change_state_handler(cpu_update_state, env);
>
> + c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0);
> + if (c) {
> + has_msr_feature_control = !!(c->ecx & CPUID_EXT_VMX) ||
> + !!(c->ecx & CPUID_EXT_SMX);
> + }
> +
> cpuid_data.cpuid.padding = 0;
> r = kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data);
> if (r) {
> @@ -1121,7 +1128,10 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
> if (hyperv_vapic_recommended()) {
> kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0);
> }
> - kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL, env->msr_ia32_feature_control);
> + if (has_msr_feature_control) {
> + kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL,
> + env->msr_ia32_feature_control);
> + }
> }
> if (env->mcg_cap) {
> int i;
> @@ -1346,7 +1356,9 @@ static int kvm_get_msrs(X86CPU *cpu)
> if (has_msr_misc_enable) {
> msrs[n++].index = MSR_IA32_MISC_ENABLE;
> }
> - msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
> + if (has_msr_feature_control) {
> + msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
> + }
>
> if (!env->tsc_valid) {
> msrs[n++].index = MSR_IA32_TSC;
> @@ -1447,6 +1459,7 @@ static int kvm_get_msrs(X86CPU *cpu)
> break;
> case MSR_IA32_FEATURE_CONTROL:
> env->msr_ia32_feature_control = msrs[i].data;
> + break;
Was the fallthrough previously intended? Or is this a second,
unmentioned bugfix?
Regards,
Andreas
> default:
> if (msrs[i].index >= MSR_MC0_CTL &&
> msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff) * 4) {
>
--
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] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
2013-08-19 14:59 ` Andreas Färber
@ 2013-08-19 15:20 ` Paolo Bonzini
2013-08-20 6:10 ` Liu, Jinsong
2013-08-20 3:33 ` Liu, Jinsong
1 sibling, 1 reply; 9+ messages in thread
From: Paolo Bonzini @ 2013-08-19 15:20 UTC (permalink / raw)
To: Andreas Färber
Cc: Liu, Jinsong, kvm, Gleb Natapov, Stefan Weil, Marcelo Tosatti,
qemu-devel@nongnu.org
Il 19/08/2013 16:59, Andreas Färber ha scritto:
> qemu-kvm is no longer maintained since 1.3 so it should not be occurring
> any more.
>
> Please use a prefix of "target-i386: " (the directory name) to signal
> where you are changing code, i.e. x86 only.
>
> "bugfix" is not a very telling description of what a patch is doing.
>
> (Up to Paolo and Gleb whether they'll fix it or whether they require a
> resend.)
No, not this time at least. :)
Paolo
> Also please use git-send-email to submit patches and use "PATCH v2" etc.
> for submission as top-level patch:
> http://wiki.qemu.org/Contribute/SubmitAPatch
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
2013-08-19 14:59 ` Andreas Färber
2013-08-19 15:20 ` Paolo Bonzini
@ 2013-08-20 3:33 ` Liu, Jinsong
2013-08-20 16:43 ` Paolo Bonzini
1 sibling, 1 reply; 9+ messages in thread
From: Liu, Jinsong @ 2013-08-20 3:33 UTC (permalink / raw)
To: Andreas Färber
Cc: Gleb Natapov, kvm, Stefan Weil, Marcelo Tosatti,
qemu-devel@nongnu.org, Paolo Bonzini
Andreas Färber wrote:
> Am 19.08.2013 16:31, schrieb Liu, Jinsong:
>> Paolo Bonzini wrote:
>>>
>>> The patch looks good. Please repost it with checkpatch.pl failures
>>> fixed.
>>>
>>> Paolo
>>
>> Thanks Stefan and Paolo! Updated patch attached.
>>
>> Regards,
>> Jinsong
>>
>> ===============
>> From a0ddf948d40e42de862543157a5668a1c12faae6 Mon Sep 17 00:00:00
>> 2001
>> From: Liu Jinsong <jinsong.liu@intel.com>
>> Date: Mon, 19 Aug 2013 09:33:30 +0800
>> Subject: [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
>>
>> This patch is to fix the bug
>> https://bugs.launchpad.net/qemu-kvm/+bug/1207623
>>
>> IA32_FEATURE_CONTROL is pointless if not expose VMX or SMX bits to
>> cpuid.1.ecx of vcpu. Current qemu-kvm will error return when
>> kvm_put_msrs
>> or kvm_get_msrs.
>>
>> Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
>
> Jinsong, if this is for upstream QEMU, then the commit message needs
> some small improvements:
>
> qemu-kvm is no longer maintained since 1.3 so it should not be
> occurring any more.
Thanks Andreas!
This patch is for qemu-kvm.
Per my understanding, there are some patches firstly checked in qemu-kvm uq/master branch.
This patch is to fix c/s 0779caeb1a17f4d3ed14e2925b36ba09b084fb7b of qemu-kvm uq/master branch
(which is to co-work w/ kvm IA32_FEATURE_CONTROL, and currently not yet in upstream qemu).
This patch is used to fix the bug introduced by 0779caeb1a17f4d3ed14e2925b36ba09b084fb7b of qemu-kvm uq/master branch. The bug is reported as
https://bugs.launchpad.net/qemu-kvm/+bug/1207623
https://bugs.launchpad.net/qemu/+bug/1213797
Anything I misunderstand, for upstream qemu and qemu-kvm?
>
> Please use a prefix of "target-i386: " (the directory name) to signal
> where you are changing code, i.e. x86 only.
>
> "bugfix" is not a very telling description of what a patch is doing.
>
> (Up to Paolo and Gleb whether they'll fix it or whether they require a
> resend.)
>
> Also please use git-send-email to submit patches and use "PATCH v2"
> etc. for submission as top-level patch:
> http://wiki.qemu.org/Contribute/SubmitAPatch
Thanks, will update per your comments :)
>
> One question inline...
>
>> ---
>> target-i386/kvm.c | 17 +++++++++++++++--
>> 1 files changed, 15 insertions(+), 2 deletions(-)
>>
>> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
>> index 84ac00a..5adeb03 100644
>> --- a/target-i386/kvm.c
>> +++ b/target-i386/kvm.c
>> @@ -65,6 +65,7 @@ static bool has_msr_star;
>> static bool has_msr_hsave_pa;
>> static bool has_msr_tsc_adjust;
>> static bool has_msr_tsc_deadline;
>> +static bool has_msr_feature_control;
>> static bool has_msr_async_pf_en;
>> static bool has_msr_pv_eoi_en;
>> static bool has_msr_misc_enable;
>> @@ -644,6 +645,12 @@ int kvm_arch_init_vcpu(CPUState *cs)
>>
>> qemu_add_vm_change_state_handler(cpu_update_state, env);
>>
>> + c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0); + if (c) {
>> + has_msr_feature_control = !!(c->ecx & CPUID_EXT_VMX) ||
>> + !!(c->ecx & CPUID_EXT_SMX); + }
>> +
>> cpuid_data.cpuid.padding = 0;
>> r = kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data); if
>> (r) { @@ -1121,7 +1128,10 @@ static int kvm_put_msrs(X86CPU *cpu,
>> int level) if (hyperv_vapic_recommended()) {
>> kvm_msr_entry_set(&msrs[n++],
>> HV_X64_MSR_APIC_ASSIST_PAGE, 0); } -
>> kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL,
>> env->msr_ia32_feature_control); + if
>> (has_msr_feature_control) { +
>> kvm_msr_entry_set(&msrs[n++], MSR_IA32_FEATURE_CONTROL, +
>> env->msr_ia32_feature_control); + } } if (env->mcg_cap) {
>> int i;
>> @@ -1346,7 +1356,9 @@ static int kvm_get_msrs(X86CPU *cpu)
>> if (has_msr_misc_enable) {
>> msrs[n++].index = MSR_IA32_MISC_ENABLE;
>> }
>> - msrs[n++].index = MSR_IA32_FEATURE_CONTROL;
>> + if (has_msr_feature_control) {
>> + msrs[n++].index = MSR_IA32_FEATURE_CONTROL; + }
>>
>> if (!env->tsc_valid) {
>> msrs[n++].index = MSR_IA32_TSC;
>> @@ -1447,6 +1459,7 @@ static int kvm_get_msrs(X86CPU *cpu)
>> break; case MSR_IA32_FEATURE_CONTROL:
>> env->msr_ia32_feature_control = msrs[i].data;
>> + break;
>
> Was the fallthrough previously intended? Or is this a second,
> unmentioned bugfix?
Hmm, it just add 'break' I think patch 0779caeb1a17f4d3ed14e2925b36ba09b084fb7b forget.
Thanks,
Jinsong
>
> Regards,
> Andreas
>
>> default:
>> if (msrs[i].index >= MSR_MC0_CTL &&
>> msrs[i].index < MSR_MC0_CTL + (env->mcg_cap & 0xff)
>> * 4) {
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
2013-08-19 15:20 ` Paolo Bonzini
@ 2013-08-20 6:10 ` Liu, Jinsong
0 siblings, 0 replies; 9+ messages in thread
From: Liu, Jinsong @ 2013-08-20 6:10 UTC (permalink / raw)
To: Paolo Bonzini, Andreas Färber
Cc: Stefan Weil, Marcelo Tosatti, qemu-devel@nongnu.org, Gleb Natapov,
kvm
Paolo Bonzini wrote:
> Il 19/08/2013 16:59, Andreas Färber ha scritto:
>> qemu-kvm is no longer maintained since 1.3 so it should not be
>> occurring any more.
>>
>> Please use a prefix of "target-i386: " (the directory name) to signal
>> where you are changing code, i.e. x86 only.
>>
>> "bugfix" is not a very telling description of what a patch is doing.
>>
>> (Up to Paolo and Gleb whether they'll fix it or whether they require
>> a resend.)
>
> No, not this time at least. :)
>
> Paolo
Thanks Paolo, and Andreas's comments is also good, so I update commit message and will send out later.
Regards,
Jinsong
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL
2013-08-20 3:33 ` Liu, Jinsong
@ 2013-08-20 16:43 ` Paolo Bonzini
0 siblings, 0 replies; 9+ messages in thread
From: Paolo Bonzini @ 2013-08-20 16:43 UTC (permalink / raw)
To: Liu, Jinsong
Cc: Gleb Natapov, kvm, Stefan Weil, Marcelo Tosatti,
qemu-devel@nongnu.org, Andreas Färber
Il 20/08/2013 05:33, Liu, Jinsong ha scritto:
> Thanks Andreas!
>
> This patch is for qemu-kvm.
Even though the repository is still called qemu-kvm, the uq/master
branch is the only active one and patches there will end up in upstream
QEMU.
There are no qemu-kvm releases anymore.
I applied the patch to uq/master, thanks.
Paolo
> Per my understanding, there are some patches firstly checked in qemu-kvm uq/master branch.
> This patch is to fix c/s 0779caeb1a17f4d3ed14e2925b36ba09b084fb7b of qemu-kvm uq/master branch
> (which is to co-work w/ kvm IA32_FEATURE_CONTROL, and currently not yet in upstream qemu).
>
> This patch is used to fix the bug introduced by 0779caeb1a17f4d3ed14e2925b36ba09b084fb7b of qemu-kvm uq/master branch. The bug is reported as
> https://bugs.launchpad.net/qemu-kvm/+bug/1207623
> https://bugs.launchpad.net/qemu/+bug/1213797
>
> Anything I misunderstand, for upstream qemu and qemu-kvm?
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-08-20 16:44 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-18 18:23 [Qemu-devel] [PATCH] qemu-kvm bugfix for IA32_FEATURE_CONTROL Liu, Jinsong
2013-08-18 18:37 ` Stefan Weil
2013-08-19 9:22 ` Paolo Bonzini
2013-08-19 14:31 ` Liu, Jinsong
2013-08-19 14:59 ` Andreas Färber
2013-08-19 15:20 ` Paolo Bonzini
2013-08-20 6:10 ` Liu, Jinsong
2013-08-20 3:33 ` Liu, Jinsong
2013-08-20 16:43 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).