mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] RISC-V: Add braces around an empty if statement bodies
@ 2022-04-19 19:48 Palmer Dabbelt
  2022-04-19 20:38 ` Randy Dunlap
  0 siblings, 1 reply; 3+ messages in thread
From: Palmer Dabbelt @ 2022-04-19 19:48 UTC (permalink / raw)
  To: panqinglin2020
  Cc: Paul Walmsley, Palmer Dabbelt, aou, alexandre.ghiti, jszhang,
	wangkefeng.wang, mick, vitaly.wool, rppt, linux-riscv,
	linux-kernel, Palmer Dabbelt, kernel test robot

From: Palmer Dabbelt <palmer@rivosinc.com>

This triggers -Wempty-body, which will cause the next statement (eventually
create_pmd_mapping) to be dropped.  Both of these were introduced by the same
commit.  This is safe for the reporting config (which is 32-bit), but IIUC
could result in breakages for 64-bit configs without 4/5 level paging like the
XIP configs.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: 677b9eb8810e ("riscv: mm: Prepare pt_ops helper functions for sv57")
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
---
Might be better to define these to functions that are empty, but that's
slightly different than just fixing the commit/warning in question.
---
 arch/riscv/mm/init.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 9535bea8688c..637916857c4d 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -798,13 +798,15 @@ static void __init create_fdt_early_page_table(pgd_t *pgdir, uintptr_t dtb_pa)
 			   PGDIR_SIZE,
 			   IS_ENABLED(CONFIG_64BIT) ? PAGE_TABLE : PAGE_KERNEL);
 
-	if (pgtable_l5_enabled)
+	if (pgtable_l5_enabled) {
 		create_p4d_mapping(early_dtb_p4d, DTB_EARLY_BASE_VA,
 				   (uintptr_t)early_dtb_pud, P4D_SIZE, PAGE_TABLE);
+	}
 
-	if (pgtable_l4_enabled)
+	if (pgtable_l4_enabled) {
 		create_pud_mapping(early_dtb_pud, DTB_EARLY_BASE_VA,
 				   (uintptr_t)early_dtb_pmd, PUD_SIZE, PAGE_TABLE);
+	}
 
 	if (IS_ENABLED(CONFIG_64BIT)) {
 		create_pmd_mapping(early_dtb_pmd, DTB_EARLY_BASE_VA,
-- 
2.34.1


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

* Re: [PATCH v1] RISC-V: Add braces around an empty if statement bodies
  2022-04-19 19:48 [PATCH v1] RISC-V: Add braces around an empty if statement bodies Palmer Dabbelt
@ 2022-04-19 20:38 ` Randy Dunlap
  2022-04-20 18:49   ` Palmer Dabbelt
  0 siblings, 1 reply; 3+ messages in thread
From: Randy Dunlap @ 2022-04-19 20:38 UTC (permalink / raw)
  To: Palmer Dabbelt, panqinglin2020
  Cc: Paul Walmsley, Palmer Dabbelt, aou, alexandre.ghiti, jszhang,
	wangkefeng.wang, mick, vitaly.wool, rppt, linux-riscv,
	linux-kernel, kernel test robot

Hi,

On 4/19/22 12:48, Palmer Dabbelt wrote:
> From: Palmer Dabbelt <palmer@rivosinc.com>
> 
> This triggers -Wempty-body, which will cause the next statement (eventually
> create_pmd_mapping) to be dropped.  Both of these were introduced by the same
> commit.  This is safe for the reporting config (which is 32-bit), but IIUC
> could result in breakages for 64-bit configs without 4/5 level paging like the
> XIP configs.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: 677b9eb8810e ("riscv: mm: Prepare pt_ops helper functions for sv57")
> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
> ---
> Might be better to define these to functions that are empty, but that's
> slightly different than just fixing the commit/warning in question.

Yes, we usually fix this type of problem by changing these to have empty bodies:

#else
...
#define create_pud_mapping(__pmdp, __va, __pa, __sz, __prot)
#define create_pmd_mapping(__pmdp, __va, __pa, __sz, __prot)
#endif /* __PAGETABLE_PMD_FOLDED */

etc.

> ---
>  arch/riscv/mm/init.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 9535bea8688c..637916857c4d 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -798,13 +798,15 @@ static void __init create_fdt_early_page_table(pgd_t *pgdir, uintptr_t dtb_pa)
>  			   PGDIR_SIZE,
>  			   IS_ENABLED(CONFIG_64BIT) ? PAGE_TABLE : PAGE_KERNEL);
>  
> -	if (pgtable_l5_enabled)
> +	if (pgtable_l5_enabled) {
>  		create_p4d_mapping(early_dtb_p4d, DTB_EARLY_BASE_VA,
>  				   (uintptr_t)early_dtb_pud, P4D_SIZE, PAGE_TABLE);
> +	}
>  
> -	if (pgtable_l4_enabled)
> +	if (pgtable_l4_enabled) {
>  		create_pud_mapping(early_dtb_pud, DTB_EARLY_BASE_VA,
>  				   (uintptr_t)early_dtb_pmd, PUD_SIZE, PAGE_TABLE);
> +	}
>  
>  	if (IS_ENABLED(CONFIG_64BIT)) {
>  		create_pmd_mapping(early_dtb_pmd, DTB_EARLY_BASE_VA,

-- 
~Randy

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

* Re: [PATCH v1] RISC-V: Add braces around an empty if statement bodies
  2022-04-19 20:38 ` Randy Dunlap
