[PATCH] drm/amdkfd: Fix the warning of array-index-out-of-bounds
Felix Kuehling
felix.kuehling at amd.com
Sat Oct 8 16:34:13 UTC 2022
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.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:
> Increasing the simbling array size to fix the warning of
> array-index-out-of-bounds. The VCRAT_SIZE_FOR_GPU is also
> increased accrordingly.
>
> Signed-off-by: Ma Jun <Jun.Ma2 at amd.com>
> ---
> 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(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
> index 477a30981c1b..3ec425c3737d 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
> @@ -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
> *
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.h b/drivers/gpu/drm/amd/amdkfd/kfd_crat.h
> index fbb5f6c32ef5..31a4bbc9f9cb 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.h
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.h
> @@ -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
More information about the amd-gfx
mailing list