Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86/x86 Add a workaround for local APIC timers runn...
details: https://anonhg.NetBSD.org/src/rev/635b53542b32
branches: trunk
changeset: 357730:635b53542b32
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Thu Nov 23 19:53:20 2017 +0000
description:
Add a workaround for local APIC timers running under KVM. It seems these
timers don't reload the current-count register in periodic mode when it
reaches 0, so we need to detect this condition and reload it ourselves.
XXX pullup
diffstat:
sys/arch/x86/x86/lapic.c | 22 ++++++++++++++++++++--
1 files changed, 20 insertions(+), 2 deletions(-)
diffs (57 lines):
diff -r 46ce79a14cc6 -r 635b53542b32 sys/arch/x86/x86/lapic.c
--- a/sys/arch/x86/x86/lapic.c Thu Nov 23 16:30:50 2017 +0000
+++ b/sys/arch/x86/x86/lapic.c Thu Nov 23 19:53:20 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lapic.c,v 1.63 2017/11/04 12:53:00 maxv Exp $ */
+/* $NetBSD: lapic.c,v 1.64 2017/11/23 19:53:20 jmcneill Exp $ */
/*-
* Copyright (c) 2000, 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.63 2017/11/04 12:53:00 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lapic.c,v 1.64 2017/11/23 19:53:20 jmcneill Exp $");
#include "acpica.h"
#include "ioapic.h"
@@ -124,6 +124,8 @@
bool x2apic_enable = false;
#endif
+static bool lapic_broken_periodic __read_mostly;
+
static uint32_t
i82489_readreg(u_int reg)
{
@@ -678,6 +680,16 @@
32;
/*
+ * Apply workaround for broken periodic timer under KVM
+ */
+ if (vm_guest == VM_GUEST_KVM) {
+ lapic_broken_periodic = true;
+ lapic_timecounter.tc_quality = -100;
+ aprint_debug_dev(ci->ci_dev,
+ "applying KVM timer workaround\n");
+ }
+
+ /*
* Now that the timer's calibrated, use the apic timer routines
* for all our timing needs..
*/
@@ -717,6 +729,12 @@
while (deltat > 0) {
xtick = lapic_gettick();
+ if (lapic_broken_periodic && xtick == 0 && otick == 0) {
+ lapic_initclocks();
+ xtick = lapic_gettick();
+ if (xtick == 0)
+ panic("lapic timer stopped ticking");
+ }
if (xtick > otick)
deltat -= lapic_tval - (xtick - otick);
else
Home |
Main Index |
Thread Index |
Old Index