public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: SVM: Add module parameter to control SEV-SNP Secure TSC feature
@ 2025-10-29  5:57 Nikunj A Dadhania
  2025-10-29 13:18 ` Tom Lendacky
  2025-10-29 13:58 ` Sean Christopherson
  0 siblings, 2 replies; 5+ messages in thread
From: Nikunj A Dadhania @ 2025-10-29  5:57 UTC (permalink / raw)
  To: seanjc, pbonzini; +Cc: kvm, thomas.lendacky, santosh.shukla, nikunj

Add a module parameter secure_tsc to allow control of the SEV-SNP Secure
TSC feature at module load time, providing administrators with the ability
to disable Secure TSC support even when the hardware and kernel support it.

Default the parameter to enabled (true) to maintain existing behavior when
the feature is supported. Set the parameter to false if the feature cannot
be enabled to reflect the actual state.

Suggested-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Nikunj A Dadhania <nikunj@amd.com>
---
 arch/x86/kvm/svm/sev.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 0835c664fbfd..1f359e31104f 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -56,6 +56,11 @@ module_param_named(sev_snp, sev_snp_enabled, bool, 0444);
 /* enable/disable SEV-ES DebugSwap support */
 static bool sev_es_debug_swap_enabled = true;
 module_param_named(debug_swap, sev_es_debug_swap_enabled, bool, 0444);
+
+/* enable/disable Secure TSC support */
+static bool sev_snp_secure_tsc_enabled = true;
+module_param_named(secure_tsc, sev_snp_secure_tsc_enabled, bool, 0444);
+
 static u64 sev_supported_vmsa_features;
 
 static unsigned int nr_ciphertext_hiding_asids;
@@ -3147,8 +3152,11 @@ void __init sev_hardware_setup(void)
 	if (sev_es_debug_swap_enabled)
 		sev_supported_vmsa_features |= SVM_SEV_FEAT_DEBUG_SWAP;
 
-	if (sev_snp_enabled && tsc_khz && cpu_feature_enabled(X86_FEATURE_SNP_SECURE_TSC))
+	if (sev_snp_enabled && sev_snp_secure_tsc_enabled &&
+	    tsc_khz && cpu_feature_enabled(X86_FEATURE_SNP_SECURE_TSC))
 		sev_supported_vmsa_features |= SVM_SEV_FEAT_SECURE_TSC;
+	else
+		sev_snp_secure_tsc_enabled = false;
 }
 
 void sev_hardware_unsetup(void)

base-commit: 6b36119b94d0b2bb8cea9d512017efafd461d6ac
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: SVM: Add module parameter to control SEV-SNP Secure TSC feature
  2025-10-29  5:57 [PATCH] KVM: SVM: Add module parameter to control SEV-SNP Secure TSC feature Nikunj A Dadhania
@ 2025-10-29 13:18 ` Tom Lendacky
  2025-10-29 13:58 ` Sean Christopherson
  1 sibling, 0 replies; 5+ messages in thread
From: Tom Lendacky @ 2025-10-29 13:18 UTC (permalink / raw)
  To: Nikunj A Dadhania, seanjc, pbonzini; +Cc: kvm, santosh.shukla

On 10/29/25 00:57, Nikunj A Dadhania wrote:
> Add a module parameter secure_tsc to allow control of the SEV-SNP Secure
> TSC feature at module load time, providing administrators with the ability
> to disable Secure TSC support even when the hardware and kernel support it.
> 
> Default the parameter to enabled (true) to maintain existing behavior when
> the feature is supported. Set the parameter to false if the feature cannot
> be enabled to reflect the actual state.
> 
> Suggested-by: Tom Lendacky <thomas.lendacky@amd.com>
> Signed-off-by: Nikunj A Dadhania <nikunj@amd.com>
> ---
>  arch/x86/kvm/svm/sev.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 0835c664fbfd..1f359e31104f 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -56,6 +56,11 @@ module_param_named(sev_snp, sev_snp_enabled, bool, 0444);
>  /* enable/disable SEV-ES DebugSwap support */
>  static bool sev_es_debug_swap_enabled = true;
>  module_param_named(debug_swap, sev_es_debug_swap_enabled, bool, 0444);
> +
> +/* enable/disable Secure TSC support */
> +static bool sev_snp_secure_tsc_enabled = true;
> +module_param_named(secure_tsc, sev_snp_secure_tsc_enabled, bool, 0444);
> +
>  static u64 sev_supported_vmsa_features;
>  
>  static unsigned int nr_ciphertext_hiding_asids;
> @@ -3147,8 +3152,11 @@ void __init sev_hardware_setup(void)
>  	if (sev_es_debug_swap_enabled)
>  		sev_supported_vmsa_features |= SVM_SEV_FEAT_DEBUG_SWAP;
>  
> -	if (sev_snp_enabled && tsc_khz && cpu_feature_enabled(X86_FEATURE_SNP_SECURE_TSC))
> +	if (sev_snp_enabled && sev_snp_secure_tsc_enabled &&
> +	    tsc_khz && cpu_feature_enabled(X86_FEATURE_SNP_SECURE_TSC))
>  		sev_supported_vmsa_features |= SVM_SEV_FEAT_SECURE_TSC;
> +	else
> +		sev_snp_secure_tsc_enabled = false;

Looks reasonable to me. My only nit is to rework this to look like the
debug_swap support, e.g.:

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 0835c664fbfd..4cf26ba637d2 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -3143,11 +3143,14 @@ void __init sev_hardware_setup(void)
 	    !cpu_feature_enabled(X86_FEATURE_NO_NESTED_DATA_BP))
 		sev_es_debug_swap_enabled = false;
 
