gpu: nvgpu: fix CERTC violation in falcon unit

Fix below CERTC violation:

linux-nvgpu/drivers/gpu/nvgpu/common/falcon/falcon.c:430
  Checker: CERT INT30-C
linux-nvgpu/drivers/gpu/nvgpu/common/falcon/falcon.c:430:
  5. cert_int30_c_violation: Unsigned integer operation
     "ucode_header[1U] + 255U" may wrap.

JIRA NVGPU-4131

Change-Id: I2e60e6468047d497bcd8b72ee0730301b8221423
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2210611
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Nitin Kumbhar <nkumbhar@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Adeel Raza <araza@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Sagar Kamble
2019-10-03 12:31:48 +05:30
committed by Alex Waterman
parent 38cc3ed48f
commit dac79ce2f9

View File

@@ -122,6 +122,7 @@
#include <nvgpu/types.h> #include <nvgpu/types.h>
#include <nvgpu/lock.h> #include <nvgpu/lock.h>
#include <nvgpu/static_analysis.h>
/** Falcon ID for PMU engine */ /** Falcon ID for PMU engine */
#define FALCON_ID_PMU (0U) #define FALCON_ID_PMU (0U)
@@ -150,8 +151,8 @@
#define GET_IMEM_TAG(IMEM_ADDR) ((IMEM_ADDR) >> 8U) #define GET_IMEM_TAG(IMEM_ADDR) ((IMEM_ADDR) >> 8U)
#define GET_NEXT_BLOCK(ADDR) \ #define GET_NEXT_BLOCK(ADDR) \
(((((ADDR) + (FALCON_BLOCK_SIZE - 1U)) & ~(FALCON_BLOCK_SIZE-1U)) \ (((nvgpu_safe_add_u32((ADDR), (FALCON_BLOCK_SIZE - 1U)) \
/ FALCON_BLOCK_SIZE) << 8U) & ~(FALCON_BLOCK_SIZE-1U)) / FALCON_BLOCK_SIZE) << 8U)
/** /**
* Falcon ucode header format * Falcon ucode header format