lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6652929c-1e14-451f-afce-c5b4c2b7af9d@amd.com>
Date: Wed, 20 Aug 2025 18:41:50 +0530
From: "Nikunj A. Dadhania" <nikunj@....com>
To: Sean Christopherson <seanjc@...gle.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 8/20/2025 6:31 PM, Sean Christopherson wrote:
> 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?  

SNP_LAUNCH_START succeeds, and the guest kernel starts and panics during early boot [*]

> If so, bailing from KVM doesn't seem to add any value.

As firmware does not bail out, I had kept this check.

RegardsNikunjhttps://lore.kernel.org/all/afcf9a0b-7450-4df7-a21b-80b56264fc15@amd.com 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