All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: [linux-next:master 16319/17742] drivers/gpu/drm/xe/xe_hwmon.c:1344 xe_hwmon_temperature_decode() warn: impossible condition '(value > ((~0 >> 1))) => (s64min-s64max > s64max)'
Date: Tue, 20 Oct 2026 10:01:47 +0200	[thread overview]
Message-ID: <202610200910.SP0zWbkd-lkp@intel.com> (raw)

Unfiltered warning: this smatch report is sent as-is and has not been
reviewed for false positives, so please treat it with due skepticism.

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Karthik Poosa <karthik.poosa@intel.com>
CC: Rodrigo Vivi <rodrigo.vivi@intel.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   3d229ce89862b8e82d71a9e11d6f840ca272a6d6
commit: 24ec15d646179a255f314e404343bf8e3200c9c0 [16319/17742] drm/xe/hwmon: Decode CRI temperature registers as IEEE-754
:::::: branch date: 14 hours ago
:::::: commit date: 5 days ago
config: x86_64-randconfig-r2202-20261019 (https://download.01.org/0day-ci/archive/20261020/202610200910.SP0zWbkd-lkp@intel.com/config)
compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
rustc: rustc 1.96.0 (ac68faa20 2026-05-25)
smatch: v0.5.0-9187-g5189e3fb

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/202610200910.SP0zWbkd-lkp@intel.com/

smatch warnings:
drivers/gpu/drm/xe/xe_hwmon.c:1344 xe_hwmon_temperature_decode() warn: impossible condition '(value > ((~0 >> 1))) => (s64min-s64max > s64max)'

vim +1344 drivers/gpu/drm/xe/xe_hwmon.c

24ec15d646179a Karthik Poosa 2026-10-15  1296  
24ec15d646179a Karthik Poosa 2026-10-15  1297  /**
24ec15d646179a Karthik Poosa 2026-10-15  1298   * xe_hwmon_temperature_decode - Decode an IEEE-754 temperature register value
24ec15d646179a Karthik Poosa 2026-10-15  1299   * @reg_val: The raw register value to decode
24ec15d646179a Karthik Poosa 2026-10-15  1300   * @temperature: Pointer to store the decoded temperature in millidegrees Celsius.
24ec15d646179a Karthik Poosa 2026-10-15  1301   *
24ec15d646179a Karthik Poosa 2026-10-15  1302   * IEEE-754 single-precision format:
24ec15d646179a Karthik Poosa 2026-10-15  1303   *
24ec15d646179a Karthik Poosa 2026-10-15  1304   *  31 30                         23 22                         0
24ec15d646179a Karthik Poosa 2026-10-15  1305   * +--+-----------------------------+----------------------------+
24ec15d646179a Karthik Poosa 2026-10-15  1306   * | S|          exponent           |          fraction          |
24ec15d646179a Karthik Poosa 2026-10-15  1307   * +--+-----------------------------+----------------------------+
24ec15d646179a Karthik Poosa 2026-10-15  1308   *
24ec15d646179a Karthik Poosa 2026-10-15  1309   * value = (-1)^S * 1.fraction * 2^(exponent - 127)
24ec15d646179a Karthik Poosa 2026-10-15  1310   *
24ec15d646179a Karthik Poosa 2026-10-15  1311   * Return: 0 on success or an error if @reg_val is non-finite or cannot be
24ec15d646179a Karthik Poosa 2026-10-15  1312   * represented in millidegrees Celsius.
24ec15d646179a Karthik Poosa 2026-10-15  1313   */
24ec15d646179a Karthik Poosa 2026-10-15  1314  static int xe_hwmon_temperature_decode(u32 reg_val, long *temperature)
24ec15d646179a Karthik Poosa 2026-10-15  1315  {
24ec15d646179a Karthik Poosa 2026-10-15  1316  	u32 exponent = REG_FIELD_GET(IEEE754_EXP_MASK, reg_val);
24ec15d646179a Karthik Poosa 2026-10-15  1317  	u32 mantissa = REG_FIELD_GET(IEEE754_MANTISSA_MASK, reg_val);
24ec15d646179a Karthik Poosa 2026-10-15  1318  	s64 value;
24ec15d646179a Karthik Poosa 2026-10-15  1319  	int shift;
24ec15d646179a Karthik Poosa 2026-10-15  1320  
24ec15d646179a Karthik Poosa 2026-10-15  1321  	/* Exponent 0xff encodes infinity or NaN. */
24ec15d646179a Karthik Poosa 2026-10-15  1322  	if (exponent == IEEE754_EXP_SPECIAL)
24ec15d646179a Karthik Poosa 2026-10-15  1323  		return -EINVAL;
24ec15d646179a Karthik Poosa 2026-10-15  1324  
24ec15d646179a Karthik Poosa 2026-10-15  1325  	/* Subnormal values are smaller than one millidegree Celsius. */
24ec15d646179a Karthik Poosa 2026-10-15  1326  	if (!exponent) {
24ec15d646179a Karthik Poosa 2026-10-15  1327  		*temperature = 0;
24ec15d646179a Karthik Poosa 2026-10-15  1328  		return 0;
24ec15d646179a Karthik Poosa 2026-10-15  1329  	}
24ec15d646179a Karthik Poosa 2026-10-15  1330  
24ec15d646179a Karthik Poosa 2026-10-15  1331  	value = (s64)(mantissa | BIT(IEEE754_MANTISSA_BITS)) * MILLIDEGREE_PER_DEGREE;
24ec15d646179a Karthik Poosa 2026-10-15  1332  	shift = exponent - (IEEE754_EXP_BIAS + IEEE754_MANTISSA_BITS);
24ec15d646179a Karthik Poosa 2026-10-15  1333  	if (shift >= 0) {
24ec15d646179a Karthik Poosa 2026-10-15  1334  		if (shift >= BITS_PER_LONG || value > (LONG_MAX >> shift))
24ec15d646179a Karthik Poosa 2026-10-15  1335  			return -ERANGE;
24ec15d646179a Karthik Poosa 2026-10-15  1336  		value <<= shift;
24ec15d646179a Karthik Poosa 2026-10-15  1337  	} else if (shift > -64) {
24ec15d646179a Karthik Poosa 2026-10-15  1338  		value >>= -shift;
24ec15d646179a Karthik Poosa 2026-10-15  1339  	} else {
24ec15d646179a Karthik Poosa 2026-10-15  1340  		value = 0;
24ec15d646179a Karthik Poosa 2026-10-15  1341  	}
24ec15d646179a Karthik Poosa 2026-10-15  1342  
24ec15d646179a Karthik Poosa 2026-10-15  1343  	/* Ensure the magnitude fits in long, which is 32-bit on some arches. */
24ec15d646179a Karthik Poosa 2026-10-15 @1344  	if (value > LONG_MAX)
24ec15d646179a Karthik Poosa 2026-10-15  1345  		return -ERANGE;
24ec15d646179a Karthik Poosa 2026-10-15  1346  
24ec15d646179a Karthik Poosa 2026-10-15  1347  	if (reg_val & IEEE754_SIGN)
24ec15d646179a Karthik Poosa 2026-10-15  1348  		value = -value;
24ec15d646179a Karthik Poosa 2026-10-15  1349  
24ec15d646179a Karthik Poosa 2026-10-15  1350  	*temperature = value;
24ec15d646179a Karthik Poosa 2026-10-15  1351  	return 0;
24ec15d646179a Karthik Poosa 2026-10-15  1352  }
24ec15d646179a Karthik Poosa 2026-10-15  1353  

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

                 reply	other threads:[~2026-10-20  8:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202610200910.SP0zWbkd-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=error27@gmail.com \
    --cc=oe-kbuild@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.