From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9153C3803EF for ; Fri, 15 May 2026 19:20:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778872831; cv=none; b=W8022ChchL949vvV7HDEK3MynMfSAgzL7y8RNcJ1WyCmn17HUqVfC/t+wa7qw+xNUeYYSSnSwv9/+7hsLAD6xq9ul2Uhclt/ObIu4tini0lXHozbJnCTx8cZLveVppin0HTJrlPpiWzgL/sGPotdtrW0OUk3njxClXLbHbIZuvU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778872831; c=relaxed/simple; bh=nvaTcMbyfjZXZc1w2lrIIDutznVhYZokau/9P9cewsQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WzHhmZHDoGSRDWmtNVvFLdksibRznJv9qbo8T6rTiICffCpFiSI52DPY0Yhfhp1PW9ptPAetNFSSvtkEHsWWsyPZDbKVZyboCcvFzsGbD0++GwemPzitoIis/rNoj9tv429qv7pK17XyHTddPNt5RN+yWhOoe4AHI/cL0ShVkCE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kfgp8CQR; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kfgp8CQR" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-8230d6d54a5so1056908b3a.1 for ; Fri, 15 May 2026 12:20:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778872829; x=1779477629; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=ikDY1x359wvY/+q3wacNdXpEm487YvEWh2udCoEd+NA=; b=kfgp8CQR7JRLTbwDImSid2uKUCmOzBOWL7J4D4kHATIvk3dQwHMNomvqowes2SAAn3 huZsR7HXAnuRe/mGMxW/w8wExK4WOguceJSl5iiQ/PNhv2tcNp/28h+vjmYUQkKMQF7L qAinNlaICcKNac7SyF3yrnodyGPavPfaCSs1gKzrozXsusb4E3wOjG3eVKacEfJOnVPT FSxs1x0nOT896eSej2u4cmPwJ87Z5Op8O34sTspBjIDtg5zoo1IHXrZmu5NwSoaekZuE JrF6yZyxRX9dAjvUP+PsbnmeGkvLWuxrTZHRgaRaJSCSirIb7PCgRsW9mq9f4UohS8OD rXjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778872829; x=1779477629; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ikDY1x359wvY/+q3wacNdXpEm487YvEWh2udCoEd+NA=; b=LnV3HOujxZ1nGZ1tuJ0VRTvYiLTICkeUaC/DcVUSjh2+5SNhCFOPPCCde67x7tq72J OwAUP91Jzu0XuAZhki+Kg7VZpxWpx7usVec/rL+zVLMFl1qeEeewk0dpUC6w+03uopz8 Da8HbIXamocFr0wPQWGr+a4Nc9Iclamzr8D3+d36QG+a282LkotoUbWgOqFESfxbfe3T 0xF/kLYyr68b1m+a3ACQ4HNZXmTOwMdqih8NyCNKKaF+maflhpkvV5kjUsRtNJQihvWj XZg73tJGqLY7uXwxmdssoNVWFV5yHzwVIC+srzF50ZN+FLqyRQfdhsgRpdSUWVgN5JCn 4o0w== X-Forwarded-Encrypted: i=1; AFNElJ9q0cJqVOHp58A9Z8ziDoJax4JforSQfD98Xwp0Up9XzQHsRsqSP5+DPnBj/kssw71zOP9KDCkBB516jwQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyGLuJCOoqoHiLaqt0XMW1w0Wa3+rWtZH6dmSOjupu2bRYhFjoL m30QX9NEm2znbnN1xJUDrdPyNXr0b0iqqxRsbSr4lkNhjLeOcg7rkwHlzzMqdi41Y7PQsROicEW 3xQbHKw== X-Received: from pfbgg10.prod.google.com ([2002:a05:6a00:630a:b0:83a:d498:99fb]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:a907:b0:835:447b:a2ac with SMTP id d2e1a72fcca58-83f18d5b8f5mr8777489b3a.5.1778872828431; Fri, 15 May 2026 12:20:28 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 15 May 2026 12:19:05 -0700 In-Reply-To: <20260515191942.1892718-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260515191942.1892718-1-seanjc@google.com> X-Mailer: git-send-email 2.54.0.563.g4f69b47b94-goog Message-ID: <20260515191942.1892718-5-seanjc@google.com> Subject: [PATCH v3 04/41] x86/sev: Move check for SNP Secure TSC support to tsc_early_init() From: Sean Christopherson To: Kiryl Shutsemau , Paolo Bonzini , Sean Christopherson , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Ajay Kaher , Alexey Makhalov , Jan Kiszka , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Juergen Gross , Daniel Lezcano , Thomas Gleixner , John Stultz Cc: Rick Edgecombe , Vitaly Kuznetsov , Broadcom internal kernel review list , Boris Ostrovsky , Stephen Boyd , x86@kernel.org, linux-coco@lists.linux.dev, kvm@vger.kernel.org, linux-hyperv@vger.kernel.org, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, Michael Kelley , Tom Lendacky , Nikunj A Dadhania , Thomas Gleixner , David Woodhouse Content-Type: text/plain; charset="UTF-8" Move the check on having a Secure TSC to the common tsc_early_init() so that it's obvious that having a Secure TSC is conditional, and to prepare for adding TDX to the mix (blindly initializing *both* SNP and TDX TSC logic looks especially weird). No functional change intended. Cc: Tom Lendacky Reviewed-by: Nikunj A Dadhania Signed-off-by: Sean Christopherson --- arch/x86/coco/sev/core.c | 3 --- arch/x86/kernel/tsc.c | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c index 14ced854cd83..39fb50697542 100644 --- a/arch/x86/coco/sev/core.c +++ b/arch/x86/coco/sev/core.c @@ -2029,9 +2029,6 @@ void __init snp_secure_tsc_init(void) unsigned long tsc_freq_mhz; void *mem; - if (!cc_platform_has(CC_ATTR_GUEST_SNP_SECURE_TSC)) - return; - mem = early_memremap_encrypted(sev_secrets_pa, PAGE_SIZE); if (!mem) { pr_err("Unable to get TSC_FACTOR: failed to map the SNP secrets page.\n"); diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 7e639c0a94a2..243999692aea 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -1559,7 +1559,8 @@ void __init tsc_early_init(void) if (is_early_uv_system()) return; - snp_secure_tsc_init(); + if (cc_platform_has(CC_ATTR_GUEST_SNP_SECURE_TSC)) + snp_secure_tsc_init(); if (!determine_cpu_tsc_frequencies(true)) return; -- 2.54.0.563.g4f69b47b94-goog