mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 18:42:29 +03:00
gpu: nvgpu: falcon: add boundary value test for copy to memory
Copy to falcon's IMEM and DMEM begins at offset that lies between 0 and (IMEM/DMEM size - 1). Hence update the validation check. Add the test case with offset set to the size of IMEM/DMEM that covers all branches in the function falcon_memcpy_params_check. JIRA NVGPU-2214 Change-Id: I4807331302014a1b012aa6c05919865b49c86dec Signed-off-by: Sagar Kamble <skamble@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2258312 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Alex Waterman
parent
6eef1a486c
commit
70f614e07e
@@ -201,7 +201,7 @@ static int falcon_memcpy_params_check(struct nvgpu_falcon *flcn,
|
||||
|
||||
mem_size = g->ops.falcon.get_mem_size(flcn, mem_type);
|
||||
|
||||
if (!(offset <= mem_size && (offset + size) <= mem_size)) {
|
||||
if (!(offset < mem_size && (offset + size) <= mem_size)) {
|
||||
nvgpu_err(g, "flcn-id 0x%x, copy overflow ",
|
||||
flcn->flcn_id);
|
||||
nvgpu_err(g, "total size 0x%x, offset 0x%x, copy size 0x%x",
|
||||
|
||||
@@ -894,6 +894,22 @@ int test_falcon_mem_rw_range(struct unit_module *m, struct gk20a *g,
|
||||
return UNIT_FAIL;
|
||||
}
|
||||
|
||||
dst = UTF_FALCON_IMEM_DMEM_SIZE;
|
||||
|
||||
/* write/read data to/from invalid offset in imem */
|
||||
err = falcon_check_read_write(g, m, pmu_flcn, MEM_IMEM, dst,
|
||||
byte_cnt, -EINVAL);
|
||||
if (err) {
|
||||
return UNIT_FAIL;
|
||||
}
|
||||
|
||||
/* write/read data to/from invalid offset in dmem */
|
||||
err = falcon_check_read_write(g, m, pmu_flcn, MEM_DMEM, dst,
|
||||
byte_cnt, -EINVAL);
|
||||
if (err) {
|
||||
return UNIT_FAIL;
|
||||
}
|
||||
|
||||
return UNIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +199,8 @@ int test_falcon_mem_rw_init(struct unit_module *m, struct gk20a *g,
|
||||
* initialized falcon struct with sample random data and valid range.
|
||||
* - Verify that writes succeed with 0 return value in both cases.
|
||||
* - Invoke nvgpu_falcon_copy_to_imem and nvgpu_falcon_copy_to_dmem with
|
||||
* initialized falcon struct with sample random data and invalid range.
|
||||
* initialized falcon struct with sample random data and invalid range
|
||||
* with valid and invalid offset.
|
||||
* - Verify that writes fail with -EINVAL return value in both cases.
|
||||
*
|
||||
* Output: Returns PASS if the steps above were executed successfully. FAIL
|
||||
|
||||
Reference in New Issue
Block a user