From: Guenter Roeck <linux@roeck-us.net>
To: "Ваторопин Андрей" <a.vatoropin@crpt.ru>,
"Jean Delvare" <jdelvare@suse.com>
Cc: "linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>
Subject: Re: [PATCH] hwmon: Use 64-bit arithmetic instead of 32-bit
Date: Thu, 30 Jan 2025 06:46:54 -0800 [thread overview]
Message-ID: <89e646a2-9377-4544-91e6-cfc55bbbf783@roeck-us.net> (raw)
In-Reply-To: <20250130070324.20403-1-a.vatoropin@crpt.ru>
On 1/29/25 23:03, Ваторопин Андрей wrote:
> From: Andrey Vatoropin <a.vatoropin@crpt.ru>
>
> Add suffix ULL to constant 500 in order to give the compiler complete
> information about the proper arithmetic to use. Notice that this
> constant is used in a context that expects an expression of type
> u64 (64 bits, unsigned).
>
> The expression PCC_NUM_RETRIES * cppc_ss->latency, which at
> preprocessing time translates to cppc_ss->latency; is currently
> being evaluated using 32-bit arithmetic.
>
> This is similar to commit b52f45110502 ("ACPI / CPPC: Use 64-bit
> arithmetic instead of 32-bit")
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
First, this does not affect the entire hardware monitoring subsystem,
just a single driver. The subject is misleading.
Second, the result of the calculation is used as parameter of a function
which takes unsigned int as parameter, and calculates jiffies from it.
If the number of jiffies to be calculated ever exceeds 4,294,967,295
microseconds, the code has severe other problems to be concerned about.
In other words, your patch does not fix anything, and neither does the
referenced commit. It just helps hiding a (hopefully non-existing) different
problem.
Yes, commit b52f45110502 "fixes" a similar "problem", and also completely
misses the point, since the 64-bit result of the calculation is also used
as parameter to usecs_to_jiffies(). The same applies to commit 8338b74a750c5
and maybe others.
I am not going to apply this patch.
Guenter
> Signed-off-by: Andrey Vatoropin <a.vatoropin@crpt.ru>
> ---
> drivers/hwmon/xgene-hwmon.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c
> index 1e3bd129a922..43a08ddb964b 100644
> --- a/drivers/hwmon/xgene-hwmon.c
> +++ b/drivers/hwmon/xgene-hwmon.c
> @@ -61,7 +61,7 @@
> * Arbitrary retries in case the remote processor is slow to respond
> * to PCC commands
> */
> -#define PCC_NUM_RETRIES 500
> +#define PCC_NUM_RETRIES 500ULL
>
> #define ASYNC_MSG_FIFO_SIZE 16
> #define MBOX_OP_TIMEOUTMS 1000
next prev parent reply other threads:[~2025-01-30 14:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-30 7:03 Ваторопин Андрей
2025-01-30 14:46 ` Guenter Roeck [this message]
2025-01-30 7:40 Ваторопин Андрей
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=89e646a2-9377-4544-91e6-cfc55bbbf783@roeck-us.net \
--to=linux@roeck-us.net \
--cc=a.vatoropin@crpt.ru \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®