* [PATCH] call kvm_cpu_synchronize_state() on target vcpu
@ 2009-09-09 15:33 Gleb Natapov
2009-09-09 15:41 ` Avi Kivity
2009-09-09 15:47 ` Jan Kiszka
0 siblings, 2 replies; 10+ messages in thread
From: Gleb Natapov @ 2009-09-09 15:33 UTC (permalink / raw)
To: avi; +Cc: kvm
regs_modified logic doesn't work if io thread calls
kvm_cpu_synchronize_state() since kvm_arch_get_registers()
returns only after vcpu thread is back to kernel. Setting
regs_modified to 1 at this stage causes loading of wrong vcpu
state on the next vcpu_run().
Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 06efd41..9ab0cec 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -874,14 +874,6 @@ int kvm_set_mpstate(kvm_vcpu_context_t vcpu, struct kvm_mp_state *mp_state)
}
#endif
-void kvm_cpu_synchronize_state(CPUState *env)
-{
- if (!env->kvm_cpu_state.regs_modified) {
- kvm_arch_get_registers(env);
- env->kvm_cpu_state.regs_modified = 1;
- }
-}
-
static int handle_mmio(kvm_vcpu_context_t vcpu)
{
unsigned long addr = vcpu->run->mmio.phys_addr;
@@ -1539,6 +1531,22 @@ static void on_vcpu(CPUState *env, void (*func)(void *data), void *data)
qemu_cond_wait(&qemu_work_cond);
}
+static void do_kvm_cpu_synchronize_state(void *_env)
+{
+ CPUState *env = _env;
+ if (!env->kvm_cpu_state.regs_modified) {
+ kvm_arch_save_regs(env);
+ kvm_arch_load_mpstate(env);
+ env->kvm_cpu_state.regs_modified = 1;
+ }
+}
+
+void kvm_cpu_synchronize_state(CPUState *env)
+{
+ if (!env->kvm_cpu_state.regs_modified)
+ on_vcpu(env, do_kvm_cpu_synchronize_state, env);
+}
+
static void inject_interrupt(void *data)
{
cpu_interrupt(current_env, (long) data);
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 2c1730b..32f74b3 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -1153,12 +1153,6 @@ static inline int kvm_sync_vcpus(void)
return 0;
}
-static inline void kvm_arch_get_registers(CPUState *env)
-{
- kvm_save_registers(env);
- kvm_save_mpstate(env);
-}
-
static inline void kvm_arch_put_registers(CPUState *env)
{
kvm_load_registers(env);
diff --git a/target-i386/helper.c b/target-i386/helper.c
index 4a16887..57c74a2 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -746,7 +746,7 @@ void cpu_dump_state(CPUState *env, FILE *f,
static const char *seg_name[6] = { "ES", "CS", "SS", "DS", "FS", "GS" };
if (kvm_enabled())
- kvm_arch_get_registers(env);
+ kvm_cpu_synchronize_state(env);
eflags = env->eflags;
#ifdef TARGET_X86_64
--
Gleb.
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] call kvm_cpu_synchronize_state() on target vcpu
2009-09-09 15:33 [PATCH] call kvm_cpu_synchronize_state() on target vcpu Gleb Natapov
@ 2009-09-09 15:41 ` Avi Kivity
2009-09-09 15:47 ` Jan Kiszka
1 sibling, 0 replies; 10+ messages in thread
From: Avi Kivity @ 2009-09-09 15:41 UTC (permalink / raw)
To: Gleb Natapov; +Cc: kvm
On 09/09/2009 06:33 PM, Gleb Natapov wrote:
> regs_modified logic doesn't work if io thread calls
> kvm_cpu_synchronize_state() since kvm_arch_get_registers()
> returns only after vcpu thread is back to kernel. Setting
> regs_modified to 1 at this stage causes loading of wrong vcpu
> state on the next vcpu_run().
>
> -static inline void kvm_arch_get_registers(CPUState *env)
> -{
> - kvm_save_registers(env);
> - kvm_save_mpstate(env);
> -}
> -
>
Please don't drop this, it's part of upstream kvm support which we're
supported to be moving towards.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] call kvm_cpu_synchronize_state() on target vcpu
2009-09-09 15:33 [PATCH] call kvm_cpu_synchronize_state() on target vcpu Gleb Natapov
2009-09-09 15:41 ` Avi Kivity
@ 2009-09-09 15:47 ` Jan Kiszka
2009-09-09 15:49 ` Gleb Natapov
1 sibling, 1 reply; 10+ messages in thread
From: Jan Kiszka @ 2009-09-09 15:47 UTC (permalink / raw)
To: Gleb Natapov; +Cc: avi, kvm-devel
Gleb Natapov wrote:
> regs_modified logic doesn't work if io thread calls
> kvm_cpu_synchronize_state() since kvm_arch_get_registers()
> returns only after vcpu thread is back to kernel. Setting
> regs_modified to 1 at this stage causes loading of wrong vcpu
> state on the next vcpu_run().
We need this upstream too, right? Could you file the corresponding patch?
Thanks,
Jan
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> diff --git a/qemu-kvm.c b/qemu-kvm.c
> index 06efd41..9ab0cec 100644
> --- a/qemu-kvm.c
> +++ b/qemu-kvm.c
> @@ -874,14 +874,6 @@ int kvm_set_mpstate(kvm_vcpu_context_t vcpu, struct kvm_mp_state *mp_state)
> }
> #endif
>
> -void kvm_cpu_synchronize_state(CPUState *env)
> -{
> - if (!env->kvm_cpu_state.regs_modified) {
> - kvm_arch_get_registers(env);
> - env->kvm_cpu_state.regs_modified = 1;
> - }
> -}
> -
> static int handle_mmio(kvm_vcpu_context_t vcpu)
> {
> unsigned long addr = vcpu->run->mmio.phys_addr;
> @@ -1539,6 +1531,22 @@ static void on_vcpu(CPUState *env, void (*func)(void *data), void *data)
> qemu_cond_wait(&qemu_work_cond);
> }
>
> +static void do_kvm_cpu_synchronize_state(void *_env)
> +{
> + CPUState *env = _env;
> + if (!env->kvm_cpu_state.regs_modified) {
> + kvm_arch_save_regs(env);
> + kvm_arch_load_mpstate(env);
> + env->kvm_cpu_state.regs_modified = 1;
> + }
> +}
> +
> +void kvm_cpu_synchronize_state(CPUState *env)
> +{
> + if (!env->kvm_cpu_state.regs_modified)
> + on_vcpu(env, do_kvm_cpu_synchronize_state, env);
> +}
> +
> static void inject_interrupt(void *data)
> {
> cpu_interrupt(current_env, (long) data);
> diff --git a/qemu-kvm.h b/qemu-kvm.h
> index 2c1730b..32f74b3 100644
> --- a/qemu-kvm.h
> +++ b/qemu-kvm.h
> @@ -1153,12 +1153,6 @@ static inline int kvm_sync_vcpus(void)
> return 0;
> }
>
> -static inline void kvm_arch_get_registers(CPUState *env)
> -{
> - kvm_save_registers(env);
> - kvm_save_mpstate(env);
> -}
> -
> static inline void kvm_arch_put_registers(CPUState *env)
> {
> kvm_load_registers(env);
> diff --git a/target-i386/helper.c b/target-i386/helper.c
> index 4a16887..57c74a2 100644
> --- a/target-i386/helper.c
> +++ b/target-i386/helper.c
> @@ -746,7 +746,7 @@ void cpu_dump_state(CPUState *env, FILE *f,
> static const char *seg_name[6] = { "ES", "CS", "SS", "DS", "FS", "GS" };
>
> if (kvm_enabled())
> - kvm_arch_get_registers(env);
> + kvm_cpu_synchronize_state(env);
>
> eflags = env->eflags;
> #ifdef TARGET_X86_64
> --
> Gleb.
--
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] call kvm_cpu_synchronize_state() on target vcpu
2009-09-09 15:47 ` Jan Kiszka
@ 2009-09-09 15:49 ` Gleb Natapov
2009-09-09 15:57 ` Jan Kiszka
0 siblings, 1 reply; 10+ messages in thread
From: Gleb Natapov @ 2009-09-09 15:49 UTC (permalink / raw)
To: Jan Kiszka; +Cc: avi, kvm-devel
On Wed, Sep 09, 2009 at 05:47:13PM +0200, Jan Kiszka wrote:
> Gleb Natapov wrote:
> > regs_modified logic doesn't work if io thread calls
> > kvm_cpu_synchronize_state() since kvm_arch_get_registers()
> > returns only after vcpu thread is back to kernel. Setting
> > regs_modified to 1 at this stage causes loading of wrong vcpu
> > state on the next vcpu_run().
>
> We need this upstream too, right? Could you file the corresponding patch?
>
Upstream is single threaded. It shouldn't suffer from this bug.
> Thanks,
> Jan
>
> >
> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> > diff --git a/qemu-kvm.c b/qemu-kvm.c
> > index 06efd41..9ab0cec 100644
> > --- a/qemu-kvm.c
> > +++ b/qemu-kvm.c
> > @@ -874,14 +874,6 @@ int kvm_set_mpstate(kvm_vcpu_context_t vcpu, struct kvm_mp_state *mp_state)
> > }
> > #endif
> >
> > -void kvm_cpu_synchronize_state(CPUState *env)
> > -{
> > - if (!env->kvm_cpu_state.regs_modified) {
> > - kvm_arch_get_registers(env);
> > - env->kvm_cpu_state.regs_modified = 1;
> > - }
> > -}
> > -
> > static int handle_mmio(kvm_vcpu_context_t vcpu)
> > {
> > unsigned long addr = vcpu->run->mmio.phys_addr;
> > @@ -1539,6 +1531,22 @@ static void on_vcpu(CPUState *env, void (*func)(void *data), void *data)
> > qemu_cond_wait(&qemu_work_cond);
> > }
> >
> > +static void do_kvm_cpu_synchronize_state(void *_env)
> > +{
> > + CPUState *env = _env;
> > + if (!env->kvm_cpu_state.regs_modified) {
> > + kvm_arch_save_regs(env);
> > + kvm_arch_load_mpstate(env);
> > + env->kvm_cpu_state.regs_modified = 1;
> > + }
> > +}
> > +
> > +void kvm_cpu_synchronize_state(CPUState *env)
> > +{
> > + if (!env->kvm_cpu_state.regs_modified)
> > + on_vcpu(env, do_kvm_cpu_synchronize_state, env);
> > +}
> > +
> > static void inject_interrupt(void *data)
> > {
> > cpu_interrupt(current_env, (long) data);
> > diff --git a/qemu-kvm.h b/qemu-kvm.h
> > index 2c1730b..32f74b3 100644
> > --- a/qemu-kvm.h
> > +++ b/qemu-kvm.h
> > @@ -1153,12 +1153,6 @@ static inline int kvm_sync_vcpus(void)
> > return 0;
> > }
> >
> > -static inline void kvm_arch_get_registers(CPUState *env)
> > -{
> > - kvm_save_registers(env);
> > - kvm_save_mpstate(env);
> > -}
> > -
> > static inline void kvm_arch_put_registers(CPUState *env)
> > {
> > kvm_load_registers(env);
> > diff --git a/target-i386/helper.c b/target-i386/helper.c
> > index 4a16887..57c74a2 100644
> > --- a/target-i386/helper.c
> > +++ b/target-i386/helper.c
> > @@ -746,7 +746,7 @@ void cpu_dump_state(CPUState *env, FILE *f,
> > static const char *seg_name[6] = { "ES", "CS", "SS", "DS", "FS", "GS" };
> >
> > if (kvm_enabled())
> > - kvm_arch_get_registers(env);
> > + kvm_cpu_synchronize_state(env);
> >
> > eflags = env->eflags;
> > #ifdef TARGET_X86_64
> > --
> > Gleb.
>
> --
> Siemens AG, Corporate Technology, CT SE 2
> Corporate Competence Center Embedded Linux
--
Gleb.
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] call kvm_cpu_synchronize_state() on target vcpu
2009-09-09 15:49 ` Gleb Natapov
@ 2009-09-09 15:57 ` Jan Kiszka
2009-09-09 16:07 ` Gleb Natapov
0 siblings, 1 reply; 10+ messages in thread
From: Jan Kiszka @ 2009-09-09 15:57 UTC (permalink / raw)
To: Gleb Natapov; +Cc: avi@redhat.com, kvm-devel
Gleb Natapov wrote:
> On Wed, Sep 09, 2009 at 05:47:13PM +0200, Jan Kiszka wrote:
>> Gleb Natapov wrote:
>>> regs_modified logic doesn't work if io thread calls
>>> kvm_cpu_synchronize_state() since kvm_arch_get_registers()
>>> returns only after vcpu thread is back to kernel. Setting
>>> regs_modified to 1 at this stage causes loading of wrong vcpu
>>> state on the next vcpu_run().
>> We need this upstream too, right? Could you file the corresponding patch?
>>
> Upstream is single threaded. It shouldn't suffer from this bug.
Not if you enable iothread support (though I don't remember if that
works now for kvm) + you are also touching shared code here. So qemu-kvm
would benefit from keeping the diff small.
Jan
>
>> Thanks,
>> Jan
>>
>>> Signed-off-by: Gleb Natapov <gleb@redhat.com>
>>> diff --git a/qemu-kvm.c b/qemu-kvm.c
>>> index 06efd41..9ab0cec 100644
>>> --- a/qemu-kvm.c
>>> +++ b/qemu-kvm.c
>>> @@ -874,14 +874,6 @@ int kvm_set_mpstate(kvm_vcpu_context_t vcpu, struct kvm_mp_state *mp_state)
>>> }
>>> #endif
>>>
>>> -void kvm_cpu_synchronize_state(CPUState *env)
>>> -{
>>> - if (!env->kvm_cpu_state.regs_modified) {
>>> - kvm_arch_get_registers(env);
>>> - env->kvm_cpu_state.regs_modified = 1;
>>> - }
>>> -}
>>> -
>>> static int handle_mmio(kvm_vcpu_context_t vcpu)
>>> {
>>> unsigned long addr = vcpu->run->mmio.phys_addr;
>>> @@ -1539,6 +1531,22 @@ static void on_vcpu(CPUState *env, void (*func)(void *data), void *data)
>>> qemu_cond_wait(&qemu_work_cond);
>>> }
>>>
>>> +static void do_kvm_cpu_synchronize_state(void *_env)
>>> +{
>>> + CPUState *env = _env;
>>> + if (!env->kvm_cpu_state.regs_modified) {
>>> + kvm_arch_save_regs(env);
>>> + kvm_arch_load_mpstate(env);
>>> + env->kvm_cpu_state.regs_modified = 1;
>>> + }
>>> +}
>>> +
>>> +void kvm_cpu_synchronize_state(CPUState *env)
>>> +{
>>> + if (!env->kvm_cpu_state.regs_modified)
>>> + on_vcpu(env, do_kvm_cpu_synchronize_state, env);
>>> +}
>>> +
>>> static void inject_interrupt(void *data)
>>> {
>>> cpu_interrupt(current_env, (long) data);
>>> diff --git a/qemu-kvm.h b/qemu-kvm.h
>>> index 2c1730b..32f74b3 100644
>>> --- a/qemu-kvm.h
>>> +++ b/qemu-kvm.h
>>> @@ -1153,12 +1153,6 @@ static inline int kvm_sync_vcpus(void)
>>> return 0;
>>> }
>>>
>>> -static inline void kvm_arch_get_registers(CPUState *env)
>>> -{
>>> - kvm_save_registers(env);
>>> - kvm_save_mpstate(env);
>>> -}
>>> -
>>> static inline void kvm_arch_put_registers(CPUState *env)
>>> {
>>> kvm_load_registers(env);
>>> diff --git a/target-i386/helper.c b/target-i386/helper.c
>>> index 4a16887..57c74a2 100644
>>> --- a/target-i386/helper.c
>>> +++ b/target-i386/helper.c
>>> @@ -746,7 +746,7 @@ void cpu_dump_state(CPUState *env, FILE *f,
>>> static const char *seg_name[6] = { "ES", "CS", "SS", "DS", "FS", "GS" };
>>>
>>> if (kvm_enabled())
>>> - kvm_arch_get_registers(env);
>>> + kvm_cpu_synchronize_state(env);
>>>
>>> eflags = env->eflags;
>>> #ifdef TARGET_X86_64
>>> --
>>> Gleb.
>> --
>> Siemens AG, Corporate Technology, CT SE 2
>> Corporate Competence Center Embedded Linux
>
> --
> Gleb.
--
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] call kvm_cpu_synchronize_state() on target vcpu
2009-09-09 15:57 ` Jan Kiszka
@ 2009-09-09 16:07 ` Gleb Natapov
2009-09-09 16:21 ` Jan Kiszka
0 siblings, 1 reply; 10+ messages in thread
From: Gleb Natapov @ 2009-09-09 16:07 UTC (permalink / raw)
To: Jan Kiszka; +Cc: avi@redhat.com, kvm-devel
On Wed, Sep 09, 2009 at 05:57:40PM +0200, Jan Kiszka wrote:
> Gleb Natapov wrote:
> > On Wed, Sep 09, 2009 at 05:47:13PM +0200, Jan Kiszka wrote:
> >> Gleb Natapov wrote:
> >>> regs_modified logic doesn't work if io thread calls
> >>> kvm_cpu_synchronize_state() since kvm_arch_get_registers()
> >>> returns only after vcpu thread is back to kernel. Setting
> >>> regs_modified to 1 at this stage causes loading of wrong vcpu
> >>> state on the next vcpu_run().
> >> We need this upstream too, right? Could you file the corresponding patch?
> >>
> > Upstream is single threaded. It shouldn't suffer from this bug.
>
> Not if you enable iothread support (though I don't remember if that
It can't work with kvm since all vcpu ioctls are called on the thread
that issues them.
> works now for kvm) + you are also touching shared code here. So qemu-kvm
> would benefit from keeping the diff small.
>
The patch doesn't touch shared code. (it is almost impossible to tell
what code is shared and what's not nowadays)
> Jan
>
> >
> >> Thanks,
> >> Jan
> >>
> >>> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> >>> diff --git a/qemu-kvm.c b/qemu-kvm.c
> >>> index 06efd41..9ab0cec 100644
> >>> --- a/qemu-kvm.c
> >>> +++ b/qemu-kvm.c
> >>> @@ -874,14 +874,6 @@ int kvm_set_mpstate(kvm_vcpu_context_t vcpu, struct kvm_mp_state *mp_state)
> >>> }
> >>> #endif
> >>>
> >>> -void kvm_cpu_synchronize_state(CPUState *env)
> >>> -{
> >>> - if (!env->kvm_cpu_state.regs_modified) {
> >>> - kvm_arch_get_registers(env);
> >>> - env->kvm_cpu_state.regs_modified = 1;
> >>> - }
> >>> -}
> >>> -
> >>> static int handle_mmio(kvm_vcpu_context_t vcpu)
> >>> {
> >>> unsigned long addr = vcpu->run->mmio.phys_addr;
> >>> @@ -1539,6 +1531,22 @@ static void on_vcpu(CPUState *env, void (*func)(void *data), void *data)
> >>> qemu_cond_wait(&qemu_work_cond);
> >>> }
> >>>
> >>> +static void do_kvm_cpu_synchronize_state(void *_env)
> >>> +{
> >>> + CPUState *env = _env;
> >>> + if (!env->kvm_cpu_state.regs_modified) {
> >>> + kvm_arch_save_regs(env);
> >>> + kvm_arch_load_mpstate(env);
> >>> + env->kvm_cpu_state.regs_modified = 1;
> >>> + }
> >>> +}
> >>> +
> >>> +void kvm_cpu_synchronize_state(CPUState *env)
> >>> +{
> >>> + if (!env->kvm_cpu_state.regs_modified)
> >>> + on_vcpu(env, do_kvm_cpu_synchronize_state, env);
> >>> +}
> >>> +
> >>> static void inject_interrupt(void *data)
> >>> {
> >>> cpu_interrupt(current_env, (long) data);
> >>> diff --git a/qemu-kvm.h b/qemu-kvm.h
> >>> index 2c1730b..32f74b3 100644
> >>> --- a/qemu-kvm.h
> >>> +++ b/qemu-kvm.h
> >>> @@ -1153,12 +1153,6 @@ static inline int kvm_sync_vcpus(void)
> >>> return 0;
> >>> }
> >>>
> >>> -static inline void kvm_arch_get_registers(CPUState *env)
> >>> -{
> >>> - kvm_save_registers(env);
> >>> - kvm_save_mpstate(env);
> >>> -}
> >>> -
> >>> static inline void kvm_arch_put_registers(CPUState *env)
> >>> {
> >>> kvm_load_registers(env);
> >>> diff --git a/target-i386/helper.c b/target-i386/helper.c
> >>> index 4a16887..57c74a2 100644
> >>> --- a/target-i386/helper.c
> >>> +++ b/target-i386/helper.c
> >>> @@ -746,7 +746,7 @@ void cpu_dump_state(CPUState *env, FILE *f,
> >>> static const char *seg_name[6] = { "ES", "CS", "SS", "DS", "FS", "GS" };
> >>>
> >>> if (kvm_enabled())
> >>> - kvm_arch_get_registers(env);
> >>> + kvm_cpu_synchronize_state(env);
> >>>
> >>> eflags = env->eflags;
> >>> #ifdef TARGET_X86_64
> >>> --
> >>> Gleb.
> >> --
> >> Siemens AG, Corporate Technology, CT SE 2
> >> Corporate Competence Center Embedded Linux
> >
> > --
> > Gleb.
>
> --
> Siemens AG, Corporate Technology, CT SE 2
> Corporate Competence Center Embedded Linux
--
Gleb.
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] call kvm_cpu_synchronize_state() on target vcpu
2009-09-09 16:07 ` Gleb Natapov
@ 2009-09-09 16:21 ` Jan Kiszka
2009-09-09 16:27 ` Gleb Natapov
0 siblings, 1 reply; 10+ messages in thread
From: Jan Kiszka @ 2009-09-09 16:21 UTC (permalink / raw)
To: Gleb Natapov; +Cc: avi@redhat.com, kvm-devel
Gleb Natapov wrote:
> On Wed, Sep 09, 2009 at 05:57:40PM +0200, Jan Kiszka wrote:
>> Gleb Natapov wrote:
>>> On Wed, Sep 09, 2009 at 05:47:13PM +0200, Jan Kiszka wrote:
>>>> Gleb Natapov wrote:
>>>>> regs_modified logic doesn't work if io thread calls
>>>>> kvm_cpu_synchronize_state() since kvm_arch_get_registers()
>>>>> returns only after vcpu thread is back to kernel. Setting
>>>>> regs_modified to 1 at this stage causes loading of wrong vcpu
>>>>> state on the next vcpu_run().
>>>> We need this upstream too, right? Could you file the corresponding patch?
>>>>
>>> Upstream is single threaded. It shouldn't suffer from this bug.
>> Not if you enable iothread support (though I don't remember if that
> It can't work with kvm since all vcpu ioctls are called on the thread
> that issues them.
Yeah, I just recalled all that on_vcpu fuzz and that upstream is still
horribly broken /wrt iothread+kvm. But once that is fixed, we also need
this fix here.
>
>> works now for kvm) + you are also touching shared code here. So qemu-kvm
>> would benefit from keeping the diff small.
>>
> The patch doesn't touch shared code. (it is almost impossible to tell
> what code is shared and what's not nowadays)
cpu_dump_state() is definitely shared.
Jan
--
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] call kvm_cpu_synchronize_state() on target vcpu
2009-09-09 16:21 ` Jan Kiszka
@ 2009-09-09 16:27 ` Gleb Natapov
2009-09-09 16:32 ` Jan Kiszka
0 siblings, 1 reply; 10+ messages in thread
From: Gleb Natapov @ 2009-09-09 16:27 UTC (permalink / raw)
To: Jan Kiszka; +Cc: avi@redhat.com, kvm-devel
On Wed, Sep 09, 2009 at 06:21:48PM +0200, Jan Kiszka wrote:
> Gleb Natapov wrote:
> > On Wed, Sep 09, 2009 at 05:57:40PM +0200, Jan Kiszka wrote:
> >> Gleb Natapov wrote:
> >>> On Wed, Sep 09, 2009 at 05:47:13PM +0200, Jan Kiszka wrote:
> >>>> Gleb Natapov wrote:
> >>>>> regs_modified logic doesn't work if io thread calls
> >>>>> kvm_cpu_synchronize_state() since kvm_arch_get_registers()
> >>>>> returns only after vcpu thread is back to kernel. Setting
> >>>>> regs_modified to 1 at this stage causes loading of wrong vcpu
> >>>>> state on the next vcpu_run().
> >>>> We need this upstream too, right? Could you file the corresponding patch?
> >>>>
> >>> Upstream is single threaded. It shouldn't suffer from this bug.
> >> Not if you enable iothread support (though I don't remember if that
> > It can't work with kvm since all vcpu ioctls are called on the thread
> > that issues them.
>
> Yeah, I just recalled all that on_vcpu fuzz and that upstream is still
> horribly broken /wrt iothread+kvm. But once that is fixed, we also need
> this fix here.
>
This will be done as part of transition to on_vcpu() for vcpu ioctls.
> >
> >> works now for kvm) + you are also touching shared code here. So qemu-kvm
> >> would benefit from keeping the diff small.
> >>
> > The patch doesn't touch shared code. (it is almost impossible to tell
> > what code is shared and what's not nowadays)
>
> cpu_dump_state() is definitely shared.
>
Ah this one line. Yes it is. But I have not good commit message for this
one liner change for upstream :)
--
Gleb.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] call kvm_cpu_synchronize_state() on target vcpu
2009-09-09 16:27 ` Gleb Natapov
@ 2009-09-09 16:32 ` Jan Kiszka
2009-09-09 16:36 ` Gleb Natapov
0 siblings, 1 reply; 10+ messages in thread
From: Jan Kiszka @ 2009-09-09 16:32 UTC (permalink / raw)
To: Gleb Natapov; +Cc: avi@redhat.com, kvm-devel
Gleb Natapov wrote:
> On Wed, Sep 09, 2009 at 06:21:48PM +0200, Jan Kiszka wrote:
>> Gleb Natapov wrote:
>>> On Wed, Sep 09, 2009 at 05:57:40PM +0200, Jan Kiszka wrote:
>>>> Gleb Natapov wrote:
>>>>> On Wed, Sep 09, 2009 at 05:47:13PM +0200, Jan Kiszka wrote:
>>>>>> Gleb Natapov wrote:
>>>>>>> regs_modified logic doesn't work if io thread calls
>>>>>>> kvm_cpu_synchronize_state() since kvm_arch_get_registers()
>>>>>>> returns only after vcpu thread is back to kernel. Setting
>>>>>>> regs_modified to 1 at this stage causes loading of wrong vcpu
>>>>>>> state on the next vcpu_run().
>>>>>> We need this upstream too, right? Could you file the corresponding patch?
>>>>>>
>>>>> Upstream is single threaded. It shouldn't suffer from this bug.
>>>> Not if you enable iothread support (though I don't remember if that
>>> It can't work with kvm since all vcpu ioctls are called on the thread
>>> that issues them.
>> Yeah, I just recalled all that on_vcpu fuzz and that upstream is still
>> horribly broken /wrt iothread+kvm. But once that is fixed, we also need
>> this fix here.
>>
> This will be done as part of transition to on_vcpu() for vcpu ioctls.
>
>>>> works now for kvm) + you are also touching shared code here. So qemu-kvm
>>>> would benefit from keeping the diff small.
>>>>
>>> The patch doesn't touch shared code. (it is almost impossible to tell
>>> what code is shared and what's not nowadays)
>> cpu_dump_state() is definitely shared.
>>
> Ah this one line. Yes it is. But I have not good commit message for this
> one liner change for upstream :)
That's why I suggested to post the corresponding change also for
upstream. Even if it doesn't need it now, it will one day. :)
Jan
--
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] call kvm_cpu_synchronize_state() on target vcpu
2009-09-09 16:32 ` Jan Kiszka
@ 2009-09-09 16:36 ` Gleb Natapov
0 siblings, 0 replies; 10+ messages in thread
From: Gleb Natapov @ 2009-09-09 16:36 UTC (permalink / raw)
To: Jan Kiszka; +Cc: avi@redhat.com, kvm-devel
On Wed, Sep 09, 2009 at 06:32:57PM +0200, Jan Kiszka wrote:
> >>> The patch doesn't touch shared code. (it is almost impossible to tell
> >>> what code is shared and what's not nowadays)
> >> cpu_dump_state() is definitely shared.
> >>
> > Ah this one line. Yes it is. But I have not good commit message for this
> > one liner change for upstream :)
>
> That's why I suggested to post the corresponding change also for
> upstream. Even if it doesn't need it now, it will one day. :)
>
I looked at the code. This changes doesn't make sense for upstream right
now IMHO. I do agree that this one linear should go into upstream. I'll
think about commit message tonight.
--
Gleb.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-09-09 16:37 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-09 15:33 [PATCH] call kvm_cpu_synchronize_state() on target vcpu Gleb Natapov
2009-09-09 15:41 ` Avi Kivity
2009-09-09 15:47 ` Jan Kiszka
2009-09-09 15:49 ` Gleb Natapov
2009-09-09 15:57 ` Jan Kiszka
2009-09-09 16:07 ` Gleb Natapov
2009-09-09 16:21 ` Jan Kiszka
2009-09-09 16:27 ` Gleb Natapov
2009-09-09 16:32 ` Jan Kiszka
2009-09-09 16:36 ` Gleb Natapov
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).