All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvm: disable stealtime via reboot notifier to avoid mem corruption
@ 2012-08-10 10:36 Florian Westphal
  2012-08-13 21:52 ` Marcelo Tosatti
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Westphal @ 2012-08-10 10:36 UTC (permalink / raw)
  To: kvm; +Cc: avi, linux-kernel, Florian Westphal

else, we get memory corruption on reboot; found when tracking down
initramfs unpack error on initial reboot (with qemu-kvm -smp 2,
no problem with single-core).

problem with doing it via kvm_shutdown() is that this file
depends on CONFIG_KVM_CLOCK, also its not enough to call it for one
cpu only.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 not subscribed, please CC on replies.
 Also, I don't know much about kvm or kexec, so its possible
 that i missed something.

 In any case, this seems to fix the initramfs corruption for me.
 patch is against virt/kvm/kvm.git.

 arch/x86/kernel/kvm.c      |    1 +
 arch/x86/kernel/kvmclock.c |    1 -
 2 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index c1d61ee..1596cc8 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -354,6 +354,7 @@ static void kvm_pv_guest_cpu_reboot(void *unused)
 	if (kvm_para_has_feature(KVM_FEATURE_PV_EOI))
 		wrmsrl(MSR_KVM_PV_EOI_EN, 0);
 	kvm_pv_disable_apf();
+	kvm_disable_steal_time();
 }
 
 static int kvm_pv_reboot_notify(struct notifier_block *nb,
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index f1b42b3..5a2fa7d 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -191,7 +191,6 @@ static void kvm_crash_shutdown(struct pt_regs *regs)
 static void kvm_shutdown(void)
 {
 	native_write_msr(msr_kvm_system_time, 0, 0);
-	kvm_disable_steal_time();
 	native_machine_shutdown();
 }
 
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] kvm: disable stealtime via reboot notifier to avoid mem corruption
  2012-08-10 10:36 [PATCH] kvm: disable stealtime via reboot notifier to avoid mem corruption Florian Westphal
@ 2012-08-13 21:52 ` Marcelo Tosatti
  2012-08-14  9:15   ` Florian Westphal
  0 siblings, 1 reply; 4+ messages in thread
From: Marcelo Tosatti @ 2012-08-13 21:52 UTC (permalink / raw)
  To: Florian Westphal; +Cc: kvm, avi, linux-kernel

On Fri, Aug 10, 2012 at 12:36:22PM +0200, Florian Westphal wrote:
> else, we get memory corruption on reboot; found when tracking down
> initramfs unpack error on initial reboot (with qemu-kvm -smp 2,
> no problem with single-core).
> 
> problem with doing it via kvm_shutdown() is that this file
> depends on CONFIG_KVM_CLOCK, also its not enough to call it for one
> cpu only.
> 
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
>  not subscribed, please CC on replies.
>  Also, I don't know much about kvm or kexec, so its possible
>  that i missed something.
> 
>  In any case, this seems to fix the initramfs corruption for me.
>  patch is against virt/kvm/kvm.git.
> 
>  arch/x86/kernel/kvm.c      |    1 +
>  arch/x86/kernel/kvmclock.c |    1 -
>  2 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index c1d61ee..1596cc8 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -354,6 +354,7 @@ static void kvm_pv_guest_cpu_reboot(void *unused)
>  	if (kvm_para_has_feature(KVM_FEATURE_PV_EOI))
>  		wrmsrl(MSR_KVM_PV_EOI_EN, 0);
>  	kvm_pv_disable_apf();
> +	kvm_disable_steal_time();
>  }
>  
>  static int kvm_pv_reboot_notify(struct notifier_block *nb,

This part below will introduce a bug for shutdown. Can you retest with
the addition of kvm_disable_steal_time to kvm_pv_guest_cpu_reboot only,
retest and resend please?

Thanks

> diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
> index f1b42b3..5a2fa7d 100644
> --- a/arch/x86/kernel/kvmclock.c
> +++ b/arch/x86/kernel/kvmclock.c
> @@ -191,7 +191,6 @@ static void kvm_crash_shutdown(struct pt_regs *regs)
>  static void kvm_shutdown(void)
>  {
>  	native_write_msr(msr_kvm_system_time, 0, 0);
> -	kvm_disable_steal_time();
>  	native_machine_shutdown();
>  }
>  
> -- 
> 1.7.8.6
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kvm: disable stealtime via reboot notifier to avoid mem corruption
  2012-08-13 21:52 ` Marcelo Tosatti
