01fc30
commit 46d2121960d81354facf4e2558c81f82257b740e
01fc30
Author: Dave Anderson <anderson@redhat.com>
01fc30
Date:   Tue May 29 14:04:03 2018 -0400
01fc30
01fc30
    Fix for the "timer -r" command on Linux 4.10 and later kernels that
01fc30
    contain commit 2456e855354415bfaeb7badaa14e11b3e02c8466, titled
01fc30
    "ktime: Get rid of the union".  Without the patch, the command fails
01fc30
    with the error message "timer: invalid structure member offset:
01fc30
    ktime_t_sec".
01fc30
    (k-hagio@ab.jp.nec.com)
01fc30
01fc30
diff --git a/kernel.c b/kernel.c
01fc30
index b1886ce..138a47f 100644
01fc30
--- a/kernel.c
01fc30
+++ b/kernel.c
01fc30
@@ -7740,7 +7740,7 @@ ktime_to_ns(const void *ktime)
01fc30
 	if (VALID_MEMBER(ktime_t_tv64)) {
01fc30
 		readmem((ulong)ktime + OFFSET(ktime_t_tv64), KVADDR, &ns,
01fc30
 			sizeof(ns), "ktime_t tv64", QUIET|RETURN_ON_ERROR);
01fc30
-	} else {
01fc30
+	} else if (VALID_MEMBER(ktime_t_sec) && VALID_MEMBER(ktime_t_nsec)) {
01fc30
 		uint32_t sec, nsec;
01fc30
 
01fc30
 		sec = 0;
01fc30
@@ -7753,6 +7753,9 @@ ktime_to_ns(const void *ktime)
01fc30
 			sizeof(nsec), "ktime_t nsec", QUIET|RETURN_ON_ERROR);
01fc30
 
01fc30
 		ns = sec * 1000000000L + nsec;
01fc30
+	} else {
01fc30
+		readmem((ulong)ktime, KVADDR, &ns,
01fc30
+			sizeof(ns), "ktime_t", QUIET|RETURN_ON_ERROR);
01fc30
 	}
01fc30
 
01fc30
 	return ns;