* [PATCH v10 0/2] Enable Secure TSC for SEV-SNP @ 2025-08-04 10:37 Nikunj A Dadhania 2025-08-04 10:37 ` [PATCH v10 1/2] x86/cpufeatures: Add SNP Secure TSC Nikunj A Dadhania ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Nikunj A Dadhania @ 2025-08-04 10:37 UTC (permalink / raw) To: seanjc, pbonzini, kvm Cc: thomas.lendacky, santosh.shukla, bp, nikunj, isaku.yamahata, vaishali.thakkar, kai.huang Patches are based on kvm/next with [1] applied Testing Secure TSC ------------------ Secure TSC guest patches are available as part of v6.14. QEMU changes: https://github.com/AMDESE/qemu/tree/snp-securetsc-latest QEMU command line SEV-SNP with Secure TSC: qemu-system-x86_64 -cpu EPYC-Milan-v2 -smp 4 \ -object memory-backend-memfd,id=ram1,size=1G,share=true,prealloc=false,reserve=false \ -object sev-snp-guest,id=sev0,cbitpos=51,reduced-phys-bits=1,secure-tsc=on,stsc-freq=2000000000 \ -machine q35,confidential-guest-support=sev0,memory-backend=ram1 \ ... Changelog: ---------- v10: * Rebased on kvm/next * Collect RB from Kai Huang v9: https://lore.kernel.org/kvm/20250716060836.2231613-1-nikunj@amd.com/ * Set guest_tsc_protected during guest vCPU creation (Kai Huang) * Improve error handling (Kai Huang) * Disable MSR_AMD64_GUEST_TSC_FREQ write interception (Sean) 1. https://lore.kernel.org/kvm/20250804090945.267199-1-nikunj@amd.com/ Nikunj A Dadhania (2): x86/cpufeatures: Add SNP Secure TSC KVM: SVM: Enable Secure TSC for SNP guests arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/svm.h | 1 + arch/x86/kvm/svm/sev.c | 27 +++++++++++++++++++++++++++ arch/x86/kvm/svm/svm.c | 2 ++ arch/x86/kvm/svm/svm.h | 2 ++ 5 files changed, 33 insertions(+) base-commit: 196d9e72c4b0bd68b74a4ec7f52d248f37d0f030 prerequisite-patch-id: 97788f545096df9ccc70cc99571d545fe4503f01 prerequisite-patch-id: 7a0edf8fa18231f19c781b4d412df4bafcb3d1ae -- 2.43.0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v10 1/2] x86/cpufeatures: Add SNP Secure TSC 2025-08-04 10:37 [PATCH v10 0/2] Enable Secure TSC for SEV-SNP Nikunj A Dadhania @ 2025-08-04 10:37 ` Nikunj A Dadhania 2025-08-04 10:37 ` [PATCH v10 2/2] KVM: SVM: Enable Secure TSC for SNP guests Nikunj A Dadhania 2025-08-19 3:47 ` [PATCH v10 0/2] Enable Secure TSC for SEV-SNP Nikunj A. Dadhania 2 siblings, 0 replies; 6+ messages in thread From: Nikunj A Dadhania @ 2025-08-04 10:37 UTC (permalink / raw) To: seanjc, pbonzini, kvm Cc: thomas.lendacky, santosh.shukla, bp, nikunj, isaku.yamahata, vaishali.thakkar, kai.huang The Secure TSC feature for SEV-SNP allows guests to securely use the RDTSC and RDTSCP instructions, ensuring that the parameters used cannot be altered by the hypervisor once the guest is launched. For more details, refer to the AMD64 APM Vol 2, Section "Secure TSC". Acked-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Tested-by: Vaishali Thakkar <vaishali.thakkar@suse.com> Signed-off-by: Nikunj A Dadhania <nikunj@amd.com> --- arch/x86/include/asm/cpufeatures.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 286d509f9363..28dd83afb09b 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -443,6 +443,7 @@ #define X86_FEATURE_VM_PAGE_FLUSH (19*32+ 2) /* VM Page Flush MSR is supported */ #define X86_FEATURE_SEV_ES (19*32+ 3) /* "sev_es" Secure Encrypted Virtualization - Encrypted State */ #define X86_FEATURE_SEV_SNP (19*32+ 4) /* "sev_snp" Secure Encrypted Virtualization - Secure Nested Paging */ +#define X86_FEATURE_SNP_SECURE_TSC (19*32+ 8) /* SEV-SNP Secure TSC */ #define X86_FEATURE_V_TSC_AUX (19*32+ 9) /* Virtual TSC_AUX */ #define X86_FEATURE_SME_COHERENT (19*32+10) /* hardware-enforced cache coherency */ #define X86_FEATURE_DEBUG_SWAP (19*32+14) /* "debug_swap" SEV-ES full debug state swap support */ -- 2.43.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v10 2/2] KVM: SVM: Enable Secure TSC for SNP guests 2025-08-04 10:37 [PATCH v10 0/2] Enable Secure TSC for SEV-SNP Nikunj A Dadhania 2025-08-04 10:37 ` [PATCH v10 1/2] x86/cpufeatures: Add SNP Secure TSC Nikunj A Dadhania @ 2025-08-04 10:37 ` Nikunj A Dadhania 2025-08-19 18:31 ` Sean Christopherson 2025-08-19 3:47 ` [PATCH v10 0/2] Enable Secure TSC for SEV-SNP Nikunj A. Dadhania 2 siblings, 1 reply; 6+ messages in thread From: Nikunj A Dadhania @ 2025-08-04 10:37 UTC (permalink / raw) To: seanjc, pbonzini, kvm Cc: thomas.lendacky, santosh.shukla, bp, nikunj, isaku.yamahata, vaishali.thakkar, kai.huang Add support for Secure TSC, allowing userspace to configure the Secure TSC feature for SNP guests. Use the SNP specification's desired TSC frequency parameter during the SNP_LAUNCH_START command to set the mean TSC frequency in KHz for Secure TSC enabled guests. Always use kvm->arch.arch.default_tsc_khz as the TSC frequency that is passed to SNP guests in the SNP_LAUNCH_START command. The default value is the host TSC frequency. The userspace can optionally change the TSC frequency via the KVM_SET_TSC_KHZ ioctl before calling the SNP_LAUNCH_START ioctl. Introduce the read-only MSR GUEST_TSC_FREQ (0xc0010134) that returns guest's effective frequency in MHZ when Secure TSC is enabled for SNP guests. Disable interception of this MSR when Secure TSC is enabled. Note that GUEST_TSC_FREQ MSR is accessible only to the guest and not from the hypervisor context. Co-developed-by: Ketan Chaturvedi <Ketan.Chaturvedi@amd.com> Signed-off-by: Ketan Chaturvedi <Ketan.Chaturvedi@amd.com> Reviewed-by: Kai Huang <kai.huang@intel.com> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Nikunj A Dadhania <nikunj@amd.com> --- arch/x86/include/asm/svm.h | 1 + arch/x86/kvm/svm/sev.c | 27 +++++++++++++++++++++++++++ arch/x86/kvm/svm/svm.c | 2 ++ arch/x86/kvm/svm/svm.h | 2 ++ 4 files changed, 32 insertions(+) diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index ffc27f676243..17f6c3fedeee 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -299,6 +299,7 @@ static_assert((X2AVIC_MAX_PHYSICAL_ID & AVIC_PHYSICAL_MAX_INDEX_MASK) == X2AVIC_ #define SVM_SEV_FEAT_RESTRICTED_INJECTION BIT(3) #define SVM_SEV_FEAT_ALTERNATE_INJECTION BIT(4) #define SVM_SEV_FEAT_DEBUG_SWAP BIT(5) +#define SVM_SEV_FEAT_SECURE_TSC BIT(9) #define VMCB_ALLOWED_SEV_FEATURES_VALID BIT_ULL(63) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index e88dce598785..f9ab9ecc213f 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -146,6 +146,14 @@ static bool sev_vcpu_has_debug_swap(struct vcpu_svm *svm) return sev->vmsa_features & SVM_SEV_FEAT_DEBUG_SWAP; } +bool snp_secure_tsc_enabled(struct kvm *kvm) +{ + struct kvm_sev_info *sev = to_kvm_sev_info(kvm); + + return (sev->vmsa_features & SVM_SEV_FEAT_SECURE_TSC) && + !WARN_ON_ONCE(!sev_snp_guest(kvm)); +} + /* Must be called with the sev_bitmap_lock held */ static bool __sev_recycle_asids(unsigned int min_asid, unsigned int max_asid) { @@ -415,6 +423,9 @@ static int __sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp, if (data->flags) return -EINVAL; + if (!snp_active) + valid_vmsa_features &= ~SVM_SEV_FEAT_SECURE_TSC; + if (data->vmsa_features & ~valid_vmsa_features) return -EINVAL; @@ -2195,6 +2206,16 @@ static int snp_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp) start.gctx_paddr = __psp_pa(sev->snp_context); start.policy = params.policy; + + if (snp_secure_tsc_enabled(kvm)) { + if (WARN_ON(!kvm->arch.default_tsc_khz)) { + rc = -EINVAL; + goto e_free_context; + } + + start.desired_tsc_khz = kvm->arch.default_tsc_khz; + } + memcpy(start.gosvw, params.gosvw, sizeof(params.gosvw)); rc = __sev_issue_cmd(argp->sev_fd, SEV_CMD_SNP_LAUNCH_START, &start, &argp->error); if (rc) { @@ -3085,6 +3106,9 @@ void __init sev_hardware_setup(void) 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)) + sev_supported_vmsa_features |= SVM_SEV_FEAT_SECURE_TSC; } void sev_hardware_unsetup(void) @@ -4455,6 +4479,9 @@ void sev_es_recalc_msr_intercepts(struct kvm_vcpu *vcpu) !guest_cpu_cap_has(vcpu, X86_FEATURE_RDTSCP) && !guest_cpu_cap_has(vcpu, X86_FEATURE_RDPID)); + if (snp_secure_tsc_enabled(vcpu->kvm)) + svm_disable_intercept_for_msr(vcpu, MSR_AMD64_GUEST_TSC_FREQ, MSR_TYPE_R); + /* * For SEV-ES, accesses to MSR_IA32_XSS should not be intercepted if * the host/guest supports its use. diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index d9931c6c4bc6..a81bf83ccb52 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1317,6 +1317,8 @@ static int svm_vcpu_create(struct kvm_vcpu *vcpu) svm->guest_state_loaded = false; + vcpu->arch.guest_tsc_protected = snp_secure_tsc_enabled(vcpu->kvm); + return 0; error_free_vmsa_page: diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 58b9d168e0c8..acb00e0fd564 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -869,6 +869,7 @@ void sev_gmem_invalidate(kvm_pfn_t start, kvm_pfn_t end); int sev_private_max_mapping_level(struct kvm *kvm, kvm_pfn_t pfn); struct vmcb_save_area *sev_decrypt_vmsa(struct kvm_vcpu *vcpu); void sev_free_decrypted_vmsa(struct kvm_vcpu *vcpu, struct vmcb_save_area *vmsa); +bool snp_secure_tsc_enabled(struct kvm *kvm); #else static inline struct page *snp_safe_alloc_page_node(int node, gfp_t gfp) { @@ -905,6 +906,7 @@ static inline struct vmcb_save_area *sev_decrypt_vmsa(struct kvm_vcpu *vcpu) return NULL; } static inline void sev_free_decrypted_vmsa(struct kvm_vcpu *vcpu, struct vmcb_save_area *vmsa) {} +static inline bool snp_secure_tsc_enabled(struct kvm *kvm) { return false; } #endif /* vmenter.S */ -- 2.43.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v10 2/2] KVM: SVM: Enable Secure TSC for SNP guests 2025-08-04 10:37 ` [PATCH v10 2/2] KVM: SVM: Enable Secure TSC for SNP guests Nikunj A Dadhania @ 2025-08-19 18:31 ` Sean Christopherson 2025-08-20 5:31 ` Nikunj A. Dadhania 0 siblings, 1 reply; 6+ messages in thread From: Sean Christopherson @ 2025-08-19 18:31 UTC (permalink / raw) To: Nikunj A Dadhania Cc: pbonzini, kvm, thomas.lendacky, santosh.shukla, bp, isaku.yamahata, vaishali.thakkar, kai.huang On Mon, Aug 04, 2025, Nikunj A Dadhania wrote: > Add support for Secure TSC, allowing userspace to configure the Secure TSC > feature for SNP guests. Use the SNP specification's desired TSC frequency > parameter during the SNP_LAUNCH_START command to set the mean TSC > frequency in KHz for Secure TSC enabled guests. > > Always use kvm->arch.arch.default_tsc_khz as the TSC frequency that is > passed to SNP guests in the SNP_LAUNCH_START command. The default value > is the host TSC frequency. The userspace can optionally change the TSC > frequency via the KVM_SET_TSC_KHZ ioctl before calling the > SNP_LAUNCH_START ioctl. > > Introduce the read-only MSR GUEST_TSC_FREQ (0xc0010134) that returns > guest's effective frequency in MHZ when Secure TSC is enabled for SNP > guests. Disable interception of this MSR when Secure TSC is enabled. Note > that GUEST_TSC_FREQ MSR is accessible only to the guest and not from the > hypervisor context. > > Co-developed-by: Ketan Chaturvedi <Ketan.Chaturvedi@amd.com> > Signed-off-by: Ketan Chaturvedi <Ketan.Chaturvedi@amd.com> > Reviewed-by: Kai Huang <kai.huang@intel.com> > Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> > Signed-off-by: Nikunj A Dadhania <nikunj@amd.com> > --- > arch/x86/include/asm/svm.h | 1 + > arch/x86/kvm/svm/sev.c | 27 +++++++++++++++++++++++++++ > arch/x86/kvm/svm/svm.c | 2 ++ > arch/x86/kvm/svm/svm.h | 2 ++ > 4 files changed, 32 insertions(+) > > diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h > index ffc27f676243..17f6c3fedeee 100644 > --- a/arch/x86/include/asm/svm.h > +++ b/arch/x86/include/asm/svm.h > @@ -299,6 +299,7 @@ static_assert((X2AVIC_MAX_PHYSICAL_ID & AVIC_PHYSICAL_MAX_INDEX_MASK) == X2AVIC_ > #define SVM_SEV_FEAT_RESTRICTED_INJECTION BIT(3) > #define SVM_SEV_FEAT_ALTERNATE_INJECTION BIT(4) > #define SVM_SEV_FEAT_DEBUG_SWAP BIT(5) > +#define SVM_SEV_FEAT_SECURE_TSC BIT(9) > > #define VMCB_ALLOWED_SEV_FEATURES_VALID BIT_ULL(63) > > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > index e88dce598785..f9ab9ecc213f 100644 > --- a/arch/x86/kvm/svm/sev.c > +++ b/arch/x86/kvm/svm/sev.c > @@ -146,6 +146,14 @@ static bool sev_vcpu_has_debug_swap(struct vcpu_svm *svm) > return sev->vmsa_features & SVM_SEV_FEAT_DEBUG_SWAP; > } > > +bool snp_secure_tsc_enabled(struct kvm *kvm) snp_is_secure_tsc_enabled() to make it super obvious this is a predicate. > +{ > + struct kvm_sev_info *sev = to_kvm_sev_info(kvm); > + > + return (sev->vmsa_features & SVM_SEV_FEAT_SECURE_TSC) && > + !WARN_ON_ONCE(!sev_snp_guest(kvm)); Align indentation. > +} > @@ -4455,6 +4479,9 @@ void sev_es_recalc_msr_intercepts(struct kvm_vcpu *vcpu) > !guest_cpu_cap_has(vcpu, X86_FEATURE_RDTSCP) && > !guest_cpu_cap_has(vcpu, X86_FEATURE_RDPID)); > > + if (snp_secure_tsc_enabled(vcpu->kvm)) > + svm_disable_intercept_for_msr(vcpu, MSR_AMD64_GUEST_TSC_FREQ, MSR_TYPE_R); I'm leaning towards: svm_set_intercept_for_msr(vcpu, MSR_AMD64_GUEST_TSC_FREQ, MSR_TYPE_R, !snp_is_secure_tsc_enabled(vcpu->kvm)); because the cost of setting a bit is negligible. > + > /* > * For SEV-ES, accesses to MSR_IA32_XSS should not be intercepted if > * the host/guest supports its use. > diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c > index d9931c6c4bc6..a81bf83ccb52 100644 > --- a/arch/x86/kvm/svm/svm.c > +++ b/arch/x86/kvm/svm/svm.c > @@ -1317,6 +1317,8 @@ static int svm_vcpu_create(struct kvm_vcpu *vcpu) > > svm->guest_state_loaded = false; > > + vcpu->arch.guest_tsc_protected = snp_secure_tsc_enabled(vcpu->kvm); Hmm, we can and should handle this in sev.c. If we add sev_vcpu_create(), then we don't need to expose snp_is_secure_tsc_enabled(), and we can move more code into that helper. I'll post a combined series of this and the GHCB version patches. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v10 2/2] KVM: SVM: Enable Secure TSC for SNP guests 2025-08-19 18:31 ` Sean Christopherson @ 2025-08-20 5:31 ` Nikunj A. Dadhania 0 siblings, 0 replies; 6+ messages in thread From: Nikunj A. Dadhania @ 2025-08-20 5:31 UTC (permalink / raw) To: Sean Christopherson Cc: pbonzini, kvm, thomas.lendacky, santosh.shukla, bp, isaku.yamahata, vaishali.thakkar, kai.huang On 8/20/2025 12:01 AM, Sean Christopherson wrote: > On Mon, Aug 04, 2025, Nikunj A Dadhania wrote: >> Add support for Secure TSC, allowing userspace to configure the Secure TSC >> feature for SNP guests. Use the SNP specification's desired TSC frequency >> parameter during the SNP_LAUNCH_START command to set the mean TSC >> frequency in KHz for Secure TSC enabled guests. >> >> Always use kvm->arch.arch.default_tsc_khz as the TSC frequency that is >> passed to SNP guests in the SNP_LAUNCH_START command. The default value >> is the host TSC frequency. The userspace can optionally change the TSC >> frequency via the KVM_SET_TSC_KHZ ioctl before calling the >> SNP_LAUNCH_START ioctl. >> >> Introduce the read-only MSR GUEST_TSC_FREQ (0xc0010134) that returns >> guest's effective frequency in MHZ when Secure TSC is enabled for SNP >> guests. Disable interception of this MSR when Secure TSC is enabled. Note >> that GUEST_TSC_FREQ MSR is accessible only to the guest and not from the >> hypervisor context. >> >> Co-developed-by: Ketan Chaturvedi <Ketan.Chaturvedi@amd.com> >> Signed-off-by: Ketan Chaturvedi <Ketan.Chaturvedi@amd.com> >> Reviewed-by: Kai Huang <kai.huang@intel.com> >> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com> >> Signed-off-by: Nikunj A Dadhania <nikunj@amd.com> >> --- >> arch/x86/include/asm/svm.h | 1 + >> arch/x86/kvm/svm/sev.c | 27 +++++++++++++++++++++++++++ >> arch/x86/kvm/svm/svm.c | 2 ++ >> arch/x86/kvm/svm/svm.h | 2 ++ >> 4 files changed, 32 insertions(+) >> >> diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h >> index ffc27f676243..17f6c3fedeee 100644 >> --- a/arch/x86/include/asm/svm.h >> +++ b/arch/x86/include/asm/svm.h >> @@ -299,6 +299,7 @@ static_assert((X2AVIC_MAX_PHYSICAL_ID & AVIC_PHYSICAL_MAX_INDEX_MASK) == X2AVIC_ >> #define SVM_SEV_FEAT_RESTRICTED_INJECTION BIT(3) >> #define SVM_SEV_FEAT_ALTERNATE_INJECTION BIT(4) >> #define SVM_SEV_FEAT_DEBUG_SWAP BIT(5) >> +#define SVM_SEV_FEAT_SECURE_TSC BIT(9) >> >> #define VMCB_ALLOWED_SEV_FEATURES_VALID BIT_ULL(63) >> >> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c >> index e88dce598785..f9ab9ecc213f 100644 >> --- a/arch/x86/kvm/svm/sev.c >> +++ b/arch/x86/kvm/svm/sev.c >> @@ -146,6 +146,14 @@ static bool sev_vcpu_has_debug_swap(struct vcpu_svm *svm) >> return sev->vmsa_features & SVM_SEV_FEAT_DEBUG_SWAP; >> } >> >> +bool snp_secure_tsc_enabled(struct kvm *kvm) > > snp_is_secure_tsc_enabled() to make it super obvious this is a predicate. Ack. > >> +{ >> + struct kvm_sev_info *sev = to_kvm_sev_info(kvm); >> + >> + return (sev->vmsa_features & SVM_SEV_FEAT_SECURE_TSC) && >> + !WARN_ON_ONCE(!sev_snp_guest(kvm)); > > Align indentation. > >> +} >> @@ -4455,6 +4479,9 @@ void sev_es_recalc_msr_intercepts(struct kvm_vcpu *vcpu) >> !guest_cpu_cap_has(vcpu, X86_FEATURE_RDTSCP) && >> !guest_cpu_cap_has(vcpu, X86_FEATURE_RDPID)); >> >> + if (snp_secure_tsc_enabled(vcpu->kvm)) >> + svm_disable_intercept_for_msr(vcpu, MSR_AMD64_GUEST_TSC_FREQ, MSR_TYPE_R); > > I'm leaning towards: > > svm_set_intercept_for_msr(vcpu, MSR_AMD64_GUEST_TSC_FREQ, MSR_TYPE_R, > !snp_is_secure_tsc_enabled(vcpu->kvm)); > > because the cost of setting a bit is negligible. > Ack. >> + >> /* >> * For SEV-ES, accesses to MSR_IA32_XSS should not be intercepted if >> * the host/guest supports its use. >> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c >> index d9931c6c4bc6..a81bf83ccb52 100644 >> --- a/arch/x86/kvm/svm/svm.c >> +++ b/arch/x86/kvm/svm/svm.c >> @@ -1317,6 +1317,8 @@ static int svm_vcpu_create(struct kvm_vcpu *vcpu) >> >> svm->guest_state_loaded = false; >> >> + vcpu->arch.guest_tsc_protected = snp_secure_tsc_enabled(vcpu->kvm); > > Hmm, we can and should handle this in sev.c. If we add sev_vcpu_create(), then > we don't need to expose snp_is_secure_tsc_enabled(), and we can move more code > into that helper. > > I'll post a combined series of this and the GHCB version patches. Thanks, I will test and get back on v11. Regards Nikunj ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v10 0/2] Enable Secure TSC for SEV-SNP 2025-08-04 10:37 [PATCH v10 0/2] Enable Secure TSC for SEV-SNP Nikunj A Dadhania 2025-08-04 10:37 ` [PATCH v10 1/2] x86/cpufeatures: Add SNP Secure TSC Nikunj A Dadhania 2025-08-04 10:37 ` [PATCH v10 2/2] KVM: SVM: Enable Secure TSC for SNP guests Nikunj A Dadhania @ 2025-08-19 3:47 ` Nikunj A. Dadhania 2 siblings, 0 replies; 6+ messages in thread From: Nikunj A. Dadhania @ 2025-08-19 3:47 UTC (permalink / raw) To: seanjc, pbonzini, kvm Cc: thomas.lendacky, santosh.shukla, bp, isaku.yamahata, vaishali.thakkar, kai.huang On 8/4/2025 4:07 PM, Nikunj A Dadhania wrote: > Patches are based on kvm/next with [1] applied > > Testing Secure TSC > ------------------ > > Secure TSC guest patches are available as part of v6.14. > > QEMU changes: > https://github.com/AMDESE/qemu/tree/snp-securetsc-latest > > QEMU command line SEV-SNP with Secure TSC: > > qemu-system-x86_64 -cpu EPYC-Milan-v2 -smp 4 \ > -object memory-backend-memfd,id=ram1,size=1G,share=true,prealloc=false,reserve=false \ > -object sev-snp-guest,id=sev0,cbitpos=51,reduced-phys-bits=1,secure-tsc=on,stsc-freq=2000000000 \ > -machine q35,confidential-guest-support=sev0,memory-backend=ram1 \ > ... > > Changelog: > ---------- > v10: > * Rebased on kvm/next > * Collect RB from Kai Huang > > v9: https://lore.kernel.org/kvm/20250716060836.2231613-1-nikunj@amd.com/ > * Set guest_tsc_protected during guest vCPU creation (Kai Huang) > * Improve error handling (Kai Huang) > * Disable MSR_AMD64_GUEST_TSC_FREQ write interception (Sean) > > > 1. https://lore.kernel.org/kvm/20250804090945.267199-1-nikunj@amd.com/ Hi Sean, A gentle reminder for review/merge. Regards, Nikunj ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-08-20 5:31 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-08-04 10:37 [PATCH v10 0/2] Enable Secure TSC for SEV-SNP Nikunj A Dadhania 2025-08-04 10:37 ` [PATCH v10 1/2] x86/cpufeatures: Add SNP Secure TSC Nikunj A Dadhania 2025-08-04 10:37 ` [PATCH v10 2/2] KVM: SVM: Enable Secure TSC for SNP guests Nikunj A Dadhania 2025-08-19 18:31 ` Sean Christopherson 2025-08-20 5:31 ` Nikunj A. Dadhania 2025-08-19 3:47 ` [PATCH v10 0/2] Enable Secure TSC for SEV-SNP Nikunj A. Dadhania
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).