mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Kalra, Ashish" <ashish.kalra@amd.com>
To: Alexey Kardashevskiy <aik@amd.com>,
	seanjc@google.com, pbonzini@redhat.com, tglx@linutronix.de,
	mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
	hpa@zytor.com, herbert@gondor.apana.org.au
Cc: x86@kernel.org, john.allen@amd.com, davem@davemloft.net,
	thomas.lendacky@amd.com, michael.roth@amd.com,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-crypto@vger.kernel.org
Subject: Re: [PATCH v4 3/5] crypto: ccp: Add support to enable CipherTextHiding on SNP_INIT_EX
Date: Thu, 5 Jun 2025 14:09:30 -0500	[thread overview]
Message-ID: <755d9317-a004-4d4a-948d-729a3b3ef13d@amd.com> (raw)
In-Reply-To: <e59803e9-017a-4257-ac9c-7bdafbc624ff@amd.com>


On 6/5/2025 1:32 AM, Alexey Kardashevskiy wrote:
> On 20/5/25 09:57, Ashish Kalra wrote:
>> From: Ashish Kalra <ashish.kalra@amd.com>
>>
>> Ciphertext hiding needs to be enabled on SNP_INIT_EX.
>>
>> Add new argument to sev_platform_init_args to allow KVM module to
>> specify during SNP initialization if CipherTextHiding feature is
>> to be enabled and the maximum ASID usable for an SEV-SNP guest
>> when CipherTextHiding feature is enabled.
>>
>> Add new API interface to indicate if SEV-SNP CipherTextHiding
>> feature is supported by SEV firmware and additionally if
>> CipherTextHiding feature is enabled in the Platform BIOS.
>>
>> Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
>> ---
>>   drivers/crypto/ccp/sev-dev.c | 30 +++++++++++++++++++++++++++---
>>   include/linux/psp-sev.h      | 15 +++++++++++++--
>>   2 files changed, 40 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
>> index b642f1183b8b..185668477182 100644
>> --- a/drivers/crypto/ccp/sev-dev.c
>> +++ b/drivers/crypto/ccp/sev-dev.c
>> @@ -1074,6 +1074,24 @@ static void snp_set_hsave_pa(void *arg)
>>       wrmsrq(MSR_VM_HSAVE_PA, 0);
>>   }
>>   +bool sev_is_snp_ciphertext_hiding_supported(void)
>> +{
>> +    struct psp_device *psp = psp_master;
>> +    struct sev_device *sev;
>> +
>> +    sev = psp->sev_data;
>> +
>> +    /*
>> +     * Feature information indicates if CipherTextHiding feature is
>> +     * supported by the SEV firmware and additionally platform status
>> +     * indicates if CipherTextHiding feature is enabled in the
>> +     * Platform BIOS.
>> +     */
>> +    return ((sev->feat_info.ecx & SNP_CIPHER_TEXT_HIDING_SUPPORTED) &&
>> +        sev->snp_plat_status.ciphertext_hiding_cap);
>> +}
>> +EXPORT_SYMBOL_GPL(sev_is_snp_ciphertext_hiding_supported);
>> +
>>   static int snp_get_platform_data(struct sev_user_data_status *status, int *error)
>>   {
>>       struct sev_data_snp_feature_info snp_feat_info;
>> @@ -1167,7 +1185,7 @@ static int snp_filter_reserved_mem_regions(struct resource *rs, void *arg)
>>       return 0;
>>   }
>>   -static int __sev_snp_init_locked(int *error)
>> +static int __sev_snp_init_locked(int *error, unsigned int snp_max_snp_asid)
>>   {
>>       struct psp_device *psp = psp_master;
>>       struct sev_data_snp_init_ex data;
>> @@ -1228,6 +1246,12 @@ static int __sev_snp_init_locked(int *error)
>>           }
>>             memset(&data, 0, sizeof(data));
>> +
>> +        if (snp_max_snp_asid) {
>> +            data.ciphertext_hiding_en = 1;
>> +            data.max_snp_asid = snp_max_snp_asid;
>> +        }
>> +
>>           data.init_rmp = 1;
>>           data.list_paddr_en = 1;
>>           data.list_paddr = __psp_pa(snp_range_list);
>> @@ -1412,7 +1436,7 @@ static int _sev_platform_init_locked(struct sev_platform_init_args *args)
>>       if (sev->state == SEV_STATE_INIT)
>>           return 0;
>>   -    rc = __sev_snp_init_locked(&args->error);
>> +    rc = __sev_snp_init_locked(&args->error, args->snp_max_snp_asid);
>>       if (rc && rc != -ENODEV)
>>           return rc;
>>   @@ -1495,7 +1519,7 @@ static int snp_move_to_init_state(struct sev_issue_cmd *argp, bool *shutdown_req
>>   {
>>       int error, rc;
>>   -    rc = __sev_snp_init_locked(&error);
>> +    rc = __sev_snp_init_locked(&error, 0);
>>       if (rc) {
>>           argp->error = SEV_RET_INVALID_PLATFORM_STATE;
>>           return rc;
>> diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h
>> index 0149d4a6aceb..66fecd0c0f88 100644
>> --- a/include/linux/psp-sev.h
>> +++ b/include/linux/psp-sev.h
>> @@ -746,10 +746,13 @@ struct sev_data_snp_guest_request {
>>   struct sev_data_snp_init_ex {
>>       u32 init_rmp:1;
>>       u32 list_paddr_en:1;
>> -    u32 rsvd:30;
>> +    u32 rapl_dis:1;
>> +    u32 ciphertext_hiding_en:1;
>> +    u32 rsvd:28;
>>       u32 rsvd1;
>>       u64 list_paddr;
>> -    u8  rsvd2[48];
>> +    u16 max_snp_asid;
>> +    u8  rsvd2[46];
>>   } __packed;
>>     /**
>> @@ -798,10 +801,13 @@ struct sev_data_snp_shutdown_ex {
>>    * @probe: True if this is being called as part of CCP module probe, which
>>    *  will defer SEV_INIT/SEV_INIT_EX firmware initialization until needed
>>    *  unless psp_init_on_probe module param is set
>> + *  @snp_max_snp_asid: maximum ASID usable for SEV-SNP guest if
>> + *  CipherTextHiding feature is to be enabled
>>    */
>>   struct sev_platform_init_args {
>>       int error;
>>       bool probe;
>> +    unsigned int snp_max_snp_asid;
>>   };
>>     /**
>> @@ -841,6 +847,8 @@ struct snp_feature_info {
>>       u32 edx;
>>   } __packed;
>>   +#define SNP_CIPHER_TEXT_HIDING_SUPPORTED    BIT(3)
> 
> SNP_FEATURE_CIPHER_TEXT_HIDING ?
> or X86_FEATURE_CIPHER_TEXT_HIDING ?
> 
> In other words, mimic X86_FEATURE_SEV which is a real CPUID bit and FEATURE_INFO mimics CPUID. Thanks,
>

I will still prefer to name it SNP_FEATURE_CIPHER_TEXT_HIDING, as the SNP FW ABI specs names it as such
and it is a SNP specific feature, prefixing X86 is confusing.

Thanks,
Ashish
 
> 
>> +
>>   #ifdef CONFIG_CRYPTO_DEV_SP_PSP
>>     /**
>> @@ -984,6 +992,7 @@ void *psp_copy_user_blob(u64 uaddr, u32 len);
>>   void *snp_alloc_firmware_page(gfp_t mask);
>>   void snp_free_firmware_page(void *addr);
>>   void sev_platform_shutdown(void);
>> +bool sev_is_snp_ciphertext_hiding_supported(void);
>>     #else    /* !CONFIG_CRYPTO_DEV_SP_PSP */
>>   @@ -1020,6 +1029,8 @@ static inline void snp_free_firmware_page(void *addr) { }
>>     static inline void sev_platform_shutdown(void) { }
>>   +static inline bool sev_is_snp_ciphertext_hiding_supported(void) { return false; }
>> +
>>   #endif    /* CONFIG_CRYPTO_DEV_SP_PSP */
>>     #endif    /* __PSP_SEV_H__ */
> 


  reply	other threads:[~2025-06-05 19:09 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-19 23:56 [PATCH v4 0/5] Add SEV-SNP CipherTextHiding feature support Ashish Kalra
2025-05-19 23:56 ` [PATCH v4 1/5] crypto: ccp: New bit-field definitions for SNP_PLATFORM_STATUS command Ashish Kalra
2025-06-03 14:03   ` Tom Lendacky
2025-05-19 23:56 ` [PATCH v4 2/5] crypto: ccp: Add support for SNP_FEATURE_INFO command Ashish Kalra
2025-06-03 15:21   ` Tom Lendacky
2025-06-04 22:52     ` Kalra, Ashish
2025-06-05 15:51       ` Tom Lendacky
2025-06-05  4:49   ` Alexey Kardashevskiy
2025-06-05 19:34     ` Kalra, Ashish
2025-05-19 23:57 ` [PATCH v4 3/5] crypto: ccp: Add support to enable CipherTextHiding on SNP_INIT_EX Ashish Kalra
2025-06-03 15:41   ` Tom Lendacky
2025-06-04 22:55     ` Kalra, Ashish
2025-06-05  6:32   ` Alexey Kardashevskiy
2025-06-05 19:09     ` Kalra, Ashish [this message]
2025-05-19 23:57 ` [PATCH v4 4/5] KVM: SEV: Introduce new min,max sev_es and sev_snp asid variables Ashish Kalra
2025-06-03 15:52   ` Tom Lendacky
2025-06-04 23:12     ` Kalra, Ashish
2025-05-20  0:02 ` [PATCH v4 5/5] KVM: SEV: Add SEV-SNP CipherTextHiding support Ashish Kalra
2025-05-23 17:29   ` Dave Hansen
2025-06-02 20:32     ` Kalra, Ashish
2025-06-03 16:26   ` Tom Lendacky
2025-06-05  0:17     ` Kalra, Ashish
2025-06-05 16:23       ` Tom Lendacky
2025-06-05 19:21         ` Kalra, Ashish
2025-06-05  6:32   ` Alexey Kardashevskiy
2025-06-05 19:18     ` Kalra, Ashish
2025-05-22 14:56 ` [PATCH v4 0/5] Add SEV-SNP CipherTextHiding feature support Kim Phillips
2025-05-27 20:47   ` Kalra, Ashish

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=755d9317-a004-4d4a-948d-729a3b3ef13d@amd.com \
    --to=ashish.kalra@amd.com \
    --cc=aik@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=hpa@zytor.com \
    --cc=john.allen@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®