drm/amdkfd: Fix the warning of array-index-out-of-bounds
Subsystems (3)
PATCH 1/1 drm/amdkfd: Fix the warning of array-index-out-of-bounds
Increasing the simbling array size to fix the warning of array-index-out-of-bounds. The VCRAT_SIZE_FOR_GPU is also increased accrordingly.
--- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_crat.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +1 -1
@@ -1683,7 +1683,7 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t *size)* expected to cover all known conditions. But to be safe additional check * is put in the code to ensure we don't overwrite. */ -#define VCRAT_SIZE_FOR_GPU (4 * PAGE_SIZE) +#define VCRAT_SIZE_FOR_GPU (6 * PAGE_SIZE)/* kfd_fill_cu_for_cpu - Fill in Compute info for the given CPU NUMA node *
drivers/gpu/drm/amd/amdkfd/kfd_crat.h +1 -1
@@ -80,7 +80,7 @@ struct crat_header {#define CRAT_SUBTYPE_IOLINK_AFFINITY 5#define CRAT_SUBTYPE_MAX 6 -#define CRAT_SIBLINGMAP_SIZE 32 +#define CRAT_SIBLINGMAP_SIZE 64/* * ComputeUnit Affinity structure and definitions
Signature · 1 line
2.25.1
Felix Kuehling
maintainerThis breaks the CRAT table ABI, which will break APUs that use an actual CRAT table from ACPI.
I think to fix this, you'll need to populate kfd_cache_properties.sibling_map without using a VCRAT to support GPUs that have more CUs than fit into the CRAT sibling map. In other words, don't populate the sibling map in fill_in_*_pcache. Instead move this code into kfd_topology.c and populate the kfd_cache_properties.sibling_map in a new function called from kfd_topology_add_device. E.g. kfd_topology_fill_cache_non_crat_info. Maybe conditionally only when using a VCRAT.
In the long run, I think we should get rid of the VCRAT stuff entirely and fill in the topology for GPUs without a CRAT without the intermediate step of creating a CRAT table.
Regards,
Felix
Am 2022-10-08 um 01:56 schrieb Ma Jun:
Quoted 36 lines
Increasing the simbling array size to fix the warning of array-index-out-of-bounds. The
VCRAT_SIZE_FOR_GPUis also increased accrordingly.Signed-off-by Ma Jun <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_crat.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_crat.c +1
-1@@ -1683,7 +1683,7 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t *size)* expected to cover all known conditions. But to be safe additional check * is put in the code to ensure we don't overwrite. */ -#define VCRAT_SIZE_FOR_GPU (4 * PAGE_SIZE) +#define VCRAT_SIZE_FOR_GPU (6 * PAGE_SIZE)/* kfd_fill_cu_for_cpu - Fill in Compute info for the given CPU NUMA node * drivers/gpu/drm/amd/amdkfd/kfd_crat.h +1
-1@@ -80,7 +80,7 @@ struct crat_header {#define CRAT_SUBTYPE_IOLINK_AFFINITY 5#define CRAT_SUBTYPE_MAX 6 -#define CRAT_SIBLINGMAP_SIZE 32 +#define CRAT_SIBLINGMAP_SIZE 64/* * ComputeUnit Affinity structure and definitions
Hi Felix,
Thanks for this suggestion, I'll make a new patch to fix this.
Regards,
Ma Jun
Quoted 57 lines · Felix Kuehling
This breaks the CRAT table ABI, which will break APUs that use an actual CRAT table from ACPI.
I think to fix this, you'll need to populate kfd_cache_properties.sibling_map without using a VCRAT to support GPUs that have more CUs than fit into the CRAT sibling map. In other words, don't populate the sibling map in fill_in_*_pcache. Instead move this code into
kfd_topology.cand populate the kfd_cache_properties.sibling_map in a new function called fromkfd_topology_add_device. E.g.kfd_topology_fill_cache_non_crat_info. Maybe conditionally only when using a VCRAT.In the long run, I think we should get rid of the VCRAT stuff entirely and fill in the topology for GPUs without a CRAT without the intermediate step of creating a CRAT table.
Regards,
FelixAm 2022-10-08 um 01:56 schrieb Ma Jun:
Quoted 36 lines
Increasing the simbling array size to fix the warning of array-index-out-of-bounds. The
VCRAT_SIZE_FOR_GPUis also increased accrordingly.Signed-off-by Ma Jun <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +- drivers/gpu/drm/amd/amdkfd/kfd_crat.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_crat.c +1
-1@@ -1683,7 +1683,7 @@ int kfd_create_crat_image_acpi(void **crat_image, size_t *size)* expected to cover all known conditions. But to be safe additional check * is put in the code to ensure we don't overwrite. */ -#define VCRAT_SIZE_FOR_GPU (4 * PAGE_SIZE) +#define VCRAT_SIZE_FOR_GPU (6 * PAGE_SIZE)/* kfd_fill_cu_for_cpu - Fill in Compute info for the given CPU NUMA node * drivers/gpu/drm/amd/amdkfd/kfd_crat.h +1
-1@@ -80,7 +80,7 @@ struct crat_header {#define CRAT_SUBTYPE_IOLINK_AFFINITY 5#define CRAT_SUBTYPE_MAX 6 -#define CRAT_SIBLINGMAP_SIZE 32 +#define CRAT_SIBLINGMAP_SIZE 64/* * ComputeUnit Affinity structure and definitions