lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Mon,  6 Mar 2023 17:20:16 +0800
From:   lirongqing@...du.com
To:     tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, x86@...nel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH] x86/apic: fix a printk precision vs width issue

From: Li RongQing <lirongqing@...du.com>

Before this patch when HZ is 1000, the host bus clock speed
is 99812KHz, but shows 99.0812 MHz

 [    0.136739] ..... calibration result: 99812
 [    0.136930] ..... host bus clock speed is 99.0812 MHz.
it should be:
 [    0.136930] ..... host bus clock speed is 99.812 MHz.

Signed-off-by: Li RongQing <lirongqing@...du.com>
---
 arch/x86/kernel/apic/apic.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 20d9a60..7e3b1bf 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -948,15 +948,15 @@ static int __init calibrate_APIC_clock(void)
 
 	if (boot_cpu_has(X86_FEATURE_TSC)) {
 		apic_printk(APIC_VERBOSE, "..... CPU clock speed is "
-			    "%ld.%04ld MHz.\n",
-			    (deltatsc / LAPIC_CAL_LOOPS) / (1000000 / HZ),
-			    (deltatsc / LAPIC_CAL_LOOPS) % (1000000 / HZ));
+			    "%ld.%03ld MHz.\n",
+			    ((deltatsc) / LAPIC_CAL_LOOPS) * HZ / 1000 / 1000,
+			    ((deltatsc) / LAPIC_CAL_LOOPS) * HZ / 1000 % 1000);
 	}
 
 	apic_printk(APIC_VERBOSE, "..... host bus clock speed is "
-		    "%u.%04u MHz.\n",
-		    lapic_timer_period / (1000000 / HZ),
-		    lapic_timer_period % (1000000 / HZ));
+		    "%u.%03u MHz.\n",
+		    (lapic_timer_period * HZ / 1000) / 1000,
+		    (lapic_timer_period * HZ / 1000) % 1000);
 
 	/*
 	 * Do a sanity check on the APIC calibration result
-- 
2.9.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