drm/amdkfd: remove dead code in kfd_create_vcrat_image_gpu
Subsystems (3)
PATCH 8/8 drm/amdkfd: remove dead code in kfd_create_vcrat_image_gpu
Since the value of avail_size is at least VCRAT_SIZE_FOR_GPU(16384),
minus struct crat_header(40UL) and struct crat_subtype_compute(40UL) it cannot be less than 0.
--- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0 -6
@@ -2213,9 +2213,6 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,* Modify length and total_entries as subunits are added. */ avail_size -=sizeof (struct crat_header ); -if (avail_size <0 ) -return -ENOMEM ; -memset (crat_table,0 ,sizeof (struct crat_header )); memcpy(&crat_table->signature, CRAT_SIGNATURE,
@@ -2229,9 +2226,6 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,* First fill in the sub type header and then sub type data */ avail_size -=sizeof (struct crat_subtype_computeunit ); -if (avail_size <0 ) -return -ENOMEM ; - sub_type_hdr = (struct crat_subtype_generic *)(crat_table +1 );memset (sub_type_hdr,0 ,sizeof (struct crat_subtype_computeunit ));
Signature · 1 line
2.25.1
Felix Kuehling
maintainerQuoted 13 lines · Jesse Zhang
Since the value of
avail_sizeis at leastVCRAT_SIZE_FOR_GPU(16384),
minus structcrat_header(40UL)and structcrat_subtype_compute(40UL)it cannot be less than 0.Signed-off-by Jesse Zhang <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 6 ------ 1 file changed, 6 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0
-0
drivers/gpu/drm/amd/amdkfd/kfd_crat.c static int kfd_create_vcrat_image_gpu(void *pcrat_image, · line 2218
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0
-3@@ -2213,9 +2213,6 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,* Modify length and total_entries as subunits are added. */ avail_size -=sizeof (struct crat_header ); -if (avail_size <0 ) -return -ENOMEM ; -
Avail_size is passed in from the caller through the *size parameter. You're making an assumption about the caller here.
Regards,
Felix
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0
-3memset (crat_table,0 ,sizeof (struct crat_header )); memcpy(&crat_table->signature, CRAT_SIGNATURE,@@ -2229,9 +2226,6 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,* First fill in the sub type header and then sub type data */ avail_size -=sizeof (struct crat_subtype_computeunit ); -if (avail_size <0 ) -return -ENOMEM ; - sub_type_hdr = (struct crat_subtype_generic *)(crat_table +1 );memset (sub_type_hdr,0 ,sizeof (struct crat_subtype_computeunit ));
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Felix,
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Friday, May 31, 2024 4:37 AM
To: Zhang, Jesse(Jie) <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Kim, Jonathan <[email protected]>; Huang, Tim <[email protected]>
Subject: Re: [PATCH 8/8] drm/amdkfd: remove dead code in kfd_create_vcrat_image_gpu
Quoted 14 lines · Jesse Zhang
Since the value of
avail_sizeis at leastVCRAT_SIZE_FOR_GPU(16384),
minus structcrat_header(40UL)and structcrat_subtype_compute(40UL)it cannot be less than 0.Signed-off-by Jesse Zhang <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 6 ------ 1 file changed, 6 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0
-0
drivers/gpu/drm/amd/amdkfd/kfd_crat.c static int kfd_create_vcrat_image_gpu(void *pcrat_image, · line 2218
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0
-3@@ -2213,9 +2213,6 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,* Modify length and total_entries as subunits are added. */ avail_size -=sizeof (struct crat_header ); -if (avail_size <0 ) -return -ENOMEM ; -
Avail_size is passed in from the caller through the *size parameter. You're making an assumption about the caller here.
[Zhang, Jesse(Jie)] avil_size is checked at the beginning of kfd_create_vcrat_image_gpu and it cannot be smaller than VCRAT_SIZE_FOR_GPU (16384).
if (!pcrat_image || avail_size < VCRAT_SIZE_FOR_GPU)
return -EINVAL;Regards
Jesse
Regards,
Felix
Quoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0
-0memset (crat_table,0 ,sizeof (struct crat_header )); memcpy(&crat_table->signature, CRAT_SIGNATURE, @@ -2229,9 +2226,6@@ static int kfd_create_vcrat_image_gpu(void
*pcrat_image,* First fill in the sub type header and then sub type data */ avail_size -= sizeof(struct crat_subtype_computeunit);drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0
-3-if (avail_size <0 ) -return -ENOMEM ; - sub_type_hdr = (struct crat_subtype_generic *)(crat_table +1 );memset (sub_type_hdr,0 ,sizeof (struct crat_subtype_computeunit ));
Quoted 36 lines · Jesse(Jie)
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Felix,
-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Friday, May 31, 2024 4:37 AM
To: Zhang, Jesse(Jie) <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Kim, Jonathan <[email protected]>; Huang, Tim <[email protected]>
Subject: Re: [PATCH 8/8] drm/amdkfd: remove dead code inkfd_create_vcrat_image_gpuQuoted 14 lines · Jesse Zhang
Since the value of
avail_sizeis at leastVCRAT_SIZE_FOR_GPU(16384),
minus structcrat_header(40UL)and structcrat_subtype_compute(40UL)it cannot be less than 0.Signed-off-by Jesse Zhang <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 6 ------ 1 file changed, 6 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0
-0drivers/gpu/drm/amd/amdkfd/kfd_crat.c static int kfd_create_vcrat_image_gpu(void *pcrat_image, · line 2218
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0
-3@@ -2213,9 +2213,6 @@ static int kfd_create_vcrat_image_gpu(void *pcrat_image,* Modify length and total_entries as subunits are added. */ avail_size -=sizeof (struct crat_header ); -if (avail_size <0 ) -return -ENOMEM ; -
Avail_sizeis passed in from the caller through the *size parameter. You're making an assumption about the caller here.
Quoted 5 lines
[Zhang, Jesse(Jie)]
avil_sizeis checked at the beginning ofkfd_create_vcrat_image_gpuand it cannot be smaller thanVCRAT_SIZE_FOR_GPU(16384).if (!pcrat_image || avail_size < VCRAT_SIZE_FOR_GPU) return -EINVAL;
Ok, I missed that. Makes sense. Maybe mention it in the commit description that kfd_create_vcrat_image_gpu itself checks the avail_size at the start. The patch is
Quoted 22 lines
Regards
JesseRegards,
FelixQuoted 13 lines
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0
-0memset (crat_table,0 ,sizeof (struct crat_header )); memcpy(&crat_table->signature, CRAT_SIGNATURE, @@ -2229,9 +2226,6@@ static int kfd_create_vcrat_image_gpu(void
*pcrat_image,* First fill in the sub type header and then sub type data */ avail_size -= sizeof(struct crat_subtype_computeunit);drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0
-3-if (avail_size <0 ) -return -ENOMEM ; - sub_type_hdr = (struct crat_subtype_generic *)(crat_table +1 );memset (sub_type_hdr,0 ,sizeof (struct crat_subtype_computeunit ));