From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5812E2D8DDB for ; Tue, 7 Jul 2026 07:37:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783409867; cv=none; b=qxpvh3NPhcVlLbvagDpmkUhLq9yztvZqAMZy/WF2cpdppk8nwsRozdNW6g+Axg/fYn5JuWNbLDu0Zp2KUoNjbbbDi7yewWj+MvMZ5//bVTqlKTsEDTsdeBMUKJ+BKu9J57jXI5mn6Ehl88+QrjWFGVecAbWNxexESBcsSb2Dkhw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783409867; c=relaxed/simple; bh=VS7pNizR+MJW4p7LTnnpvm75stoehl0rNwg7nXG+ZTA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DCiQI/8Q1KAoTCKC73X3pSDrbsPBAKQk1WV0eD4RbJs/ALB0bCdwCCcSSkvuzSNXyqo95L4ssDi64ycEURRqtfYJXYhddo5eto4ztPuuYEmkIKConRtzR10R/ZF9zSyX9pGvka4B29AqKDiTSlFyokFZXD+pmjwLCy3dCvn9hpg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=nLWuvh7Z; arc=none smtp.client-ip=95.215.58.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="nLWuvh7Z" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783409862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=6dBRD4sBZv6Bu5ftDZ1XTUZfxFajf5nA78K+3UEbwM8=; b=nLWuvh7ZMOyVK2YYzWS1Z5mT366K6RlZstH3zBurH8g772B7rOyvyOYhJVuv7IjTnw5/BO v3OjKDdOBxtuRXbHr85t38qNF8XZaBokhp8HrhS5eizIZYSQdDTrmJ9p8yQQafF9rz0XBE BvU2+5kiEHcjBbAooL4g6k9B6a1wA+Q= From: Thorsten Blum To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Tom Lendacky , Neeraj Upadhyay , Tianyu Lan , Kishon Vijay Abraham I , Ard Biesheuvel Cc: Thorsten Blum , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] x86/sev: Use KHZ_PER_MHZ in snp_secure_tsc_init() Date: Tue, 7 Jul 2026 09:34:44 +0200 Message-ID: <20260707073444.438054-3-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1118; i=thorsten.blum@linux.dev; h=from:subject; bh=VS7pNizR+MJW4p7LTnnpvm75stoehl0rNwg7nXG+ZTA=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFk+a0QPXd1wN5zx1T5twXO5R9JuSzSq2T2zsril/C8nU Zejqcyio5SFQYyLQVZMkeXBrB8zfEtrKjeZROyEmcPKBDKEgYtTACby1paRYecDp5ZPKTvkJ365 zpQ0/b1kl+P1vAUXlkvor4g56O9xX56RYeox/TPTHHgl8t5MFVu57tqpg8tEj7p+vqyyXyJ/PcN HDR4A X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Replace the hard-coded conversion factor with KHZ_PER_MHZ to convert tsc_freq_mhz from MHz to kHz. Signed-off-by: Thorsten Blum --- arch/x86/coco/sev/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c index ecd77d3217f3..b7be9a8ab484 100644 --- a/arch/x86/coco/sev/core.c +++ b/arch/x86/coco/sev/core.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -2042,7 +2043,8 @@ void __init snp_secure_tsc_init(void) /* Extract the GUEST TSC MHZ from BIT[17:0], rest is reserved space */ tsc_freq_mhz &= GENMASK_ULL(17, 0); - snp_tsc_freq_khz = SNP_SCALE_TSC_FREQ(tsc_freq_mhz * 1000, secrets->tsc_factor); + snp_tsc_freq_khz = SNP_SCALE_TSC_FREQ(tsc_freq_mhz * KHZ_PER_MHZ, + secrets->tsc_factor); x86_platform.calibrate_cpu = securetsc_get_tsc_khz; x86_platform.calibrate_tsc = securetsc_get_tsc_khz;