[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aKXHNDiKys9y8Xdw@google.com>
Date: Wed, 20 Aug 2025 06:01:40 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: "Nikunj A. Dadhania" <nikunj@....com>
Cc: Paolo Bonzini <pbonzini@...hat.com>, kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
Thomas Lendacky <thomas.lendacky@....com>, Michael Roth <michael.roth@....com>,
Borislav Petkov <bp@...en8.de>, Vaishali Thakkar <vaishali.thakkar@...e.com>,
Kai Huang <kai.huang@...el.com>, David.Kaplan@....com
Subject: Re: [PATCH v11 8/8] KVM: SVM: Enable Secure TSC for SNP guests
On Wed, Aug 20, 2025, Nikunj A. Dadhania wrote:
>
>
> On 8/20/2025 5:18 AM, Sean Christopherson wrote:
> > From: Nikunj A Dadhania <nikunj@....com>
> >
> > @@ -2195,6 +2206,12 @@ 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_is_secure_tsc_enabled(kvm)) {
> > + WARN_ON_ONCE(!kvm->arch.default_tsc_khz);
>
> Any particular reason to drop the the following change:
>
> + if (WARN_ON(!kvm->arch.default_tsc_khz)) {
> + rc = -EINVAL;
> + goto e_free_context;
> + }
Based on this conversation[*], both Kai and I expected KVM to let firmware deal
with the should-be-impossible situation.
On Tue, Jul 8, 2025 at 9:15 PM Nikunj A. Dadhania <nikunj@....com> wrote:
> On 7/8/2025 8:04 PM, Sean Christopherson wrote:
> > On Tue, Jul 08, 2025, Kai Huang wrote:
> >>>> Even some bug results in the default_tsc_khz being 0, will the
> >>>> SNP_LAUNCH_START command catch this and return error?
> >>>
> >>> No, that is an invalid configuration, desired_tsc_khz is set to 0 when
> >>> SecureTSC is disabled. If SecureTSC is enabled, desired_tsc_khz should
> >>> have correct value.
> >>
> >> So it's an invalid configuration that when Secure TSC is enabled and
> >> desired_tsc_khz is 0. Assuming the SNP_LAUNCH_START will return an error
> >> if such configuration is used, wouldn't it be simpler if you remove the
> >> above check and depend on the SNP_LAUNCH_START command to catch the
> >> invalid configuration?
> >
> > Support for secure TSC should depend on tsc_khz being non-zero. That way it'll
> > be impossible for arch.default_tsc_khz to be zero at runtime. Then KVM can WARN
> > on arch.default_tsc_khz being zero during SNP_LAUNCH_START.
>
> Sure.
https://lore.kernel.org/all/c327df02-c2eb-41e7-9402-5a16aa211265@amd.com
>
> As this is an unsupported configuration as per the SEV SNP Firmware ABI Specification:
Right, but what happens if KVM manages to pass in '0' for the frequency? Does
SNP_LAUNCH_START fail? If so, bailing from KVM doesn't seem to add any value.
>
> 8.16 SNP_LAUNCH_START
>
> DESIRED_TSC_FREQ
> Hypervisor-desired mean TSC frequency in KHz of the guest. This field has no
> effect if guests do not enable Secure TSC in the VMSA. The hypervisor should
> set this field to 0h if it *does not support Secure TSC* for this guest.
>
> > + start.desired_tsc_khz = kvm->arch.default_tsc_khz;
> > + }
> > +
> Regards,Nikunj
Powered by blists - more mailing lists