Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 93831
b: refs/heads/master
c: 1e977aa
h: refs/heads/master
i:
  93829: 92478ae
  93827: 26d44d5
  93823: b18bb34
v: v3
  • Loading branch information
Glauber Costa authored and Avi Kivity committed Apr 27, 2008
1 parent 3046028 commit 5527233
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3c62c62502bea24448d4e82aa1f33c7dbca61a32
refs/heads/master: 1e977aa12dd4f80688b1f243762212e75c6d7fe8
27 changes: 27 additions & 0 deletions trunk/arch/x86/kernel/kvmclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <asm/msr.h>
#include <asm/apic.h>
#include <linux/percpu.h>
#include <asm/reboot.h>

#define KVM_SCALE 22

Expand Down Expand Up @@ -143,6 +144,28 @@ static void kvm_setup_secondary_clock(void)
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, this memory
* won't be valid. In cases like kexec, in which you install a new kernel, this
* means 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
*/
#ifdef CONFIG_KEXEC
static void kvm_crash_shutdown(struct pt_regs *regs)
{
native_write_msr_safe(MSR_KVM_SYSTEM_TIME, 0, 0);
native_machine_crash_shutdown(regs);
}
#endif

static void kvm_shutdown(void)
{
native_write_msr_safe(MSR_KVM_SYSTEM_TIME, 0, 0);
native_machine_shutdown();
}

void __init kvmclock_init(void)
{
if (!kvm_para_available())
Expand All @@ -155,6 +178,10 @@ void __init kvmclock_init(void)
pv_time_ops.set_wallclock = kvm_set_wallclock;
pv_time_ops.sched_clock = kvm_clock_read;
pv_apic_ops.setup_secondary_clock = kvm_setup_secondary_clock;
machine_ops.shutdown = kvm_shutdown;
#ifdef CONFIG_KEXEC
machine_ops.crash_shutdown = kvm_crash_shutdown;
#endif
clocksource_register(&kvm_clock);
}
}

0 comments on commit 5527233

Please sign in to comment.