From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86A9E1C68A2; Thu, 1 Aug 2024 00:39:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722472791; cv=none; b=gqys2c7TngsTJAoEo0wrP+YzeNUwHpzE8SWPv8kfA4aZi0E8CDD0uao2+4+uUtJEsST/87dV7aIt3eI76fgp3rSs49kFPeUJB77+DTViH8BK1Fj0zzYUg4DxPeoh2b+BNbU+2EeOl+KkGfwp4VXEZADrvU09p5Lx4/K/rdYuh2g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722472791; c=relaxed/simple; bh=Zv1R4rBZzoxvmbPtS8MXR+WTTcEsfsWDjXzqJvKFYME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oPogetM29QyIV3zwZkqcyEvwFJlcg3igRiJBqnGXXb9gQq7OyxSsV5nkgfFWmtwP8ZvGL99ej0rhv2PL8AwUHeuqR6y6cZe4biA5Q4XI+Qgc2oiUKjnmMEG5CMwlvcFaVGbq5gJPRiZx5fL+Fy9gSzMB09VDVVp+JO9rDwD3Fhc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=D3hs8osz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="D3hs8osz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA58EC116B1; Thu, 1 Aug 2024 00:39:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722472791; bh=Zv1R4rBZzoxvmbPtS8MXR+WTTcEsfsWDjXzqJvKFYME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D3hs8oszhFneBIYz8jEKRiZIALO3+V3RJqfMG+qxiOW984dZFE0XldFbGX+SHTnTP 5te8J3qTteh2dQ/JTwupbMECZNPwF8zaracziCBD9LqvFdWZd7MtN0Xk1UIYwBIZ5f CB/yo4W0CWGSL6MXsc2waOSXzY5JDF9+cY2dJHAH3TjbcTE523sHsZMpMcj8GUK2+9 ZRsAup8fOzLJw79jm+RpAMyg+2n2Y6Q9zAC1E7+Yy3XpvwBQcTOa7Ez0IhUVa0CpEx oaaLyUnMSf2SjxQAPXZjMY8QZ98tgb3OwjYHMKUlB2u5dqfIT7rD4T7qmo2KqTRYo2 ujUrJgih//wIg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Michael Chen , Felix Kuehling , Alex Deucher , Sasha Levin , Felix.Kuehling@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.4 08/22] drm/amdkfd: Reconcile the definition and use of oem_id in struct kfd_topology_device Date: Wed, 31 Jul 2024 20:38:37 -0400 Message-ID: <20240801003918.3939431-8-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240801003918.3939431-1-sashal@kernel.org> References: <20240801003918.3939431-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.4.281 Content-Transfer-Encoding: 8bit From: Michael Chen [ 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 Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdkfd/kfd_crat.h | 2 -- drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 3 +-- drivers/gpu/drm/amd/amdkfd/kfd_topology.h | 5 ++++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.h b/drivers/gpu/drm/amd/amdkfd/kfd_crat.h index d54ceebd346b7..30c70b3ab17f1 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.h @@ -42,8 +42,6 @@ #define CRAT_OEMTABLEID_LENGTH 8 #define CRAT_RESERVED_LENGTH 6 -#define CRAT_OEMID_64BIT_MASK ((1ULL << (CRAT_OEMID_LENGTH * 8)) - 1) - /* Compute Unit flags */ #define COMPUTE_UNIT_CPU (1 << 0) /* Create Virtual CRAT for CPU */ #define COMPUTE_UNIT_GPU (1 << 1) /* Create Virtual CRAT for GPU */ diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c index a49e2ab071d68..de892ee147dea 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c @@ -883,8 +883,7 @@ static void kfd_update_system_properties(void) dev = list_last_entry(&topology_device_list, struct kfd_topology_device, list); if (dev) { - sys_props.platform_id = - (*((uint64_t *)dev->oem_id)) & CRAT_OEMID_64BIT_MASK; + sys_props.platform_id = dev->oem_id64; sys_props.platform_oem = *((uint64_t *)dev->oem_table_id); sys_props.platform_rev = dev->oem_revision; } diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.h b/drivers/gpu/drm/amd/amdkfd/kfd_topology.h index d4718d58d0f24..7230b5b5bfe5a 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.h @@ -172,7 +172,10 @@ struct kfd_topology_device { struct attribute attr_gpuid; struct attribute attr_name; struct attribute attr_props; - uint8_t oem_id[CRAT_OEMID_LENGTH]; + union { + uint8_t oem_id[CRAT_OEMID_LENGTH]; + uint64_t oem_id64; + }; uint8_t oem_table_id[CRAT_OEMTABLEID_LENGTH]; uint32_t oem_revision; }; -- 2.43.0