All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Palmer <daniel@0x0f.com>
To: Romain Perier <romain.perier@gmail.com>
Cc: Colin King <colin.king@canonical.com>,
	Daniel Palmer <daniel@thingy.jp>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Nobuhiro Iwamatsu <iwamatsu@nigauri.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	linux-rtc@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][next] rtc: msc313: Fix unintentional sign extension issue on left shift of a u16
Date: Wed, 29 Sep 2021 21:56:36 +0900	[thread overview]
Message-ID: <CAFr9PXna7YsYnfdtu1jvJhkVSX0SiyixYr_bTsx3tDepeHqcMg@mail.gmail.com> (raw)
In-Reply-To: <CABgxDoLPTcRbZZgAdJ9+=9OG+a=F59x9SQ9HvQkVvGmkDjO6-A@mail.gmail.com>

Hi Romain,

On Tue, 28 Sept 2021 at 22:55, Romain Perier <romain.perier@gmail.com> wrote:
>
> Hi,
>
> Le mar. 28 sept. 2021 à 15:31, Daniel Palmer <daniel@0x0f.com> a écrit :
> The crazy stuff being, I ran rtctest from selftests and rtc-range (1)
> that tests a variety
> of dates including 2038 and 2106 for example. Both tests passed :) (probably
> because *this case* specifically did not happen while running the test)

I suspect it works because for reading the time because seconds is a
u32 not unsigned long like the other functions.
So if the high word of the register is read, is promoted to a wider
type and sign extended it doesn't actually matter because it gets
truncated to 32 bits so the sign extended part is gone.

Cheers,

Daniel

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Palmer <daniel@0x0f.com>
To: Romain Perier <romain.perier@gmail.com>
Cc: Colin King <colin.king@canonical.com>,
	Daniel Palmer <daniel@thingy.jp>,
	 Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>,
	 linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	linux-rtc@vger.kernel.org, kernel-janitors@vger.kernel.org,
	 Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][next] rtc: msc313: Fix unintentional sign extension issue on left shift of a u16
Date: Wed, 29 Sep 2021 21:56:36 +0900	[thread overview]
Message-ID: <CAFr9PXna7YsYnfdtu1jvJhkVSX0SiyixYr_bTsx3tDepeHqcMg@mail.gmail.com> (raw)
In-Reply-To: <CABgxDoLPTcRbZZgAdJ9+=9OG+a=F59x9SQ9HvQkVvGmkDjO6-A@mail.gmail.com>

Hi Romain,

On Tue, 28 Sept 2021 at 22:55, Romain Perier <romain.perier@gmail.com> wrote:
>
> Hi,
>
> Le mar. 28 sept. 2021 à 15:31, Daniel Palmer <daniel@0x0f.com> a écrit :
> The crazy stuff being, I ran rtctest from selftests and rtc-range (1)
> that tests a variety
> of dates including 2038 and 2106 for example. Both tests passed :) (probably
> because *this case* specifically did not happen while running the test)

I suspect it works because for reading the time because seconds is a
u32 not unsigned long like the other functions.
So if the high word of the register is read, is promoted to a wider
type and sign extended it doesn't actually matter because it gets
truncated to 32 bits so the sign extended part is gone.

Cheers,

Daniel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-09-29 12:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28 12:39 [PATCH][next] rtc: msc313: Fix unintentional sign extension issue on left shift of a u16 Colin King
2021-09-28 12:39 ` Colin King
2021-09-28 13:31 ` Daniel Palmer
2021-09-28 13:31   ` Daniel Palmer
2021-09-28 13:34   ` Colin Ian King
2021-09-28 13:34     ` Colin Ian King
2021-09-28 13:54   ` Romain Perier
2021-09-28 13:54     ` Romain Perier
2021-09-29 12:56     ` Daniel Palmer [this message]
2021-09-29 12:56       ` Daniel Palmer

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=CAFr9PXna7YsYnfdtu1jvJhkVSX0SiyixYr_bTsx3tDepeHqcMg@mail.gmail.com \
    --to=daniel@0x0f.com \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=colin.king@canonical.com \
    --cc=daniel@thingy.jp \
    --cc=iwamatsu@nigauri.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=romain.perier@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.