Skip to content

Commit 4daf71a

Browse files
michchen-amdsmb49
authored andcommitted
drm/amdkfd: Reconcile the definition and use of oem_id in struct kfd_topology_device
BugLink: https://bugs.launchpad.net/bugs/2081279 [ Upstream commit 10f624ef239bd136cdcc5bbc626157a57b938a31 ] Currently oem_id is defined as uint8_t[6] and casted to uint64_t* in some use case. This would lead code scanner to complain about access beyond. Re-define it in union to enforce 8-byte size and alignment to avoid potential issue. Signed-off-by: Michael Chen <michael.chen@amd.com> Reviewed-by: Felix Kuehling <felix.kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent df45646 commit 4daf71a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

drivers/gpu/drm/amd/amdkfd/kfd_crat.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
#define CRAT_OEMTABLEID_LENGTH 8
4343
#define CRAT_RESERVED_LENGTH 6
4444

45-
#define CRAT_OEMID_64BIT_MASK ((1ULL << (CRAT_OEMID_LENGTH * 8)) - 1)
46-
4745
/* Compute Unit flags */
4846
#define COMPUTE_UNIT_CPU (1 << 0) /* Create Virtual CRAT for CPU */
4947
#define COMPUTE_UNIT_GPU (1 << 1) /* Create Virtual CRAT for GPU */

drivers/gpu/drm/amd/amdkfd/kfd_topology.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,8 +910,7 @@ static void kfd_update_system_properties(void)
910910
dev = list_last_entry(&topology_device_list,
911911
struct kfd_topology_device, list);
912912
if (dev) {
913-
sys_props.platform_id =
914-
(*((uint64_t *)dev->oem_id)) & CRAT_OEMID_64BIT_MASK;
913+
sys_props.platform_id = dev->oem_id64;
915914
sys_props.platform_oem = *((uint64_t *)dev->oem_table_id);
916915
sys_props.platform_rev = dev->oem_revision;
917916
}

drivers/gpu/drm/amd/amdkfd/kfd_topology.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ struct kfd_topology_device {
184184
struct attribute attr_gpuid;
185185
struct attribute attr_name;
186186
struct attribute attr_props;
187-
uint8_t oem_id[CRAT_OEMID_LENGTH];
187+
union {
188+
uint8_t oem_id[CRAT_OEMID_LENGTH];
189+
uint64_t oem_id64;
190+
};
188191
uint8_t oem_table_id[CRAT_OEMTABLEID_LENGTH];
189192
uint32_t oem_revision;
190193
};

0 commit comments

Comments
 (0)