From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) (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 4E74B3F0ABB for ; Mon, 27 Jul 2026 10:09:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785146944; cv=none; b=fKM0+v/la9QrKJ+ApYVTRktW3fbMjcGHYRH175yMfZm6BXlId8O3X5ia0ma9TLovywLi3hdCdmK3qEDPrfxnBxH5j8M3SyVmON6H6cQ2PwAJU4JnN8LIPAK6sRmEAPhiMtZarM8mCgDHYyLPnEdWNb7I1kJbnXIJ9ZHNZ3eVqO4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785146944; c=relaxed/simple; bh=2rDcHvQRUbNaVIkmwQM6EQKxFwT+WbFA5a/a498KtH4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ortyvmH0doNP8GKMHT1XEseIlx+IW8D8ltk7zo8P1K2ndJij0HCzw62S7ekoK3qEby+7hRielOk6wrYcsoHYTjbLeHGF6lxy5eBDMwTameXSWBXE+UOm+t++LI3LaK5u6SUtSg6NjpBFtKbeQtW4z6ykq2QCyjzKGT2+Arnbhq4= 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=uHiQSVpk; arc=none smtp.client-ip=91.218.175.171 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="uHiQSVpk" 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=1785146940; 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=93Tty8s5/B2oNmF08AUqWDpmW9Y98eU8mX9r238y81o=; b=uHiQSVpkfapOI3svUw+GBGBoWJeLyUkd/sQWY88H3pBi6hFZOUZi1s+M+8MzAuyOeTZT+r 70EtdxSZLrnDPUpJM0VWvQEGMI00stJcl4iulZsAlWT+Srl0dD/50kMo+OYrqmsBsj3oo4 AN+VUjCIj7qUCMC69cdREgRh/pOCcSs= From: Thorsten Blum To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Tom Lendacky , Neeraj Upadhyay , Kishon Vijay Abraham I , Ard Biesheuvel Cc: Thorsten Blum , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] x86/sev: Use KHZ_PER_MHZ in snp_secure_tsc_init() Date: Mon, 27 Jul 2026 12:08:36 +0200 Message-ID: <20260727100837.411342-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=1313; i=thorsten.blum@linux.dev; h=from:subject; bh=2rDcHvQRUbNaVIkmwQM6EQKxFwT+WbFA5a/a498KtH4=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFnpeqqtF003dS/4vfmgQKh5nGnr9s13l/Bx8n9JKe0ve x49396go5SFQYyLQVZMkeXBrB8zfEtrKjeZROyEmcPKBDKEgYtTACaivI2RoT1Ren3cSyOH73v4 riRULEx93lH5auXfsGL3z0arPtt938TI8P5P0PoJreo2oWfqZ6dxybwtYkiJPWZ/KU2y1onv41I 1RgA= 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. Acked-by: Tom Lendacky Signed-off-by: Thorsten Blum --- Changes in v2: - Keep the change on a single line as suggested by Tom - v1: https://lore.kernel.org/r/20260707073444.438054-3-thorsten.blum@linux.dev/ --- arch/x86/coco/sev/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c index ecd77d3217f3..6c050417f5d5 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,7 @@ 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;