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