netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5
@ 2025-02-05 10:42 Przemek Kitszel
  2025-02-05 11:19 ` Michal Swiatkowski
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Przemek Kitszel @ 2025-02-05 10:42 UTC (permalink / raw)
  To: intel-wired-lan, Tony Nguyen
  Cc: netdev, Konrad Knitter, Michal Swiatkowski, Przemek Kitszel,
	Qiuxu Zhuo, Linus Torvalds, Kees Cook, Nick Desaulniers

GCC 7 is not as good as GCC 8+ in telling what is a compile-time const,
and thus could be used for static storage. So we could not use variables
for that, no matter how much "const" keyword is sprinkled around.

Excerpt from the report:
My GCC is: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0.

  CC [M]  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o
drivers/net/ethernet/intel/ice/devlink/health.c:35:3: error: initializer element is not constant
   ice_common_port_solutions, {ice_port_number_label}},
   ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/intel/ice/devlink/health.c:35:3: note: (near initialization for 'ice_health_status_lookup[0].solution')
drivers/net/ethernet/intel/ice/devlink/health.c:35:31: error: initializer element is not constant
   ice_common_port_solutions, {ice_port_number_label}},
                               ^~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/intel/ice/devlink/health.c:35:31: note: (near initialization for 'ice_health_status_lookup[0].data_label[0]')
drivers/net/ethernet/intel/ice/devlink/health.c:37:46: error: initializer element is not constant
   "Change or replace the module or cable.", {ice_port_number_label}},
                                              ^~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/intel/ice/devlink/health.c:37:46: note: (near initialization for 'ice_health_status_lookup[1].data_label[0]')
drivers/net/ethernet/intel/ice/devlink/health.c:39:3: error: initializer element is not constant
   ice_common_port_solutions, {ice_port_number_label}},
   ^~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: 85d6164ec56d ("ice: add fw and port health reporters")
Reported-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Closes: https://lore.kernel.org/netdev/CY8PR11MB7134BF7A46D71E50D25FA7A989F72@CY8PR11MB7134.namprd11.prod.outlook.com
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
I would really like to bump min gcc to 8.5 (RH 8 family),
instead of supporting old Ubuntu. However SLES 15 is also stuck with gcc 7.5 :(

CC: Linus Torvalds <torvalds@linux-foundation.org>
CC: Kees Cook <kees@kernel.org>
CC: Nick Desaulniers <nick.desaulniers@gmail.com>
---
 drivers/net/ethernet/intel/ice/devlink/health.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/devlink/health.c b/drivers/net/ethernet/intel/ice/devlink/health.c
index ea40f7941259..4bc546bafad1 100644
--- a/drivers/net/ethernet/intel/ice/devlink/health.c
+++ b/drivers/net/ethernet/intel/ice/devlink/health.c
@@ -23,12 +23,12 @@ struct ice_health_status {
  * For instance, Health Code 0x1002 is triggered when the command fails.
  * Such codes should be disregarded by the end-user.
  * The below lookup requires to be sorted by code.
+ * #defines instead of proper const strings are used due to gcc 7 limitation.
  */
 
-static const char *const ice_common_port_solutions =
-	"Check your cable connection. Change or replace the module or cable. Manually set speed and duplex.";
-static const char *const ice_port_number_label = "Port Number";
-static const char *const ice_update_nvm_solution = "Update to the latest NVM image.";
+#define ice_common_port_solutions	"Check your cable connection. Change or replace the module or cable. Manually set speed and duplex."
+#define ice_port_number_label		"Port Number"
+#define ice_update_nvm_solution		"Update to the latest NVM image."
 
 static const struct ice_health_status ice_health_status_lookup[] = {
 	{ICE_AQC_HEALTH_STATUS_ERR_UNKNOWN_MOD_STRICT, "An unsupported module was detected.",

base-commit: 4241a702e0d0c2ca9364cfac08dbf134264962de
-- 
2.46.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5
  2025-02-05 10:42 [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5 Przemek Kitszel
@ 2025-02-05 11:19 ` Michal Swiatkowski
  2025-02-05 11:39 ` Zhuo, Qiuxu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Michal Swiatkowski @ 2025-02-05 11:19 UTC (permalink / raw)
  To: Przemek Kitszel
  Cc: intel-wired-lan, Tony Nguyen, netdev, Konrad Knitter, Qiuxu Zhuo,
	Linus Torvalds, Kees Cook, Nick Desaulniers

On Wed, Feb 05, 2025 at 11:42:12AM +0100, Przemek Kitszel wrote:
> GCC 7 is not as good as GCC 8+ in telling what is a compile-time const,
> and thus could be used for static storage. So we could not use variables
> for that, no matter how much "const" keyword is sprinkled around.
> 
> Excerpt from the report:
> My GCC is: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0.
> 
>   CC [M]  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o
> drivers/net/ethernet/intel/ice/devlink/health.c:35:3: error: initializer element is not constant
>    ice_common_port_solutions, {ice_port_number_label}},
>    ^~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/intel/ice/devlink/health.c:35:3: note: (near initialization for 'ice_health_status_lookup[0].solution')
> drivers/net/ethernet/intel/ice/devlink/health.c:35:31: error: initializer element is not constant
>    ice_common_port_solutions, {ice_port_number_label}},
>                                ^~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/intel/ice/devlink/health.c:35:31: note: (near initialization for 'ice_health_status_lookup[0].data_label[0]')
> drivers/net/ethernet/intel/ice/devlink/health.c:37:46: error: initializer element is not constant
>    "Change or replace the module or cable.", {ice_port_number_label}},
>                                               ^~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/intel/ice/devlink/health.c:37:46: note: (near initialization for 'ice_health_status_lookup[1].data_label[0]')
> drivers/net/ethernet/intel/ice/devlink/health.c:39:3: error: initializer element is not constant
>    ice_common_port_solutions, {ice_port_number_label}},
>    ^~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Fixes: 85d6164ec56d ("ice: add fw and port health reporters")
> Reported-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
> Closes: https://lore.kernel.org/netdev/CY8PR11MB7134BF7A46D71E50D25FA7A989F72@CY8PR11MB7134.namprd11.prod.outlook.com
> Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> ---
> I would really like to bump min gcc to 8.5 (RH 8 family),
> instead of supporting old Ubuntu. However SLES 15 is also stuck with gcc 7.5 :(
> 
> CC: Linus Torvalds <torvalds@linux-foundation.org>
> CC: Kees Cook <kees@kernel.org>
> CC: Nick Desaulniers <nick.desaulniers@gmail.com>
> ---
>  drivers/net/ethernet/intel/ice/devlink/health.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/devlink/health.c b/drivers/net/ethernet/intel/ice/devlink/health.c
> index ea40f7941259..4bc546bafad1 100644
> --- a/drivers/net/ethernet/intel/ice/devlink/health.c
> +++ b/drivers/net/ethernet/intel/ice/devlink/health.c
> @@ -23,12 +23,12 @@ struct ice_health_status {
>   * For instance, Health Code 0x1002 is triggered when the command fails.
>   * Such codes should be disregarded by the end-user.
>   * The below lookup requires to be sorted by code.
> + * #defines instead of proper const strings are used due to gcc 7 limitation.
>   */
>  
> -static const char *const ice_common_port_solutions =
> -	"Check your cable connection. Change or replace the module or cable. Manually set speed and duplex.";
> -static const char *const ice_port_number_label = "Port Number";
> -static const char *const ice_update_nvm_solution = "Update to the latest NVM image.";
> +#define ice_common_port_solutions	"Check your cable connection. Change or replace the module or cable. Manually set speed and duplex."
> +#define ice_port_number_label		"Port Number"
> +#define ice_update_nvm_solution		"Update to the latest NVM image."

>  
>  static const struct ice_health_status ice_health_status_lookup[] = {
>  	{ICE_AQC_HEALTH_STATUS_ERR_UNKNOWN_MOD_STRICT, "An unsupported module was detected.",
> 
> base-commit: 4241a702e0d0c2ca9364cfac08dbf134264962de

Thanks for fixing
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>

> -- 
> 2.46.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5
  2025-02-05 10:42 [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5 Przemek Kitszel
  2025-02-05 11:19 ` Michal Swiatkowski
