.../drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
Since commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"),
UBSAN_BOUNDS no longer pretends 1-element arrays are unbounded. The
bounds check is tripped in smu7_get_pp_table_entry_callback_func_v1(),
while reading from mclk_dep_table.
For consistency, fix all affected struct definitions in this file.
Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
---
.../drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h | 20 +++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h
index b0ac4d121adc..fb5e935ef786 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h
@@ -164,7 +164,7 @@ typedef struct _ATOM_Tonga_State {
typedef struct _ATOM_Tonga_State_Array {
UCHAR ucRevId;
UCHAR ucNumEntries; /* Number of entries. */
- ATOM_Tonga_State entries[1]; /* Dynamically allocate entries. */
+ ATOM_Tonga_State entries[]; /* Dynamically allocate entries. */
} ATOM_Tonga_State_Array;
typedef struct _ATOM_Tonga_MCLK_Dependency_Record {
@@ -179,7 +179,7 @@ typedef struct _ATOM_Tonga_MCLK_Dependency_Record {
typedef struct _ATOM_Tonga_MCLK_Dependency_Table {
UCHAR ucRevId;
UCHAR ucNumEntries; /* Number of entries. */
- ATOM_Tonga_MCLK_Dependency_Record entries[1]; /* Dynamically allocate entries. */
+ ATOM_Tonga_MCLK_Dependency_Record entries[]; /* Dynamically allocate entries. */
} ATOM_Tonga_MCLK_Dependency_Table;
typedef struct _ATOM_Tonga_SCLK_Dependency_Record {
@@ -194,7 +194,7 @@ typedef struct _ATOM_Tonga_SCLK_Dependency_Record {
typedef struct _ATOM_Tonga_SCLK_Dependency_Table {
UCHAR ucRevId;
UCHAR ucNumEntries; /* Number of entries. */
- ATOM_Tonga_SCLK_Dependency_Record entries[1]; /* Dynamically allocate entries. */
+ ATOM_Tonga_SCLK_Dependency_Record entries[]; /* Dynamically allocate entries. */
} ATOM_Tonga_SCLK_Dependency_Table;
typedef struct _ATOM_Polaris_SCLK_Dependency_Record {
@@ -210,7 +210,7 @@ typedef struct _ATOM_Polaris_SCLK_Dependency_Record {
typedef struct _ATOM_Polaris_SCLK_Dependency_Table {
UCHAR ucRevId;
UCHAR ucNumEntries; /* Number of entries. */
- ATOM_Polaris_SCLK_Dependency_Record entries[1]; /* Dynamically allocate entries. */
+ ATOM_Polaris_SCLK_Dependency_Record entries[]; /* Dynamically allocate entries. */
} ATOM_Polaris_SCLK_Dependency_Table;
typedef struct _ATOM_Tonga_PCIE_Record {
@@ -222,7 +222,7 @@ typedef struct _ATOM_Tonga_PCIE_Record {
typedef struct _ATOM_Tonga_PCIE_Table {
UCHAR ucRevId;
UCHAR ucNumEntries; /* Number of entries. */
- ATOM_Tonga_PCIE_Record entries[1]; /* Dynamically allocate entries. */
+ ATOM_Tonga_PCIE_Record entries[]; /* Dynamically allocate entries. */
} ATOM_Tonga_PCIE_Table;
typedef struct _ATOM_Polaris10_PCIE_Record {
@@ -235,7 +235,7 @@ typedef struct _ATOM_Polaris10_PCIE_Record {
typedef struct _ATOM_Polaris10_PCIE_Table {
UCHAR ucRevId;
UCHAR ucNumEntries; /* Number of entries. */
- ATOM_Polaris10_PCIE_Record entries[1]; /* Dynamically allocate entries. */
+ ATOM_Polaris10_PCIE_Record entries[]; /* Dynamically allocate entries. */
} ATOM_Polaris10_PCIE_Table;
@@ -252,7 +252,7 @@ typedef struct _ATOM_Tonga_MM_Dependency_Record {
typedef struct _ATOM_Tonga_MM_Dependency_Table {
UCHAR ucRevId;
UCHAR ucNumEntries; /* Number of entries. */
- ATOM_Tonga_MM_Dependency_Record entries[1]; /* Dynamically allocate entries. */
+ ATOM_Tonga_MM_Dependency_Record entries[]; /* Dynamically allocate entries. */
} ATOM_Tonga_MM_Dependency_Table;
typedef struct _ATOM_Tonga_Voltage_Lookup_Record {
@@ -265,7 +265,7 @@ typedef struct _ATOM_Tonga_Voltage_Lookup_Record {
typedef struct _ATOM_Tonga_Voltage_Lookup_Table {
UCHAR ucRevId;
UCHAR ucNumEntries; /* Number of entries. */
- ATOM_Tonga_Voltage_Lookup_Record entries[1]; /* Dynamically allocate entries. */
+ ATOM_Tonga_Voltage_Lookup_Record entries[]; /* Dynamically allocate entries. */
} ATOM_Tonga_Voltage_Lookup_Table;
typedef struct _ATOM_Tonga_Fan_Table {
@@ -367,7 +367,7 @@ typedef struct _ATOM_Tonga_VCE_State_Record {
typedef struct _ATOM_Tonga_VCE_State_Table {
UCHAR ucRevId;
UCHAR ucNumEntries;
- ATOM_Tonga_VCE_State_Record entries[1];
+ ATOM_Tonga_VCE_State_Record entries[];
} ATOM_Tonga_VCE_State_Table;
typedef struct _ATOM_Tonga_PowerTune_Table {
@@ -482,7 +482,7 @@ typedef struct _ATOM_Tonga_Hard_Limit_Record {
typedef struct _ATOM_Tonga_Hard_Limit_Table {
UCHAR ucRevId;
UCHAR ucNumEntries;
- ATOM_Tonga_Hard_Limit_Record entries[1];
+ ATOM_Tonga_Hard_Limit_Record entries[];
} ATOM_Tonga_Hard_Limit_Table;
typedef struct _ATOM_Tonga_GPIO_Table {
--
2.41.0
[Public]
> -----Original Message-----
> From: Samuel Holland <samuel.holland@sifive.com>
> Sent: Wednesday, August 30, 2023 2:58 PM
> To: Quan, Evan <Evan.Quan@amd.com>; Deucher, Alexander
> <Alexander.Deucher@amd.com>; Koenig, Christian
> <Christian.Koenig@amd.com>
> Cc: Samuel Holland <samuel.holland@sifive.com>; Daniel Vetter
> <daniel@ffwll.ch>; David Airlie <airlied@gmail.com>; Pan, Xinhui
> <Xinhui.Pan@amd.com>; amd-gfx@lists.freedesktop.org; dri-
> devel@lists.freedesktop.org; linux-kernel@vger.kernel.org
> Subject: [PATCH] drm/amd/pm: Replace 1-element arrays with flexible array
> members
>
> Since commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"),
> UBSAN_BOUNDS no longer pretends 1-element arrays are unbounded. The
> bounds check is tripped in smu7_get_pp_table_entry_callback_func_v1(),
> while reading from mclk_dep_table.
>
> For consistency, fix all affected struct definitions in this file.
>
> Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
+ Gustavo
Please make sure any code that uses these structures properly deals with the change in structure size.
Alex
> ---
>
> .../drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h | 20 +++++++++--------
> --
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h
> b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h
> index b0ac4d121adc..fb5e935ef786 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h
> +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/pptable_v1_0.h
> @@ -164,7 +164,7 @@ typedef struct _ATOM_Tonga_State { typedef struct
> _ATOM_Tonga_State_Array {
> UCHAR ucRevId;
> UCHAR ucNumEntries; /* Number of entries. */
> - ATOM_Tonga_State entries[1]; /* Dynamically allocate entries. */
> + ATOM_Tonga_State entries[]; /* Dynamically allocate entries. */
> } ATOM_Tonga_State_Array;
>
> typedef struct _ATOM_Tonga_MCLK_Dependency_Record { @@ -179,7
> +179,7 @@ typedef struct _ATOM_Tonga_MCLK_Dependency_Record {
> typedef struct _ATOM_Tonga_MCLK_Dependency_Table {
> UCHAR ucRevId;
> UCHAR ucNumEntries;
> /* Number of entries. */
> - ATOM_Tonga_MCLK_Dependency_Record entries[1];
> /* Dynamically allocate entries. */
> + ATOM_Tonga_MCLK_Dependency_Record entries[];
> /* Dynamically allocate entries. */
> } ATOM_Tonga_MCLK_Dependency_Table;
>
> typedef struct _ATOM_Tonga_SCLK_Dependency_Record { @@ -194,7
> +194,7 @@ typedef struct _ATOM_Tonga_SCLK_Dependency_Record {
> typedef struct _ATOM_Tonga_SCLK_Dependency_Table {
> UCHAR ucRevId;
> UCHAR ucNumEntries;
> /* Number of entries. */
> - ATOM_Tonga_SCLK_Dependency_Record entries[1];
> /* Dynamically allocate entries. */
> + ATOM_Tonga_SCLK_Dependency_Record entries[];
> /* Dynamically allocate entries. */
> } ATOM_Tonga_SCLK_Dependency_Table;
>
> typedef struct _ATOM_Polaris_SCLK_Dependency_Record { @@ -210,7
> +210,7 @@ typedef struct _ATOM_Polaris_SCLK_Dependency_Record {
> typedef struct _ATOM_Polaris_SCLK_Dependency_Table {
> UCHAR ucRevId;
> UCHAR ucNumEntries;
> /* Number of entries. */
> - ATOM_Polaris_SCLK_Dependency_Record entries[1];
> /* Dynamically allocate entries. */
> + ATOM_Polaris_SCLK_Dependency_Record entries[];
> /* Dynamically allocate entries. */
> } ATOM_Polaris_SCLK_Dependency_Table;
>
> typedef struct _ATOM_Tonga_PCIE_Record { @@ -222,7 +222,7 @@ typedef
> struct _ATOM_Tonga_PCIE_Record { typedef struct
> _ATOM_Tonga_PCIE_Table {
> UCHAR ucRevId;
> UCHAR ucNumEntries;
> /* Number of entries. */
> - ATOM_Tonga_PCIE_Record entries[1];
> /* Dynamically allocate entries. */
> + ATOM_Tonga_PCIE_Record entries[];
> /* Dynamically allocate entries. */
> } ATOM_Tonga_PCIE_Table;
>
> typedef struct _ATOM_Polaris10_PCIE_Record { @@ -235,7 +235,7 @@
> typedef struct _ATOM_Polaris10_PCIE_Record { typedef struct
> _ATOM_Polaris10_PCIE_Table {
> UCHAR ucRevId;
> UCHAR ucNumEntries; /* Number of entries. */
> - ATOM_Polaris10_PCIE_Record entries[1]; /* Dynamically
> allocate entries. */
> + ATOM_Polaris10_PCIE_Record entries[]; /* Dynamically
> allocate entries. */
> } ATOM_Polaris10_PCIE_Table;
>
>
> @@ -252,7 +252,7 @@ typedef struct
> _ATOM_Tonga_MM_Dependency_Record { typedef struct
> _ATOM_Tonga_MM_Dependency_Table {
> UCHAR ucRevId;
> UCHAR ucNumEntries;
> /* Number of entries. */
> - ATOM_Tonga_MM_Dependency_Record entries[1];
> /* Dynamically allocate entries. */
> + ATOM_Tonga_MM_Dependency_Record entries[];
> /* Dynamically allocate entries. */
> } ATOM_Tonga_MM_Dependency_Table;
>
> typedef struct _ATOM_Tonga_Voltage_Lookup_Record { @@ -265,7 +265,7
> @@ typedef struct _ATOM_Tonga_Voltage_Lookup_Record { typedef struct
> _ATOM_Tonga_Voltage_Lookup_Table {
> UCHAR ucRevId;
> UCHAR ucNumEntries;
> /* Number of entries. */
> - ATOM_Tonga_Voltage_Lookup_Record entries[1];
> /* Dynamically allocate entries. */
> + ATOM_Tonga_Voltage_Lookup_Record entries[];
> /* Dynamically allocate entries. */
> } ATOM_Tonga_Voltage_Lookup_Table;
>
> typedef struct _ATOM_Tonga_Fan_Table {
> @@ -367,7 +367,7 @@ typedef struct _ATOM_Tonga_VCE_State_Record {
> typedef struct _ATOM_Tonga_VCE_State_Table {
> UCHAR ucRevId;
> UCHAR ucNumEntries;
> - ATOM_Tonga_VCE_State_Record entries[1];
> + ATOM_Tonga_VCE_State_Record entries[];
> } ATOM_Tonga_VCE_State_Table;
>
> typedef struct _ATOM_Tonga_PowerTune_Table { @@ -482,7 +482,7 @@
> typedef struct _ATOM_Tonga_Hard_Limit_Record { typedef struct
> _ATOM_Tonga_Hard_Limit_Table {
> UCHAR ucRevId;
> UCHAR ucNumEntries;
> - ATOM_Tonga_Hard_Limit_Record entries[1];
> + ATOM_Tonga_Hard_Limit_Record entries[];
> } ATOM_Tonga_Hard_Limit_Table;
>
> typedef struct _ATOM_Tonga_GPIO_Table {
> --
> 2.41.0
© 2016 - 2025 Red Hat, Inc.