diff mbox series

[v3,2/5] crypto: ccp: Add missing member in SNP_LAUNCH_START command structure

Message ID 20250217102237.16434-3-nikunj@amd.com (mailing list archive)
State New
Headers show
Series Enable Secure TSC for SEV-SNP | expand

Commit Message

Nikunj A Dadhania Feb. 17, 2025, 10:22 a.m. UTC
The sev_data_snp_launch_start structure should include a 4-byte
desired_tsc_khz field before the gosvw field, which was missed in the
initial implementation. As a result, the structure is 4 bytes shorter than
expected by the firmware, causing the gosvw field to start 4 bytes early.
Fix this by adding the missing 4-byte member for the desired TSC frequency.

Fixes: 3a45dc2b419e ("crypto: ccp: Define the SEV-SNP commands")
Cc: stable@vger.kernel.org
Suggested-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Nikunj A Dadhania <nikunj@amd.com>
---
 include/linux/psp-sev.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Tom Lendacky Feb. 17, 2025, 7:18 p.m. UTC | #1
On 2/17/25 04:22, Nikunj A Dadhania wrote:
> The sev_data_snp_launch_start structure should include a 4-byte
> desired_tsc_khz field before the gosvw field, which was missed in the
> initial implementation. As a result, the structure is 4 bytes shorter than
> expected by the firmware, causing the gosvw field to start 4 bytes early.
> Fix this by adding the missing 4-byte member for the desired TSC frequency.
> 
> Fixes: 3a45dc2b419e ("crypto: ccp: Define the SEV-SNP commands")
> Cc: stable@vger.kernel.org
> Suggested-by: Tom Lendacky <thomas.lendacky@amd.com>
> Signed-off-by: Nikunj A Dadhania <nikunj@amd.com>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

Even though you're using the "crypto: ccp:" tag (which should actually
be "crypto: ccp -"), this can probably go through the KVM tree. Not sure
if it makes sense to tag it as "KVM: SVM:" instead.

Thanks,
Tom

> ---
>  include/linux/psp-sev.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h
> index f3cad182d4ef..1f3620aaa4e7 100644
> --- a/include/linux/psp-sev.h
> +++ b/include/linux/psp-sev.h
> @@ -594,6 +594,7 @@ struct sev_data_snp_addr {
>   * @imi_en: launch flow is launching an IMI (Incoming Migration Image) for the
>   *          purpose of guest-assisted migration.
>   * @rsvd: reserved
> + * @desired_tsc_khz: hypervisor desired mean TSC freq in kHz of the guest
>   * @gosvw: guest OS-visible workarounds, as defined by hypervisor
>   */
>  struct sev_data_snp_launch_start {
> @@ -603,6 +604,7 @@ struct sev_data_snp_launch_start {
>  	u32 ma_en:1;				/* In */
>  	u32 imi_en:1;				/* In */
>  	u32 rsvd:30;
> +	u32 desired_tsc_khz;			/* In */
>  	u8 gosvw[16];				/* In */
>  } __packed;
>
Nikunj A Dadhania Feb. 18, 2025, 7:57 a.m. UTC | #2
Tom Lendacky <thomas.lendacky@amd.com> writes:

> On 2/17/25 04:22, Nikunj A Dadhania wrote:
>> The sev_data_snp_launch_start structure should include a 4-byte
>> desired_tsc_khz field before the gosvw field, which was missed in the
>> initial implementation. As a result, the structure is 4 bytes shorter than
>> expected by the firmware, causing the gosvw field to start 4 bytes early.
>> Fix this by adding the missing 4-byte member for the desired TSC frequency.
>> 
>> Fixes: 3a45dc2b419e ("crypto: ccp: Define the SEV-SNP commands")
>> Cc: stable@vger.kernel.org
>> Suggested-by: Tom Lendacky <thomas.lendacky@amd.com>
>> Signed-off-by: Nikunj A Dadhania <nikunj@amd.com>
>
> Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
>
> Even though you're using the "crypto: ccp:" tag (which should actually
> be "crypto: ccp -"), this can probably go through the KVM tree. Not sure
> if it makes sense to tag it as "KVM: SVM:" instead.

Thanks, I will update the subject.

Regards
Nikunj
diff mbox series

Patch

diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h
index f3cad182d4ef..1f3620aaa4e7 100644
--- a/include/linux/psp-sev.h
+++ b/include/linux/psp-sev.h
@@ -594,6 +594,7 @@  struct sev_data_snp_addr {
  * @imi_en: launch flow is launching an IMI (Incoming Migration Image) for the
  *          purpose of guest-assisted migration.
  * @rsvd: reserved
+ * @desired_tsc_khz: hypervisor desired mean TSC freq in kHz of the guest
  * @gosvw: guest OS-visible workarounds, as defined by hypervisor
  */
 struct sev_data_snp_launch_start {
@@ -603,6 +604,7 @@  struct sev_data_snp_launch_start {
 	u32 ma_en:1;				/* In */
 	u32 imi_en:1;				/* In */
 	u32 rsvd:30;
+	u32 desired_tsc_khz;			/* In */
 	u8 gosvw[16];				/* In */
 } __packed;