@ 2025-02-05 11:39 ` Zhuo, Qiuxu
  2025-02-05 20:45 ` Simon Horman
  2025-03-14  7:03 ` [Intel-wired-lan] " Mekala, SunithaX D
  3 siblings, 0 replies; 9+ messages in thread
From: Zhuo, Qiuxu @ 2025-02-05 11:39 UTC (permalink / raw)
  To: Kitszel, Przemyslaw, intel-wired-lan@lists.osuosl.org,
	Nguyen, Anthony L
  Cc: netdev@vger.kernel.org, Knitter, Konrad, Michal Swiatkowski,
	Linus Torvalds, Kees Cook, Nick Desaulniers

> From: Kitszel, Przemyslaw <przemyslaw.kitszel@intel.com>
> [...]
> Subject: [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5
> 
> GCC 7 is not as good as GCC 8+ in telling what is a compile-time const, and
> thus could be used for static storage. So we could not use variables for that,
> no matter how much "const" keyword is sprinkled around.
> 
> Excerpt from the report:
> My GCC is: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0.
> 
>   CC [M]  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o
> drivers/net/ethernet/intel/ice/devlink/health.c:35:3: error: initializer element
> is not constant
>    ice_common_port_solutions, {ice_port_number_label}},
>    ^~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/intel/ice/devlink/health.c:35:3: note: (near initialization
> for 'ice_health_status_lookup[0].solution')
> drivers/net/ethernet/intel/ice/devlink/health.c:35:31: error: initializer
> element is not constant
>    ice_common_port_solutions, {ice_port_number_label}},
>                                ^~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/intel/ice/devlink/health.c:35:31: note: (near initialization
> for 'ice_health_status_lookup[0].data_label[0]')
> drivers/net/ethernet/intel/ice/devlink/health.c:37:46: error: initializer
> element is not constant
>    "Change or replace the module or cable.", {ice_port_number_label}},
>                                               ^~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/intel/ice/devlink/health.c:37:46: note: (near initialization
> for 'ice_health_status_lookup[1].data_label[0]')
> drivers/net/ethernet/intel/ice/devlink/health.c:39:3: error: initializer element
> is not constant
>    ice_common_port_solutions, {ice_port_number_label}},
>    ^~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Fixes: 85d6164ec56d ("ice: add fw and port health reporters")
> Reported-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
> Closes:
> https://lore.kernel.org/netdev/CY8PR11MB7134BF7A46D71E50D25FA7A989F
> 72@CY8PR11MB7134.namprd11.prod.outlook.com
> Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>

Tested-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>

[...]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5
  2025-02-05 10:42 [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5 Przemek Kitszel
  2025-02-05 11:19 ` Michal Swiatkowski
  2025-02-05 11:39 ` Zhuo, Qiuxu
@ 2025-02-05 20:45 ` Simon Horman
  2025-02-05 22:56   ` David Laight
                     ` (2 more replies)
  2025-03-14  7:03 ` [Intel-wired-lan] " Mekala, SunithaX D
  3 siblings, 3 replies; 9+ messages in thread
From: Simon Horman @ 2025-02-05 20:45 UTC (permalink / raw)
  To: Przemek Kitszel
  Cc: intel-wired-lan, Tony Nguyen, netdev, Konrad Knitter,
	Michal Swiatkowski, Qiuxu Zhuo, Linus Torvalds, Kees Cook,
	Nick Desaulniers, Jiri Slaby

+ Jiri

On Wed, Feb 05, 2025 at 11:42:12AM +0100, Przemek Kitszel wrote:
> GCC 7 is not as good as GCC 8+ in telling what is a compile-time const,
> and thus could be used for static storage. So we could not use variables
> for that, no matter how much "const" keyword is sprinkled around.
> 
> Excerpt from the report:
> My GCC is: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0.
> 
>   CC [M]  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o
> drivers/net/ethernet/intel/ice/devlink/health.c:35:3: error: initializer element is not constant
>    ice_common_port_solutions, {ice_port_number_label}},
>    ^~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/intel/ice/devlink/health.c:35:3: note: (near initialization for 'ice_health_status_lookup[0].solution')
> drivers/net/ethernet/intel/ice/devlink/health.c:35:31: error: initializer element is not constant
>    ice_common_port_solutions, {ice_port_number_label}},
>                                ^~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/intel/ice/devlink/health.c:35:31: note: (near initialization for 'ice_health_status_lookup[0].data_label[0]')
> drivers/net/ethernet/intel/ice/devlink/health.c:37:46: error: initializer element is not constant
>    "Change or replace the module or cable.", {ice_port_number_label}},
>                                               ^~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/intel/ice/devlink/health.c:37:46: note: (near initialization for 'ice_health_status_lookup[1].data_label[0]')
> drivers/net/ethernet/intel/ice/devlink/health.c:39:3: error: initializer element is not constant
>    ice_common_port_solutions, {ice_port_number_label}},
>    ^~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Fixes: 85d6164ec56d ("ice: add fw and port health reporters")
> Reported-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
> Closes: https://lore.kernel.org/netdev/CY8PR11MB7134BF7A46D71E50D25FA7A989F72@CY8PR11MB7134.namprd11.prod.outlook.com
> Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> ---
> I would really like to bump min gcc to 8.5 (RH 8 family),
> instead of supporting old Ubuntu. However SLES 15 is also stuck with gcc 7.5 :(
> 
> CC: Linus Torvalds <torvalds@linux-foundation.org>
> CC: Kees Cook <kees@kernel.org>
> CC: Nick Desaulniers <nick.desaulniers@gmail.com>

Hi Prezemek,

I ran into a similar problem not so long ago and I'm wondering if
the following, based on a suggestion by Jiri Slaby, resolves your
problem.

diff --git a/drivers/net/ethernet/intel/ice/devlink/health.c b/drivers/net/ethernet/intel/ice/devlink/health.c
index ea40f7941259..19c3d37aa768 100644
--- a/drivers/net/ethernet/intel/ice/devlink/health.c
+++ b/drivers/net/ethernet/intel/ice/devlink/health.c
@@ -25,10 +25,10 @@ struct ice_health_status {
  * The below lookup requires to be sorted by code.
  */
 
-static const char *const ice_common_port_solutions =
+static const char ice_common_port_solutions[] =
 	"Check your cable connection. Change or replace the module or cable. Manually set speed and duplex.";
-static const char *const ice_port_number_label = "Port Number";
-static const char *const ice_update_nvm_solution = "Update to the latest NVM image.";
+static const char ice_port_number_label[] = "Port Number";
+static const char ice_update_nvm_solution[] = "Update to the latest NVM image.";
 
 static const struct ice_health_status ice_health_status_lookup[] = {
 	{ICE_AQC_HEALTH_STATUS_ERR_UNKNOWN_MOD_STRICT, "An unsupported module was detected.",


Link: https://lore.kernel.org/netdev/485dbc5a-a04b-40c2-9481-955eaa5ce2e2@kernel.org/
Link: https://git.kernel.org/netdev/net-next/c/36fb51479e3c

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5
  2025-02-05 20:45 ` Simon Horman
