Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: ccp - Cache SEV platform status and platform state

Cache the SEV platform status into sev_device structure and use this
cached SEV platform status for api_major/minor/build.

The platform state is unique between SEV and SNP and hence needs to be
tracked independently.

Remove the state field from sev_device structure and instead track SEV
state from the cached SEV platform status.

Suggested-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
Reviewed-by: Kim Phillips <kim.phillips@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Ashish Kalra and committed by
Herbert Xu
459daec4 450bbe43

+14 -11
+12 -10
drivers/crypto/ccp/sev-dev.c
··· 1286 1286 1287 1287 sev = psp_master->sev_data; 1288 1288 1289 - if (sev->state == SEV_STATE_INIT) 1289 + if (sev->sev_plat_status.state == SEV_STATE_INIT) 1290 1290 return 0; 1291 1291 1292 1292 __sev_platform_init_handle_tmr(sev); ··· 1318 1318 return rc; 1319 1319 } 1320 1320 1321 - sev->state = SEV_STATE_INIT; 1321 + sev->sev_plat_status.state = SEV_STATE_INIT; 1322 1322 1323 1323 /* Prepare for first SEV guest launch after INIT */ 1324 1324 wbinvd_on_all_cpus(); ··· 1347 1347 1348 1348 sev = psp_master->sev_data; 1349 1349 1350 - if (sev->state == SEV_STATE_INIT) 1350 + if (sev->sev_plat_status.state == SEV_STATE_INIT) 1351 1351 return 0; 1352 1352 1353 1353 rc = __sev_snp_init_locked(&args->error); ··· 1384 1384 1385 1385 sev = psp->sev_data; 1386 1386 1387 - if (sev->state == SEV_STATE_UNINIT) 1387 + if (sev->sev_plat_status.state == SEV_STATE_UNINIT) 1388 1388 return 0; 1389 1389 1390 1390 ret = __sev_do_cmd_locked(SEV_CMD_SHUTDOWN, NULL, error); ··· 1394 1394 return ret; 1395 1395 } 1396 1396 1397 - sev->state = SEV_STATE_UNINIT; 1397 + sev->sev_plat_status.state = SEV_STATE_UNINIT; 1398 1398 dev_dbg(sev->dev, "SEV firmware shutdown\n"); 1399 1399 1400 1400 return ret; ··· 1502 1502 if (!writable) 1503 1503 return -EPERM; 1504 1504 1505 - if (sev->state == SEV_STATE_UNINIT) { 1505 + if (sev->sev_plat_status.state == SEV_STATE_UNINIT) { 1506 1506 rc = sev_move_to_init_state(argp, &shutdown_required); 1507 1507 if (rc) 1508 1508 return rc; ··· 1551 1551 data.len = input.length; 1552 1552 1553 1553 cmd: 1554 - if (sev->state == SEV_STATE_UNINIT) { 1554 + if (sev->sev_plat_status.state == SEV_STATE_UNINIT) { 1555 1555 ret = sev_move_to_init_state(argp, &shutdown_required); 1556 1556 if (ret) 1557 1557 goto e_free_blob; ··· 1606 1606 return 1; 1607 1607 } 1608 1608 1609 + /* Cache SEV platform status */ 1610 + sev->sev_plat_status = status; 1611 + 1609 1612 sev->api_major = status.api_major; 1610 1613 sev->api_minor = status.api_minor; 1611 1614 sev->build = status.build; 1612 - sev->state = status.state; 1613 1615 1614 1616 return 0; 1615 1617 } ··· 1839 1837 data.oca_cert_len = input.oca_cert_len; 1840 1838 1841 1839 /* If platform is not in INIT state then transition it to INIT */ 1842 - if (sev->state != SEV_STATE_INIT) { 1840 + if (sev->sev_plat_status.state != SEV_STATE_INIT) { 1843 1841 ret = sev_move_to_init_state(argp, &shutdown_required); 1844 1842 if (ret) 1845 1843 goto e_free_oca; ··· 2010 2008 2011 2009 cmd: 2012 2010 /* If platform is not in INIT state then transition it to INIT. */ 2013 - if (sev->state != SEV_STATE_INIT) { 2011 + if (sev->sev_plat_status.state != SEV_STATE_INIT) { 2014 2012 if (!writable) { 2015 2013 ret = -EPERM; 2016 2014 goto e_free_cert;
+2 -1
drivers/crypto/ccp/sev-dev.h
··· 42 42 43 43 struct sev_vdata *vdata; 44 44 45 - int state; 46 45 unsigned int int_rcvd; 47 46 wait_queue_head_t int_queue; 48 47 struct sev_misc_dev *misc; ··· 56 57 bool cmd_buf_backup_active; 57 58 58 59 bool snp_initialized; 60 + 61 + struct sev_user_data_status sev_plat_status; 59 62 }; 60 63 61 64 int sev_dev_init(struct psp_device *psp);