* [PATCH v2] drm/amdgpu: Fix memcpy() in sienna_cichlid_append_powerplay_table function.
@ 2023-06-09 8:45 Srinivasan Shanmugam
2023-06-09 17:55 ` Deucher, Alexander
2023-06-12 0:07 ` Quan, Evan
0 siblings, 2 replies; 3+ messages in thread
From: Srinivasan Shanmugam @ 2023-06-09 8:45 UTC (permalink / raw)
To: Alex Deucher, Christian König, Evan Quan, Chengming Gui
Cc: Srinivasan Shanmugam, amd-gfx
Fixes the following gcc with W=1:
In file included from ./include/linux/string.h:253,
from ./include/linux/bitmap.h:11,
from ./include/linux/cpumask.h:12,
from ./arch/x86/include/asm/cpumask.h:5,
from ./arch/x86/include/asm/msr.h:11,
from ./arch/x86/include/asm/processor.h:22,
from ./arch/x86/include/asm/cpufeature.h:5,
from ./arch/x86/include/asm/thread_info.h:53,
from ./include/linux/thread_info.h:60,
from ./arch/x86/include/asm/preempt.h:7,
from ./include/linux/preempt.h:78,
from ./include/linux/spinlock.h:56,
from ./include/linux/mmzone.h:8,
from ./include/linux/gfp.h:7,
from ./include/linux/firmware.h:7,
from drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:26:
In function ‘fortify_memcpy_chk’,
inlined from ‘sienna_cichlid_append_powerplay_table’ at drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:444:2,
inlined from ‘sienna_cichlid_setup_pptable’ at drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:506:8,
inlined from ‘sienna_cichlid_setup_pptable’ at drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:494:12:
./include/linux/fortify-string.h:413:4: warning: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
413 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
the compiler complains about the size calculation in the memcpy() -
"sizeof(*smc_dpm_table) - sizeof(smc_dpm_table->table_header)" is much
larger than what fits into table_member.
'Fixes: 7077b19a38240 ("drm/amd/pm: use macro to get pptable members")'
Suggested-by: Evan Quan <Evan.Quan@amd.com>
Cc: Evan Quan <Evan.Quan@amd.com>
Cc: Chengming Gui <Jack.Gui@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
---
v2:
- turned to the way used for nv1x (Evan)
.../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
index 85d53597eb07..f7ed3e655e39 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
@@ -431,7 +431,13 @@ static int sienna_cichlid_append_powerplay_table(struct smu_context *smu)
{
struct atom_smc_dpm_info_v4_9 *smc_dpm_table;
int index, ret;
- I2cControllerConfig_t *table_member;
+ PPTable_beige_goby_t *ppt_beige_goby;
+ PPTable_t *ppt;
+
+ if (smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0, 13))
+ ppt_beige_goby = smu->smu_table.driver_pptable;
+ else
+ ppt = smu->smu_table.driver_pptable;
index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
smc_dpm_info);
@@ -440,9 +446,13 @@ static int sienna_cichlid_append_powerplay_table(struct smu_context *smu)
(uint8_t **)&smc_dpm_table);
if (ret)
return ret;
- GET_PPTABLE_MEMBER(I2cControllers, &table_member);
- memcpy(table_member, smc_dpm_table->I2cControllers,
- sizeof(*smc_dpm_table) - sizeof(smc_dpm_table->table_header));
+
+ if (smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0, 13))
+ smu_memcpy_trailing(ppt_beige_goby, I2cControllers, BoardReserved,
+ smc_dpm_table, I2cControllers);
+ else
+ smu_memcpy_trailing(ppt, I2cControllers, BoardReserved,
+ smc_dpm_table, I2cControllers);
return 0;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] drm/amdgpu: Fix memcpy() in sienna_cichlid_append_powerplay_table function.
2023-06-09 8:45 [PATCH v2] drm/amdgpu: Fix memcpy() in sienna_cichlid_append_powerplay_table function Srinivasan Shanmugam
@ 2023-06-09 17:55 ` Deucher, Alexander
2023-06-12 0:07 ` Quan, Evan
1 sibling, 0 replies; 3+ messages in thread
From: Deucher, Alexander @ 2023-06-09 17:55 UTC (permalink / raw)
To: SHANMUGAM, SRINIVASAN, Koenig, Christian, Quan, Evan, Gui, Jack; +Cc: amd-gfx
[-- Attachment #1: Type: text/plain, Size: 4857 bytes --]
[Public]
Acked-by: Alex Deucher <alexander.deucher@amd.com>
________________________________
From: SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM@amd.com>
Sent: Friday, June 9, 2023 4:45 AM
To: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Quan, Evan <Evan.Quan@amd.com>; Gui, Jack <Jack.Gui@amd.com>
Cc: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM@amd.com>
Subject: [PATCH v2] drm/amdgpu: Fix memcpy() in sienna_cichlid_append_powerplay_table function.
Fixes the following gcc with W=1:
In file included from ./include/linux/string.h:253,
from ./include/linux/bitmap.h:11,
from ./include/linux/cpumask.h:12,
from ./arch/x86/include/asm/cpumask.h:5,
from ./arch/x86/include/asm/msr.h:11,
from ./arch/x86/include/asm/processor.h:22,
from ./arch/x86/include/asm/cpufeature.h:5,
from ./arch/x86/include/asm/thread_info.h:53,
from ./include/linux/thread_info.h:60,
from ./arch/x86/include/asm/preempt.h:7,
from ./include/linux/preempt.h:78,
from ./include/linux/spinlock.h:56,
from ./include/linux/mmzone.h:8,
from ./include/linux/gfp.h:7,
from ./include/linux/firmware.h:7,
from drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:26:
In function ‘fortify_memcpy_chk’,
inlined from ‘sienna_cichlid_append_powerplay_table’ at drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:444:2,
inlined from ‘sienna_cichlid_setup_pptable’ at drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:506:8,
inlined from ‘sienna_cichlid_setup_pptable’ at drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:494:12:
./include/linux/fortify-string.h:413:4: warning: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Wattribute-warning]
413 | __read_overflow2_field(q_size_field, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
the compiler complains about the size calculation in the memcpy() -
"sizeof(*smc_dpm_table) - sizeof(smc_dpm_table->table_header)" is much
larger than what fits into table_member.
'Fixes: 7077b19a38240 ("drm/amd/pm: use macro to get pptable members")'
Suggested-by: Evan Quan <Evan.Quan@amd.com>
Cc: Evan Quan <Evan.Quan@amd.com>
Cc: Chengming Gui <Jack.Gui@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
---
v2:
- turned to the way used for nv1x (Evan)
.../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
index 85d53597eb07..f7ed3e655e39 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
@@ -431,7 +431,13 @@ static int sienna_cichlid_append_powerplay_table(struct smu_context *smu)
{
struct atom_smc_dpm_info_v4_9 *smc_dpm_table;
int index, ret;
- I2cControllerConfig_t *table_member;
+ PPTable_beige_goby_t *ppt_beige_goby;
+ PPTable_t *ppt;
+
+ if (smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0, 13))
+ ppt_beige_goby = smu->smu_table.driver_pptable;
+ else
+ ppt = smu->smu_table.driver_pptable;
index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
smc_dpm_info);
@@ -440,9 +446,13 @@ static int sienna_cichlid_append_powerplay_table(struct smu_context *smu)
(uint8_t **)&smc_dpm_table);
if (ret)
return ret;
- GET_PPTABLE_MEMBER(I2cControllers, &table_member);
- memcpy(table_member, smc_dpm_table->I2cControllers,
- sizeof(*smc_dpm_table) - sizeof(smc_dpm_table->table_header));
+
+ if (smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0, 13))
+ smu_memcpy_trailing(ppt_beige_goby, I2cControllers, BoardReserved,
+ smc_dpm_table, I2cControllers);
+ else
+ smu_memcpy_trailing(ppt, I2cControllers, BoardReserved,
+ smc_dpm_table, I2cControllers);
return 0;
}
--
2.25.1
[-- Attachment #2: Type: text/html, Size: 9297 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH v2] drm/amdgpu: Fix memcpy() in sienna_cichlid_append_powerplay_table function.
2023-06-09 8:45 [PATCH v2] drm/amdgpu: Fix memcpy() in sienna_cichlid_append_powerplay_table function Srinivasan Shanmugam
2023-06-09 17:55 ` Deucher, Alexander
@ 2023-06-12 0:07 ` Quan, Evan
1 sibling, 0 replies; 3+ messages in thread
From: Quan, Evan @ 2023-06-12 0:07 UTC (permalink / raw)
To: SHANMUGAM, SRINIVASAN, Deucher, Alexander, Koenig, Christian, Gui, Jack
Cc: amd-gfx
[AMD Official Use Only - General]
Reviewed-by: Evan Quan <evan.quan@amd.com>
> -----Original Message-----
> From: SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM@amd.com>
> Sent: Friday, June 9, 2023 4:45 PM
> To: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian
> <Christian.Koenig@amd.com>; Quan, Evan <Evan.Quan@amd.com>; Gui, Jack
> <Jack.Gui@amd.com>
> Cc: amd-gfx@lists.freedesktop.org; SHANMUGAM, SRINIVASAN
> <SRINIVASAN.SHANMUGAM@amd.com>
> Subject: [PATCH v2] drm/amdgpu: Fix memcpy() in
> sienna_cichlid_append_powerplay_table function.
>
> Fixes the following gcc with W=1:
>
> In file included from ./include/linux/string.h:253,
> from ./include/linux/bitmap.h:11,
> from ./include/linux/cpumask.h:12,
> from ./arch/x86/include/asm/cpumask.h:5,
> from ./arch/x86/include/asm/msr.h:11,
> from ./arch/x86/include/asm/processor.h:22,
> from ./arch/x86/include/asm/cpufeature.h:5,
> from ./arch/x86/include/asm/thread_info.h:53,
> from ./include/linux/thread_info.h:60,
> from ./arch/x86/include/asm/preempt.h:7,
> from ./include/linux/preempt.h:78,
> from ./include/linux/spinlock.h:56,
> from ./include/linux/mmzone.h:8,
> from ./include/linux/gfp.h:7,
> from ./include/linux/firmware.h:7,
> from
> drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:2
> 6:
> In function ‘fortify_memcpy_chk’,
> inlined from ‘sienna_cichlid_append_powerplay_table’ at
> drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:4
> 44:2,
> inlined from ‘sienna_cichlid_setup_pptable’ at
> drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:5
> 06:8,
> inlined from ‘sienna_cichlid_setup_pptable’ at
> drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu11/sienna_cichlid_ppt.c:4
> 94:12:
> ./include/linux/fortify-string.h:413:4: warning: call to
> ‘__read_overflow2_field’ declared with attribute warning: detected read
> beyond size of field (2nd parameter); maybe use struct_group()? [-
> Wattribute-warning]
> 413 | __read_overflow2_field(q_size_field, size);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> the compiler complains about the size calculation in the memcpy() -
> "sizeof(*smc_dpm_table) - sizeof(smc_dpm_table->table_header)" is much
> larger than what fits into table_member.
>
> 'Fixes: 7077b19a38240 ("drm/amd/pm: use macro to get pptable members")'
> Suggested-by: Evan Quan <Evan.Quan@amd.com>
> Cc: Evan Quan <Evan.Quan@amd.com>
> Cc: Chengming Gui <Jack.Gui@amd.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
> ---
>
> v2:
> - turned to the way used for nv1x (Evan)
>
> .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
> b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
> index 85d53597eb07..f7ed3e655e39 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
> @@ -431,7 +431,13 @@ static int
> sienna_cichlid_append_powerplay_table(struct smu_context *smu) {
> struct atom_smc_dpm_info_v4_9 *smc_dpm_table;
> int index, ret;
> - I2cControllerConfig_t *table_member;
> + PPTable_beige_goby_t *ppt_beige_goby;
> + PPTable_t *ppt;
> +
> + if (smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0,
> 13))
> + ppt_beige_goby = smu->smu_table.driver_pptable;
> + else
> + ppt = smu->smu_table.driver_pptable;
>
> index =
> get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
> smc_dpm_info);
> @@ -440,9 +446,13 @@ static int
> sienna_cichlid_append_powerplay_table(struct smu_context *smu)
> (uint8_t **)&smc_dpm_table);
> if (ret)
> return ret;
> - GET_PPTABLE_MEMBER(I2cControllers, &table_member);
> - memcpy(table_member, smc_dpm_table->I2cControllers,
> - sizeof(*smc_dpm_table) - sizeof(smc_dpm_table-
> >table_header));
> +
> + if (smu->adev->ip_versions[MP1_HWIP][0] == IP_VERSION(11, 0,
> 13))
> + smu_memcpy_trailing(ppt_beige_goby, I2cControllers,
> BoardReserved,
> + smc_dpm_table, I2cControllers);
> + else
> + smu_memcpy_trailing(ppt, I2cControllers, BoardReserved,
> + smc_dpm_table, I2cControllers);
>
> return 0;
> }
> --
> 2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-12 0:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-09 8:45 [PATCH v2] drm/amdgpu: Fix memcpy() in sienna_cichlid_append_powerplay_table function Srinivasan Shanmugam
2023-06-09 17:55 ` Deucher, Alexander
2023-06-12 0:07 ` Quan, Evan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.