All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ACPI/IORT: Fix GCC 12 warning
@ 2022-02-10  0:32 ` Victor Erminpour
  0 siblings, 0 replies; 16+ messages in thread
From: Victor Erminpour @ 2022-02-10  0:32 UTC (permalink / raw)
  To: lorenzo.pieralisi
  Cc: guohanjun, sudeep.holla, rafael, lenb, linux-acpi,
	linux-arm-kernel, linux-kernel, trivial, victor.erminpour

When building with automatic stack variable initialization, GCC 12
complains about variables defined outside of switch case statements.
Move the variable into the case that uses it, which silences the warning:

./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
  1670 |                         struct acpi_iort_named_component *ncomp;
       |                                                           ^~~~~

Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
---
 drivers/acpi/arm64/iort.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index 3b23fb775ac4..5c5d2e56d756 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
  */
 phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
 {
-	phys_addr_t limit = PHYS_ADDR_MAX;
+	phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
 	struct acpi_iort_node *node, *end;
 	struct acpi_table_iort *iort;
 	acpi_status status;
@@ -1667,17 +1667,15 @@ phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
 			break;
 
 		switch (node->type) {
-			struct acpi_iort_named_component *ncomp;
-			struct acpi_iort_root_complex *rc;
-			phys_addr_t local_limit;
-
 		case ACPI_IORT_NODE_NAMED_COMPONENT:
+			struct acpi_iort_named_component *ncomp;
 			ncomp = (struct acpi_iort_named_component *)node->node_data;
 			local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
 			limit = min_not_zero(limit, local_limit);
 			break;
 
 		case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
+			struct acpi_iort_root_complex *rc;
 			if (node->revision < 1)
 				break;
 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH] ACPI/IORT: Fix GCC 12 warning
@ 2022-02-10  0:32 ` Victor Erminpour
  0 siblings, 0 replies; 16+ messages in thread
From: Victor Erminpour @ 2022-02-10  0:32 UTC (permalink / raw)
  To: lorenzo.pieralisi
  Cc: guohanjun, sudeep.holla, rafael, lenb, linux-acpi,
	linux-arm-kernel, linux-kernel, trivial, victor.erminpour

When building with automatic stack variable initialization, GCC 12
complains about variables defined outside of switch case statements.
Move the variable into the case that uses it, which silences the warning:

./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
  1670 |                         struct acpi_iort_named_component *ncomp;
       |                                                           ^~~~~

Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
---
 drivers/acpi/arm64/iort.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
