* [PATCH] qemu-kvm: x86: Fix mismerge in cpu_post_load
@ 2009-12-03 18:21 Jan Kiszka
2009-12-06 9:54 ` Avi Kivity
2009-12-06 10:33 ` Gleb Natapov
0 siblings, 2 replies; 8+ messages in thread
From: Jan Kiszka @ 2009-12-03 18:21 UTC (permalink / raw)
To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, Gleb Natapov
Merge 8e2c5ec2f6 forgot to restore some qemu-kvm-specific hooks in
cpu_post_load. mp_state was readded later on, but tsc was missing,
breaking the guest timing after resume. Also, reset of halt was dropped
which is obviously required for in-kernel irqchip.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
This solves "Problem 1" on my list.
BTW, this patch just made me realize that the TSC MSR belongs to the
list states that should not be written back unconditionally. Upstream
does this currently, qemu-kvm not (at the price one more kvm-specific
hook into generic code). Unlike the other states we discussed, this one
is not "fixable" in the kernel. So I tend to think there is a real need
for my write-back scope abstraction - which would also be able to handle
the other states cleanly, both in upstream and here.
target-i386/machine.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 6bd447f..9ac477b 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -366,7 +366,15 @@ static int cpu_post_load(void *opaque, int version_id)
hw_breakpoint_insert(env, i);
tlb_flush(env, 1);
- kvm_load_mpstate(env);
+
+ if (kvm_enabled()) {
+ /* when in-kernel irqchip is used, env->halted causes deadlock
+ because no userspace IRQs will ever clear this flag */
+ env->halted = 0;
+
+ kvm_load_tsc(env);
+ kvm_load_mpstate(env);
+ }
return 0;
}
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH] qemu-kvm: x86: Fix mismerge in cpu_post_load
2009-12-03 18:21 [PATCH] qemu-kvm: x86: Fix mismerge in cpu_post_load Jan Kiszka
@ 2009-12-06 9:54 ` Avi Kivity
2009-12-06 10:39 ` Jan Kiszka
2009-12-06 10:33 ` Gleb Natapov
1 sibling, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2009-12-06 9:54 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Marcelo Tosatti, kvm, Gleb Natapov
On 12/03/2009 08:21 PM, Jan Kiszka wrote:
> Merge 8e2c5ec2f6 forgot to restore some qemu-kvm-specific hooks in
> cpu_post_load. mp_state was readded later on, but tsc was missing,
> breaking the guest timing after resume. Also, reset of halt was dropped
> which is obviously required for in-kernel irqchip.
>
Applied, thanks.
> BTW, this patch just made me realize that the TSC MSR belongs to the
> list states that should not be written back unconditionally. Upstream
> does this currently, qemu-kvm not (at the price one more kvm-specific
> hook into generic code).
Yet another reminder why we don't rewrite, only refactor.
> Unlike the other states we discussed, this one
> is not "fixable" in the kernel. So I tend to think there is a real need
> for my write-back scope abstraction - which would also be able to handle
> the other states cleanly, both in upstream and here.
>
Yes. Gleb suggested treating mpstate/nmi as part of the APIC state
(which makes sense), which would work, as APIC state is not
automatically written back. But the tsc msr would need special treatment.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] qemu-kvm: x86: Fix mismerge in cpu_post_load
2009-12-06 9:54 ` Avi Kivity
@ 2009-12-06 10:39 ` Jan Kiszka
2009-12-06 10:41 ` Avi Kivity
2009-12-06 10:56 ` Gleb Natapov
0 siblings, 2 replies; 8+ messages in thread
From: Jan Kiszka @ 2009-12-06 10:39 UTC (permalink / raw)
To: Avi Kivity; +Cc: Marcelo Tosatti, kvm, Gleb Natapov
[-- Attachment #1: Type: text/plain, Size: 1848 bytes --]
Avi Kivity wrote:
> On 12/03/2009 08:21 PM, Jan Kiszka wrote:
>> Merge 8e2c5ec2f6 forgot to restore some qemu-kvm-specific hooks in
>> cpu_post_load. mp_state was readded later on, but tsc was missing,
>> breaking the guest timing after resume. Also, reset of halt was dropped
>> which is obviously required for in-kernel irqchip.
>>
>
> Applied, thanks.
>
>> BTW, this patch just made me realize that the TSC MSR belongs to the
>> list states that should not be written back unconditionally. Upstream
>> does this currently, qemu-kvm not (at the price one more kvm-specific
>> hook into generic code).
>
> Yet another reminder why we don't rewrite, only refactor.
Which also has it's downsides like slow merging progress with quite a
few subtle merge regressions on qemu-kvm side...
>
>> Unlike the other states we discussed, this one
>> is not "fixable" in the kernel. So I tend to think there is a real need
>> for my write-back scope abstraction - which would also be able to handle
>> the other states cleanly, both in upstream and here.
>>
>
> Yes. Gleb suggested treating mpstate/nmi as part of the APIC state
> (which makes sense), which would work, as APIC state is not
> automatically written back. But the tsc msr would need special treatment.
(just realized that I forgot to answer him)
While this would make sense for mpstate, NMIs are not coupled to the
APICs. The APIC just happens to be one source for them (though a common
one). So if there is no in-kernel APIC state, there would never be a
write-back of the NMI state, which is bad.
That said, I think we should hurry to add some mask to the new
KVM_SET_VCPU_EVENTS (for 2.6.33) in order to skip nmi_pending and
sipi_vector, giving us maximum flexibility how to address the issue.
Will send a patch later.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] qemu-kvm: x86: Fix mismerge in cpu_post_load
2009-12-06 10:39 ` Jan Kiszka
@ 2009-12-06 10:41 ` Avi Kivity
2009-12-06 10:56 ` Gleb Natapov
1 sibling, 0 replies; 8+ messages in thread
From: Avi Kivity @ 2009-12-06 10:41 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Marcelo Tosatti, kvm, Gleb Natapov
On 12/06/2009 12:39 PM, Jan Kiszka wrote:
> That said, I think we should hurry to add some mask to the new
> KVM_SET_VCPU_EVENTS (for 2.6.33) in order to skip nmi_pending and
> sipi_vector, giving us maximum flexibility how to address the issue.
> Will send a patch later.
>
Yes. Thanks.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] qemu-kvm: x86: Fix mismerge in cpu_post_load
2009-12-06 10:39 ` Jan Kiszka
2009-12-06 10:41 ` Avi Kivity
@ 2009-12-06 10:56 ` Gleb Natapov
1 sibling, 0 replies; 8+ messages in thread
From: Gleb Natapov @ 2009-12-06 10:56 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Avi Kivity, Marcelo Tosatti, kvm
On Sun, Dec 06, 2009 at 11:39:22AM +0100, Jan Kiszka wrote:
> >> Unlike the other states we discussed, this one
> >> is not "fixable" in the kernel. So I tend to think there is a real need
> >> for my write-back scope abstraction - which would also be able to handle
> >> the other states cleanly, both in upstream and here.
> >>
> >
> > Yes. Gleb suggested treating mpstate/nmi as part of the APIC state
> > (which makes sense), which would work, as APIC state is not
> > automatically written back. But the tsc msr would need special treatment.
>
> (just realized that I forgot to answer him)
>
> While this would make sense for mpstate, NMIs are not coupled to the
> APICs. The APIC just happens to be one source for them (though a common
> one). So if there is no in-kernel APIC state, there would never be a
> write-back of the NMI state, which is bad.
>
I agree about NMI. We never do RMW to NMI anyway. Mpstate/sipi_vector belong
to APIC state though.
--
Gleb.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] qemu-kvm: x86: Fix mismerge in cpu_post_load
2009-12-03 18:21 [PATCH] qemu-kvm: x86: Fix mismerge in cpu_post_load Jan Kiszka
2009-12-06 9:54 ` Avi Kivity
@ 2009-12-06 10:33 ` Gleb Natapov
2009-12-06 10:44 ` Jan Kiszka
1 sibling, 1 reply; 8+ messages in thread
From: Gleb Natapov @ 2009-12-06 10:33 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Avi Kivity, Marcelo Tosatti, kvm
On Thu, Dec 03, 2009 at 07:21:01PM +0100, Jan Kiszka wrote:
> Merge 8e2c5ec2f6 forgot to restore some qemu-kvm-specific hooks in
> cpu_post_load. mp_state was readded later on, but tsc was missing,
> breaking the guest timing after resume. Also, reset of halt was dropped
> which is obviously required for in-kernel irqchip.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> This solves "Problem 1" on my list.
>
> BTW, this patch just made me realize that the TSC MSR belongs to the
> list states that should not be written back unconditionally. Upstream
> does this currently, qemu-kvm not (at the price one more kvm-specific
> hook into generic code). Unlike the other states we discussed, this one
> is not "fixable" in the kernel. So I tend to think there is a real need
> for my write-back scope abstraction - which would also be able to handle
> the other states cleanly, both in upstream and here.
>
> target-i386/machine.c | 10 +++++++++-
> 1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/target-i386/machine.c b/target-i386/machine.c
> index 6bd447f..9ac477b 100644
> --- a/target-i386/machine.c
> +++ b/target-i386/machine.c
> @@ -366,7 +366,15 @@ static int cpu_post_load(void *opaque, int version_id)
> hw_breakpoint_insert(env, i);
>
> tlb_flush(env, 1);
> - kvm_load_mpstate(env);
> +
> + if (kvm_enabled()) {
> + /* when in-kernel irqchip is used, env->halted causes deadlock
> + because no userspace IRQs will ever clear this flag */
> + env->halted = 0;
> +
That is strange. env->halted should be used only for "info cpus" output
in case of in-kernel irqchip. Can you see where it hangs?
> + kvm_load_tsc(env);
> + kvm_load_mpstate(env);
> + }
>
> return 0;
> }
--
Gleb.
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] qemu-kvm: x86: Fix mismerge in cpu_post_load
2009-12-06 10:33 ` Gleb Natapov
@ 2009-12-06 10:44 ` Jan Kiszka
2009-12-06 10:49 ` Gleb Natapov
0 siblings, 1 reply; 8+ messages in thread
From: Jan Kiszka @ 2009-12-06 10:44 UTC (permalink / raw)
To: Gleb Natapov; +Cc: Avi Kivity, Marcelo Tosatti, kvm
[-- Attachment #1: Type: text/plain, Size: 2365 bytes --]
Gleb Natapov wrote:
> On Thu, Dec 03, 2009 at 07:21:01PM +0100, Jan Kiszka wrote:
>> Merge 8e2c5ec2f6 forgot to restore some qemu-kvm-specific hooks in
>> cpu_post_load. mp_state was readded later on, but tsc was missing,
>> breaking the guest timing after resume. Also, reset of halt was dropped
>> which is obviously required for in-kernel irqchip.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>>
>> This solves "Problem 1" on my list.
>>
>> BTW, this patch just made me realize that the TSC MSR belongs to the
>> list states that should not be written back unconditionally. Upstream
>> does this currently, qemu-kvm not (at the price one more kvm-specific
>> hook into generic code). Unlike the other states we discussed, this one
>> is not "fixable" in the kernel. So I tend to think there is a real need
>> for my write-back scope abstraction - which would also be able to handle
>> the other states cleanly, both in upstream and here.
>>
>> target-i386/machine.c | 10 +++++++++-
>> 1 files changed, 9 insertions(+), 1 deletions(-)
>>
>> diff --git a/target-i386/machine.c b/target-i386/machine.c
>> index 6bd447f..9ac477b 100644
>> --- a/target-i386/machine.c
>> +++ b/target-i386/machine.c
>> @@ -366,7 +366,15 @@ static int cpu_post_load(void *opaque, int version_id)
>> hw_breakpoint_insert(env, i);
>>
>> tlb_flush(env, 1);
>> - kvm_load_mpstate(env);
>> +
>> + if (kvm_enabled()) {
>> + /* when in-kernel irqchip is used, env->halted causes deadlock
>> + because no userspace IRQs will ever clear this flag */
>> + env->halted = 0;
>> +
> That is strange. env->halted should be used only for "info cpus" output
> in case of in-kernel irqchip. Can you see where it hangs?
This line was not directly involved in the regression I saw, it was just
the next one (load_tsc). But I simply restored qemu-kvm to the state
before the vmstate conversion merge, dropping only obviously unneeded
bits (namely the full register write-back).
The above line may no longer be required, but I wanted to play safe. If
you can explain which qemu-kvm change made this obsolete, please file a
removal patch!
>
>> + kvm_load_tsc(env);
>> + kvm_load_mpstate(env);
>> + }
>>
>> return 0;
>> }
>
> --
> Gleb.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] qemu-kvm: x86: Fix mismerge in cpu_post_load
2009-12-06 10:44 ` Jan Kiszka
@ 2009-12-06 10:49 ` Gleb Natapov
0 siblings, 0 replies; 8+ messages in thread
From: Gleb Natapov @ 2009-12-06 10:49 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Avi Kivity, Marcelo Tosatti, kvm
On Sun, Dec 06, 2009 at 11:44:40AM +0100, Jan Kiszka wrote:
> Gleb Natapov wrote:
> > On Thu, Dec 03, 2009 at 07:21:01PM +0100, Jan Kiszka wrote:
> >> Merge 8e2c5ec2f6 forgot to restore some qemu-kvm-specific hooks in
> >> cpu_post_load. mp_state was readded later on, but tsc was missing,
> >> breaking the guest timing after resume. Also, reset of halt was dropped
> >> which is obviously required for in-kernel irqchip.
> >>
> >> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> >> ---
> >>
> >> This solves "Problem 1" on my list.
> >>
> >> BTW, this patch just made me realize that the TSC MSR belongs to the
> >> list states that should not be written back unconditionally. Upstream
> >> does this currently, qemu-kvm not (at the price one more kvm-specific
> >> hook into generic code). Unlike the other states we discussed, this one
> >> is not "fixable" in the kernel. So I tend to think there is a real need
> >> for my write-back scope abstraction - which would also be able to handle
> >> the other states cleanly, both in upstream and here.
> >>
> >> target-i386/machine.c | 10 +++++++++-
> >> 1 files changed, 9 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/target-i386/machine.c b/target-i386/machine.c
> >> index 6bd447f..9ac477b 100644
> >> --- a/target-i386/machine.c
> >> +++ b/target-i386/machine.c
> >> @@ -366,7 +366,15 @@ static int cpu_post_load(void *opaque, int version_id)
> >> hw_breakpoint_insert(env, i);
> >>
> >> tlb_flush(env, 1);
> >> - kvm_load_mpstate(env);
> >> +
> >> + if (kvm_enabled()) {
> >> + /* when in-kernel irqchip is used, env->halted causes deadlock
> >> + because no userspace IRQs will ever clear this flag */
> >> + env->halted = 0;
> >> +
> > That is strange. env->halted should be used only for "info cpus" output
> > in case of in-kernel irqchip. Can you see where it hangs?
>
> This line was not directly involved in the regression I saw, it was just
> the next one (load_tsc). But I simply restored qemu-kvm to the state
> before the vmstate conversion merge, dropping only obviously unneeded
> bits (namely the full register write-back).
>
> The above line may no longer be required, but I wanted to play safe. If
> you can explain which qemu-kvm change made this obsolete, please file a
> removal patch!
>
Ah, OK then. There was no particular patch that made in kernel irqchip
to not use env->halted. AFAIR it was always this way.
> >
> >> + kvm_load_tsc(env);
> >> + kvm_load_mpstate(env);
> >> + }
> >>
> >> return 0;
> >> }
> >
> > --
> > Gleb.
>
> Jan
>
--
Gleb.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-12-06 10:56 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-03 18:21 [PATCH] qemu-kvm: x86: Fix mismerge in cpu_post_load Jan Kiszka
2009-12-06 9:54 ` Avi Kivity
2009-12-06 10:39 ` Jan Kiszka
2009-12-06 10:41 ` Avi Kivity
2009-12-06 10:56 ` Gleb Natapov
2009-12-06 10:33 ` Gleb Natapov
2009-12-06 10:44 ` Jan Kiszka
2009-12-06 10:49 ` Gleb Natapov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox