crypto: ccp - Retry SEV INIT command in case of integrity check failure.
Subsystems (4)
Kalra, Ashish
maintainerPATCH 1/1 crypto: ccp - Retry SEV INIT command in case of integrity check failure.
From: Ashish Kalra <[email protected]>
SEV INIT command loads the SEV related persistent data from NVS and initializes the platform context. The firmware validates the persistent state. If validation fails, the firmware will reset the persisent state and return an integrity check failure status.
At this point, a subsequent INIT command should succeed, so retry the command. The INIT command retry is only done during driver initialization.
Additional enums along with SEV_RET_SECURE_DATA_INVALID are added to sev_ret_code to maintain continuity and relevance of enum values.
--- drivers/crypto/ccp/psp-dev.c | 12 ++++++++++++ include/uapi/linux/psp-sev.h | 3 +++ 2 files changed, 15 insertions(+)
drivers/crypto/ccp/psp-dev.c +12 -0
@@ -1064,6 +1064,18 @@ void psp_pci_init(void)/* Initialize the platform */ rc =sev_platform_init (&error); +if (rc && (error ==SEV_RET_SECURE_DATA_INVALID )) { +/* +* INIT command returned an integrity check failure +* status code, meaning that firmware load and +* validation of SEV related persistent data has +* failed and persistent state has been erased. +* Retrying INIT command here should succeed. +*/ +dev_dbg (sp->dev,"SEV: retrying INIT command" ); + rc =sev_platform_init (&error); + } +if (rc) {dev_err (sp->dev,"SEV: failed to INIT error %#x\n" , error);return ;
include/uapi/linux/psp-sev.h +3 -0
@@ -58,6 +58,9 @@ typedef enum {SEV_RET_HWSEV_RET_PLATFORM ,SEV_RET_HWSEV_RET_UNSAFE ,SEV_RET_UNSUPPORTED , +SEV_RET_INVALID_PARAM , +SEV_RET_RESOURCE_LIMIT , +SEV_RET_SECURE_DATA_INVALID ,SEV_RET_MAX , } sev_ret_code;
Signature · 1 line
2.17.1
Quoted 33 lines · Ashish
From: Ashish Kalra <[email protected]>
SEV INIT command loads the SEV related persistent data from NVS and initializes the platform context. The firmware validates the persistent state. If validation fails, the firmware will reset the persisent state and return an integrity check failure status.
At this point, a subsequent INIT command should succeed, so retry the command. The INIT command retry is only done during driver initialization.
Additional enums along with
SEV_RET_SECURE_DATA_INVALIDare added tosev_ret_codeto maintain continuity and relevance of enum values.Signed-off-by Ashish Kalra <[email protected]>--- drivers/crypto/ccp/psp-dev.c | 12 ++++++++++++ include/uapi/linux/psp-sev.h | 3 +++ 2 files changed, 15 insertions(+)drivers/crypto/ccp/psp-dev.c +5
-0@@ -1064,6 +1064,18 @@ void psp_pci_init(void)/* Initialize the platform */ rc =sev_platform_init (&error); +if (rc && (error ==SEV_RET_SECURE_DATA_INVALID )) { +/* +* INIT command returned an integrity check failure +* status code, meaning that firmware load and +* validation of SEV related persistent data has
drivers/crypto/ccp/psp-dev.c void psp_pci_init(void) · line 1081
Quoted 10 lines
drivers/crypto/ccp/psp-dev.c +7
-0+* failed and persistent state has been erased. +* Retrying INIT command here should succeed. +*/ +dev_dbg (sp->dev,"SEV: retrying INIT command" ); + rc =sev_platform_init (&error); + } +if (rc) {dev_err (sp->dev,"SEV: failed to INIT error %#x\n" , error);return ;
Curious why this isn't done in __sev_platform_init_locked() since sev_platform_init() can be called when loading the kvm module and the same init failure can happen that way.
Quoted 14 lines
include/uapi/linux/psp-sev.h +3
-0@@ -58,6 +58,9 @@ typedef enum {SEV_RET_HWSEV_RET_PLATFORM ,SEV_RET_HWSEV_RET_UNSAFE ,SEV_RET_UNSUPPORTED , +SEV_RET_INVALID_PARAM , +SEV_RET_RESOURCE_LIMIT , +SEV_RET_SECURE_DATA_INVALID ,SEV_RET_MAX , } sev_ret_code;
Quoted 41 lines · David Rientjes
Quoted 39 lines · Ashish
From: Ashish Kalra <[email protected]>
SEV INIT command loads the SEV related persistent data from NVS and initializes the platform context. The firmware validates the persistent state. If validation fails, the firmware will reset the persisent state and return an integrity check failure status.
At this point, a subsequent INIT command should succeed, so retry the command. The INIT command retry is only done during driver initialization.
Additional enums along with
SEV_RET_SECURE_DATA_INVALIDare added tosev_ret_codeto maintain continuity and relevance of enum values.Signed-off-by Ashish Kalra <[email protected]>--- drivers/crypto/ccp/psp-dev.c | 12 ++++++++++++ include/uapi/linux/psp-sev.h | 3 +++ 2 files changed, 15 insertions(+)drivers/crypto/ccp/psp-dev.c +11
-0@@ -1064,6 +1064,18 @@ void psp_pci_init(void)/* Initialize the platform */ rc =sev_platform_init (&error); +if (rc && (error ==SEV_RET_SECURE_DATA_INVALID )) { +/* +* INIT command returned an integrity check failure +* status code, meaning that firmware load and +* validation of SEV related persistent data has +* failed and persistent state has been erased. +* Retrying INIT command here should succeed. +*/ +dev_dbg (sp->dev,"SEV: retrying INIT command" ); + rc =sev_platform_init (&error); + }
Quoted 9 lines
drivers/crypto/ccp/psp-dev.c void psp_pci_init(void) · line 1081
Quoted 4 lines
drivers/crypto/ccp/psp-dev.c +1
-0+if (rc) {dev_err (sp->dev,"SEV: failed to INIT error %#x\n" , error);return ;Curious why this isn't done in
__sev_platform_init_locked()sincesev_platform_init()can be called when loading the kvm module and the same init failure can happen that way.
The FW initialization (aka PLATFORM_INIT) is called in the following code paths:
1. During system boot up
and
2. After the platform reset command is issued
The patch takes care of #1. Based on the spec, platform reset command should erase the persistent data and the PLATFORM_INIT should *not* fail with SEV_RET_SECURE_DATA_INVALID error code. So, I am not able to see any strong reason to move the retry code in __sev_platform_init_locked().
thanks
Quoted 56 lines · Brijesh
Quoted 39 lines
Quoted 39 lines
From: Ashish Kalra <[email protected]>
SEV INIT command loads the SEV related persistent data from NVS and initializes the platform context. The firmware validates the persistent state. If validation fails, the firmware will reset the persisent state and return an integrity check failure status.
At this point, a subsequent INIT command should succeed, so retry the command. The INIT command retry is only done during driver initialization.
Additional enums along with
SEV_RET_SECURE_DATA_INVALIDare added tosev_ret_codeto maintain continuity and relevance of enum values.Signed-off-by Ashish Kalra <[email protected]>--- drivers/crypto/ccp/psp-dev.c | 12 ++++++++++++ include/uapi/linux/psp-sev.h | 3 +++ 2 files changed, 15 insertions(+)drivers/crypto/ccp/psp-dev.c +11
-0@@ -1064,6 +1064,18 @@ void psp_pci_init(void)/* Initialize the platform */ rc =sev_platform_init (&error); +if (rc && (error ==SEV_RET_SECURE_DATA_INVALID )) { +/* +* INIT command returned an integrity check failure +* status code, meaning that firmware load and +* validation of SEV related persistent data has +* failed and persistent state has been erased. +* Retrying INIT command here should succeed. +*/ +dev_dbg (sp->dev,"SEV: retrying INIT command" ); + rc =sev_platform_init (&error); + }Quoted 9 lines
drivers/crypto/ccp/psp-dev.c void psp_pci_init(void) · line 1081
Quoted 4 lines
drivers/crypto/ccp/psp-dev.c +1
-0+if (rc) {dev_err (sp->dev,"SEV: failed to INIT error %#x\n" , error);return ;Curious why this isn't done in
__sev_platform_init_locked()sincesev_platform_init()can be called when loading the kvm module and the same init failure can happen that way.The FW initialization (aka
PLATFORM_INIT) is called in the following code paths:1. During system boot up
and
Quoted 8 lines
2. After the platform reset command is issued
The patch takes care of #1. Based on the spec, platform reset command should erase the persistent data and the
PLATFORM_INITshould *not* fail withSEV_RET_SECURE_DATA_INVALIDerror code. So, I am not able to see any strong reason to move the retry code in__sev_platform_init_locked().
Hmm, is the sev_platform_init() call in sev_guest_init() intended to do SEV_CMD_INIT only after platform reset? I was under the impression it was done in case any previous init failed.
Quoted 67 lines · David Rientjes
Quoted 56 lines · Brijesh
Quoted 39 lines
Quoted 39 lines
From: Ashish Kalra <[email protected]>
SEV INIT command loads the SEV related persistent data from NVS and initializes the platform context. The firmware validates the persistent state. If validation fails, the firmware will reset the persisent state and return an integrity check failure status.
At this point, a subsequent INIT command should succeed, so retry the command. The INIT command retry is only done during driver initialization.
Additional enums along with
SEV_RET_SECURE_DATA_INVALIDare added tosev_ret_codeto maintain continuity and relevance of enum values.Signed-off-by Ashish Kalra <[email protected]>--- drivers/crypto/ccp/psp-dev.c | 12 ++++++++++++ include/uapi/linux/psp-sev.h | 3 +++ 2 files changed, 15 insertions(+)drivers/crypto/ccp/psp-dev.c +11
-0@@ -1064,6 +1064,18 @@ void psp_pci_init(void)/* Initialize the platform */ rc =sev_platform_init (&error); +if (rc && (error ==SEV_RET_SECURE_DATA_INVALID )) { +/* +* INIT command returned an integrity check failure +* status code, meaning that firmware load and +* validation of SEV related persistent data has +* failed and persistent state has been erased. +* Retrying INIT command here should succeed. +*/ +dev_dbg (sp->dev,"SEV: retrying INIT command" ); + rc =sev_platform_init (&error); + }Quoted 9 lines
drivers/crypto/ccp/psp-dev.c void psp_pci_init(void) · line 1081
Quoted 4 lines
drivers/crypto/ccp/psp-dev.c +1
-0+if (rc) {dev_err (sp->dev,"SEV: failed to INIT error %#x\n" , error);return ;Curious why this isn't done in
__sev_platform_init_locked()sincesev_platform_init()can be called when loading the kvm module and the same init failure can happen that way.The FW initialization (aka
PLATFORM_INIT) is called in the following code paths:1. During system boot up
and
Quoted 8 lines
2. After the platform reset command is issued
The patch takes care of #1. Based on the spec, platform reset command should erase the persistent data and the
PLATFORM_INITshould *not* fail withSEV_RET_SECURE_DATA_INVALIDerror code. So, I am not able to see any strong reason to move the retry code in__sev_platform_init_locked().
Quoted 4 lines
Hmm, is the
sev_platform_init()call insev_guest_init()intended to doSEV_CMD_INITonly after platform reset? I was under the impression it was done in case any previous init failed.
The PLATFORM_INIT command is allowed only when FW is in UINIT state. On boot, the FW will be in UNINIT state and similarly after the platform reset command the FW goes back to UNINIT state.
The __sev_platform_init_locked() checks the FW state before issuing the command, if FW is already in INIT state then it returns immediately.
thanks
David Rientjes
Acked-byQuoted 71 lines · Brijesh
Quoted 65 lines
Quoted 56 lines
Quoted 39 lines
Quoted 39 lines
From: Ashish Kalra <[email protected]>
SEV INIT command loads the SEV related persistent data from NVS and initializes the platform context. The firmware validates the persistent state. If validation fails, the firmware will reset the persisent state and return an integrity check failure status.
At this point, a subsequent INIT command should succeed, so retry the command. The INIT command retry is only done during driver initialization.
Additional enums along with
SEV_RET_SECURE_DATA_INVALIDare added tosev_ret_codeto maintain continuity and relevance of enum values.Signed-off-by Ashish Kalra <[email protected]>--- drivers/crypto/ccp/psp-dev.c | 12 ++++++++++++ include/uapi/linux/psp-sev.h | 3 +++ 2 files changed, 15 insertions(+)drivers/crypto/ccp/psp-dev.c +11
-0@@ -1064,6 +1064,18 @@ void psp_pci_init(void)/* Initialize the platform */ rc =sev_platform_init (&error); +if (rc && (error ==SEV_RET_SECURE_DATA_INVALID )) { +/* +* INIT command returned an integrity check failure +* status code, meaning that firmware load and +* validation of SEV related persistent data has +* failed and persistent state has been erased. +* Retrying INIT command here should succeed. +*/ +dev_dbg (sp->dev,"SEV: retrying INIT command" ); + rc =sev_platform_init (&error); + }Quoted 9 lines
drivers/crypto/ccp/psp-dev.c void psp_pci_init(void) · line 1081
Quoted 4 lines
drivers/crypto/ccp/psp-dev.c +1
-0+if (rc) {dev_err (sp->dev,"SEV: failed to INIT error %#x\n" , error);return ;Curious why this isn't done in
__sev_platform_init_locked()sincesev_platform_init()can be called when loading the kvm module and the same init failure can happen that way.The FW initialization (aka
PLATFORM_INIT) is called in the following code paths:1. During system boot up
and
Quoted 8 lines
2. After the platform reset command is issued
The patch takes care of #1. Based on the spec, platform reset command should erase the persistent data and the
PLATFORM_INITshould *not* fail withSEV_RET_SECURE_DATA_INVALIDerror code. So, I am not able to see any strong reason to move the retry code in__sev_platform_init_locked().Quoted 4 lines
Hmm, is the
sev_platform_init()call insev_guest_init()intended to doSEV_CMD_INITonly after platform reset? I was under the impression it was done in case any previous init failed.
Quoted 7 lines
The
PLATFORM_INITcommand is allowed only when FW is in UINIT state. On boot, the FW will be in UNINIT state and similarly after the platform reset command the FW goes back to UNINIT state.The
__sev_platform_init_locked()checks the FW state before issuing the command, if FW is already in INIT state then it returns immediately.
Ah, got it, thanks.
Quoted 7 lines · Ashish
From: Ashish Kalra <[email protected]>
SEV INIT command loads the SEV related persistent data from NVS and initializes the platform context. The firmware validates the persistent state. If validation fails, the firmware will reset the persisent state and return an integrity check failure status.
Quoted 8 lines
At this point, a subsequent INIT command should succeed, so retry the command. The INIT command retry is only done during driver initialization.
Additional enums along with
SEV_RET_SECURE_DATA_INVALIDare added tosev_ret_codeto maintain continuity and relevance of enum values.Signed-off-by Ashish Kalra <[email protected]>
thanks
Herbert Xu
maintainerQuoted 11 lines · Ashish
From: Ashish Kalra <[email protected]>
SEV INIT command loads the SEV related persistent data from NVS and initializes the platform context. The firmware validates the persistent state. If validation fails, the firmware will reset the persisent state and return an integrity check failure status.
At this point, a subsequent INIT command should succeed, so retry the command. The INIT command retry is only done during driver initialization.
Quoted 8 lines
Additional enums along with
SEV_RET_SECURE_DATA_INVALIDare added tosev_ret_codeto maintain continuity and relevance of enum values.Signed-off-by Ashish Kalra <[email protected]>--- drivers/crypto/ccp/psp-dev.c | 12 ++++++++++++ include/uapi/linux/psp-sev.h | 3 +++ 2 files changed, 15 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