From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org,
Christian Borntraeger <borntraeger@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>
Subject: [ 04/10] s390/timer: avoid overflow when programming clock comparator
Date: Fri, 15 Feb 2013 14:56:36 -0800 [thread overview]
Message-ID: <20130215225544.063361115@linuxfoundation.org> (raw)
In-Reply-To: <20130215225543.586012193@linuxfoundation.org>
3.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <heiko.carstens@de.ibm.com>
commit d911e03d097bdc01363df5d81c43f69432eb785c upstream.
Since ed4f209 "s390/time: fix sched_clock() overflow" a new helper function
is used to avoid overflows when converting TOD format values to nanosecond
values.
The kvm interrupt code formerly however only worked by accident because of
an overflow. It tried to program a timer that would expire in more than ~29
years. Because of the old TOD-to-nanoseconds overflow bug the real expiry
value however was much smaller, but now it isn't anymore.
This however triggers yet another bug in the function that programs the clock
comparator s390_next_ktime(): if the absolute "expires" value is after 2042
this will result in an overflow and the programmed value is lower than the
current TOD value which immediatly triggers a clock comparator (= timer)
interrupt.
Since the timer isn't expired it will be programmed immediately again and so
on... the result is a dead system.
To fix this simply program the maximum possible value if an overflow is
detected.
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
arch/s390/kernel/time.c | 3 +++
1 file changed, 3 insertions(+)
--- a/arch/s390/kernel/time.c
+++ b/arch/s390/kernel/time.c
@@ -120,6 +120,9 @@ static int s390_next_ktime(ktime_t expir
nsecs = ktime_to_ns(ktime_add(timespec_to_ktime(ts), expires));
do_div(nsecs, 125);
S390_lowcore.clock_comparator = sched_clock_base_cc + (nsecs << 9);
+ /* Program the maximum value if we have an overflow (== year 2042) */
+ if (unlikely(S390_lowcore.clock_comparator < sched_clock_base_cc))
+ S390_lowcore.clock_comparator = -1ULL;
set_clock_comparator(S390_lowcore.clock_comparator);
return 0;
}
next prev parent reply other threads:[~2013-02-15 22:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-15 22:56 [ 00/10] 3.7.9-stable review Greg Kroah-Hartman
2013-02-15 22:56 ` [ 01/10] Revert: xfs: fix _xfs_buf_find oops on blocks beyond the filesystem end Greg Kroah-Hartman
2013-02-16 8:06 ` Dave Chinner
2013-02-15 22:56 ` [ 02/10] drivers/rtc/rtc-pl031.c: restore ST variant functionality Greg Kroah-Hartman
2013-02-15 22:56 ` [ 03/10] mm: dont overwrite mm->def_flags in do_mlockall() Greg Kroah-Hartman
2013-02-15 22:56 ` Greg Kroah-Hartman [this message]
2013-02-15 22:56 ` [ 05/10] x86: Do not leak kernel page mapping locations Greg Kroah-Hartman
2013-02-15 22:56 ` [ 06/10] x86/apic: Work around boot failure on HP ProLiant DL980 G7 Server systems Greg Kroah-Hartman
2013-02-15 22:56 ` [ 07/10] x86/mm: Check if PUD is large when validating a kernel address Greg Kroah-Hartman
2013-02-15 22:56 ` [ 08/10] x86/xen: dont assume %ds is usable in xen_iret for 32-bit PVOPS Greg Kroah-Hartman
2013-02-15 22:56 ` [ 09/10] PCI/PM: Clean up PME state when removing a device Greg Kroah-Hartman
2013-02-15 22:56 ` [ 10/10] efi: Clear EFI_RUNTIME_SERVICES rather than EFI_BOOT by "noefi" boot parameter Greg Kroah-Hartman
2013-02-16 22:09 ` [ 00/10] 3.7.9-stable review Shuah Khan
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=20130215225544.063361115@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=borntraeger@de.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.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