@ 2022-04-20 18:49   ` Palmer Dabbelt
  0 siblings, 0 replies; 3+ messages in thread
From: Palmer Dabbelt @ 2022-04-20 18:49 UTC (permalink / raw)
  To: rdunlap
  Cc: panqinglin2020, Paul Walmsley, aou, alexandre.ghiti, jszhang,
	wangkefeng.wang, mick, vitaly.wool, rppt, linux-riscv,
	linux-kernel, lkp

On Tue, 19 Apr 2022 13:38:42 PDT (-0700), rdunlap@infradead.org wrote:
> Hi,
>
> On 4/19/22 12:48, Palmer Dabbelt wrote:
>> From: Palmer Dabbelt <palmer@rivosinc.com>
>>
>> This triggers -Wempty-body, which will cause the next statement (eventually
>> create_pmd_mapping) to be dropped.  Both of these were introduced by the same
>> commit.  This is safe for the reporting config (which is 32-bit), but IIUC
>> could result in breakages for 64-bit configs without 4/5 level paging like the
>> XIP configs.
>>
>> Reported-by: kernel test robot <lkp@intel.com>
>> Fixes: 677b9eb8810e ("riscv: mm: Prepare pt_ops helper functions for sv57")
>> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
>> ---
>> Might be better to define these to functions that are empty, but that's
>> slightly different than just fixing the commit/warning in question.
>
> Yes, we usually fix this type of problem by changing these to have empty bodies:
>
> #else
> ...
> #define create_pud_mapping(__pmdp, __va, __pa, __sz, __prot)
> #define create_pmd_mapping(__pmdp, __va, __pa, __sz, __prot)
> #endif /* __PAGETABLE_PMD_FOLDED */
>
> etc.

Ya, that's the right way to do it -- not sure why I was being lazy here.  
Turns out there was a bunch of other XIP breakage, I sent a v2 that's a 
whole series.

Thanks!

>
>> ---
>>  arch/riscv/mm/init.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
>> index 9535bea8688c..637916857c4d 100644
>> --- a/arch/riscv/mm/init.c
>> +++ b/arch/riscv/mm/init.c
>> @@ -798,13 +798,15 @@ static void __init create_fdt_early_page_table(pgd_t *pgdir, uintptr_t dtb_pa)
>>  			   PGDIR_SIZE,
>>  			   IS_ENABLED(CONFIG_64BIT) ? PAGE_TABLE : PAGE_KERNEL);
>>
>> -	if (pgtable_l5_enabled)
>> +	if (pgtable_l5_enabled) {
>>  		create_p4d_mapping(early_dtb_p4d, DTB_EARLY_BASE_VA,
>>  				   (uintptr_t)early_dtb_pud, P4D_SIZE, PAGE_TABLE);
>> +	}
>>
>> -	if (pgtable_l4_enabled)
>> +	if (pgtable_l4_enabled) {
>>  		create_pud_mapping(early_dtb_pud, DTB_EARLY_BASE_VA,
>>  				   (uintptr_t)early_dtb_pmd, PUD_SIZE, PAGE_TABLE);
>> +	}
>>
>>  	if (IS_ENABLED(CONFIG_64BIT)) {
>>  		create_pmd_mapping(early_dtb_pmd, DTB_EARLY_BASE_VA,

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

end of thread, other threads:[~2022-04-20 18:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 19:48 [PATCH v1] RISC-V: Add braces around an empty if statement bodies Palmer Dabbelt
2022-04-19 20:38 ` Randy Dunlap
2022-04-20 18:49   ` Palmer Dabbelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®