* [Qemu-devel] [PATCH] kvm: x86: Fix initial kvm_has_msr_star
@ 2009-12-06 14:51 Jan Kiszka
2009-12-06 14:54 ` [Qemu-devel] [FOR 0.12][FOR 0.11][PATCH] " Jan Kiszka
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Jan Kiszka @ 2009-12-06 14:51 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Marcelo Tosatti, qemu-devel, Avi Kivity
[-- Attachment #1: Type: text/plain, Size: 1185 bytes --]
KVM_GET_MSR_INDEX_LIST returns -E2BIG when the provided space is too
small for all MSRs. But this is precisely the error we trigger with the
initial request in order to obtain that size. Do not fail in that case.
This caused a subtle corruption of the guest state as MSR_STAR was not
properly saved/restored. The corruption became visible with latest kvm
optimizing the MSR updates.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
target-i386/kvm.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 3b61a7f..88b504c 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -244,9 +244,9 @@ static int kvm_has_msr_star(CPUState *env)
* save/restore */
msr_list.nmsrs = 0;
ret = kvm_ioctl(env->kvm_state, KVM_GET_MSR_INDEX_LIST, &msr_list);
- if (ret < 0)
+ if (ret < 0 && ret != -E2BIG) {
return 0;
-
+ }
/* Old kernel modules had a bug and could write beyond the provided
memory. Allocate at least a safe amount of 1K. */
kvm_msr_list = qemu_mallocz(MAX(1024, sizeof(msr_list) +
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [FOR 0.12][FOR 0.11][PATCH] kvm: x86: Fix initial kvm_has_msr_star
2009-12-06 14:51 [Qemu-devel] [PATCH] kvm: x86: Fix initial kvm_has_msr_star Jan Kiszka
@ 2009-12-06 14:54 ` Jan Kiszka
2009-12-06 15:12 ` [Qemu-devel] [PATCH] " Avi Kivity
2009-12-07 8:12 ` [Qemu-devel] " Avi Kivity
2 siblings, 0 replies; 9+ messages in thread
From: Jan Kiszka @ 2009-12-06 14:54 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Marcelo Tosatti, qemu-devel, Avi Kivity
[-- Attachment #1: Type: text/plain, Size: 1361 bytes --]
Sorry, this is of course a critical fix for all branches that have KVM
support.
Jan
Jan Kiszka wrote:
> KVM_GET_MSR_INDEX_LIST returns -E2BIG when the provided space is too
> small for all MSRs. But this is precisely the error we trigger with the
> initial request in order to obtain that size. Do not fail in that case.
>
> This caused a subtle corruption of the guest state as MSR_STAR was not
> properly saved/restored. The corruption became visible with latest kvm
> optimizing the MSR updates.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> target-i386/kvm.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 3b61a7f..88b504c 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -244,9 +244,9 @@ static int kvm_has_msr_star(CPUState *env)
> * save/restore */
> msr_list.nmsrs = 0;
> ret = kvm_ioctl(env->kvm_state, KVM_GET_MSR_INDEX_LIST, &msr_list);
> - if (ret < 0)
> + if (ret < 0 && ret != -E2BIG) {
> return 0;
> -
> + }
> /* Old kernel modules had a bug and could write beyond the provided
> memory. Allocate at least a safe amount of 1K. */
> kvm_msr_list = qemu_mallocz(MAX(1024, sizeof(msr_list) +
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] kvm: x86: Fix initial kvm_has_msr_star
2009-12-06 14:51 [Qemu-devel] [PATCH] kvm: x86: Fix initial kvm_has_msr_star Jan Kiszka
2009-12-06 14:54 ` [Qemu-devel] [FOR 0.12][FOR 0.11][PATCH] " Jan Kiszka
@ 2009-12-06 15:12 ` Avi Kivity
2009-12-07 8:12 ` [Qemu-devel] " Avi Kivity
2 siblings, 0 replies; 9+ messages in thread
From: Avi Kivity @ 2009-12-06 15:12 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Anthony Liguori, Marcelo Tosatti, qemu-devel
On 12/06/2009 04:51 PM, Jan Kiszka wrote:
> KVM_GET_MSR_INDEX_LIST returns -E2BIG when the provided space is too
> small for all MSRs. But this is precisely the error we trigger with the
> initial request in order to obtain that size. Do not fail in that case.
>
> This caused a subtle corruption of the guest state as MSR_STAR was not
> properly saved/restored. The corruption became visible with latest kvm
> optimizing the MSR updates.
>
Strong ack. Anthony, please apply ASAP. This is worthy of a 0.11.2, IMO.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] Re: [PATCH] kvm: x86: Fix initial kvm_has_msr_star
2009-12-06 14:51 [Qemu-devel] [PATCH] kvm: x86: Fix initial kvm_has_msr_star Jan Kiszka
2009-12-06 14:54 ` [Qemu-devel] [FOR 0.12][FOR 0.11][PATCH] " Jan Kiszka
2009-12-06 15:12 ` [Qemu-devel] [PATCH] " Avi Kivity
@ 2009-12-07 8:12 ` Avi Kivity
2009-12-07 8:24 ` Jan Kiszka
2009-12-07 14:47 ` Anthony Liguori
2 siblings, 2 replies; 9+ messages in thread
From: Avi Kivity @ 2009-12-07 8:12 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Anthony Liguori, Marcelo Tosatti, qemu-devel
On 12/06/2009 04:51 PM, Jan Kiszka wrote:
> KVM_GET_MSR_INDEX_LIST returns -E2BIG when the provided space is too
> small for all MSRs. But this is precisely the error we trigger with the
> initial request in order to obtain that size. Do not fail in that case.
>
> This caused a subtle corruption of the guest state as MSR_STAR was not
> properly saved/restored. The corruption became visible with latest kvm
> optimizing the MSR updates.
>
I applied this to qemu-kvm since it missed 0.12-rc1.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] Re: [PATCH] kvm: x86: Fix initial kvm_has_msr_star
2009-12-07 8:12 ` [Qemu-devel] " Avi Kivity
@ 2009-12-07 8:24 ` Jan Kiszka
2009-12-07 8:42 ` Avi Kivity
2009-12-07 14:47 ` Anthony Liguori
1 sibling, 1 reply; 9+ messages in thread
From: Jan Kiszka @ 2009-12-07 8:24 UTC (permalink / raw)
To: Avi Kivity; +Cc: Anthony Liguori, Marcelo Tosatti, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 660 bytes --]
Avi Kivity wrote:
> On 12/06/2009 04:51 PM, Jan Kiszka wrote:
>> KVM_GET_MSR_INDEX_LIST returns -E2BIG when the provided space is too
>> small for all MSRs. But this is precisely the error we trigger with the
>> initial request in order to obtain that size. Do not fail in that case.
>>
>> This caused a subtle corruption of the guest state as MSR_STAR was not
>> properly saved/restored. The corruption became visible with latest kvm
>> optimizing the MSR updates.
>>
>
> I applied this to qemu-kvm since it missed 0.12-rc1.
>
OK, but this part is unused in qemu-kvm as we use our own (unaffected)
implementation there so far.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] Re: [PATCH] kvm: x86: Fix initial kvm_has_msr_star
2009-12-07 8:24 ` Jan Kiszka
@ 2009-12-07 8:42 ` Avi Kivity
0 siblings, 0 replies; 9+ messages in thread
From: Avi Kivity @ 2009-12-07 8:42 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Anthony Liguori, Marcelo Tosatti, qemu-devel
On 12/07/2009 10:24 AM, Jan Kiszka wrote:
>
>> I applied this to qemu-kvm since it missed 0.12-rc1.
>>
>>
> OK, but this part is unused in qemu-kvm as we use our own (unaffected)
> implementation there so far.
>
#include <toldyouso.h>
Will unapply.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Qemu-devel] Re: [PATCH] kvm: x86: Fix initial kvm_has_msr_star
2009-12-07 8:12 ` [Qemu-devel] " Avi Kivity
2009-12-07 8:24 ` Jan Kiszka
@ 2009-12-07 14:47 ` Anthony Liguori
2009-12-07 16:31 ` Avi Kivity
1 sibling, 1 reply; 9+ messages in thread
From: Anthony Liguori @ 2009-12-07 14:47 UTC (permalink / raw)
To: Avi Kivity; +Cc: Marcelo Tosatti, Jan Kiszka, qemu-devel
Avi Kivity wrote:
> On 12/06/2009 04:51 PM, Jan Kiszka wrote:
>> KVM_GET_MSR_INDEX_LIST returns -E2BIG when the provided space is too
>> small for all MSRs. But this is precisely the error we trigger with the
>> initial request in order to obtain that size. Do not fail in that case.
>>
>> This caused a subtle corruption of the guest state as MSR_STAR was not
>> properly saved/restored. The corruption became visible with latest kvm
>> optimizing the MSR updates.
>>
>
> I applied this to qemu-kvm since it missed 0.12-rc1.
I've got it in my tree. It will be a part of 0.12-rc2 and I'll push to
master today.
Don't know when 0.11.2 will happen but I'll also push it to the
stable-0.11 branch.
--
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-12-07 16:34 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-06 14:51 [Qemu-devel] [PATCH] kvm: x86: Fix initial kvm_has_msr_star Jan Kiszka
2009-12-06 14:54 ` [Qemu-devel] [FOR 0.12][FOR 0.11][PATCH] " Jan Kiszka
2009-12-06 15:12 ` [Qemu-devel] [PATCH] " Avi Kivity
2009-12-07 8:12 ` [Qemu-devel] " Avi Kivity
2009-12-07 8:24 ` Jan Kiszka
2009-12-07 8:42 ` Avi Kivity
2009-12-07 14:47 ` Anthony Liguori
2009-12-07 16:31 ` Avi Kivity
2009-12-07 16:33 ` Anthony Liguori
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).