All of lore.kernel.org
 help / color / mirror / Atom feed
* arch/x86/include/uapi/../../../../lib/vdso/gettimeofday.c:308 __cvdso_clock_gettime_common() warn: right shifting more than type allows 32 vs 40
@ 2026-02-11 12:13 ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-02-11 11:09 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: "H. Peter Anvin" <hpa@zytor.com>
CC: Dave Hansen <dave.hansen@linux.intel.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   192c0159402e6bfbe13de6f8379546943297783d
commit: 693c819fedcdcabfda7488e2d5e355a84c2fd1b0 x86/entry/vdso: Refactor the vdso build
date:   4 weeks ago
:::::: branch date: 5 hours ago
:::::: commit date: 4 weeks ago
config: x86_64-randconfig-161-20260210 (https://download.01.org/0day-ci/archive/20260211/202602111941.PIhubgrb-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
smatch version: v0.5.0-8994-gd50c5a4c

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202602111941.PIhubgrb-lkp@intel.com/

smatch warnings:
arch/x86/include/uapi/../../../../lib/vdso/gettimeofday.c:308 __cvdso_clock_gettime_common() warn: right shifting more than type allows 32 vs 40
arch/x86/include/uapi/../../../../lib/vdso/gettimeofday.c:308 __cvdso_clock_gettime_common() warn: bitwise AND condition is false here
arch/x86/include/uapi/../../../../lib/vdso/gettimeofday.c:454 __cvdso_clock_getres_common() warn: right shifting more than type allows 32 vs 40
arch/x86/include/uapi/../../../../lib/vdso/gettimeofday.c:454 __cvdso_clock_getres_common() warn: bitwise AND condition is false here

vim +308 arch/x86/include/uapi/../../../../lib/vdso/gettimeofday.c

cd3557a7618bf5 Thomas Weißschuh   2025-07-01  286  
fb61bdb27fd730 Thomas Weißschuh   2025-07-01  287  static __always_inline bool
ac1a42f4e4e296 Thomas Weißschuh   2025-02-04  288  __cvdso_clock_gettime_common(const struct vdso_time_data *vd, clockid_t clock,
e876f0b69dc993 Christophe Leroy   2020-02-07  289  			     struct __kernel_timespec *ts)
00b26474c2f161 Vincenzo Frascino  2019-06-21  290  {
886653e3663917 Anna-Maria Behnsen 2025-03-03  291  	const struct vdso_clock *vc = vd->clock_data;
00b26474c2f161 Vincenzo Frascino  2019-06-21  292  	u32 msk;
00b26474c2f161 Vincenzo Frascino  2019-06-21  293  
1a1cd5fe881fdf Thomas Weißschuh   2025-07-01  294  	if (!vdso_clockid_valid(clock))
fb61bdb27fd730 Thomas Weißschuh   2025-07-01  295  		return false;
00b26474c2f161 Vincenzo Frascino  2019-06-21  296  
00b26474c2f161 Vincenzo Frascino  2019-06-21  297  	/*
00b26474c2f161 Vincenzo Frascino  2019-06-21  298  	 * Convert the clockid to a bitmask and use it to check which
00b26474c2f161 Vincenzo Frascino  2019-06-21  299  	 * clocks are handled in the VDSO directly.
00b26474c2f161 Vincenzo Frascino  2019-06-21  300  	 */
00b26474c2f161 Vincenzo Frascino  2019-06-21  301  	msk = 1U << clock;
8463cf80529d0f Christophe Leroy   2019-12-23  302  	if (likely(msk & VDSO_HRES))
cddb82d1c4de56 Anna-Maria Behnsen 2025-03-03  303  		vc = &vc[CS_HRES_COARSE];
8463cf80529d0f Christophe Leroy   2019-12-23  304  	else if (msk & VDSO_COARSE)
70067ae181f302 Anna-Maria Behnsen 2025-03-03  305  		return do_coarse(vd, &vc[CS_HRES_COARSE], clock, ts);
8463cf80529d0f Christophe Leroy   2019-12-23  306  	else if (msk & VDSO_RAW)
cddb82d1c4de56 Anna-Maria Behnsen 2025-03-03  307  		vc = &vc[CS_RAW];
cd3557a7618bf5 Thomas Weißschuh   2025-07-01 @308  	else if (msk & VDSO_AUX)
cd3557a7618bf5 Thomas Weißschuh   2025-07-01  309  		return do_aux(vd, clock, ts);
c966533f8c6c45 Andrei Vagin       2019-11-12  310  	else
fb61bdb27fd730 Thomas Weißschuh   2025-07-01  311  		return false;
c966533f8c6c45 Andrei Vagin       2019-11-12  312  
64c3613ce31a1a Anna-Maria Behnsen 2025-03-03  313  	return do_hres(vd, vc, clock, ts);
502a590a170b3b Thomas Gleixner    2019-07-28  314  }
00b26474c2f161 Vincenzo Frascino  2019-06-21  315  
502a590a170b3b Thomas Gleixner    2019-07-28  316  static __maybe_unused int
ac1a42f4e4e296 Thomas Weißschuh   2025-02-04  317  __cvdso_clock_gettime_data(const struct vdso_time_data *vd, clockid_t clock,
e876f0b69dc993 Christophe Leroy   2020-02-07  318  			   struct __kernel_timespec *ts)
502a590a170b3b Thomas Gleixner    2019-07-28  319  {
fb61bdb27fd730 Thomas Weißschuh   2025-07-01  320  	bool ok;
502a590a170b3b Thomas Gleixner    2019-07-28  321  
fb61bdb27fd730 Thomas Weißschuh   2025-07-01  322  	ok = __cvdso_clock_gettime_common(vd, clock, ts);
fb61bdb27fd730 Thomas Weißschuh   2025-07-01  323  
fb61bdb27fd730 Thomas Weißschuh   2025-07-01  324  	if (unlikely(!ok))
00b26474c2f161 Vincenzo Frascino  2019-06-21  325  		return clock_gettime_fallback(clock, ts);
502a590a170b3b Thomas Gleixner    2019-07-28  326  	return 0;
00b26474c2f161 Vincenzo Frascino  2019-06-21  327  }
00b26474c2f161 Vincenzo Frascino  2019-06-21  328  
e876f0b69dc993 Christophe Leroy   2020-02-07  329  static __maybe_unused int
e876f0b69dc993 Christophe Leroy   2020-02-07  330  __cvdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts)
e876f0b69dc993 Christophe Leroy   2020-02-07  331  {
df7fcbefa71090 Thomas Weißschuh   2025-02-04  332  	return __cvdso_clock_gettime_data(__arch_get_vdso_u_time_data(), clock, ts);
e876f0b69dc993 Christophe Leroy   2020-02-07  333  }
e876f0b69dc993 Christophe Leroy   2020-02-07  334  
bf279849ad5953 Vincenzo Frascino  2019-08-30  335  #ifdef BUILD_VDSO32
00b26474c2f161 Vincenzo Frascino  2019-06-21  336  static __maybe_unused int
ac1a42f4e4e296 Thomas Weißschuh   2025-02-04  337  __cvdso_clock_gettime32_data(const struct vdso_time_data *vd, clockid_t clock,
e876f0b69dc993 Christophe Leroy   2020-02-07  338  			     struct old_timespec32 *res)
00b26474c2f161 Vincenzo Frascino  2019-06-21  339  {
00b26474c2f161 Vincenzo Frascino  2019-06-21  340  	struct __kernel_timespec ts;
fb61bdb27fd730 Thomas Weißschuh   2025-07-01  341  	bool ok;
00b26474c2f161 Vincenzo Frascino  2019-06-21  342  
fb61bdb27fd730 Thomas Weißschuh   2025-07-01  343  	ok = __cvdso_clock_gettime_common(vd, clock, &ts);
00b26474c2f161 Vincenzo Frascino  2019-06-21  344  
fb61bdb27fd730 Thomas Weißschuh   2025-07-01  345  	if (unlikely(!ok))
c60a32ea4f459f Thomas Gleixner    2019-07-30  346  		return clock_gettime32_fallback(clock, res);
502a590a170b3b Thomas Gleixner    2019-07-28  347  
fb61bdb27fd730 Thomas Weißschuh   2025-07-01  348  	/* For ok == true */
00b26474c2f161 Vincenzo Frascino  2019-06-21  349  	res->tv_sec = ts.tv_sec;
00b26474c2f161 Vincenzo Frascino  2019-06-21  350  	res->tv_nsec = ts.tv_nsec;
a279235ddbe975 Vincenzo Frascino  2019-08-30  351  
fb61bdb27fd730 Thomas Weißschuh   2025-07-01  352  	return 0;
00b26474c2f161 Vincenzo Frascino  2019-06-21  353  }
e876f0b69dc993 Christophe Leroy   2020-02-07  354  
e876f0b69dc993 Christophe Leroy   2020-02-07  355  static __maybe_unused int
e876f0b69dc993 Christophe Leroy   2020-02-07  356  __cvdso_clock_gettime32(clockid_t clock, struct old_timespec32 *res)
e876f0b69dc993 Christophe Leroy   2020-02-07  357  {
df7fcbefa71090 Thomas Weißschuh   2025-02-04  358  	return __cvdso_clock_gettime32_data(__arch_get_vdso_u_time_data(), clock, res);
e876f0b69dc993 Christophe Leroy   2020-02-07  359  }
bf279849ad5953 Vincenzo Frascino  2019-08-30  360  #endif /* BUILD_VDSO32 */
00b26474c2f161 Vincenzo Frascino  2019-06-21  361  
00b26474c2f161 Vincenzo Frascino  2019-06-21  362  static __maybe_unused int
ac1a42f4e4e296 Thomas Weißschuh   2025-02-04  363  __cvdso_gettimeofday_data(const struct vdso_time_data *vd,
e876f0b69dc993 Christophe Leroy   2020-02-07  364  			  struct __kernel_old_timeval *tv, struct timezone *tz)
00b26474c2f161 Vincenzo Frascino  2019-06-21  365  {
886653e3663917 Anna-Maria Behnsen 2025-03-03  366  	const struct vdso_clock *vc = vd->clock_data;
00b26474c2f161 Vincenzo Frascino  2019-06-21  367  
00b26474c2f161 Vincenzo Frascino  2019-06-21  368  	if (likely(tv != NULL)) {
00b26474c2f161 Vincenzo Frascino  2019-06-21  369  		struct __kernel_timespec ts;
00b26474c2f161 Vincenzo Frascino  2019-06-21  370  
fb61bdb27fd730 Thomas Weißschuh   2025-07-01  371  		if (!do_hres(vd, &vc[CS_HRES_COARSE], CLOCK_REALTIME, &ts))
00b26474c2f161 Vincenzo Frascino  2019-06-21  372  			return gettimeofday_fallback(tv, tz);
00b26474c2f161 Vincenzo Frascino  2019-06-21  373  
00b26474c2f161 Vincenzo Frascino  2019-06-21  374  		tv->tv_sec = ts.tv_sec;
00b26474c2f161 Vincenzo Frascino  2019-06-21  375  		tv->tv_usec = (u32)ts.tv_nsec / NSEC_PER_USEC;
00b26474c2f161 Vincenzo Frascino  2019-06-21  376  	}
00b26474c2f161 Vincenzo Frascino  2019-06-21  377  
00b26474c2f161 Vincenzo Frascino  2019-06-21  378  	if (unlikely(tz != NULL)) {
660fd04f931717 Thomas Gleixner    2019-11-12  379  		if (IS_ENABLED(CONFIG_TIME_NS) &&
cddb82d1c4de56 Anna-Maria Behnsen 2025-03-03  380  		    vc->clock_mode == VDSO_CLOCKMODE_TIMENS)
ac1a42f4e4e296 Thomas Weißschuh   2025-02-04  381  			vd = __arch_get_vdso_u_timens_data(vd);
660fd04f931717 Thomas Gleixner    2019-11-12  382  
00b26474c2f161 Vincenzo Frascino  2019-06-21  383  		tz->tz_minuteswest = vd[CS_HRES_COARSE].tz_minuteswest;
00b26474c2f161 Vincenzo Frascino  2019-06-21  384  		tz->tz_dsttime = vd[CS_HRES_COARSE].tz_dsttime;
00b26474c2f161 Vincenzo Frascino  2019-06-21  385  	}
00b26474c2f161 Vincenzo Frascino  2019-06-21  386  
00b26474c2f161 Vincenzo Frascino  2019-06-21  387  	return 0;
00b26474c2f161 Vincenzo Frascino  2019-06-21  388  }
00b26474c2f161 Vincenzo Frascino  2019-06-21  389  
e876f0b69dc993 Christophe Leroy   2020-02-07  390  static __maybe_unused int
e876f0b69dc993 Christophe Leroy   2020-02-07  391  __cvdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
e876f0b69dc993 Christophe Leroy   2020-02-07  392  {
df7fcbefa71090 Thomas Weißschuh   2025-02-04  393  	return __cvdso_gettimeofday_data(__arch_get_vdso_u_time_data(), tv, tz);
e876f0b69dc993 Christophe Leroy   2020-02-07  394  }
e876f0b69dc993 Christophe Leroy   2020-02-07  395  
00b26474c2f161 Vincenzo Frascino  2019-06-21  396  #ifdef VDSO_HAS_TIME
e876f0b69dc993 Christophe Leroy   2020-02-07  397  static __maybe_unused __kernel_old_time_t
ac1a42f4e4e296 Thomas Weißschuh   2025-02-04  398  __cvdso_time_data(const struct vdso_time_data *vd, __kernel_old_time_t *time)
00b26474c2f161 Vincenzo Frascino  2019-06-21  399  {
886653e3663917 Anna-Maria Behnsen 2025-03-03  400  	const struct vdso_clock *vc = vd->clock_data;
660fd04f931717 Thomas Gleixner    2019-11-12  401  	__kernel_old_time_t t;
660fd04f931717 Thomas Gleixner    2019-11-12  402  
2d6b01bd88ccab Thomas Gleixner    2020-02-07  403  	if (IS_ENABLED(CONFIG_TIME_NS) &&
cddb82d1c4de56 Anna-Maria Behnsen 2025-03-03  404  	    vc->clock_mode == VDSO_CLOCKMODE_TIMENS) {
ac1a42f4e4e296 Thomas Weißschuh   2025-02-04  405  		vd = __arch_get_vdso_u_timens_data(vd);
886653e3663917 Anna-Maria Behnsen 2025-03-03  406  		vc = vd->clock_data;
cddb82d1c4de56 Anna-Maria Behnsen 2025-03-03  407  	}
660fd04f931717 Thomas Gleixner    2019-11-12  408  
cddb82d1c4de56 Anna-Maria Behnsen 2025-03-03  409  	t = READ_ONCE(vc[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec);
00b26474c2f161 Vincenzo Frascino  2019-06-21  410  
00b26474c2f161 Vincenzo Frascino  2019-06-21  411  	if (time)
00b26474c2f161 Vincenzo Frascino  2019-06-21  412  		*time = t;
00b26474c2f161 Vincenzo Frascino  2019-06-21  413  
00b26474c2f161 Vincenzo Frascino  2019-06-21  414  	return t;
00b26474c2f161 Vincenzo Frascino  2019-06-21  415  }
e876f0b69dc993 Christophe Leroy   2020-02-07  416  
e876f0b69dc993 Christophe Leroy   2020-02-07  417  static __maybe_unused __kernel_old_time_t __cvdso_time(__kernel_old_time_t *time)
e876f0b69dc993 Christophe Leroy   2020-02-07  418  {
df7fcbefa71090 Thomas Weißschuh   2025-02-04  419  	return __cvdso_time_data(__arch_get_vdso_u_time_data(), time);
e876f0b69dc993 Christophe Leroy   2020-02-07  420  }
00b26474c2f161 Vincenzo Frascino  2019-06-21  421  #endif /* VDSO_HAS_TIME */
00b26474c2f161 Vincenzo Frascino  2019-06-21  422  
00b26474c2f161 Vincenzo Frascino  2019-06-21  423  #ifdef VDSO_HAS_CLOCK_GETRES
00b26474c2f161 Vincenzo Frascino  2019-06-21  424  static __maybe_unused
34f888e3405ace Thomas Weißschuh   2025-07-01  425  bool __cvdso_clock_getres_common(const struct vdso_time_data *vd, clockid_t clock,
e876f0b69dc993 Christophe Leroy   2020-02-07  426  				 struct __kernel_timespec *res)
00b26474c2f161 Vincenzo Frascino  2019-06-21  427  {
886653e3663917 Anna-Maria Behnsen 2025-03-03  428  	const struct vdso_clock *vc = vd->clock_data;
00b26474c2f161 Vincenzo Frascino  2019-06-21  429  	u32 msk;
502a590a170b3b Thomas Gleixner    2019-07-28  430  	u64 ns;
00b26474c2f161 Vincenzo Frascino  2019-06-21  431  
1a1cd5fe881fdf Thomas Weißschuh   2025-07-01  432  	if (!vdso_clockid_valid(clock))
34f888e3405ace Thomas Weißschuh   2025-07-01  433  		return false;
00b26474c2f161 Vincenzo Frascino  2019-06-21  434  
2d6b01bd88ccab Thomas Gleixner    2020-02-07  435  	if (IS_ENABLED(CONFIG_TIME_NS) &&
cddb82d1c4de56 Anna-Maria Behnsen 2025-03-03  436  	    vc->clock_mode == VDSO_CLOCKMODE_TIMENS)
ac1a42f4e4e296 Thomas Weißschuh   2025-02-04  437  		vd = __arch_get_vdso_u_timens_data(vd);
660fd04f931717 Thomas Gleixner    2019-11-12  438  
00b26474c2f161 Vincenzo Frascino  2019-06-21  439  	/*
00b26474c2f161 Vincenzo Frascino  2019-06-21  440  	 * Convert the clockid to a bitmask and use it to check which
00b26474c2f161 Vincenzo Frascino  2019-06-21  441  	 * clocks are handled in the VDSO directly.
00b26474c2f161 Vincenzo Frascino  2019-06-21  442  	 */
00b26474c2f161 Vincenzo Frascino  2019-06-21  443  	msk = 1U << clock;
cdb7c5a9c897ab Christophe Leroy   2019-12-23  444  	if (msk & (VDSO_HRES | VDSO_RAW)) {
00b26474c2f161 Vincenzo Frascino  2019-06-21  445  		/*
00b26474c2f161 Vincenzo Frascino  2019-06-21  446  		 * Preserves the behaviour of posix_get_hrtimer_res().
00b26474c2f161 Vincenzo Frascino  2019-06-21  447  		 */
886653e3663917 Anna-Maria Behnsen 2025-03-03  448  		ns = READ_ONCE(vd->hrtimer_res);
00b26474c2f161 Vincenzo Frascino  2019-06-21  449  	} else if (msk & VDSO_COARSE) {
00b26474c2f161 Vincenzo Frascino  2019-06-21  450  		/*
00b26474c2f161 Vincenzo Frascino  2019-06-21  451  		 * Preserves the behaviour of posix_get_coarse_res().
00b26474c2f161 Vincenzo Frascino  2019-06-21  452  		 */
00b26474c2f161 Vincenzo Frascino  2019-06-21  453  		ns = LOW_RES_NSEC;
cd3557a7618bf5 Thomas Weißschuh   2025-07-01 @454  	} else if (msk & VDSO_AUX) {
cd3557a7618bf5 Thomas Weißschuh   2025-07-01  455  		ns = aux_clock_resolution_ns();
00b26474c2f161 Vincenzo Frascino  2019-06-21  456  	} else {
34f888e3405ace Thomas Weißschuh   2025-07-01  457  		return false;
00b26474c2f161 Vincenzo Frascino  2019-06-21  458  	}
00b26474c2f161 Vincenzo Frascino  2019-06-21  459  
1638b8f096ca16 Thomas Gleixner    2019-10-21  460  	if (likely(res)) {
00b26474c2f161 Vincenzo Frascino  2019-06-21  461  		res->tv_sec = 0;
00b26474c2f161 Vincenzo Frascino  2019-06-21  462  		res->tv_nsec = ns;
1638b8f096ca16 Thomas Gleixner    2019-10-21  463  	}
34f888e3405ace Thomas Weißschuh   2025-07-01  464  	return true;
502a590a170b3b Thomas Gleixner    2019-07-28  465  }
502a590a170b3b Thomas Gleixner    2019-07-28  466  

:::::: The code at line 308 was first introduced by commit
:::::: cd3557a7618bf5c1935e9f66b58a329f1f1f4b27 vdso/gettimeofday: Add support for auxiliary clocks

:::::: TO: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
:::::: CC: Thomas Gleixner <tglx@linutronix.de>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-02-11 12:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-11 11:09 arch/x86/include/uapi/../../../../lib/vdso/gettimeofday.c:308 __cvdso_clock_gettime_common() warn: right shifting more than type allows 32 vs 40 kernel test robot
2026-02-11 12:13 ` Dan Carpenter
2026-02-11 12:29 ` Thomas Weißschuh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.