diff --git a/drivers/gpu/nvgpu/common/falcon/falcon.c b/drivers/gpu/nvgpu/common/falcon/falcon.c index 9df3411f1..c30a57874 100644 --- a/drivers/gpu/nvgpu/common/falcon/falcon.c +++ b/drivers/gpu/nvgpu/common/falcon/falcon.c @@ -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", diff --git a/userspace/units/falcon/falcon_tests/falcon.c b/userspace/units/falcon/falcon_tests/falcon.c index 36c7d689f..76e979ed1 100644 --- a/userspace/units/falcon/falcon_tests/falcon.c +++ b/userspace/units/falcon/falcon_tests/falcon.c @@ -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; } diff --git a/userspace/units/falcon/falcon_tests/nvgpu-falcon.h b/userspace/units/falcon/falcon_tests/nvgpu-falcon.h index 5d4becff4..9b82abb63 100644 --- a/userspace/units/falcon/falcon_tests/nvgpu-falcon.h +++ b/userspace/units/falcon/falcon_tests/nvgpu-falcon.h @@ -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