@ 2012-08-14  9:15   ` Florian Westphal
  2012-08-14 15:32     ` Marcelo Tosatti
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Westphal @ 2012-08-14  9:15 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Florian Westphal, kvm, avi, linux-kernel

Marcelo Tosatti <mtosatti@redhat.com> wrote:
> On Fri, Aug 10, 2012 at 12:36:22PM +0200, Florian Westphal wrote:
> > --- a/arch/x86/kernel/kvmclock.c
> > +++ b/arch/x86/kernel/kvmclock.c
> > @@ -191,7 +191,6 @@ static void kvm_crash_shutdown(struct pt_regs *regs)
> >  static void kvm_shutdown(void)
> >  {
> >  	native_write_msr(msr_kvm_system_time, 0, 0);
> > -	kvm_disable_steal_time();
> >  	native_machine_shutdown();
> >  }
> This part below will introduce a bug for shutdown. Can you retest with
> the addition of kvm_disable_steal_time to kvm_pv_guest_cpu_reboot only,
> retest and resend please?

I can, but the problem with kvm_disable_steal_time() in
kvmclock.c is that with CONFIG_KVM_CLOCK=n the entire
file won't be compiled.

And steal time doesn't depend on CONFIG_KVM_CLOCK=y.
So if removing it there is a bug leaving it in only avoids
that bug for CONFIG_KVM_CLOCK=y.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kvm: disable stealtime via reboot notifier to avoid mem corruption
  2012-08-14  9:15   ` Florian Westphal
@ 2012-08-14 15:32     ` Marcelo Tosatti
  0 siblings, 0 replies; 4+ messages in thread
From: Marcelo Tosatti @ 2012-08-14 15:32 UTC (permalink / raw)
  To: Florian Westphal; +Cc: kvm, avi, linux-kernel

On Tue, Aug 14, 2012 at 11:15:06AM +0200, Florian Westphal wrote:
> Marcelo Tosatti <mtosatti@redhat.com> wrote:
> > On Fri, Aug 10, 2012 at 12:36:22PM +0200, Florian Westphal wrote:
> > > --- a/arch/x86/kernel/kvmclock.c
> > > +++ b/arch/x86/kernel/kvmclock.c
> > > @@ -191,7 +191,6 @@ static void kvm_crash_shutdown(struct pt_regs *regs)
> > >  static void kvm_shutdown(void)
> > >  {
> > >  	native_write_msr(msr_kvm_system_time, 0, 0);
> > > -	kvm_disable_steal_time();
> > >  	native_machine_shutdown();
> > >  }
> > This part below will introduce a bug for shutdown. Can you retest with
> > the addition of kvm_disable_steal_time to kvm_pv_guest_cpu_reboot only,
> > retest and resend please?
> 
> I can, but the problem with kvm_disable_steal_time() in
> kvmclock.c is that with CONFIG_KVM_CLOCK=n the entire
> file won't be compiled.
> 
> And steal time doesn't depend on CONFIG_KVM_CLOCK=y.
> So if removing it there is a bug leaving it in only avoids
> that bug for CONFIG_KVM_CLOCK=y.

I meant to add kvm_disable_steal_time() call to arch/x86/kernel/kvm.c,
the first part of your patch, here:

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index c1d61ee..1596cc8 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -354,6 +354,7 @@ static void kvm_pv_guest_cpu_reboot(void *unused)
      if (kvm_para_has_feature(KVM_FEATURE_PV_EOI))
              wrmsrl(MSR_KVM_PV_EOI_EN, 0);
      kvm_pv_disable_apf();
+     kvm_disable_steal_time();
 }
 
 static int kvm_pv_reboot_notify(struct notifier_block *nb,

Can you test only that part and resend? 

The call to kvm_disable_steal_time() in kvmclock.c should not be
removed.


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-08-14 15:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-10 10:36 [PATCH] kvm: disable stealtime via reboot notifier to avoid mem corruption Florian Westphal
2012-08-13 21:52 ` Marcelo Tosatti
2012-08-14  9:15   ` Florian Westphal
2012-08-14 15:32     ` Marcelo Tosatti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.