From: Jules Irenge <jbi.octave@gmail.com>
To: mingo@redgat.com
Cc: tglx@linutronix.de, bp@alien8.de, x86@kernel.org, hpa@zytor.com,
peterz@infradead.org, rdunlap@infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] x86/tsc: Use div64_64 instead of do_div()
Date: Sun, 28 Apr 2024 18:32:57 +0100 [thread overview]
Message-ID: <Zi6ISSkMLzM-C4yk@octinomon.home> (raw)
do_div() truncates a u64 divisor to 32 bit.
This can lead to non-zero being truncated to zero for division.
Fix coccinelle warning
WARNING: do_div() does a 64-by-32 division, please consider using div64_64 instead
Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
arch/x86/kernel/tsc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 2ed154a2642c..9106069f18b2 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -401,7 +401,7 @@ static unsigned long calc_pmtimer_ref(u64 deltatsc, u64 pm1, u64 pm2)
pm2 -= pm1;
tmp = pm2 * 1000000000LL;
do_div(tmp, PMTMR_TICKS_PER_SEC);
- do_div(deltatsc, tmp);
+ div64_u64(deltatsc, tmp);
return (unsigned long) deltatsc;
}
--
2.43.2
reply other threads:[~2024-04-28 17:33 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=Zi6ISSkMLzM-C4yk@octinomon.home \
--to=jbi.octave@gmail.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redgat.com \
--cc=peterz@infradead.org \
--cc=rdunlap@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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®