kvm: disable stealtime via reboot notifier to avoid mem corruption
Subsystems (3)
PATCH 1/1 kvm: disable stealtime via reboot notifier to avoid mem corruption
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.
---
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(-)
arch/x86/kernel/kvm.c +1 -0
@@ -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,
arch/x86/kernel/kvmclock.c +0 -1
@@ -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 (); }
Signature · 1 line
1.7.8.6
Quoted 26 lines · 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 onCONFIG_KVM_CLOCK, also its not enough to call it for one cpu only.Signed-off-by Florian Westphal <[email protected]>---
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(-)arch/x86/kernel/kvm.c +0
-0
arch/x86/kernel/kvm.c static void kvm_pv_guest_cpu_reboot(void *unused) · line 360
Quoted 7 lines
arch/x86/kernel/kvm.c +1
-0@@ -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
Quoted 19 lines
arch/x86/kernel/kvmclock.c +0
-1@@ -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 (); }Signature · 6 lines
1.7.8.6 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 13 lines · Marcelo Tosatti
arch/x86/kernel/kvmclock.c static void kvm_crash_shutdown(struct pt_regs *regs) · line 195
Quoted 9 lines · Florian Westphal
arch/x86/kernel/kvmclock.c +0
-1@@ -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_timetokvm_pv_guest_cpu_rebootonly, 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.
Quoted 15 lines · Florian Westphal
Quoted 13 lines · Marcelo Tosatti
arch/x86/kernel/kvmclock.c static void kvm_crash_shutdown(struct pt_regs *regs) · line 195
Quoted 9 lines · Florian Westphal
arch/x86/kernel/kvmclock.c +0
-1@@ -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_timetokvm_pv_guest_cpu_rebootonly, retest and resend please?
Quoted 7 lines
I can, but the problem with
kvm_disable_steal_time()inkvmclock.cis that withCONFIG_KVM_CLOCK=nthe 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 forCONFIG_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:
arch/x86/kernel/kvm.c +1 -0
@@ -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.