Skip to content

Commit c9760b0

Browse files
ashkalraherbertx
authored andcommitted
crypto: ccp - Add support to enable CipherTextHiding on SNP_INIT_EX
To enable ciphertext hiding, it must be specified in the SNP_INIT_EX command as part of SNP initialization. Modify the sev_platform_init_args structure, which is used as input to sev_platform_init(), to include a field that, when non-zero, indicates that ciphertext hiding should be enabled and specifies the maximum ASID that can be used for an SEV-SNP guest. Reviewed-by: Tom Lendacky <[email protected]> Signed-off-by: Ashish Kalra <[email protected]> Reviewed-by: Kim Phillips <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 45d59bd commit c9760b0

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

drivers/crypto/ccp/sev-dev.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ static int snp_filter_reserved_mem_regions(struct resource *rs, void *arg)
11861186
return 0;
11871187
}
11881188

1189-
static int __sev_snp_init_locked(int *error)
1189+
static int __sev_snp_init_locked(int *error, unsigned int max_snp_asid)
11901190
{
11911191
struct psp_device *psp = psp_master;
11921192
struct sev_data_snp_init_ex data;
@@ -1247,6 +1247,12 @@ static int __sev_snp_init_locked(int *error)
12471247
}
12481248

12491249
memset(&data, 0, sizeof(data));
1250+
1251+
if (max_snp_asid) {
1252+
data.ciphertext_hiding_en = 1;
1253+
data.max_snp_asid = max_snp_asid;
1254+
}
1255+
12501256
data.init_rmp = 1;
12511257
data.list_paddr_en = 1;
12521258
data.list_paddr = __psp_pa(snp_range_list);
@@ -1433,7 +1439,7 @@ static int _sev_platform_init_locked(struct sev_platform_init_args *args)
14331439
if (sev->sev_plat_status.state == SEV_STATE_INIT)
14341440
return 0;
14351441

1436-
rc = __sev_snp_init_locked(&args->error);
1442+
rc = __sev_snp_init_locked(&args->error, args->max_snp_asid);
14371443
if (rc && rc != -ENODEV)
14381444
return rc;
14391445

@@ -1516,7 +1522,7 @@ static int snp_move_to_init_state(struct sev_issue_cmd *argp, bool *shutdown_req
15161522
{
15171523
int error, rc;
15181524

1519-
rc = __sev_snp_init_locked(&error);
1525+
rc = __sev_snp_init_locked(&error, 0);
15201526
if (rc) {
15211527
argp->error = SEV_RET_INVALID_PLATFORM_STATE;
15221528
return rc;

include/linux/psp-sev.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,10 +748,13 @@ struct sev_data_snp_guest_request {
748748
struct sev_data_snp_init_ex {
749749
u32 init_rmp:1;
750750
u32 list_paddr_en:1;
751-
u32 rsvd:30;
751+
u32 rapl_dis:1;
752+
u32 ciphertext_hiding_en:1;
753+
u32 rsvd:28;
752754
u32 rsvd1;
753755
u64 list_paddr;
754-
u8 rsvd2[48];
756+
u16 max_snp_asid;
757+
u8 rsvd2[46];
755758
} __packed;
756759

757760
/**
@@ -800,10 +803,13 @@ struct sev_data_snp_shutdown_ex {
800803
* @probe: True if this is being called as part of CCP module probe, which
801804
* will defer SEV_INIT/SEV_INIT_EX firmware initialization until needed
802805
* unless psp_init_on_probe module param is set
806+
* @max_snp_asid: When non-zero, enable ciphertext hiding and specify the
807+
* maximum ASID that can be used for an SEV-SNP guest.
803808
*/
804809
struct sev_platform_init_args {
805810
int error;
806811
bool probe;
812+
unsigned int max_snp_asid;
807813
};
808814

809815
/**

0 commit comments

Comments
 (0)