@ 2025-02-05 22:56   ` David Laight
  2025-02-06  7:53     ` Jiri Slaby
  2025-02-06  7:45   ` Jiri Slaby
  2025-02-06 18:57   ` Kees Cook
  2 siblings, 1 reply; 9+ messages in thread
From: David Laight @ 2025-02-05 22:56 UTC (permalink / raw)
  To: Simon Horman
  Cc: Przemek Kitszel, intel-wired-lan, Tony Nguyen, netdev,
	Konrad Knitter, Michal Swiatkowski, Qiuxu Zhuo, Linus Torvalds,
	Kees Cook, Nick Desaulniers, Jiri Slaby

On Wed, 5 Feb 2025 20:45:46 +0000
Simon Horman <horms@kernel.org> wrote:

> + Jiri
> 
> On Wed, Feb 05, 2025 at 11:42:12AM +0100, Przemek Kitszel wrote:
> > GCC 7 is not as good as GCC 8+ in telling what is a compile-time const,
> > and thus could be used for static storage. So we could not use variables
> > for that, no matter how much "const" keyword is sprinkled around.
> > 
> > Excerpt from the report:
> > My GCC is: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0.
> > 
> >   CC [M]  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o
> > drivers/net/ethernet/intel/ice/devlink/health.c:35:3: error: initializer element is not constant
> >    ice_common_port_solutions, {ice_port_number_label}},
> >    ^~~~~~~~~~~~~~~~~~~~~~~~~
> > drivers/net/ethernet/intel/ice/devlink/health.c:35:3: note: (near initialization for 'ice_health_status_lookup[0].solution')
> > drivers/net/ethernet/intel/ice/devlink/health.c:35:31: error: initializer element is not constant
> >    ice_common_port_solutions, {ice_port_number_label}},
> >                                ^~~~~~~~~~~~~~~~~~~~~
> > drivers/net/ethernet/intel/ice/devlink/health.c:35:31: note: (near initialization for 'ice_health_status_lookup[0].data_label[0]')
> > drivers/net/ethernet/intel/ice/devlink/health.c:37:46: error: initializer element is not constant
> >    "Change or replace the module or cable.", {ice_port_number_label}},
> >                                               ^~~~~~~~~~~~~~~~~~~~~
> > drivers/net/ethernet/intel/ice/devlink/health.c:37:46: note: (near initialization for 'ice_health_status_lookup[1].data_label[0]')
> > drivers/net/ethernet/intel/ice/devlink/health.c:39:3: error: initializer element is not constant
> >    ice_common_port_solutions, {ice_port_number_label}},
> >    ^~~~~~~~~~~~~~~~~~~~~~~~~
> > 
> > Fixes: 85d6164ec56d ("ice: add fw and port health reporters")
> > Reported-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
> > Closes: https://lore.kernel.org/netdev/CY8PR11MB7134BF7A46D71E50D25FA7A989F72@CY8PR11MB7134.namprd11.prod.outlook.com
> > Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> > ---
> > I would really like to bump min gcc to 8.5 (RH 8 family),
> > instead of supporting old Ubuntu. However SLES 15 is also stuck with gcc 7.5 :(
> > 
> > CC: Linus Torvalds <torvalds@linux-foundation.org>
> > CC: Kees Cook <kees@kernel.org>
> > CC: Nick Desaulniers <nick.desaulniers@gmail.com>  
> 
> Hi Prezemek,
> 
> I ran into a similar problem not so long ago and I'm wondering if
> the following, based on a suggestion by Jiri Slaby, resolves your
> problem.

I'm sure I remember from somewhere that although the variables are
'static const' they have to be real variables because they can still
be patched.

Which stops you using their contents as initialisers.

Maybe I'm mis-remembering it.

	David

> 
> diff --git a/drivers/net/ethernet/intel/ice/devlink/health.c b/drivers/net/ethernet/intel/ice/devlink/health.c
> index ea40f7941259..19c3d37aa768 100644
> --- a/drivers/net/ethernet/intel/ice/devlink/health.c
> +++ b/drivers/net/ethernet/intel/ice/devlink/health.c
> @@ -25,10 +25,10 @@ struct ice_health_status {
>   * The below lookup requires to be sorted by code.
>   */
>  
> -static const char *const ice_common_port_solutions =
> +static const char ice_common_port_solutions[] =
>  	"Check your cable connection. Change or replace the module or cable. Manually set speed and duplex.";
> -static const char *const ice_port_number_label = "Port Number";
> -static const char *const ice_update_nvm_solution = "Update to the latest NVM image.";
> +static const char ice_port_number_label[] = "Port Number";
> +static const char ice_update_nvm_solution[] = "Update to the latest NVM image.";
>  
>  static const struct ice_health_status ice_health_status_lookup[] = {
>  	{ICE_AQC_HEALTH_STATUS_ERR_UNKNOWN_MOD_STRICT, "An unsupported module was detected.",
> 
> 
> Link: https://lore.kernel.org/netdev/485dbc5a-a04b-40c2-9481-955eaa5ce2e2@kernel.org/
> Link: https://git.kernel.org/netdev/net-next/c/36fb51479e3c
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5
  2025-02-05 20:45 ` Simon Horman
  2025-02-05 22:56   ` David Laight
@ 2025-02-06  7:45   ` Jiri Slaby
  2025-02-06 18:57   ` Kees Cook
  2 siblings, 0 replies; 9+ messages in thread
From: Jiri Slaby @ 2025-02-06  7:45 UTC (permalink / raw)
  To: Simon Horman, Przemek Kitszel
  Cc: intel-wired-lan, Tony Nguyen, netdev, Konrad Knitter,
	Michal Swiatkowski, Qiuxu Zhuo, Linus Torvalds, Kees Cook,
	Nick Desaulniers

On 05. 02. 25, 21:45, Simon Horman wrote:
> + Jiri
> 
> On Wed, Feb 05, 2025 at 11:42:12AM +0100, Przemek Kitszel wrote:
>> GCC 7 is not as good as GCC 8+ in telling what is a compile-time const,
>> and thus could be used for static storage. So we could not use variables
>> for that, no matter how much "const" keyword is sprinkled around.
>>
>> Excerpt from the report:
>> My GCC is: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0.
>>
>>    CC [M]  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o
>> drivers/net/ethernet/intel/ice/devlink/health.c:35:3: error: initializer element is not constant
>>     ice_common_port_solutions, {ice_port_number_label}},
>>     ^~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/intel/ice/devlink/health.c:35:3: note: (near initialization for 'ice_health_status_lookup[0].solution')
>> drivers/net/ethernet/intel/ice/devlink/health.c:35:31: error: initializer element is not constant
>>     ice_common_port_solutions, {ice_port_number_label}},
>>                                 ^~~~~~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/intel/ice/devlink/health.c:35:31: note: (near initialization for 'ice_health_status_lookup[0].data_label[0]')
>> drivers/net/ethernet/intel/ice/devlink/health.c:37:46: error: initializer element is not constant
>>     "Change or replace the module or cable.", {ice_port_number_label}},
>>                                                ^~~~~~~~~~~~~~~~~~~~~
>> drivers/net/ethernet/intel/ice/devlink/health.c:37:46: note: (near initialization for 'ice_health_status_lookup[1].data_label[0]')
>> drivers/net/ethernet/intel/ice/devlink/health.c:39:3: error: initializer element is not constant
>>     ice_common_port_solutions, {ice_port_number_label}},
>>     ^~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> Fixes: 85d6164ec56d ("ice: add fw and port health reporters")
>> Reported-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
>> Closes: https://lore.kernel.org/netdev/CY8PR11MB7134BF7A46D71E50D25FA7A989F72@CY8PR11MB7134.namprd11.prod.outlook.com
>> Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
>> ---
>> I would really like to bump min gcc to 8.5 (RH 8 family),
>> instead of supporting old Ubuntu. However SLES 15 is also stuck with gcc 7.5 :(
>>
>> CC: Linus Torvalds <torvalds@linux-foundation.org>
>> CC: Kees Cook <kees@kernel.org>
>> CC: Nick Desaulniers <nick.desaulniers@gmail.com>
> 
> Hi Prezemek,
> 
> I ran into a similar problem not so long ago and I'm wondering if
> the following, based on a suggestion by Jiri Slaby, resolves your
> problem.
> 
> diff --git a/drivers/net/ethernet/intel/ice/devlink/health.c b/drivers/net/ethernet/intel/ice/devlink/health.c
> index ea40f7941259..19c3d37aa768 100644
> --- a/drivers/net/ethernet/intel/ice/devlink/health.c
> +++ b/drivers/net/ethernet/intel/ice/devlink/health.c
> @@ -25,10 +25,10 @@ struct ice_health_status {
>    * The below lookup requires to be sorted by code.
>    */
>   
> -static const char *const ice_common_port_solutions =
> +static const char ice_common_port_solutions[] =
>   	"Check your cable connection. Change or replace the module or cable. Manually set speed and duplex.";
> -static const char *const ice_port_number_label = "Port Number";
> -static const char *const ice_update_nvm_solution = "Update to the latest NVM image.";
> +static const char ice_port_number_label[] = "Port Number";
> +static const char ice_update_nvm_solution[] = "Update to the latest NVM image.";

Indeed, no reason to create an (unused) pointer.

And no, don't use macros for strings.

thanks,
-- 
js
suse labs

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5
  2025-02-05 22:56   ` David Laight
@ 2025-02-06  7:53     ` Jiri Slaby
  0 siblings, 0 replies; 9+ messages in thread
From: Jiri Slaby @ 2025-02-06  7:53 UTC (permalink / raw)
  To: David Laight, Simon Horman
  Cc: Przemek Kitszel, intel-wired-lan, Tony Nguyen, netdev,
	Konrad Knitter, Michal Swiatkowski, Qiuxu Zhuo, Linus Torvalds,
	Kees Cook, Nick Desaulniers

On 05. 02. 25, 23:56, David Laight wrote:
> On Wed, 5 Feb 2025 20:45:46 +0000
> Simon Horman <horms@kernel.org> wrote:
> 
>> + Jiri
>>
>> On Wed, Feb 05, 2025 at 11:42:12AM +0100, Przemek Kitszel wrote:
>>> GCC 7 is not as good as GCC 8+ in telling what is a compile-time const,
>>> and thus could be used for static storage. So we could not use variables
>>> for that, no matter how much "const" keyword is sprinkled around.
>>>
>>> Excerpt from the report:
>>> My GCC is: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0.
>>>
>>>    CC [M]  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o
>>> drivers/net/ethernet/intel/ice/devlink/health.c:35:3: error: initializer element is not constant
>>>     ice_common_port_solutions, {ice_port_number_label}},
>>>     ^~~~~~~~~~~~~~~~~~~~~~~~~
>>> drivers/net/ethernet/intel/ice/devlink/health.c:35:3: note: (near initialization for 'ice_health_status_lookup[0].solution')
>>> drivers/net/ethernet/intel/ice/devlink/health.c:35:31: error: initializer element is not constant
>>>     ice_common_port_solutions, {ice_port_number_label}},
>>>                                 ^~~~~~~~~~~~~~~~~~~~~
>>> drivers/net/ethernet/intel/ice/devlink/health.c:35:31: note: (near initialization for 'ice_health_status_lookup[0].data_label[0]')
>>> drivers/net/ethernet/intel/ice/devlink/health.c:37:46: error: initializer element is not constant
>>>     "Change or replace the module or cable.", {ice_port_number_label}},
>>>                                                ^~~~~~~~~~~~~~~~~~~~~
>>> drivers/net/ethernet/intel/ice/devlink/health.c:37:46: note: (near initialization for 'ice_health_status_lookup[1].data_label[0]')
>>> drivers/net/ethernet/intel/ice/devlink/health.c:39:3: error: initializer element is not constant
>>>     ice_common_port_solutions, {ice_port_number_label}},
>>>     ^~~~~~~~~~~~~~~~~~~~~~~~~
>>>
>>> Fixes: 85d6164ec56d ("ice: add fw and port health reporters")
>>> Reported-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
>>> Closes: https://lore.kernel.org/netdev/CY8PR11MB7134BF7A46D71E50D25FA7A989F72@CY8PR11MB7134.namprd11.prod.outlook.com
>>> Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
>>> ---
>>> I would really like to bump min gcc to 8.5 (RH 8 family),
>>> instead of supporting old Ubuntu. However SLES 15 is also stuck with gcc 7.5 :(
>>>
>>> CC: Linus Torvalds <torvalds@linux-foundation.org>
>>> CC: Kees Cook <kees@kernel.org>
>>> CC: Nick Desaulniers <nick.desaulniers@gmail.com>
>>
>> Hi Prezemek,
>>
>> I ran into a similar problem not so long ago and I'm wondering if
>> the following, based on a suggestion by Jiri Slaby, resolves your
>> problem.
> 
> I'm sure I remember from somewhere that although the variables are
> 'static const' they have to be real variables because they can still
> be patched.

Not sure what you mean -- using macros, they placed the strings into 
.rodata anyway.

Mind the difference between:
const char *X;
char *const X;
const char *const X;

They are all different and allow different things (X++, (*X)++, nothing).

Possibly, the problem above could be fixed by the third variant too, 
IMO. But is ineffective (having generated an unused pointer).

thanks,
-- 
js
suse labs

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5
  2025-02-05 20:45 ` Simon Horman
  2025-02-05 22:56   ` David Laight
  2025-02-06  7:45   ` Jiri Slaby
@ 2025-02-06 18:57   ` Kees Cook
  2 siblings, 0 replies; 9+ messages in thread
From: Kees Cook @ 2025-02-06 18:57 UTC (permalink / raw)
  To: Simon Horman
  Cc: Przemek Kitszel, intel-wired-lan, Tony Nguyen, netdev,
	Konrad Knitter, Michal Swiatkowski, Qiuxu Zhuo, Linus Torvalds,
	Nick Desaulniers, Jiri Slaby

On Wed, Feb 05, 2025 at 08:45:46PM +0000, Simon Horman wrote:
> I ran into a similar problem not so long ago and I'm wondering if
> the following, based on a suggestion by Jiri Slaby, resolves your
> problem.
> 
> diff --git a/drivers/net/ethernet/intel/ice/devlink/health.c b/drivers/net/ethernet/intel/ice/devlink/health.c
> index ea40f7941259..19c3d37aa768 100644
> --- a/drivers/net/ethernet/intel/ice/devlink/health.c
> +++ b/drivers/net/ethernet/intel/ice/devlink/health.c
> @@ -25,10 +25,10 @@ struct ice_health_status {
>   * The below lookup requires to be sorted by code.
>   */
>  
> -static const char *const ice_common_port_solutions =
> +static const char ice_common_port_solutions[] =
>  	"Check your cable connection. Change or replace the module or cable. Manually set speed and duplex.";
> -static const char *const ice_port_number_label = "Port Number";
> -static const char *const ice_update_nvm_solution = "Update to the latest NVM image.";
> +static const char ice_port_number_label[] = "Port Number";
> +static const char ice_update_nvm_solution[] = "Update to the latest NVM image.";
>  
>  static const struct ice_health_status ice_health_status_lookup[] = {
>  	{ICE_AQC_HEALTH_STATUS_ERR_UNKNOWN_MOD_STRICT, "An unsupported module was detected.",
> 

I'd agree that would be the preferred fix. :)

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [Intel-wired-lan] [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5
  2025-02-05 10:42 [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5 Przemek Kitszel
                   ` (2 preceding siblings ...)
  2025-02-05 20:45 ` Simon Horman
@ 2025-03-14  7:03 ` Mekala, SunithaX D
  3 siblings, 0 replies; 9+ messages in thread
From: Mekala, SunithaX D @ 2025-03-14  7:03 UTC (permalink / raw)
  To: Kitszel, Przemyslaw, intel-wired-lan@lists.osuosl.org,
	Nguyen, Anthony L
  Cc: netdev@vger.kernel.org, Knitter, Konrad, Michal Swiatkowski,
	Kitszel, Przemyslaw, Zhuo, Qiuxu, Linus Torvalds, Kees Cook,
	Nick Desaulniers

> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Przemek Kitszel
> Sent: Wednesday, February 5, 2025 2:42 AM
> To: intel-wired-lan@lists.osuosl.org; Nguyen, Anthony L <anthony.l.nguyen@intel.com>
> Cc: netdev@vger.kernel.org; Knitter, Konrad <konrad.knitter@intel.com>; Michal Swiatkowski <michal.swiatkowski@linux.intel.com>; Kitszel, Przemyslaw <przemyslaw.kitszel@intel.com>; Zhuo, Qiuxu > <qiuxu.zhuo@intel.com>; Linus Torvalds <torvalds@linux-foundation.org>; Kees Cook <kees@kernel.org>; Nick Desaulniers <nick.desaulniers@gmail.com>
> Subject: [Intel-wired-lan] [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5
>
>  GCC 7 is not as good as GCC 8+ in telling what is a compile-time const,
> and thus could be used for static storage. So we could not use variables
>  for that, no matter how much "const" keyword is sprinkled around.
>
> Excerpt from the report:
> My GCC is: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0.
>
 >  CC [M]  drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.o
> drivers/net/ethernet/intel/ice/devlink/health.c:35:3: error: initializer element is not constant
>   ice_common_port_solutions, {ice_port_number_label}},
>    ^~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/intel/ice/devlink/health.c:35:3: note: (near initialization for 'ice_health_status_lookup[0].solution')
> drivers/net/ethernet/intel/ice/devlink/health.c:35:31: error: initializer element is not constant
>   ice_common_port_solutions, {ice_port_number_label}},
>                                ^~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/intel/ice/devlink/health.c:35:31: note: (near initialization for 'ice_health_status_lookup[0].data_label[0]')
> drivers/net/ethernet/intel/ice/devlink/health.c:37:46: error: initializer element is not constant
>    "Change or replace the module or cable.", {ice_port_number_label}},
>                                               ^~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/intel/ice/devlink/health.c:37:46: note: (near initialization for 'ice_health_status_lookup[1].data_label[0]')
> drivers/net/ethernet/intel/ice/devlink/health.c:39:3: error: initializer element is not constant
>   ice_common_port_solutions, {ice_port_number_label}},
>   ^~~~~~~~~~~~~~~~~~~~~~~~~
>
> Fixes: 85d6164ec56d ("ice: add fw and port health reporters")
> Reported-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
> Closes: https://lore.kernel.org/netdev/CY8PR11MB7134BF7A46D71E50D25FA7A989F72@CY8PR11MB7134.namprd11.prod.outlook.com
> Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
> ---
> I would really like to bump min gcc to 8.5 (RH 8 family),
> instead of supporting old Ubuntu. However SLES 15 is also stuck with gcc 7.5 :(
>
> CC: Linus Torvalds <torvalds@linux-foundation.org>
> CC: Kees Cook <kees@kernel.org>
> CC: Nick Desaulniers <nick.desaulniers@gmail.com>
> ---
>  drivers/net/ethernet/intel/ice/devlink/health.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
Tested-by: Sunitha Mekala <sunithax.d.mekala@intel.com> (A Contingent worker at Intel)

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-03-14  7:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-05 10:42 [PATCH iwl-net] ice: health.c: fix compilation on gcc 7.5 Przemek Kitszel
2025-02-05 11:19 ` Michal Swiatkowski
2025-02-05 11:39 ` Zhuo, Qiuxu
2025-02-05 20:45 ` Simon Horman
2025-02-05 22:56   ` David Laight
2025-02-06  7:53     ` Jiri Slaby
2025-02-06  7:45   ` Jiri Slaby
2025-02-06 18:57   ` Kees Cook
2025-03-14  7:03 ` [Intel-wired-lan] " Mekala, SunithaX D

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).