From 19f44e042128dbf67ffa5b6cab439106ce1a6826 Mon Sep 17 00:00:00 2001 From: Dinesh Kamalakannan Date: Tue, 6 Dec 2022 20:51:54 +0530 Subject: [PATCH] gpu: nvgpu: ls ucode decryption support On T234 theCTXSW LS ucodes are encrypted. ACR will perform the decryption and the decrypted content will be written back into the same WPR location. So on recovery with LSPMU absence and on warm boot case, to perform the authentication , the ucode blob needs to be copied into the WPR from sysmem always. Below are the LS ucodes authentication type * LSPMU - Only Signed ( Only for non-safety build, for safety LSPMU is NA) * CTXSW FECS/GPCCS - Encrypted and Signed (on both safety and non-safety build) ACR FW P4 Change : 32110924 JIRA NVGPU-7903 Change-Id: If447148c02b9cf310102cfb9c688eef402699409 Signed-off-by: Dinesh Kamalakannan Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2822656 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: svc-mobile-misra Reviewed-by: Vaibhav Kachore GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/acr/acr.c | 1 + drivers/gpu/nvgpu/common/acr/acr_priv.h | 1 + drivers/gpu/nvgpu/common/acr/acr_sw_ga10b.c | 31 +++++++++++++++++++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/common/acr/acr.c b/drivers/gpu/nvgpu/common/acr/acr.c index cb1cec1ac..42658e757 100644 --- a/drivers/gpu/nvgpu/common/acr/acr.c +++ b/drivers/gpu/nvgpu/common/acr/acr.c @@ -162,6 +162,7 @@ int nvgpu_acr_init(struct gk20a *g) nvgpu_gv11b_acr_sw_init(g, g->acr); break; case NVGPU_GPUID_GA10B: + g->acr->is_lsf_encrypt_support = true; nvgpu_ga10b_acr_sw_init(g, g->acr); break; #ifdef CONFIG_NVGPU_DGPU diff --git a/drivers/gpu/nvgpu/common/acr/acr_priv.h b/drivers/gpu/nvgpu/common/acr/acr_priv.h index 1dda2005b..4fd9eefe9 100644 --- a/drivers/gpu/nvgpu/common/acr/acr_priv.h +++ b/drivers/gpu/nvgpu/common/acr/acr_priv.h @@ -136,6 +136,7 @@ struct nvgpu_acr { /* LSF properties */ u64 lsf_enable_mask; + bool is_lsf_encrypt_support; struct acr_lsf_config lsf[FALCON_ID_END]; /* diff --git a/drivers/gpu/nvgpu/common/acr/acr_sw_ga10b.c b/drivers/gpu/nvgpu/common/acr/acr_sw_ga10b.c index b800ce274..0d0b6a17c 100644 --- a/drivers/gpu/nvgpu/common/acr/acr_sw_ga10b.c +++ b/drivers/gpu/nvgpu/common/acr/acr_sw_ga10b.c @@ -102,8 +102,22 @@ static int ga10b_acr_patch_wpr_info_to_ucode(struct gk20a *g, nvgpu_err(g, "invalid mem acr_falcon2_sysmem_desc"); return -EINVAL; } - acr_sysmem_desc->nonwpr_ucode_blob_size = + + /* + * In T234 the CTXSW LS ucodes are encrypted. ACR will perform the + * decryption and the decrypted content will be written back + * into the same WPR location. So on recovery with LSPMU absence + * and on warm boot case, to perform the authentication , the ucode + * blob needs to be copied into the WPR from sysmem always. + * Below are the LS ucodes authentication type + * LSPMU - Only Signed ( Only for non-safety build, for safety LSPMU is NA) + * CTXSW FECS/GPCCS - Encrypted and Signed (on both safety + * and non-safety build) + */ + if (!acr->is_lsf_encrypt_support) { + acr_sysmem_desc->nonwpr_ucode_blob_size = RECOVERY_UCODE_BLOB_SIZE; + } } else #endif { @@ -121,8 +135,21 @@ static int ga10b_acr_patch_wpr_info_to_ucode(struct gk20a *g, goto end; } } else { - acr_sysmem_desc->nonwpr_ucode_blob_size = + /* + * In T234 the CTXSW LS ucodes are encrypted. ACR will perform the + * decryption and the decrypted content will be written back + * into the same WPR location. So on recovery with LSPMU absence + * and on warm boot case, to perform the authentication , the ucode + * blob needs to be copied into the WPR from sysmem always. + * Below are the LS ucodes authentication type + * LSPMU - Only Signed ( Only for non-safety build, for safety LSPMU is NA) + * CTXSW FECS/GPCCS - Encrypted and Signed (on both safety + * and non-safety build + */ + if (!acr->is_lsf_encrypt_support) { + acr_sysmem_desc->nonwpr_ucode_blob_size = RECOVERY_UCODE_BLOB_SIZE; + } goto load; }