Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1265992

Re: [Y2038] [PATCH v3] scsi: pmcraid: replace struct timeval with ktime_get_real_seconds()

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject Re: [Y2038] [PATCH v3] scsi: pmcraid: replace struct timeval with ktime_get_real_seconds()
Date 2015-11-09 21:40 +0100
Message-ID <qt1om-2Rg-15@gated-at.bofh.it> (permalink)
References <qt0si-2g6-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Monday 09 November 2015 11:34:20 Alison Schofield wrote:
> Replace the use of struct timeval and do_gettimeofday() with
> 64 bit ktime_get_real_seconds. Prevents 32-bit type overflow
> in year 2038 on 32-bit systems.
> 
> Driver was using the seconds portion of struct timeval (.tv_secs)
> to pass a millseconds timestamp to the firmware. This change maintains
> that same behavior using ktime_get_real_seconds.
> 
> The structure used to pass the timestamp to firmware is 48 bits and
> works fine as long as the top 16 bits are zero and they will be zero
> for a long time..ie. thousands of years.
> 
> Alternative Change:  Add sub second granularity to timestamp
> 
> As noted above, the driver only used the seconds portion of timeval,
> ignores the microseconds portion, and by multiplying by 1000 effectively
> does a <<10 and always writes zero into timestamp[0].
> 
> The alternative change would pass all the bits to the firmware:
> 
>         struct timespec64 ts;
> 
>         ktime_get_real_ts64(&ts);
>         timestamp = ts.tv_sec * MSEC_PER_SEC + ts.tv_nsec / NSEC_PER_MSEC;
> 
> MAINTAINER: Please request alternate change if preferred.
> 
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
> 

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

just the last sentence of the changelog should probably go below the
"---" line as it is irrelevant in the git history if the patch gets
applied. James can probably remove that line manually when he applies
it, just remember this if you have to send a version 4 for another
reason.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3] scsi: pmcraid: replace struct timeval with ktime_get_real_seconds() Alison Schofield <amsfield22@gmail.com> - 2015-11-09 20:40 +0100
  Re: [Y2038] [PATCH v3] scsi: pmcraid: replace struct timeval with ktime_get_real_seconds() Arnd Bergmann <arnd@arndb.de> - 2015-11-09 21:40 +0100
  Re: [PATCH v3] scsi: pmcraid: replace struct timeval with ktime_get_real_seconds() "Martin K. Petersen" <martin.petersen@oracle.com> - 2015-11-12 03:00 +0100

csiph-web