On 9/20/2025 3:36 AM, Tom Lendacky wrote:
> On 9/18/25 05:27, Naveen N Rao (AMD) wrote:
>> @@ -1085,6 +1093,18 @@ sev_snp_launch_start(SevCommonState *sev_common)
>> return 1;
>> }
>>
>> + if (is_sev_feature_set(sev_common, SVM_SEV_FEAT_SECURE_TSC)) {
>> + rc = -EINVAL;
>> + if (kvm_check_extension(kvm_state, KVM_CAP_VM_TSC_CONTROL)) {
>> + rc = kvm_vm_ioctl(kvm_state, KVM_SET_TSC_KHZ,
>> sev_snp_guest->tsc_khz);
>> + }
>> + if (rc < 0) {
>> + error_report("%s: Unable to set Secure TSC frequency to %u kHz
>> ret=%d",
>> + __func__, sev_snp_guest->tsc_khz, rc);
>> + return 1;
>> + }
>
> It looks like KVM_CAP_VM_TSC_CONTROL is required for Secure TSC. Should
> this cap check be part of check_sev_features() then, rather than waiting
> until launch start?
If the user has not provided tsc-frequency, KVM_CAP_VM_TSC_CONTROL is not
required.
>
> And does KVM_SET_TSC_KHZ have to be called if "tsc-frequency" wasn't set?
No, this is not required. This patch has changed a bit from my original
version, we should have something like below:
if (is_sev_feature_set(sev_common, SVM_SEV_FEAT_SECURE_TSC) &&
sev_snp_guest->stsc_khz) {
...
}
Regards
Nikunj