crypto: ccp: fix the SEV probe in kexec boot path
Subsystems (2)
PATCH 1/1 crypto: ccp: fix the SEV probe in kexec boot path
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.
--- drivers/crypto/ccp/psp-dev.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/crypto/ccp/psp-dev.c +16 -0
@@ -437,6 +437,7 @@ static int sev_get_api_version(void) psp_master->api_major = status->api_major; psp_master->api_minor = status->api_minor; psp_master->build = status->build; + psp_master->sev_state = status->state;return 0 ; }
@@ -964,6 +965,21 @@ void psp_pci_init(void)if (sev_get_api_version ()) goto err; +/* +* 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 !=SEV_STATE_UNINIT ) { +sev_platform_shutdown (NULL ); + psp_master->sev_state =SEV_STATE_UNINIT ; + } +if (SEV_VERSION_GREATER_OR_EQUAL (0 ,15 ) &&sev_update_firmware (psp_master->dev) ==0 )sev_get_api_version ();
Signature · 1 line
2.17.1
Quoted 7 lines · Brijesh
A kexec reboot may leave the firmware in INIT or WORKING state. Currently, we issue
PLATFORM_INITcommand during the probe without checking the current state. ThePLATFORM_INITcommand 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.
Quoted 6 lines
Signed-off-by Brijesh Singh <[email protected]>Cc Tom Lendacky <[email protected]>Cc Gary Hook <[email protected]>--- drivers/crypto/ccp/psp-dev.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Quoted 36 lines
drivers/crypto/ccp/psp-dev.c +16
-0@@ -437,6 +437,7 @@ static int sev_get_api_version(void) psp_master->api_major = status->api_major; psp_master->api_minor = status->api_minor; psp_master->build = status->build; + psp_master->sev_state = status->state;return 0 ; }@@ -964,6 +965,21 @@ void psp_pci_init(void)if (sev_get_api_version ()) goto err; +/* +* 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 !=SEV_STATE_UNINIT ) { +sev_platform_shutdown (NULL ); + psp_master->sev_state =SEV_STATE_UNINIT ; + } +if (SEV_VERSION_GREATER_OR_EQUAL (0 ,15 ) &&sev_update_firmware (psp_master->dev) ==0 )sev_get_api_version ();
Herbert Xu
maintainerRe: [PATCH] crypto: ccp - fix the SEV probe in kexec boot path
In reply to Singh, BrijeshQuoted 7 lines · Brijesh
A kexec reboot may leave the firmware in INIT or WORKING state. Currently, we issue
PLATFORM_INITcommand during the probe without checking the current state. ThePLATFORM_INITcommand 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.
Quoted 7 lines
Signed-off-by Brijesh Singh <[email protected]>Cc Tom Lendacky <[email protected]>Cc Gary Hook <[email protected]>Reviewed-by Tom Lendacky <[email protected]>--- drivers/crypto/ccp/psp-dev.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt