From: Vladimir Davydov <vdavydov@parallels.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
Andy Lutomirski <luto@mit.edu>, Jan Beulich <jbeulich@suse.com>
Cc: Vladimir Davydov <vdavydov@parallels.com>, <x86@kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH] arch: x86: take precautions against spurious timer interrupts
Date: Mon, 23 Apr 2012 16:18:14 +0400 [thread overview]
Message-ID: <1335183494-19645-1-git-send-email-vdavydov@parallels.com> (raw)
If hpet is enabled by hpet_late_init() - this usually occurs on systems
with buggy BIOS, which does not report about hpet presence through ACPI,
hpet_clockevent's event_handler can be left uninitialized by
clockevents_register_device() because of hpet_clockevent low rating (by
the time hpet_late_init() is called, high prio apic timers have already
been setup). The event_handler is then initialized a bit later by the
clocksource_done_booting() procedure.
Normally, timer interrupts should not be delivered between these two
calls, but if e.g. the kernel is booted using kexec, there might be some
pending interrupts from the previous kernel's context, which can lead to
a NULL pointer dereference.
So, take precautions against spurious timer interrupts by checking the
event_handler value before calling it.
---
arch/x86/kernel/time.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
index c6eba2b..43bdd3a 100644
--- a/arch/x86/kernel/time.c
+++ b/arch/x86/kernel/time.c
@@ -57,7 +57,23 @@ EXPORT_SYMBOL(profile_pc);
*/
static irqreturn_t timer_interrupt(int irq, void *dev_id)
{
- global_clock_event->event_handler(global_clock_event);
+ /*
+ * If hpet is enabled by hpet_late_init(), event_handler can be left
+ * uninitialized by clockevents_register_device() because of
+ * hpet_clockevent low rating (by the time hpet_late_init() is called,
+ * high prio apic timers have already been setup). The event_handler is
+ * then initialized a bit later by the clocksource_done_booting()
+ * procedure.
+ *
+ * Normally, timer interrupts should not be delivered between these two
+ * calls, but if e.g. the kernel is booted using kexec, there might be
+ * some pending interrupts from the previous kernel's context, which
+ * can lead to a NULL pointer dereference.
+ *
+ * So, take precautions against spurious timer interrupts.
+ */
+ if (global_clock_event->event_handler)
+ global_clock_event->event_handler(global_clock_event);
/* MCA bus quirk: Acknowledge irq0 by setting bit 7 in port 0x61 */
if (MCA_bus)
--
1.7.1
next reply other threads:[~2012-04-23 12:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-23 12:18 Vladimir Davydov [this message]
2012-04-24 13:55 ` Paul Gortmaker
2012-04-24 14:08 ` Vladimir Davydov
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=1335183494-19645-1-git-send-email-vdavydov@parallels.com \
--to=vdavydov@parallels.com \
--cc=hpa@zytor.com \
--cc=jbeulich@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@mit.edu \
--cc=mingo@redhat.com \
--cc=paul.gortmaker@windriver.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®