git: 2bb0efbb7b64 - main - Revert: LinuxKPI: switch jiffies and timer->expire to unsigned long
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 08 Jan 2025 08:33:33 UTC
The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=2bb0efbb7b64fa957d46d4f443b000f375fc03d4 commit 2bb0efbb7b64fa957d46d4f443b000f375fc03d4 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2025-01-08 08:30:00 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2025-01-08 08:30:14 +0000 Revert: LinuxKPI: switch jiffies and timer->expire to unsigned long There are possible problems when jiffies (ticks) which still are int wrap around. Also given this did not touch every single place some checks may be broken now. Reported by: markj This reverts commit fd27f86dd71b7ff1df6981297095b88d1d29652e. --- sys/compat/linuxkpi/common/include/linux/jiffies.h | 28 +++++++++++----------- sys/compat/linuxkpi/common/include/linux/timer.h | 4 ++-- sys/compat/linuxkpi/common/src/linux_compat.c | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/jiffies.h b/sys/compat/linuxkpi/common/include/linux/jiffies.h index 8346e74fb830..bd05a0db0767 100644 --- a/sys/compat/linuxkpi/common/include/linux/jiffies.h +++ b/sys/compat/linuxkpi/common/include/linux/jiffies.h @@ -38,7 +38,7 @@ #define jiffies ticks #define jiffies_64 ticks -#define jiffies_to_msecs(x) ((unsigned int)(((int64_t)(unsigned long)(x)) * 1000 / hz)) +#define jiffies_to_msecs(x) ((unsigned int)(((int64_t)(int)(x)) * 1000 / hz)) #define MAX_JIFFY_OFFSET ((INT_MAX >> 1) - 1) @@ -68,7 +68,7 @@ extern uint64_t lkpi_msec2hz_rem; extern uint64_t lkpi_msec2hz_div; extern uint64_t lkpi_msec2hz_max; -static inline unsigned long +static inline int timespec_to_jiffies(const struct timespec *ts) { u64 result; @@ -78,10 +78,10 @@ timespec_to_jiffies(const struct timespec *ts) if (result > MAX_JIFFY_OFFSET) result = MAX_JIFFY_OFFSET; - return ((unsigned long)result); + return ((int)result); } -static inline unsigned long +static inline int msecs_to_jiffies(uint64_t msec) { uint64_t result; @@ -92,10 +92,10 @@ msecs_to_jiffies(uint64_t msec) if (result > MAX_JIFFY_OFFSET) result = MAX_JIFFY_OFFSET; - return ((unsigned long)result); + return ((int)result); } -static inline unsigned long +static inline int usecs_to_jiffies(uint64_t usec) { uint64_t result; @@ -106,7 +106,7 @@ usecs_to_jiffies(uint64_t usec) if (result > MAX_JIFFY_OFFSET) result = MAX_JIFFY_OFFSET; - return ((unsigned long)result); + return ((int)result); } static inline uint64_t @@ -133,17 +133,17 @@ nsecs_to_jiffies(uint64_t nsec) } static inline uint64_t -jiffies_to_nsecs(const unsigned long j) +jiffies_to_nsecs(int j) { - return ((1000000000ULL / hz) * (const uint64_t)j); + return ((1000000000ULL / hz) * (uint64_t)(unsigned int)j); } static inline uint64_t -jiffies_to_usecs(const unsigned long j) +jiffies_to_usecs(int j) { - return ((1000000ULL / hz) * (const uint64_t)j); + return ((1000000ULL / hz) * (uint64_t)(unsigned int)j); } static inline uint64_t @@ -153,10 +153,10 @@ get_jiffies_64(void) return ((uint64_t)(unsigned int)ticks); } -static inline unsigned long -linux_timer_jiffies_until(unsigned long expires) +static inline int +linux_timer_jiffies_until(int expires) { - unsigned long delta = expires - jiffies; + int delta = expires - jiffies; /* guard against already expired values */ if (delta < 1) delta = 1; diff --git a/sys/compat/linuxkpi/common/include/linux/timer.h b/sys/compat/linuxkpi/common/include/linux/timer.h index f9c76222795c..8bea082c3e6c 100644 --- a/sys/compat/linuxkpi/common/include/linux/timer.h +++ b/sys/compat/linuxkpi/common/include/linux/timer.h @@ -42,7 +42,7 @@ struct timer_list { void (*function_415) (struct timer_list *); }; unsigned long data; - unsigned long expires; + int expires; }; extern unsigned long linux_timer_hz_mask; @@ -76,7 +76,7 @@ extern unsigned long linux_timer_hz_mask; callout_init(&(timer)->callout, 1); \ } while (0) -extern int mod_timer(struct timer_list *, unsigned long); +extern int mod_timer(struct timer_list *, int); extern void add_timer(struct timer_list *); extern void add_timer_on(struct timer_list *, int cpu); extern int del_timer(struct timer_list *); diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 35cb2fc2f3d7..ec3ccb16b47d 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -1938,7 +1938,7 @@ linux_timer_callback_wrapper(void *context) } int -mod_timer(struct timer_list *timer, unsigned long expires) +mod_timer(struct timer_list *timer, int expires) { int ret;