+	if (!sev_snp_enabled || !tsc_khz || !cpu_feature_enabled(X86_FEATURE_SNP_SECURE_TSC))
+		sev_snp_secure_tsc_enabled = false;
+
 	sev_supported_vmsa_features = 0;
 	if (sev_es_debug_swap_enabled)
 		sev_supported_vmsa_features |= SVM_SEV_FEAT_DEBUG_SWAP;
 
-	if (sev_snp_enabled && tsc_khz && cpu_feature_enabled(X86_FEATURE_SNP_SECURE_TSC))
+	if (sev_snp_secure_tsc_enabled)
 		sev_supported_vmsa_features |= SVM_SEV_FEAT_SECURE_TSC;
 }

But I'll leave that decision up to the maintainers.

Thanks,
Tom

>  }
>  
>  void sev_hardware_unsetup(void)
> 
> base-commit: 6b36119b94d0b2bb8cea9d512017efafd461d6ac


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: SVM: Add module parameter to control SEV-SNP Secure TSC feature
  2025-10-29  5:57 [PATCH] KVM: SVM: Add module parameter to control SEV-SNP Secure TSC feature Nikunj A Dadhania
  2025-10-29 13:18 ` Tom Lendacky
@ 2025-10-29 13:58 ` Sean Christopherson
  2025-10-29 15:38   ` Tom Lendacky
  1 sibling, 1 reply; 5+ messages in thread
From: Sean Christopherson @ 2025-10-29 13:58 UTC (permalink / raw)
  To: Nikunj A Dadhania; +Cc: pbonzini, kvm, thomas.lendacky, santosh.shukla

On Wed, Oct 29, 2025, Nikunj A Dadhania wrote:
> Add a module parameter secure_tsc to allow control of the SEV-SNP Secure
> TSC feature at module load time, providing administrators with the ability
> to disable Secure TSC support even when the hardware and kernel support it.

Why?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: SVM: Add module parameter to control SEV-SNP Secure TSC feature
  2025-10-29 13:58 ` Sean Christopherson
@ 2025-10-29 15:38   ` Tom Lendacky
  2025-10-29 16:52     ` Sean Christopherson
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Lendacky @ 2025-10-29 15:38 UTC (permalink / raw)
  To: Sean Christopherson, Nikunj A Dadhania; +Cc: pbonzini, kvm, santosh.shukla

On 10/29/25 08:58, Sean Christopherson wrote:
> On Wed, Oct 29, 2025, Nikunj A Dadhania wrote:
>> Add a module parameter secure_tsc to allow control of the SEV-SNP Secure
>> TSC feature at module load time, providing administrators with the ability
>> to disable Secure TSC support even when the hardware and kernel support it.
> 
> Why?

That's on me. Based on the debug_swap parameter I thought we wanted to
be able to control all SEV features that are advertised and thought this
was just missed for Secure TSC. I'm good with not adding it we don't
need to do that.

Thanks,
Tom


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] KVM: SVM: Add module parameter to control SEV-SNP Secure TSC feature
  2025-10-29 15:38   ` Tom Lendacky
@ 2025-10-29 16:52     ` Sean Christopherson
  0 siblings, 0 replies; 5+ messages in thread
From: Sean Christopherson @ 2025-10-29 16:52 UTC (permalink / raw)
  To: Tom Lendacky; +Cc: Nikunj A Dadhania, pbonzini, kvm, santosh.shukla

On Wed, Oct 29, 2025, Tom Lendacky wrote:
> On 10/29/25 08:58, Sean Christopherson wrote:
> > On Wed, Oct 29, 2025, Nikunj A Dadhania wrote:
> >> Add a module parameter secure_tsc to allow control of the SEV-SNP Secure
> >> TSC feature at module load time, providing administrators with the ability
> >> to disable Secure TSC support even when the hardware and kernel support it.
> > 
> > Why?
> 
> That's on me. Based on the debug_swap parameter I thought we wanted to
> be able to control all SEV features that are advertised and thought this
> was just missed for Secure TSC. I'm good with not adding it we don't
> need to do that.

DebugSwap was one big mistake.  At this point, I think we can and should rip out
its module param.

Commit d1f85fbe836e ("KVM: SEV: Enable data breakpoints in SEV-ES") goofed by not
adding a way for the userspace VMM to control the feature.  Functionally, that was
fine, but it broke attestation signatures because SEV_FEATURES are included in the
signature.

Commit 5abf6dceb066 ("SEV: disable SEV-ES DebugSwap by default") fixed that issue,
but the underlying flaw of userspace not having a way to control SEV_FEATURES was
still there.

That flaw was addressed by commit 4f5defae7089 ("KVM: SEV: introduce KVM_SEV_INIT2
operation"), and so then 4dd5ecacb9a4 ("KVM: SEV: allow SEV-ES DebugSwap again")
re-enabled DebugSwap by default.

Now that the dust is settled, the module param doesn't serve any meaningful purpose.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-10-29 16:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-29  5:57 [PATCH] KVM: SVM: Add module parameter to control SEV-SNP Secure TSC feature Nikunj A Dadhania
2025-10-29 13:18 ` Tom Lendacky
2025-10-29 13:58 ` Sean Christopherson
2025-10-29 15:38   ` Tom Lendacky
2025-10-29 16:52     ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox