arm64: armv8_deprecated: fix unused-function error

Message ID 20221122032010.202956-1-renzhijie2@huawei.com
State New
Headers
Series arm64: armv8_deprecated: fix unused-function error |

Commit Message

Ren Zhijie Nov. 22, 2022, 3:20 a.m. UTC
  If CONFIG_SWP_EMULATION is not set and
CONFIG_CP15_BARRIER_EMULATION is not set,
aarch64-linux-gnu complained about unused-function :

arch/arm64/kernel/armv8_deprecated.c:67:21: error: ‘aarch32_check_condition’ defined but not used [-Werror=unused-function]
 static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
                     ^~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

To fix this error, warp the definition of
aarch32_check_condition() by defined(CONFIG_SWP_EMULATION) ||
defined(CONFIG_CP15_BARRIER_EMULATION)

Fixes: 0c5f416219da ("arm64: armv8_deprecated: move aarch32 helper earlier")
Signed-off-by: Ren Zhijie <renzhijie2@huawei.com>
---
 arch/arm64/kernel/armv8_deprecated.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Mark Rutland Nov. 22, 2022, 4:48 p.m. UTC | #1
On Tue, Nov 22, 2022 at 03:20:10AM +0000, Ren Zhijie wrote:
> If CONFIG_SWP_EMULATION is not set and
> CONFIG_CP15_BARRIER_EMULATION is not set,
> aarch64-linux-gnu complained about unused-function :
> 
> arch/arm64/kernel/armv8_deprecated.c:67:21: error: ‘aarch32_check_condition’ defined but not used [-Werror=unused-function]
>  static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
>                      ^~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> 
> To fix this error, warp the definition of
> aarch32_check_condition() by defined(CONFIG_SWP_EMULATION) ||
> defined(CONFIG_CP15_BARRIER_EMULATION)
> 
> Fixes: 0c5f416219da ("arm64: armv8_deprecated: move aarch32 helper earlier")

This also depends on building with additional options to turn warnings into
errors, no?

> Signed-off-by: Ren Zhijie <renzhijie2@huawei.com>
> ---
>  arch/arm64/kernel/armv8_deprecated.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
> index ed0788cf6bbb..3f29ceb6653a 100644
> --- a/arch/arm64/kernel/armv8_deprecated.c
> +++ b/arch/arm64/kernel/armv8_deprecated.c
> @@ -64,6 +64,7 @@ struct insn_emulation {
>  
>  #define	ARM_OPCODE_CONDITION_UNCOND	0xf
>  
> +#if defined(CONFIG_SWP_EMULATION) || defined(CONFIG_CP15_BARRIER_EMULATION)
>  static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
>  {
>  	u32 cc_bits  = opcode >> 28;
> @@ -76,6 +77,7 @@ static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
>  	}
>  	return ARM_OPCODE_CONDTEST_UNCOND;
>  }
> +#endif

Could we mark this as '__maybe_unused' or 'inline' instead? I think that's
preferable to the ifdeferry.

Thanks,
Mark.

>  
>  #ifdef CONFIG_SWP_EMULATION
>  /*
> -- 
> 2.17.1
>
  
Ren Zhijie Nov. 23, 2022, 2:06 a.m. UTC | #2
在 2022/11/23 0:48, Mark Rutland 写道:
> On Tue, Nov 22, 2022 at 03:20:10AM +0000, Ren Zhijie wrote:
>> If CONFIG_SWP_EMULATION is not set and
>> CONFIG_CP15_BARRIER_EMULATION is not set,
>> aarch64-linux-gnu complained about unused-function :
>>
>> arch/arm64/kernel/armv8_deprecated.c:67:21: error: ‘aarch32_check_condition’ defined but not used [-Werror=unused-function]
>>   static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
>>                       ^~~~~~~~~~~~~~~~~~~~~~~
>> cc1: all warnings being treated as errors
>>
>> To fix this error, warp the definition of
>> aarch32_check_condition() by defined(CONFIG_SWP_EMULATION) ||
>> defined(CONFIG_CP15_BARRIER_EMULATION)
>>
>> Fixes: 0c5f416219da ("arm64: armv8_deprecated: move aarch32 helper earlier")
> This also depends on building with additional options to turn warnings into
> errors, no?

No,i just run the normal command as follow:

make ARCH="arm64" CROSS_COMPILE="aarch64-linux-gnu-"

>> Signed-off-by: Ren Zhijie <renzhijie2@huawei.com>
>> ---
>>   arch/arm64/kernel/armv8_deprecated.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
>> index ed0788cf6bbb..3f29ceb6653a 100644
>> --- a/arch/arm64/kernel/armv8_deprecated.c
>> +++ b/arch/arm64/kernel/armv8_deprecated.c
>> @@ -64,6 +64,7 @@ struct insn_emulation {
>>   
>>   #define	ARM_OPCODE_CONDITION_UNCOND	0xf
>>   
>> +#if defined(CONFIG_SWP_EMULATION) || defined(CONFIG_CP15_BARRIER_EMULATION)
>>   static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
>>   {
>>   	u32 cc_bits  = opcode >> 28;
>> @@ -76,6 +77,7 @@ static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
>>   	}
>>   	return ARM_OPCODE_CONDTEST_UNCOND;
>>   }
>> +#endif
> Could we mark this as '__maybe_unused' or 'inline' instead? I think that's
> preferable to the ifdeferry.

sure, i will use __maybe_unused in v2.

Thanks,

Ren.

> Thanks,
> Mark.
>
>>   
>>   #ifdef CONFIG_SWP_EMULATION
>>   /*
>> -- 
>> 2.17.1
>>
> .
  
Mark Rutland Nov. 23, 2022, 11:01 a.m. UTC | #3
On Wed, Nov 23, 2022 at 10:06:03AM +0800, Ren Zhijie wrote:
> 
> 在 2022/11/23 0:48, Mark Rutland 写道:
> > On Tue, Nov 22, 2022 at 03:20:10AM +0000, Ren Zhijie wrote:
> > > If CONFIG_SWP_EMULATION is not set and
> > > CONFIG_CP15_BARRIER_EMULATION is not set,
> > > aarch64-linux-gnu complained about unused-function :
> > > 
> > > arch/arm64/kernel/armv8_deprecated.c:67:21: error: ‘aarch32_check_condition’ defined but not used [-Werror=unused-function]
> > >   static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
> > >                       ^~~~~~~~~~~~~~~~~~~~~~~
> > > cc1: all warnings being treated as errors
> > > 
> > > To fix this error, warp the definition of
> > > aarch32_check_condition() by defined(CONFIG_SWP_EMULATION) ||
> > > defined(CONFIG_CP15_BARRIER_EMULATION)
> > > 
> > > Fixes: 0c5f416219da ("arm64: armv8_deprecated: move aarch32 helper earlier")
> > This also depends on building with additional options to turn warnings into
> > errors, no?
> 
> No,i just run the normal command as follow:
> 
> make ARCH="arm64" CROSS_COMPILE="aarch64-linux-gnu-"

I think you must also have CONFIG_WERROR enabled?

Just building defconfig + CONFIG_ARMV8_DEPRECATED=y gives me a warning, but not
an error, and the kernel builds just fine.

So this is a problem to fix, and I appreciate that in test configs this might
be broken, but it's not a full build-time failure for most users.

Thanks,
Mark.

> > > Signed-off-by: Ren Zhijie <renzhijie2@huawei.com>
> > > ---
> > >   arch/arm64/kernel/armv8_deprecated.c | 2 ++
> > >   1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
> > > index ed0788cf6bbb..3f29ceb6653a 100644
> > > --- a/arch/arm64/kernel/armv8_deprecated.c
> > > +++ b/arch/arm64/kernel/armv8_deprecated.c
> > > @@ -64,6 +64,7 @@ struct insn_emulation {
> > >   #define	ARM_OPCODE_CONDITION_UNCOND	0xf
> > > +#if defined(CONFIG_SWP_EMULATION) || defined(CONFIG_CP15_BARRIER_EMULATION)
> > >   static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
> > >   {
> > >   	u32 cc_bits  = opcode >> 28;
> > > @@ -76,6 +77,7 @@ static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
> > >   	}
> > >   	return ARM_OPCODE_CONDTEST_UNCOND;
> > >   }
> > > +#endif
> > Could we mark this as '__maybe_unused' or 'inline' instead? I think that's
> > preferable to the ifdeferry.
> 
> sure, i will use __maybe_unused in v2.
> 
> Thanks,
> 
> Ren.
> 
> > Thanks,
> > Mark.
> > 
> > >   #ifdef CONFIG_SWP_EMULATION
> > >   /*
> > > -- 
> > > 2.17.1
> > > 
> > .
  
Ren Zhijie Nov. 24, 2022, 2:17 a.m. UTC | #4
在 2022/11/23 19:01, Mark Rutland 写道:
> On Wed, Nov 23, 2022 at 10:06:03AM +0800, Ren Zhijie wrote:
>> 在 2022/11/23 0:48, Mark Rutland 写道:
>>> On Tue, Nov 22, 2022 at 03:20:10AM +0000, Ren Zhijie wrote:
>>>> If CONFIG_SWP_EMULATION is not set and
>>>> CONFIG_CP15_BARRIER_EMULATION is not set,
>>>> aarch64-linux-gnu complained about unused-function :
>>>>
>>>> arch/arm64/kernel/armv8_deprecated.c:67:21: error: ‘aarch32_check_condition’ defined but not used [-Werror=unused-function]
>>>>    static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
>>>>                        ^~~~~~~~~~~~~~~~~~~~~~~
>>>> cc1: all warnings being treated as errors
>>>>
>>>> To fix this error, warp the definition of
>>>> aarch32_check_condition() by defined(CONFIG_SWP_EMULATION) ||
>>>> defined(CONFIG_CP15_BARRIER_EMULATION)
>>>>
>>>> Fixes: 0c5f416219da ("arm64: armv8_deprecated: move aarch32 helper earlier")
>>> This also depends on building with additional options to turn warnings into
>>> errors, no?
>> No,i just run the normal command as follow:
>>
>> make ARCH="arm64" CROSS_COMPILE="aarch64-linux-gnu-"
> I think you must also have CONFIG_WERROR enabled?
>
> Just building defconfig + CONFIG_ARMV8_DEPRECATED=y gives me a warning, but not
> an error, and the kernel builds just fine.
>
> So this is a problem to fix, and I appreciate that in test configs this might
> be broken, but it's not a full build-time failure for most users.

I get it, thanks a lot!

Thanks,

Ren

> Thanks,
> Mark.
>
>>>> Signed-off-by: Ren Zhijie <renzhijie2@huawei.com>
>>>> ---
>>>>    arch/arm64/kernel/armv8_deprecated.c | 2 ++
>>>>    1 file changed, 2 insertions(+)
>>>>
>>>> diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
>>>> index ed0788cf6bbb..3f29ceb6653a 100644
>>>> --- a/arch/arm64/kernel/armv8_deprecated.c
>>>> +++ b/arch/arm64/kernel/armv8_deprecated.c
>>>> @@ -64,6 +64,7 @@ struct insn_emulation {
>>>>    #define	ARM_OPCODE_CONDITION_UNCOND	0xf
>>>> +#if defined(CONFIG_SWP_EMULATION) || defined(CONFIG_CP15_BARRIER_EMULATION)
>>>>    static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
>>>>    {
>>>>    	u32 cc_bits  = opcode >> 28;
>>>> @@ -76,6 +77,7 @@ static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
>>>>    	}
>>>>    	return ARM_OPCODE_CONDTEST_UNCOND;
>>>>    }
>>>> +#endif
>>> Could we mark this as '__maybe_unused' or 'inline' instead? I think that's
>>> preferable to the ifdeferry.
>> sure, i will use __maybe_unused in v2.
>>
>> Thanks,
>>
>> Ren.
>>
>>> Thanks,
>>> Mark.
>>>
>>>>    #ifdef CONFIG_SWP_EMULATION
>>>>    /*
>>>> -- 
>>>> 2.17.1
>>>>
>>> .
> .
  

Patch

diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
index ed0788cf6bbb..3f29ceb6653a 100644
--- a/arch/arm64/kernel/armv8_deprecated.c
+++ b/arch/arm64/kernel/armv8_deprecated.c
@@ -64,6 +64,7 @@  struct insn_emulation {
 
 #define	ARM_OPCODE_CONDITION_UNCOND	0xf
 
+#if defined(CONFIG_SWP_EMULATION) || defined(CONFIG_CP15_BARRIER_EMULATION)
 static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
 {
 	u32 cc_bits  = opcode >> 28;
@@ -76,6 +77,7 @@  static unsigned int aarch32_check_condition(u32 opcode, u32 psr)
 	}
 	return ARM_OPCODE_CONDTEST_UNCOND;
 }
+#endif
 
 #ifdef CONFIG_SWP_EMULATION
 /*