index 3b23fb775ac4..5c5d2e56d756 100644
--- a/drivers/acpi/arm64/iort.c
+++ b/drivers/acpi/arm64/iort.c
@@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
  */
 phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
 {
-	phys_addr_t limit = PHYS_ADDR_MAX;
+	phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
 	struct acpi_iort_node *node, *end;
 	struct acpi_table_iort *iort;
 	acpi_status status;
@@ -1667,17 +1667,15 @@ phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
 			break;
 
 		switch (node->type) {
-			struct acpi_iort_named_component *ncomp;
-			struct acpi_iort_root_complex *rc;
-			phys_addr_t local_limit;
-
 		case ACPI_IORT_NODE_NAMED_COMPONENT:
+			struct acpi_iort_named_component *ncomp;
 			ncomp = (struct acpi_iort_named_component *)node->node_data;
 			local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
 			limit = min_not_zero(limit, local_limit);
 			break;
 
 		case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
+			struct acpi_iort_root_complex *rc;
 			if (node->revision < 1)
 				break;
 

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

* Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
  2022-02-10  0:32 ` Victor Erminpour
@ 2022-02-10  9:11   ` Ard Biesheuvel
  -1 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2022-02-10  9:11 UTC (permalink / raw)
  To: Victor Erminpour
  Cc: Lorenzo Pieralisi, Hanjun Guo, Sudeep Holla, Rafael J. Wysocki,
	Len Brown, ACPI Devel Maling List, Linux ARM,
	Linux Kernel Mailing List, trivial

On Thu, 10 Feb 2022 at 01:34, Victor Erminpour
<victor.erminpour@oracle.com> wrote:
>
> When building with automatic stack variable initialization, GCC 12
> complains about variables defined outside of switch case statements.
> Move the variable into the case that uses it, which silences the warning:
>
> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
>   1670 |                         struct acpi_iort_named_component *ncomp;
>        |                                                           ^~~~~
>
> Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>

GCC 12 is not released yet, and this is clearly a compiler bug (a
declaration is not a statement, and the hidden offending statement
[the zero-init] is emitted by the compiler itself), so please report
this to the GCC folks instead.


> ---
>  drivers/acpi/arm64/iort.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
> index 3b23fb775ac4..5c5d2e56d756 100644
> --- a/drivers/acpi/arm64/iort.c
> +++ b/drivers/acpi/arm64/iort.c
> @@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
>   */
>  phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>  {
> -       phys_addr_t limit = PHYS_ADDR_MAX;
> +       phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
>         struct acpi_iort_node *node, *end;
>         struct acpi_table_iort *iort;
>         acpi_status status;
> @@ -1667,17 +1667,15 @@ phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>                         break;
>
>                 switch (node->type) {
> -                       struct acpi_iort_named_component *ncomp;
> -                       struct acpi_iort_root_complex *rc;
> -                       phys_addr_t local_limit;
> -
>                 case ACPI_IORT_NODE_NAMED_COMPONENT:
> +                       struct acpi_iort_named_component *ncomp;
>                         ncomp = (struct acpi_iort_named_component *)node->node_data;
>                         local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
>                         limit = min_not_zero(limit, local_limit);
>                         break;
>
>                 case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
> +                       struct acpi_iort_root_complex *rc;
>                         if (node->revision < 1)
>                                 break;
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
@ 2022-02-10  9:11   ` Ard Biesheuvel
  0 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2022-02-10  9:11 UTC (permalink / raw)
  To: Victor Erminpour
  Cc: Lorenzo Pieralisi, Hanjun Guo, Sudeep Holla, Rafael J. Wysocki,
	Len Brown, ACPI Devel Maling List, Linux ARM,
	Linux Kernel Mailing List, trivial

On Thu, 10 Feb 2022 at 01:34, Victor Erminpour
<victor.erminpour@oracle.com> wrote:
>
> When building with automatic stack variable initialization, GCC 12
> complains about variables defined outside of switch case statements.
> Move the variable into the case that uses it, which silences the warning:
>
> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
>   1670 |                         struct acpi_iort_named_component *ncomp;
>        |                                                           ^~~~~
>
> Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>

GCC 12 is not released yet, and this is clearly a compiler bug (a
declaration is not a statement, and the hidden offending statement
[the zero-init] is emitted by the compiler itself), so please report
this to the GCC folks instead.


> ---
>  drivers/acpi/arm64/iort.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
> index 3b23fb775ac4..5c5d2e56d756 100644
> --- a/drivers/acpi/arm64/iort.c
> +++ b/drivers/acpi/arm64/iort.c
> @@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
>   */
>  phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>  {
> -       phys_addr_t limit = PHYS_ADDR_MAX;
> +       phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
>         struct acpi_iort_node *node, *end;
>         struct acpi_table_iort *iort;
>         acpi_status status;
> @@ -1667,17 +1667,15 @@ phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>                         break;
>
>                 switch (node->type) {
> -                       struct acpi_iort_named_component *ncomp;
> -                       struct acpi_iort_root_complex *rc;
> -                       phys_addr_t local_limit;
> -
>                 case ACPI_IORT_NODE_NAMED_COMPONENT:
> +                       struct acpi_iort_named_component *ncomp;
>                         ncomp = (struct acpi_iort_named_component *)node->node_data;
>                         local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
>                         limit = min_not_zero(limit, local_limit);
>                         break;
>
>                 case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
> +                       struct acpi_iort_root_complex *rc;
>                         if (node->revision < 1)
>                                 break;
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
  2022-02-10  9:11   ` Ard Biesheuvel
@ 2022-02-10 17:36     ` Victor Erminpour
  -1 siblings, 0 replies; 16+ messages in thread
From: Victor Erminpour @ 2022-02-10 17:36 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Lorenzo Pieralisi, Hanjun Guo, Sudeep Holla, Rafael J. Wysocki,
	Len Brown, ACPI Devel Maling List, Linux ARM,
	Linux Kernel Mailing List, trivial


On 2/10/22 1:11 AM, Ard Biesheuvel wrote:
> On Thu, 10 Feb 2022 at 01:34, Victor Erminpour
> <victor.erminpour@oracle.com> wrote:
>> When building with automatic stack variable initialization, GCC 12
>> complains about variables defined outside of switch case statements.
>> Move the variable into the case that uses it, which silences the warning:
>>
>> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
>>    1670 |                         struct acpi_iort_named_component *ncomp;
>>         |                                                           ^~~~~
>>
>> Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
> GCC 12 is not released yet, and this is clearly a compiler bug (a
> declaration is not a statement, and the hidden offending statement
> [the zero-init] is emitted by the compiler itself), so please report
> this to the GCC folks instead.

Hi Ard,

Thanks for the reply.
This fix is similar to the following commits that have been integrated 
upstream:
https://lore.kernel.org/linux-hardening/20211209043456.1377875-1-keescook@chromium.org/
https://lore.kernel.org/linux-hardening/20211209043915.1378393-1-keescook@chromium.org/

You're not obligated to integrate this commit, but you may run into this 
issue once
upstream starts using GCC 12 (or a patched version of GCC 11 in my case) 
with the
CONFIG_INIT_STACK_ALL_ZERO option enabled.

Regards,
--Victor


>
>> ---
>>   drivers/acpi/arm64/iort.c | 8 +++-----
>>   1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
>> index 3b23fb775ac4..5c5d2e56d756 100644
>> --- a/drivers/acpi/arm64/iort.c
>> +++ b/drivers/acpi/arm64/iort.c
>> @@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
>>    */
>>   phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>>   {
>> -       phys_addr_t limit = PHYS_ADDR_MAX;
>> +       phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
>>          struct acpi_iort_node *node, *end;
>>          struct acpi_table_iort *iort;
>>          acpi_status status;
>> @@ -1667,17 +1667,15 @@ phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>>                          break;
>>
>>                  switch (node->type) {
>> -                       struct acpi_iort_named_component *ncomp;
>> -                       struct acpi_iort_root_complex *rc;
>> -                       phys_addr_t local_limit;
>> -
>>                  case ACPI_IORT_NODE_NAMED_COMPONENT:
>> +                       struct acpi_iort_named_component *ncomp;
>>                          ncomp = (struct acpi_iort_named_component *)node->node_data;
>>                          local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
>>                          limit = min_not_zero(limit, local_limit);
>>                          break;
>>
>>                  case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
>> +                       struct acpi_iort_root_complex *rc;
>>                          if (node->revision < 1)
>>                                  break;
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> https://urldefense.com/v3/__http://lists.infradead.org/mailman/listinfo/linux-arm-kernel__;!!ACWV5N9M2RV99hQ!dguMEUG-y4wN_Scw_dP1umWKxZKxiQA2Fv9sHuQx6Un9QIqSMbkQVxTeIZInR2h7YL-f$

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

* Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
@ 2022-02-10 17:36     ` Victor Erminpour
  0 siblings, 0 replies; 16+ messages in thread
From: Victor Erminpour @ 2022-02-10 17:36 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Lorenzo Pieralisi, Hanjun Guo, Sudeep Holla, Rafael J. Wysocki,
	Len Brown, ACPI Devel Maling List, Linux ARM,
	Linux Kernel Mailing List, trivial


On 2/10/22 1:11 AM, Ard Biesheuvel wrote:
> On Thu, 10 Feb 2022 at 01:34, Victor Erminpour
> <victor.erminpour@oracle.com> wrote:
>> When building with automatic stack variable initialization, GCC 12
>> complains about variables defined outside of switch case statements.
>> Move the variable into the case that uses it, which silences the warning:
>>
>> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
>>    1670 |                         struct acpi_iort_named_component *ncomp;
>>         |                                                           ^~~~~
>>
>> Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
> GCC 12 is not released yet, and this is clearly a compiler bug (a
> declaration is not a statement, and the hidden offending statement
> [the zero-init] is emitted by the compiler itself), so please report
> this to the GCC folks instead.

Hi Ard,

Thanks for the reply.
This fix is similar to the following commits that have been integrated 
upstream:
https://lore.kernel.org/linux-hardening/20211209043456.1377875-1-keescook@chromium.org/
https://lore.kernel.org/linux-hardening/20211209043915.1378393-1-keescook@chromium.org/

You're not obligated to integrate this commit, but you may run into this 
issue once
upstream starts using GCC 12 (or a patched version of GCC 11 in my case) 
with the
CONFIG_INIT_STACK_ALL_ZERO option enabled.

Regards,
--Victor


>
>> ---
>>   drivers/acpi/arm64/iort.c | 8 +++-----
>>   1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
>> index 3b23fb775ac4..5c5d2e56d756 100644
>> --- a/drivers/acpi/arm64/iort.c
>> +++ b/drivers/acpi/arm64/iort.c
>> @@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
>>    */
>>   phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>>   {
>> -       phys_addr_t limit = PHYS_ADDR_MAX;
>> +       phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
>>          struct acpi_iort_node *node, *end;
>>          struct acpi_table_iort *iort;
>>          acpi_status status;
>> @@ -1667,17 +1667,15 @@ phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>>                          break;
>>
>>                  switch (node->type) {
>> -                       struct acpi_iort_named_component *ncomp;
>> -                       struct acpi_iort_root_complex *rc;
>> -                       phys_addr_t local_limit;
>> -
>>                  case ACPI_IORT_NODE_NAMED_COMPONENT:
>> +                       struct acpi_iort_named_component *ncomp;
>>                          ncomp = (struct acpi_iort_named_component *)node->node_data;
>>                          local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
>>                          limit = min_not_zero(limit, local_limit);
>>                          break;
>>
>>                  case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
>> +                       struct acpi_iort_root_complex *rc;
>>                          if (node->revision < 1)
>>                                  break;
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> https://urldefense.com/v3/__http://lists.infradead.org/mailman/listinfo/linux-arm-kernel__;!!ACWV5N9M2RV99hQ!dguMEUG-y4wN_Scw_dP1umWKxZKxiQA2Fv9sHuQx6Un9QIqSMbkQVxTeIZInR2h7YL-f$

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
  2022-02-10  0:32 ` Victor Erminpour
@ 2022-02-10 18:06   ` Robin Murphy
  -1 siblings, 0 replies; 16+ messages in thread
From: Robin Murphy @ 2022-02-10 18:06 UTC (permalink / raw)
  To: Victor Erminpour, lorenzo.pieralisi
  Cc: guohanjun, sudeep.holla, rafael, lenb, linux-acpi,
	linux-arm-kernel, linux-kernel, trivial

On 2022-02-10 00:32, Victor Erminpour wrote:
> When building with automatic stack variable initialization, GCC 12
> complains about variables defined outside of switch case statements.
> Move the variable into the case that uses it, which silences the warning:
> 
> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
>    1670 |                         struct acpi_iort_named_component *ncomp;
>         |                                                           ^~~~~

Notwithstanding the fact that that warning is nonsensical, this patch 
changes valid C code into invalid C code that doesn't even compile:

drivers/acpi/arm64/iort.c: In function ‘acpi_iort_dma_get_max_cpu_address’:
drivers/acpi/arm64/iort.c:1669:4: error: a label can only be part of a 
statement and a declaration is not a statement
  1669 |    struct acpi_iort_named_component *ncomp;
       |    ^~~~~~
drivers/acpi/arm64/iort.c:1676:4: error: a label can only be part of a 
statement and a declaration is not a statement
  1676 |    struct acpi_iort_root_complex *rc;
       |    ^~~~~~

Robin.

> Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
> ---
>   drivers/acpi/arm64/iort.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
> index 3b23fb775ac4..5c5d2e56d756 100644
> --- a/drivers/acpi/arm64/iort.c
> +++ b/drivers/acpi/arm64/iort.c
> @@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
>    */
>   phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>   {
> -	phys_addr_t limit = PHYS_ADDR_MAX;
> +	phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
>   	struct acpi_iort_node *node, *end;
>   	struct acpi_table_iort *iort;
>   	acpi_status status;
> @@ -1667,17 +1667,15 @@ phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>   			break;
>   
>   		switch (node->type) {
> -			struct acpi_iort_named_component *ncomp;
> -			struct acpi_iort_root_complex *rc;
> -			phys_addr_t local_limit;
> -
>   		case ACPI_IORT_NODE_NAMED_COMPONENT:
> +			struct acpi_iort_named_component *ncomp;
>   			ncomp = (struct acpi_iort_named_component *)node->node_data;
>   			local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
>   			limit = min_not_zero(limit, local_limit);
>   			break;
>   
>   		case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
> +			struct acpi_iort_root_complex *rc;
>   			if (node->revision < 1)
>   				break;
>   
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
@ 2022-02-10 18:06   ` Robin Murphy
  0 siblings, 0 replies; 16+ messages in thread
From: Robin Murphy @ 2022-02-10 18:06 UTC (permalink / raw)
  To: Victor Erminpour, lorenzo.pieralisi
  Cc: guohanjun, sudeep.holla, rafael, lenb, linux-acpi,
	linux-arm-kernel, linux-kernel, trivial

On 2022-02-10 00:32, Victor Erminpour wrote:
> When building with automatic stack variable initialization, GCC 12
> complains about variables defined outside of switch case statements.
> Move the variable into the case that uses it, which silences the warning:
> 
> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
>    1670 |                         struct acpi_iort_named_component *ncomp;
>         |                                                           ^~~~~

Notwithstanding the fact that that warning is nonsensical, this patch 
changes valid C code into invalid C code that doesn't even compile:

drivers/acpi/arm64/iort.c: In function ‘acpi_iort_dma_get_max_cpu_address’:
drivers/acpi/arm64/iort.c:1669:4: error: a label can only be part of a 
statement and a declaration is not a statement
  1669 |    struct acpi_iort_named_component *ncomp;
       |    ^~~~~~
drivers/acpi/arm64/iort.c:1676:4: error: a label can only be part of a 
statement and a declaration is not a statement
  1676 |    struct acpi_iort_root_complex *rc;
       |    ^~~~~~

Robin.

> Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
> ---
>   drivers/acpi/arm64/iort.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
> index 3b23fb775ac4..5c5d2e56d756 100644
> --- a/drivers/acpi/arm64/iort.c
> +++ b/drivers/acpi/arm64/iort.c
> @@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
>    */
>   phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>   {
> -	phys_addr_t limit = PHYS_ADDR_MAX;
> +	phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
>   	struct acpi_iort_node *node, *end;
>   	struct acpi_table_iort *iort;
>   	acpi_status status;
> @@ -1667,17 +1667,15 @@ phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>   			break;
>   
>   		switch (node->type) {
> -			struct acpi_iort_named_component *ncomp;
> -			struct acpi_iort_root_complex *rc;
> -			phys_addr_t local_limit;
> -
>   		case ACPI_IORT_NODE_NAMED_COMPONENT:
> +			struct acpi_iort_named_component *ncomp;
>   			ncomp = (struct acpi_iort_named_component *)node->node_data;
>   			local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
>   			limit = min_not_zero(limit, local_limit);
>   			break;
>   
>   		case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
> +			struct acpi_iort_root_complex *rc;
>   			if (node->revision < 1)
>   				break;
>   
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
  2022-02-10 18:06   ` Robin Murphy
@ 2022-02-10 18:27     ` Victor Erminpour
  -1 siblings, 0 replies; 16+ messages in thread
From: Victor Erminpour @ 2022-02-10 18:27 UTC (permalink / raw)
  To: Robin Murphy, lorenzo.pieralisi
  Cc: guohanjun, sudeep.holla, rafael, lenb, linux-acpi,
	linux-arm-kernel, linux-kernel, trivial


On 2/10/22 10:06 AM, Robin Murphy wrote:
> On 2022-02-10 00:32, Victor Erminpour wrote:
>> When building with automatic stack variable initialization, GCC 12
>> complains about variables defined outside of switch case statements.
>> Move the variable into the case that uses it, which silences the 
>> warning:
>>
>> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be 
>> executed [-Werror=switch-unreachable]
>>    1670 |                         struct acpi_iort_named_component 
>> *ncomp;
>> | ^~~~~
>
> Notwithstanding the fact that that warning is nonsensical, this patch 
> changes valid C code into invalid C code that doesn't even compile:
>
> drivers/acpi/arm64/iort.c: In function 
> ‘acpi_iort_dma_get_max_cpu_address’:
> drivers/acpi/arm64/iort.c:1669:4: error: a label can only be part of a 
> statement and a declaration is not a statement
>  1669 |    struct acpi_iort_named_component *ncomp;
>       |    ^~~~~~
> drivers/acpi/arm64/iort.c:1676:4: error: a label can only be part of a 
> statement and a declaration is not a statement
>  1676 |    struct acpi_iort_root_complex *rc;
>       |    ^~~~~~
>
> Robin.
>

Hi Robin,

Thank you for your constructive criticism.
Could the solution be enclosing the case statement in curly braces?

I know this isn't a big issue for you, but this is a legitimate error 
for people
building the kernel with GCC 12 and CONFIG_INIT_STACK_ALL_ZERO enabled.

Regards,
--Victor



>> Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
>> ---
>>   drivers/acpi/arm64/iort.c | 8 +++-----
>>   1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
>> index 3b23fb775ac4..5c5d2e56d756 100644
>> --- a/drivers/acpi/arm64/iort.c
>> +++ b/drivers/acpi/arm64/iort.c
>> @@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
>>    */
>>   phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>>   {
>> -    phys_addr_t limit = PHYS_ADDR_MAX;
>> +    phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
>>       struct acpi_iort_node *node, *end;
>>       struct acpi_table_iort *iort;
>>       acpi_status status;
>> @@ -1667,17 +1667,15 @@ phys_addr_t __init 
>> acpi_iort_dma_get_max_cpu_address(void)
>>               break;
>>             switch (node->type) {
>> -            struct acpi_iort_named_component *ncomp;
>> -            struct acpi_iort_root_complex *rc;
>> -            phys_addr_t local_limit;
>> -
>>           case ACPI_IORT_NODE_NAMED_COMPONENT:
>> +            struct acpi_iort_named_component *ncomp;
>>               ncomp = (struct acpi_iort_named_component 
>> *)node->node_data;
>>               local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
>>               limit = min_not_zero(limit, local_limit);
>>               break;
>>             case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
>> +            struct acpi_iort_root_complex *rc;
>>               if (node->revision < 1)
>>                   break;
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> https://urldefense.com/v3/__http://lists.infradead.org/mailman/listinfo/linux-arm-kernel__;!!ACWV5N9M2RV99hQ!ZcNRWTaQIb1uVqcZAusSzXd2kBnWuqAuICpxkOm6bOWBouQoFygbcIMJVUNp34LqhNrc$ 
>

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

* Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
@ 2022-02-10 18:27     ` Victor Erminpour
  0 siblings, 0 replies; 16+ messages in thread
From: Victor Erminpour @ 2022-02-10 18:27 UTC (permalink / raw)
  To: Robin Murphy, lorenzo.pieralisi
  Cc: guohanjun, sudeep.holla, rafael, lenb, linux-acpi,
	linux-arm-kernel, linux-kernel, trivial


On 2/10/22 10:06 AM, Robin Murphy wrote:
> On 2022-02-10 00:32, Victor Erminpour wrote:
>> When building with automatic stack variable initialization, GCC 12
>> complains about variables defined outside of switch case statements.
>> Move the variable into the case that uses it, which silences the 
>> warning:
>>
>> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be 
>> executed [-Werror=switch-unreachable]
>>    1670 |                         struct acpi_iort_named_component 
>> *ncomp;
>> | ^~~~~
>
> Notwithstanding the fact that that warning is nonsensical, this patch 
> changes valid C code into invalid C code that doesn't even compile:
>
> drivers/acpi/arm64/iort.c: In function 
> ‘acpi_iort_dma_get_max_cpu_address’:
> drivers/acpi/arm64/iort.c:1669:4: error: a label can only be part of a 
> statement and a declaration is not a statement
>  1669 |    struct acpi_iort_named_component *ncomp;
>       |    ^~~~~~
> drivers/acpi/arm64/iort.c:1676:4: error: a label can only be part of a 
> statement and a declaration is not a statement
>  1676 |    struct acpi_iort_root_complex *rc;
>       |    ^~~~~~
>
> Robin.
>

Hi Robin,

Thank you for your constructive criticism.
Could the solution be enclosing the case statement in curly braces?

I know this isn't a big issue for you, but this is a legitimate error 
for people
building the kernel with GCC 12 and CONFIG_INIT_STACK_ALL_ZERO enabled.

Regards,
--Victor



>> Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
>> ---
>>   drivers/acpi/arm64/iort.c | 8 +++-----
>>   1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
>> index 3b23fb775ac4..5c5d2e56d756 100644
>> --- a/drivers/acpi/arm64/iort.c
>> +++ b/drivers/acpi/arm64/iort.c
>> @@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
>>    */
>>   phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>>   {
>> -    phys_addr_t limit = PHYS_ADDR_MAX;
>> +    phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
>>       struct acpi_iort_node *node, *end;
>>       struct acpi_table_iort *iort;
>>       acpi_status status;
>> @@ -1667,17 +1667,15 @@ phys_addr_t __init 
>> acpi_iort_dma_get_max_cpu_address(void)
>>               break;
>>             switch (node->type) {
>> -            struct acpi_iort_named_component *ncomp;
>> -            struct acpi_iort_root_complex *rc;
>> -            phys_addr_t local_limit;
>> -
>>           case ACPI_IORT_NODE_NAMED_COMPONENT:
>> +            struct acpi_iort_named_component *ncomp;
>>               ncomp = (struct acpi_iort_named_component 
>> *)node->node_data;
>>               local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
>>               limit = min_not_zero(limit, local_limit);
>>               break;
>>             case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
>> +            struct acpi_iort_root_complex *rc;
>>               if (node->revision < 1)
>>                   break;
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> https://urldefense.com/v3/__http://lists.infradead.org/mailman/listinfo/linux-arm-kernel__;!!ACWV5N9M2RV99hQ!ZcNRWTaQIb1uVqcZAusSzXd2kBnWuqAuICpxkOm6bOWBouQoFygbcIMJVUNp34LqhNrc$ 
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
  2022-02-10 18:27     ` Victor Erminpour
@ 2022-02-10 18:35       ` Robin Murphy
  -1 siblings, 0 replies; 16+ messages in thread
From: Robin Murphy @ 2022-02-10 18:35 UTC (permalink / raw)
  To: Victor Erminpour, lorenzo.pieralisi
  Cc: guohanjun, sudeep.holla, rafael, lenb, linux-acpi,
	linux-arm-kernel, linux-kernel, trivial

On 2022-02-10 18:27, Victor Erminpour wrote:
> 
> On 2/10/22 10:06 AM, Robin Murphy wrote:
>> On 2022-02-10 00:32, Victor Erminpour wrote:
>>> When building with automatic stack variable initialization, GCC 12
>>> complains about variables defined outside of switch case statements.
>>> Move the variable into the case that uses it, which silences the 
>>> warning:
>>>
>>> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be 
>>> executed [-Werror=switch-unreachable]
>>>    1670 |                         struct acpi_iort_named_component 
>>> *ncomp;
>>> | ^~~~~
>>
>> Notwithstanding the fact that that warning is nonsensical, this patch 
>> changes valid C code into invalid C code that doesn't even compile:
>>
>> drivers/acpi/arm64/iort.c: In function 
>> ‘acpi_iort_dma_get_max_cpu_address’:
>> drivers/acpi/arm64/iort.c:1669:4: error: a label can only be part of a 
>> statement and a declaration is not a statement
>>  1669 |    struct acpi_iort_named_component *ncomp;
>>       |    ^~~~~~
>> drivers/acpi/arm64/iort.c:1676:4: error: a label can only be part of a 
>> statement and a declaration is not a statement
>>  1676 |    struct acpi_iort_root_complex *rc;
>>       |    ^~~~~~
>>
>> Robin.
>>
> 
> Hi Robin,
> 
> Thank you for your constructive criticism.
> Could the solution be enclosing the case statement in curly braces?
> 
> I know this isn't a big issue for you, but this is a legitimate error 
> for people
> building the kernel with GCC 12 and CONFIG_INIT_STACK_ALL_ZERO enabled.

As Ard pointed out first, it is not a legitimate error, it is a spurious 
error. The fact that you seemingly didn't get the label errors above, 
nor even "ISO C90 forbids mixed declarations and code 
[-Wdeclaration-after-statement]", implies that GCC 12 currently has a 
completely broken notion of declarations vs. statements with that option 
enabled, so GCC 12 needs fixing.

Robin.

> 
> Regards,
> --Victor
> 
> 
> 
>>> Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
>>> ---
>>>   drivers/acpi/arm64/iort.c | 8 +++-----
>>>   1 file changed, 3 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
>>> index 3b23fb775ac4..5c5d2e56d756 100644
>>> --- a/drivers/acpi/arm64/iort.c
>>> +++ b/drivers/acpi/arm64/iort.c
>>> @@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
>>>    */
>>>   phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>>>   {
>>> -    phys_addr_t limit = PHYS_ADDR_MAX;
>>> +    phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
>>>       struct acpi_iort_node *node, *end;
>>>       struct acpi_table_iort *iort;
>>>       acpi_status status;
>>> @@ -1667,17 +1667,15 @@ phys_addr_t __init 
>>> acpi_iort_dma_get_max_cpu_address(void)
>>>               break;
>>>             switch (node->type) {
>>> -            struct acpi_iort_named_component *ncomp;
>>> -            struct acpi_iort_root_complex *rc;
>>> -            phys_addr_t local_limit;
>>> -
>>>           case ACPI_IORT_NODE_NAMED_COMPONENT:
>>> +            struct acpi_iort_named_component *ncomp;
>>>               ncomp = (struct acpi_iort_named_component 
>>> *)node->node_data;
>>>               local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
>>>               limit = min_not_zero(limit, local_limit);
>>>               break;
>>>             case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
>>> +            struct acpi_iort_root_complex *rc;
>>>               if (node->revision < 1)
>>>                   break;
>>>
>>> _______________________________________________
>>> linux-arm-kernel mailing list
>>> linux-arm-kernel@lists.infradead.org
>>> https://urldefense.com/v3/__http://lists.infradead.org/mailman/listinfo/linux-arm-kernel__;!!ACWV5N9M2RV99hQ!ZcNRWTaQIb1uVqcZAusSzXd2kBnWuqAuICpxkOm6bOWBouQoFygbcIMJVUNp34LqhNrc$ 
>>
>>

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

* Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
@ 2022-02-10 18:35       ` Robin Murphy
  0 siblings, 0 replies; 16+ messages in thread
From: Robin Murphy @ 2022-02-10 18:35 UTC (permalink / raw)
  To: Victor Erminpour, lorenzo.pieralisi
  Cc: guohanjun, sudeep.holla, rafael, lenb, linux-acpi,
	linux-arm-kernel, linux-kernel, trivial

On 2022-02-10 18:27, Victor Erminpour wrote:
> 
> On 2/10/22 10:06 AM, Robin Murphy wrote:
>> On 2022-02-10 00:32, Victor Erminpour wrote:
>>> When building with automatic stack variable initialization, GCC 12
>>> complains about variables defined outside of switch case statements.
>>> Move the variable into the case that uses it, which silences the 
>>> warning:
>>>
>>> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be 
>>> executed [-Werror=switch-unreachable]
>>>    1670 |                         struct acpi_iort_named_component 
>>> *ncomp;
>>> | ^~~~~
>>
>> Notwithstanding the fact that that warning is nonsensical, this patch 
>> changes valid C code into invalid C code that doesn't even compile:
>>
>> drivers/acpi/arm64/iort.c: In function 
>> ‘acpi_iort_dma_get_max_cpu_address’:
>> drivers/acpi/arm64/iort.c:1669:4: error: a label can only be part of a 
>> statement and a declaration is not a statement
>>  1669 |    struct acpi_iort_named_component *ncomp;
>>       |    ^~~~~~
>> drivers/acpi/arm64/iort.c:1676:4: error: a label can only be part of a 
>> statement and a declaration is not a statement
>>  1676 |    struct acpi_iort_root_complex *rc;
>>       |    ^~~~~~
>>
>> Robin.
>>
> 
> Hi Robin,
> 
> Thank you for your constructive criticism.
> Could the solution be enclosing the case statement in curly braces?
> 
> I know this isn't a big issue for you, but this is a legitimate error 
> for people
> building the kernel with GCC 12 and CONFIG_INIT_STACK_ALL_ZERO enabled.

As Ard pointed out first, it is not a legitimate error, it is a spurious 
error. The fact that you seemingly didn't get the label errors above, 
nor even "ISO C90 forbids mixed declarations and code 
[-Wdeclaration-after-statement]", implies that GCC 12 currently has a 
completely broken notion of declarations vs. statements with that option 
enabled, so GCC 12 needs fixing.

Robin.

> 
> Regards,
> --Victor
> 
> 
> 
>>> Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
>>> ---
>>>   drivers/acpi/arm64/iort.c | 8 +++-----
>>>   1 file changed, 3 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
>>> index 3b23fb775ac4..5c5d2e56d756 100644
>>> --- a/drivers/acpi/arm64/iort.c
>>> +++ b/drivers/acpi/arm64/iort.c
>>> @@ -1645,7 +1645,7 @@ void __init acpi_iort_init(void)
>>>    */
>>>   phys_addr_t __init acpi_iort_dma_get_max_cpu_address(void)
>>>   {
>>> -    phys_addr_t limit = PHYS_ADDR_MAX;
>>> +    phys_addr_t local_limit, limit = PHYS_ADDR_MAX;
>>>       struct acpi_iort_node *node, *end;
>>>       struct acpi_table_iort *iort;
>>>       acpi_status status;
>>> @@ -1667,17 +1667,15 @@ phys_addr_t __init 
>>> acpi_iort_dma_get_max_cpu_address(void)
>>>               break;
>>>             switch (node->type) {
>>> -            struct acpi_iort_named_component *ncomp;
>>> -            struct acpi_iort_root_complex *rc;
>>> -            phys_addr_t local_limit;
>>> -
>>>           case ACPI_IORT_NODE_NAMED_COMPONENT:
>>> +            struct acpi_iort_named_component *ncomp;
>>>               ncomp = (struct acpi_iort_named_component 
>>> *)node->node_data;
>>>               local_limit = DMA_BIT_MASK(ncomp->memory_address_limit);
>>>               limit = min_not_zero(limit, local_limit);
>>>               break;
>>>             case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
>>> +            struct acpi_iort_root_complex *rc;
>>>               if (node->revision < 1)
>>>                   break;
>>>
>>> _______________________________________________
>>> linux-arm-kernel mailing list
>>> linux-arm-kernel@lists.infradead.org
>>> https://urldefense.com/v3/__http://lists.infradead.org/mailman/listinfo/linux-arm-kernel__;!!ACWV5N9M2RV99hQ!ZcNRWTaQIb1uVqcZAusSzXd2kBnWuqAuICpxkOm6bOWBouQoFygbcIMJVUNp34LqhNrc$ 
>>
>>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
  2022-02-10 17:36     ` Victor Erminpour
@ 2022-02-10 19:29       ` Ard Biesheuvel
  -1 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2022-02-10 19:29 UTC (permalink / raw)
  To: Victor Erminpour
  Cc: Lorenzo Pieralisi, Hanjun Guo, Sudeep Holla, Rafael J. Wysocki,
	Len Brown, ACPI Devel Maling List, Linux ARM,
	Linux Kernel Mailing List, trivial, Robin Murphy

(cc Kees)

On Thu, 10 Feb 2022 at 18:36, Victor Erminpour
<victor.erminpour@oracle.com> wrote:
>
>
> On 2/10/22 1:11 AM, Ard Biesheuvel wrote:
> > On Thu, 10 Feb 2022 at 01:34, Victor Erminpour
> > <victor.erminpour@oracle.com> wrote:
> >> When building with automatic stack variable initialization, GCC 12
> >> complains about variables defined outside of switch case statements.
> >> Move the variable into the case that uses it, which silences the warning:
> >>
> >> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
> >>    1670 |                         struct acpi_iort_named_component *ncomp;
> >>         |                                                           ^~~~~
> >>
> >> Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
> > GCC 12 is not released yet, and this is clearly a compiler bug (a
> > declaration is not a statement, and the hidden offending statement
> > [the zero-init] is emitted by the compiler itself), so please report
> > this to the GCC folks instead.
>
> Hi Ard,
>
> Thanks for the reply.
> This fix is similar to the following commits that have been integrated
> upstream:
> https://lore.kernel.org/linux-hardening/20211209043456.1377875-1-keescook@chromium.org/
> https://lore.kernel.org/linux-hardening/20211209043915.1378393-1-keescook@chromium.org/
>

If GCC 12 rejects valid C with this feature enabled, the compiler is
broken and needs to be fixed. Papering over this by making changes to
perfectly valid C code is a slippery slope that we should avoid.

Since GCC 12 is not released yet, there is time to get this fixed properly.

> You're not obligated to integrate this commit,

Why, thank you :-)

> but you may run into this
> issue once
> upstream starts using GCC 12 (or a patched version of GCC 11 in my case)
> with the
> CONFIG_INIT_STACK_ALL_ZERO option enabled.
>

Yes, that part was perfectly clear.

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

* Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
@ 2022-02-10 19:29       ` Ard Biesheuvel
  0 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2022-02-10 19:29 UTC (permalink / raw)
  To: Victor Erminpour
  Cc: Lorenzo Pieralisi, Hanjun Guo, Sudeep Holla, Rafael J. Wysocki,
	Len Brown, ACPI Devel Maling List, Linux ARM,
	Linux Kernel Mailing List, trivial, Robin Murphy

(cc Kees)

On Thu, 10 Feb 2022 at 18:36, Victor Erminpour
<victor.erminpour@oracle.com> wrote:
>
>
> On 2/10/22 1:11 AM, Ard Biesheuvel wrote:
> > On Thu, 10 Feb 2022 at 01:34, Victor Erminpour
> > <victor.erminpour@oracle.com> wrote:
> >> When building with automatic stack variable initialization, GCC 12
> >> complains about variables defined outside of switch case statements.
> >> Move the variable into the case that uses it, which silences the warning:
> >>
> >> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
> >>    1670 |                         struct acpi_iort_named_component *ncomp;
> >>         |                                                           ^~~~~
> >>
> >> Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
> > GCC 12 is not released yet, and this is clearly a compiler bug (a
> > declaration is not a statement, and the hidden offending statement
> > [the zero-init] is emitted by the compiler itself), so please report
> > this to the GCC folks instead.
>
> Hi Ard,
>
> Thanks for the reply.
> This fix is similar to the following commits that have been integrated
> upstream:
> https://lore.kernel.org/linux-hardening/20211209043456.1377875-1-keescook@chromium.org/
> https://lore.kernel.org/linux-hardening/20211209043915.1378393-1-keescook@chromium.org/
>

If GCC 12 rejects valid C with this feature enabled, the compiler is
broken and needs to be fixed. Papering over this by making changes to
perfectly valid C code is a slippery slope that we should avoid.

Since GCC 12 is not released yet, there is time to get this fixed properly.

> You're not obligated to integrate this commit,

Why, thank you :-)

> but you may run into this
> issue once
> upstream starts using GCC 12 (or a patched version of GCC 11 in my case)
> with the
> CONFIG_INIT_STACK_ALL_ZERO option enabled.
>

Yes, that part was perfectly clear.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
  2022-02-10 19:29       ` Ard Biesheuvel
@ 2022-02-10 19:39         ` Ard Biesheuvel
  -1 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2022-02-10 19:39 UTC (permalink / raw)
  To: Victor Erminpour, Kees Cook
  Cc: Lorenzo Pieralisi, Hanjun Guo, Sudeep Holla, Rafael J. Wysocki,
	Len Brown, ACPI Devel Maling List, Linux ARM,
	Linux Kernel Mailing List, trivial, Robin Murphy

On Thu, 10 Feb 2022 at 20:29, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> (cc Kees)
>

... for real this time :-)

> On Thu, 10 Feb 2022 at 18:36, Victor Erminpour
> <victor.erminpour@oracle.com> wrote:
> >
> >
> > On 2/10/22 1:11 AM, Ard Biesheuvel wrote:
> > > On Thu, 10 Feb 2022 at 01:34, Victor Erminpour
> > > <victor.erminpour@oracle.com> wrote:
> > >> When building with automatic stack variable initialization, GCC 12
> > >> complains about variables defined outside of switch case statements.
> > >> Move the variable into the case that uses it, which silences the warning:
> > >>
> > >> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
> > >>    1670 |                         struct acpi_iort_named_component *ncomp;
> > >>         |                                                           ^~~~~
> > >>
> > >> Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
> > > GCC 12 is not released yet, and this is clearly a compiler bug (a
> > > declaration is not a statement, and the hidden offending statement
> > > [the zero-init] is emitted by the compiler itself), so please report
> > > this to the GCC folks instead.
> >
> > Hi Ard,
> >
> > Thanks for the reply.
> > This fix is similar to the following commits that have been integrated
> > upstream:
> > https://lore.kernel.org/linux-hardening/20211209043456.1377875-1-keescook@chromium.org/
> > https://lore.kernel.org/linux-hardening/20211209043915.1378393-1-keescook@chromium.org/
> >
>
> If GCC 12 rejects valid C with this feature enabled, the compiler is
> broken and needs to be fixed. Papering over this by making changes to
> perfectly valid C code is a slippery slope that we should avoid.
>
> Since GCC 12 is not released yet, there is time to get this fixed properly.
>
> > You're not obligated to integrate this commit,
>
> Why, thank you :-)
>
> > but you may run into this
> > issue once
> > upstream starts using GCC 12 (or a patched version of GCC 11 in my case)
> > with the
> > CONFIG_INIT_STACK_ALL_ZERO option enabled.
> >
>
> Yes, that part was perfectly clear.

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

* Re: [PATCH] ACPI/IORT: Fix GCC 12 warning
@ 2022-02-10 19:39         ` Ard Biesheuvel
  0 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2022-02-10 19:39 UTC (permalink / raw)
  To: Victor Erminpour, Kees Cook
  Cc: Lorenzo Pieralisi, Hanjun Guo, Sudeep Holla, Rafael J. Wysocki,
	Len Brown, ACPI Devel Maling List, Linux ARM,
	Linux Kernel Mailing List, trivial, Robin Murphy

On Thu, 10 Feb 2022 at 20:29, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> (cc Kees)
>

... for real this time :-)

> On Thu, 10 Feb 2022 at 18:36, Victor Erminpour
> <victor.erminpour@oracle.com> wrote:
> >
> >
> > On 2/10/22 1:11 AM, Ard Biesheuvel wrote:
> > > On Thu, 10 Feb 2022 at 01:34, Victor Erminpour
> > > <victor.erminpour@oracle.com> wrote:
> > >> When building with automatic stack variable initialization, GCC 12
> > >> complains about variables defined outside of switch case statements.
> > >> Move the variable into the case that uses it, which silences the warning:
> > >>
> > >> ./drivers/acpi/arm64/iort.c:1670:59: error: statement will never be executed [-Werror=switch-unreachable]
> > >>    1670 |                         struct acpi_iort_named_component *ncomp;
> > >>         |                                                           ^~~~~
> > >>
> > >> Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
> > > GCC 12 is not released yet, and this is clearly a compiler bug (a
> > > declaration is not a statement, and the hidden offending statement
> > > [the zero-init] is emitted by the compiler itself), so please report
> > > this to the GCC folks instead.
> >
> > Hi Ard,
> >
> > Thanks for the reply.
> > This fix is similar to the following commits that have been integrated
> > upstream:
> > https://lore.kernel.org/linux-hardening/20211209043456.1377875-1-keescook@chromium.org/
> > https://lore.kernel.org/linux-hardening/20211209043915.1378393-1-keescook@chromium.org/
> >
>
> If GCC 12 rejects valid C with this feature enabled, the compiler is
> broken and needs to be fixed. Papering over this by making changes to
> perfectly valid C code is a slippery slope that we should avoid.
>
> Since GCC 12 is not released yet, there is time to get this fixed properly.
>
> > You're not obligated to integrate this commit,
>
> Why, thank you :-)
>
> > but you may run into this
> > issue once
> > upstream starts using GCC 12 (or a patched version of GCC 11 in my case)
> > with the
> > CONFIG_INIT_STACK_ALL_ZERO option enabled.
> >
>
> Yes, that part was perfectly clear.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-02-10 19:41 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10  0:32 [PATCH] ACPI/IORT: Fix GCC 12 warning Victor Erminpour
2022-02-10  0:32 ` Victor Erminpour
2022-02-10  9:11 ` Ard Biesheuvel
2022-02-10  9:11   ` Ard Biesheuvel
2022-02-10 17:36   ` Victor Erminpour
2022-02-10 17:36     ` Victor Erminpour
2022-02-10 19:29     ` Ard Biesheuvel
2022-02-10 19:29       ` Ard Biesheuvel
2022-02-10 19:39       ` Ard Biesheuvel
2022-02-10 19:39         ` Ard Biesheuvel
2022-02-10 18:06 ` Robin Murphy
2022-02-10 18:06   ` Robin Murphy
2022-02-10 18:27   ` Victor Erminpour
2022-02-10 18:27     ` Victor Erminpour
2022-02-10 18:35     ` Robin Murphy
2022-02-10 18:35       ` Robin Murphy

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.