Skip to contentSkip to conversation

crypto: ccp: fix the SEV probe in kexec boot path

PATCH New Hook, Gary 1 participant 1 message Feb 8, 2019 1 message not in the archive Crypto API

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20190130205710.14268-1-brijesh.singh () amd ! com

Hook, Gary

author
#1 lore raw

PATCH 1/1 crypto: ccp: fix the SEV probe in kexec boot path

Quoted 11 lines · Brijesh

A kexec reboot may leave the firmware in INIT or WORKING state. Currently, we issue PLATFORM_INIT command during the probe without checking the current state. The PLATFORM_INIT command fails if the FW is already in INIT state. Lets check the current state, if FW is not in UNINIT state then transition it to UNINIT before initializing or upgrading the FW.

Cc Tom Lendacky <[email protected]>
Cc Gary Hook <[email protected]>

---

Quoted 37 lines
 drivers/crypto/ccp/psp-dev.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/crypto/ccp/psp-dev.c +1 -0
index b16be8a11d92..966ca6f9cf79 100644
@@ -437,6 +437,7 @@ static int sev_get_api_version(void)
 	psp_master->api_major =3D status->api_major;
 	psp_master->api_minor =3D status->api_minor;
 	psp_master->build =3D status->build;
+	psp_master->sev_state =3D status->state;

=20

drivers/crypto/ccp/psp-dev.c +0 -0
 	return 0;
 }
@@ -964,6 +965,21 @@ void psp_pci_init(void)
 	if (sev_get_api_version())
 		goto err;

=20

drivers/crypto/ccp/psp-dev.c +15 -0
+	/*
+	 * If platform is not in UNINIT state then firmware upgrade and/or
+	 * platform INIT command will fail. These command require UNINIT state.
+	 *
+	 * In a normal boot we should never run into case where the firmware
+	 * is not in UNINIT state on boot. But in case of kexec boot, a reboot
+	 * may not go through a typical shutdown sequence and may leave the
+	 * firmware in INIT or WORKING state.
+	 */
+
+	if (psp_master->sev_state !=3D SEV_STATE_UNINIT) {
+		sev_platform_shutdown(NULL);
+		psp_master->sev_state =3D SEV_STATE_UNINIT;
+	}
+
 	if (SEV_VERSION_GREATER_OR_EQUAL(0, 15) &&
 	    sev_update_firmware(psp_master->dev) =3D=3D 0)
 		sev_get_api_version();