27 Aug, 2011

1 commit

  • Even though the Linux kernel does not use the tm_isdst field, it is
    exposed as part of the ABI. This field can accidentally be left
    initialized, which is why we currently memset buffers returned to
    userland in rtc_read_time.

    There is a case however where the field can return garbage from the
    stack though when using the RTC_ALM_READ ioctl on the rtc device. This
    ioctl invokes rtc_read_alarm, which is careful to memset the rtc_wkalrm
    buffer that is copied to userland, but it then uses a struct copy to
    assign to alarm->time given the return value from rtc_ktime_to_tm().

    rtc_ktime_to_tm() is implemented by calling rtc_time_to_tm using a
    derivative seconds counds from ktime, but rtc_time_to_tm does not assign
    a value to ->tm_isdst. This results in garbage from rtc_ktime_to_tm()'s
    frame ending up being copied out to userland as part of the returned
    rtc_wkalrm.

    Fix this by initializing rtc_time->tm_isdst to 0 in rtc_time_to_tm.

    Signed-off-by: Mike Waychison
    Signed-off-by: John Stultz

    Mike Waychison
     

11 Dec, 2010

1 commit

  • This patch reworks a large portion of the generic RTC code
    to in-effect virtualize the rtc interrupt code.

    The current RTC interface is very much a raw hardware interface.
    Via the proc, /dev/, or sysfs interfaces, applciations can set
    the hardware to trigger interrupts in one of three modes:

    AIE: Alarm interrupt
    UIE: Update interrupt (ie: once per second)
    PIE: Periodic interrupt (sub-second irqs)

    The problem with this interface is that it limits the RTC hardware
    so it can only be used by one application at a time.

    The purpose of this patch is to extend the RTC code so that we can
    multiplex multiple applications event needs onto a single RTC device.
    This is done by utilizing the timerqueue infrastructure to manage
    a list of events, which cause the RTC hardware to be programmed
    to fire an interrupt for the next event in the list.

    In order to preserve the functionality of the exsting proc,/dev/ and
    sysfs interfaces, we emulate the different interrupt modes as follows:

    AIE: We create a rtc_timer dedicated to AIE mode interrupts. There is
    only one per device, so we don't change existing interface semantics.

    UIE: Again, a dedicated rtc_timer, set for periodic mode, is used
    to emulate UIE interrupts. Again, only one per device.

    PIE: Since PIE mode interrupts fire faster then the RTC's clock read
    granularity, we emulate PIE mode interrupts using a hrtimer. Again,
    one per device.

    With this patch, the rtctest.c application in Documentation/rtc.txt
    passes fine on x86 hardware. However, there may very well still be
    bugs, so greatly I'd appreciate any feedback or testing!

    Signed-off-by: John Stultz
    LKML Reference:
    Acked-by: Alessandro Zummo
    Reviewed-by: Thomas Gleixner
    CC: Alessandro Zummo
    CC: Thomas Gleixner
    CC: Richard Cochran

    John Stultz
     

01 Apr, 2009

1 commit

  • - the LEAP_YEAR macro is buggy - it references its arg multiple times.
    Fix this by turning it into a C function.

    - give it a more approriate name

    - Move it to rtc.h so that other .c files can use it, instead of copying it.

    Cc: dann frazier
    Acked-by: Alessandro Zummo
    Cc: stephane eranian
    Cc: "Luck, Tony"
    Cc: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

03 Sep, 2008

1 commit

  • commit 945185a69daa457c4c5e46e47f4afad7dcea734f ("rtc: rtc_time_to_tm: use
    unsigned arithmetic") changed the some types in rtc_time_to_tm() to
    unsigned:

    void rtc_time_to_tm(unsigned long time, struct rtc_time *tm)
    {
    - register int days, month, year;
    + unsigned int days, month, year;

    This doesn't work for all cases, because days is checked for < 0 later
    on:

    if (days < 0) {
    year -= 1;
    days += 365 + LEAP_YEAR(year);
    }

    I think the correct fix would be to keep days signed and do an appropriate
    cast later on.

    Signed-off-by: Jan Altenberg
    Cc: Maciej W. Rozycki
    Cc: Alessandro Zummo
    Cc: David Brownell
    Cc: Dmitri Vorobiev
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Altenberg
     

13 May, 2008

1 commit

  • The input argument to rtc_time_to_tm() is unsigned as well as are members of
    the output structure. However signed arithmetic is used within for
    calculations leading to incorrect results for input values outside the signed
    positive range. If this happens the time of day returned is out of range.

    Found the problem when fiddling with the RTC and the driver where year was set
    to an unexpectedly large value like 2070, e.g.:

    rtc0: setting system clock to 2070-01-01 1193046:71582832:26 UTC (3155760954)

    while it should be:

    rtc0: setting system clock to 2070-01-01 00:15:54 UTC (3155760954)

    Changing types to unsigned fixes the problem.

    [akpm@linux-foundation.org: remove old-fashioned `register' keyword]
    Signed-off-by: Maciej W. Rozycki
    Cc: Alessandro Zummo
    Cc: David Brownell
    Cc: Dmitri Vorobiev
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Maciej W. Rozycki
     

09 May, 2007

1 commit

  • David says "884b4aaaa242a2db8c8252796f0118164a680ab5 should be reverted. It
    added an rtc_merge_alarm() call to the 2.6.20 kernel, which hasn't yet been
    used by any in-tree driver; this patch obviates the need for that call, and
    uses a more robust approach."

    Cc: Scott Wood
    Cc: Alessandro Zummo
    Cc: David Brownell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

11 Dec, 2006

1 commit

  • Add rtc_merge_alarm(), which can be used by rtc drivers to turn a partially
    specified alarm expiry (i.e. most significant fields set to -1, as with the
    RTC_ALM_SET ioctl()) into a fully specified expiry.

    If the most significant specified field is earlier than the current time, the
    least significant unspecified field is incremented.

    Signed-off-by: Scott Wood
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Scott Wood
     

01 Oct, 2006

1 commit

  • The rtc_is_valid_tm() routine needs to treat some of the fields it checks as
    unsigned, to prevent wrongly accepting invalid rtc_time structs; this is the
    same approach used elsewhere in the RTC code for such tests.

    Conversely, rtc_proc_show() is missing one invalid-day-of-month test that
    rtc_is_valid_tm() makes: there is no day zero.

    Signed-off-by: David Brownell
    Cc: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Brownell
     

26 Jun, 2006

1 commit


28 Mar, 2006

1 commit