diff mbox series

input_event: Provide override for sparc64

Message ID 20181229183514.24644-1-deepa.kernel@gmail.com (mailing list archive)
State Mainlined
Commit 2e746942ebacf1565caa72cf980745e5ce297c48
Headers show
Series input_event: Provide override for sparc64 | expand

Commit Message

Deepa Dinamani Dec. 29, 2018, 6:35 p.m. UTC
The usec part of the timeval is defined as
__kernel_suseconds_t	tv_usec; /* microseconds */

Arnd noticed that sparc64 is the only architecture
that defines __kernel_suseconds_t as int rather than long.

This breaks the current y2038 fix for kernel as we only
access and define the timeval struct for non-kernel use cases.
But, this was hidden by an another typo in the use of __KERNEL__
qualifier.

Fix the typo, and provide an override for sparc64.

Fixes: 152194fe9c3f ("Input: extend usable life of event timestamps to 2106 on 32 bit systems")
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
---
 include/uapi/linux/input.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Deepa Dinamani Jan. 14, 2019, 4:37 a.m. UTC | #1
> On Dec 29, 2018, at 10:35 AM, Deepa Dinamani <deepa.kernel@gmail.com> wrote:
> 
> The usec part of the timeval is defined as
> __kernel_suseconds_t    tv_usec; /* microseconds */
> 
> Arnd noticed that sparc64 is the only architecture
> that defines __kernel_suseconds_t as int rather than long.
> 
> This breaks the current y2038 fix for kernel as we only
> access and define the timeval struct for non-kernel use cases.
> But, this was hidden by an another typo in the use of __KERNEL__
> qualifier.
> 
> Fix the typo, and provide an override for sparc64.
> 
> Fixes: 152194fe9c3f ("Input: extend usable life of event timestamps to 2106 on 32 bit systems")
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
> ---
> include/uapi/linux/input.h | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
> index fb78f6f500f3..ffab958bc512 100644
> --- a/include/uapi/linux/input.h
> +++ b/include/uapi/linux/input.h
> @@ -26,13 +26,17 @@
>  */
> 
> struct input_event {
> -#if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL)
> +#if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL__)
>    struct timeval time;
> #define input_event_sec time.tv_sec
> #define input_event_usec time.tv_usec
> #else
>    __kernel_ulong_t __sec;
> +#ifdef CONFIG_SPARC64
> +    unsigned int __usec;
> +#else
>    __kernel_ulong_t __usec;
> +#endif
> #define input_event_sec  __sec
> #define input_event_usec __usec
> #endif
> -- 
> 2.17.1

Ping.


This is required for the proper functioning of the y2038 additions to input event.

-Deepa
Dmitry Torokhov Jan. 14, 2019, 6:52 a.m. UTC | #2
On Sat, Dec 29, 2018 at 10:35:14AM -0800, Deepa Dinamani wrote:
> The usec part of the timeval is defined as
> __kernel_suseconds_t	tv_usec; /* microseconds */
> 
> Arnd noticed that sparc64 is the only architecture
> that defines __kernel_suseconds_t as int rather than long.
> 
> This breaks the current y2038 fix for kernel as we only
> access and define the timeval struct for non-kernel use cases.
> But, this was hidden by an another typo in the use of __KERNEL__
> qualifier.
> 
> Fix the typo, and provide an override for sparc64.
> 
> Fixes: 152194fe9c3f ("Input: extend usable life of event timestamps to 2106 on 32 bit systems")
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>

Applied, thank you.

> ---
>  include/uapi/linux/input.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
> index fb78f6f500f3..ffab958bc512 100644
> --- a/include/uapi/linux/input.h
> +++ b/include/uapi/linux/input.h
> @@ -26,13 +26,17 @@
>   */
>  
>  struct input_event {
> -#if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL)
> +#if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL__)
>  	struct timeval time;
>  #define input_event_sec time.tv_sec
>  #define input_event_usec time.tv_usec
>  #else
>  	__kernel_ulong_t __sec;
> +#ifdef CONFIG_SPARC64
> +	unsigned int __usec;
> +#else
>  	__kernel_ulong_t __usec;
> +#endif
>  #define input_event_sec  __sec
>  #define input_event_usec __usec
>  #endif
> -- 
> 2.17.1
>
Arnd Bergmann Jan. 15, 2019, 9:19 p.m. UTC | #3
On Sat, Dec 29, 2018 at 7:35 PM Deepa Dinamani <deepa.kernel@gmail.com> wrote:

>         struct timeval time;
>  #define input_event_sec time.tv_sec
>  #define input_event_usec time.tv_usec
>  #else
>         __kernel_ulong_t __sec;
> +#ifdef CONFIG_SPARC64
> +       unsigned int __usec;
> +#else
>         __kernel_ulong_t __usec;
> +#endif
>  #define input_event_sec  __sec
>  #define input_event_usec __usec
>  #endif

Sorry for not having looked at this earlier, I just realized that this
is a mistake
in user space: uapi headers are not allowed to reference CONFIG_* symbols,
since the headers are supposed to be configuration independent and the
CONFIG_* namespace might clash with user space identifiers.

The correct check appears to be

#if defined(__sparc__) && defined(__arch64__)

      Arnd
David Miller Jan. 15, 2019, 9:29 p.m. UTC | #4
From: Arnd Bergmann <arnd@arndb.de>
Date: Tue, 15 Jan 2019 22:19:27 +0100

> The correct check appears to be
> 
> #if defined(__sparc__) && defined(__arch64__)

That is correct.
Dmitry Torokhov Jan. 15, 2019, 10:32 p.m. UTC | #5
On Tue, Jan 15, 2019 at 1:29 PM David Miller <davem@davemloft.net> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
> Date: Tue, 15 Jan 2019 22:19:27 +0100
>
> > The correct check appears to be
> >
> > #if defined(__sparc__) && defined(__arch64__)
>
> That is correct.

OK. Deepa, could you please send me a fixup as I already pushed out
the original patch?

Thanks.
Deepa Dinamani Jan. 16, 2019, 12:10 a.m. UTC | #6
> On Jan 15, 2019, at 2:32 PM, Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> 
>> On Tue, Jan 15, 2019 at 1:29 PM David Miller <davem@davemloft.net> wrote:
>> 
>> From: Arnd Bergmann <arnd@arndb.de>
>> Date: Tue, 15 Jan 2019 22:19:27 +0100
>> 
>>> The correct check appears to be
>>> 
>>> #if defined(__sparc__) && defined(__arch64__)
>> 
>> That is correct.
> 
> OK. Deepa, could you please send me a fixup as I already pushed out
> the original patch?

Ok, I’m traveling. I will post an update in a couple of days.

Thanks,
Deepa
diff mbox series

Patch

diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index fb78f6f500f3..ffab958bc512 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -26,13 +26,17 @@ 
  */
 
 struct input_event {
-#if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL)
+#if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL__)
 	struct timeval time;
 #define input_event_sec time.tv_sec
 #define input_event_usec time.tv_usec
 #else
 	__kernel_ulong_t __sec;
+#ifdef CONFIG_SPARC64
+	unsigned int __usec;
+#else
 	__kernel_ulong_t __usec;
+#endif
 #define input_event_sec  __sec
 #define input_event_usec __usec
 #endif