From: Avi Kivity <avi@qumranet.com>
To: Glauber Costa <gcosta@redhat.com>
Cc: kvm-devel@lists.sourceforge.net
Subject: Re: [PATCH] disable clock before rebooting.
Date: Fri, 07 Mar 2008 11:10:59 +0200 [thread overview]
Message-ID: <47D106A3.7010909@qumranet.com> (raw)
In-Reply-To: <1204820092-16532-1-git-send-email-gcosta@redhat.com>
Glauber Costa wrote:
> This patch writes 0 (actually, what really matters is that the
> LSB is cleared) to the system time msr before rebooting/shutting down
> the machine.
>
> Without it, we can have a random memory location being written
> when the guest comes back
>
> Signed-off-by: Glauber Costa <gcosta@redhat.com>
> ---
> arch/x86/kernel/kvmclock.c | 32 ++++++++++++++++++++++++++++++++
> 1 files changed, 32 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
> index f654a12..5c9ff8d 100644
> --- a/arch/x86/kernel/kvmclock.c
> +++ b/arch/x86/kernel/kvmclock.c
> @@ -21,6 +21,7 @@ #include <linux/kvm_para.h>
> #include <asm/arch_hooks.h>
> #include <asm/msr.h>
> #include <linux/percpu.h>
> +#include <asm/reboot.h>
>
> #define KVM_SCALE 22
>
> @@ -142,6 +143,32 @@ static void kvm_setup_secondary_clock(vo
> setup_secondary_APIC_clock();
> }
>
> +/*
> + * After the clock is registered, the host will keep writing to the
> + * registered memory location. If the guest happens to shutdown, or restart,
> + * this memory won't be valid. In cases like kexec, in which you install a new kernel,
> + * this will mean a random memory location will be kept being written. So before
> + * any kind of shutdown from our side, we unregister the clock by writting anything
> + * that does not have the 'enable' bit set in the msr
> + */
> +static void kvm_restart(char *unused) {
>
This looks like a struct, with the { sitting there on the end.
> + native_write_msr_safe(MSR_KVM_SYSTEM_TIME, 0, 0);
> + native_machine_restart(unused);
> +}
> +
> +/* Forgive me dear lord, for my laziness */
> +#define kvm_reboot_fn(x) \
> +static void kvm_##x(void) { \
> + native_write_msr_safe(MSR_KVM_SYSTEM_TIME, 0, 0); \
> + native_machine_##x(); \
> +}
> +
> +kvm_reboot_fn(emergency_restart)
> +kvm_reboot_fn(shutdown)
> +kvm_reboot_fn(halt)
> +kvm_reboot_fn(power_off)
> +#undef kvm_reboot_fn
> +
>
Why not go all the way and to _restart the same way?
--
Any sufficiently difficult bug is indistinguishable from a feature.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
next prev parent reply other threads:[~2008-03-07 9:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-06 16:14 [PATCH] disable clock before rebooting Glauber Costa
2008-03-07 9:10 ` Avi Kivity [this message]
2008-03-07 14:04 ` Glauber Costa
2008-03-07 15:55 ` Avi Kivity
2008-03-07 9:15 ` Avi Kivity
2008-03-07 14:23 ` Glauber Costa
2008-03-07 16:07 ` Avi Kivity
2008-03-07 16:10 ` Glauber Costa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47D106A3.7010909@qumranet.com \
--to=avi@qumranet.com \
--cc=gcosta@redhat.com \
--cc=kvm-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox