Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/1] arm64: CCA TSM module autoloading
@ 2024-12-03  0:01 Jeremy Linton
  2024-12-03  0:01 ` [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading Jeremy Linton
  0 siblings, 1 reply; 8+ messages in thread
From: Jeremy Linton @ 2024-12-03  0:01 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: gshan, steven.price, sami.mujawar, suzuki.poulose, will,
	catalin.marinas, linux-kernel, Jeremy Linton

The TSM module provides both guest identification as well as
attestation when a guest is run in CCA mode. Lets assure by creating a
dummy platform device that the module is automatically loaded during
boot.  The TSM module will be loaded by udev daemon after it receives
the device addition event. Once it is in place it can be used earlier
in the boot process to say decrypt a LUKS rootfs.

v1->v2:
	Various comment updates/variable renames
	Add missing __maybe_unused to the platform_device_id

Jeremy Linton (1):
  arm64: rsi: Add automatic arm-cca-guest module loading

 arch/arm64/include/asm/rsi.h                    |  2 ++
 arch/arm64/kernel/rsi.c                         | 15 +++++++++++++++
 drivers/virt/coco/arm-cca-guest/arm-cca-guest.c |  8 ++++++++
 3 files changed, 25 insertions(+)

-- 
2.46.0



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

* [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
  2024-12-03  0:01 [PATCH v2 0/1] arm64: CCA TSM module autoloading Jeremy Linton
@ 2024-12-03  0:01 ` Jeremy Linton
  2024-12-03  1:22   ` Gavin Shan
                     ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jeremy Linton @ 2024-12-03  0:01 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: gshan, steven.price, sami.mujawar, suzuki.poulose, will,
	catalin.marinas, linux-kernel, Jeremy Linton

The TSM module provides both guest identification as well as
attestation when a guest is run in CCA mode. Lets assure by creating a
dummy platform device that the module is automatically loaded during
boot.  The TSM module will be loaded by udev daemon after it receives
the device addition event. Once it is in place it can be used earlier
in the boot process to say decrypt a LUKS rootfs.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
---
 arch/arm64/include/asm/rsi.h                    |  2 ++
 arch/arm64/kernel/rsi.c                         | 15 +++++++++++++++
 drivers/virt/coco/arm-cca-guest/arm-cca-guest.c |  8 ++++++++
 3 files changed, 25 insertions(+)

diff --git a/arch/arm64/include/asm/rsi.h b/arch/arm64/include/asm/rsi.h
index 188cbb9b23f5..b42aeac05340 100644
--- a/arch/arm64/include/asm/rsi.h
+++ b/arch/arm64/include/asm/rsi.h
@@ -10,6 +10,8 @@
 #include <linux/jump_label.h>
 #include <asm/rsi_cmds.h>
 
+#define RSI_PDEV_NAME "arm-cca-dev"
+
 DECLARE_STATIC_KEY_FALSE(rsi_present);
 
 void __init arm64_rsi_init(void);
diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c
index 3031f25c32ef..5434e5496ac2 100644
--- a/arch/arm64/kernel/rsi.c
+++ b/arch/arm64/kernel/rsi.c
@@ -8,6 +8,7 @@
 #include <linux/psci.h>
 #include <linux/swiotlb.h>
 #include <linux/cc_platform.h>
+#include <linux/platform_device.h>
 
 #include <asm/io.h>
 #include <asm/mem_encrypt.h>
@@ -140,3 +141,17 @@ void __init arm64_rsi_init(void)
 	static_branch_enable(&rsi_present);
 }
 
+static struct platform_device rsi_dev = {
+	.name = RSI_PDEV_NAME,
+	.id = PLATFORM_DEVID_NONE
+};
+
+static int __init rsi_init(void)
+{
+	if (is_realm_world() &&
+	    platform_device_register(&rsi_dev))
+		pr_err("failed to register rsi platform device\n");
+	return 0;
+}
+
+arch_initcall(rsi_init)
diff --git a/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c b/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
index 488153879ec9..1f8d8439f617 100644
--- a/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
+++ b/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
@@ -6,6 +6,7 @@
 #include <linux/arm-smccc.h>
 #include <linux/cc_platform.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/smp.h>
 #include <linux/tsm.h>
@@ -219,6 +220,13 @@ static void __exit arm_cca_guest_exit(void)
 }
 module_exit(arm_cca_guest_exit);
 
+/* modalias, so userspace can autoload this module when RSI is available */
+static const struct __maybe_unused platform_device_id arm_cca_match[] = {
+	{ RSI_PDEV_NAME, 0},
+	{ }
+};
+
+MODULE_DEVICE_TABLE(platform, arm_cca_match);
 MODULE_AUTHOR("Sami Mujawar <sami.mujawar@arm.com>");
 MODULE_DESCRIPTION("Arm CCA Guest TSM Driver");
 MODULE_LICENSE("GPL");
-- 
2.46.0



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

* Re: [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
  2024-12-03  0:01 ` [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading Jeremy Linton
@ 2024-12-03  1:22   ` Gavin Shan
  2024-12-03  6:03   ` kernel test robot
  2024-12-03  6:16   ` kernel test robot
  2 siblings, 0 replies; 8+ messages in thread
From: Gavin Shan @ 2024-12-03  1:22 UTC (permalink / raw)
  To: Jeremy Linton, linux-arm-kernel
  Cc: steven.price, sami.mujawar, suzuki.poulose, will, catalin.marinas,
	linux-kernel

On 12/3/24 10:01 AM, Jeremy Linton wrote:
> The TSM module provides both guest identification as well as
> attestation when a guest is run in CCA mode. Lets assure by creating a
> dummy platform device that the module is automatically loaded during
> boot.  The TSM module will be loaded by udev daemon after it receives
> the device addition event. Once it is in place it can be used earlier
> in the boot process to say decrypt a LUKS rootfs.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
>   arch/arm64/include/asm/rsi.h                    |  2 ++
>   arch/arm64/kernel/rsi.c                         | 15 +++++++++++++++
>   drivers/virt/coco/arm-cca-guest/arm-cca-guest.c |  8 ++++++++
>   3 files changed, 25 insertions(+)
> 

Reviewed-by: Gavin Shan <gshan@redhat.com>



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

* Re: [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
  2024-12-03  0:01 ` [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading Jeremy Linton
  2024-12-03  1:22   ` Gavin Shan
@ 2024-12-03  6:03   ` kernel test robot
  2024-12-03  8:56     ` Gavin Shan
  2024-12-03  6:16   ` kernel test robot
  2 siblings, 1 reply; 8+ messages in thread
From: kernel test robot @ 2024-12-03  6:03 UTC (permalink / raw)
  To: Jeremy Linton, linux-arm-kernel
  Cc: llvm, oe-kbuild-all, gshan, steven.price, sami.mujawar,
	suzuki.poulose, will, catalin.marinas, linux-kernel,
	Jeremy Linton

Hi Jeremy,

kernel test robot noticed the following build warnings:

[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on linus/master v6.13-rc1 next-20241128]
[cannot apply to kvmarm/next soc/for-next arm/for-next arm/fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jeremy-Linton/arm64-rsi-Add-automatic-arm-cca-guest-module-loading/20241203-080347
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
patch link:    https://lore.kernel.org/r/20241203000156.72451-2-jeremy.linton%40arm.com
patch subject: [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
config: arm64-randconfig-004-20241203 (https://download.01.org/0day-ci/archive/20241203/202412031348.bp5i3ws2-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 592c0fe55f6d9a811028b5f3507be91458ab2713)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241203/202412031348.bp5i3ws2-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412031348.bp5i3ws2-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/virt/coco/arm-cca-guest/arm-cca-guest.c:224:21: warning: attribute declaration must precede definition [-Wignored-attributes]
     224 | static const struct __maybe_unused platform_device_id arm_cca_match[] = {
         |                     ^
   include/linux/compiler_attributes.h:356:56: note: expanded from macro '__maybe_unused'
     356 | #define __maybe_unused                  __attribute__((__unused__))
         |                                                        ^
   include/linux/mod_devicetable.h:607:8: note: previous definition is here
     607 | struct platform_device_id {
         |        ^
>> drivers/virt/coco/arm-cca-guest/arm-cca-guest.c:224:55: warning: unused variable 'arm_cca_match' [-Wunused-const-variable]
     224 | static const struct __maybe_unused platform_device_id arm_cca_match[] = {
         |                                                       ^~~~~~~~~~~~~
   2 warnings generated.


vim +224 drivers/virt/coco/arm-cca-guest/arm-cca-guest.c

   222	
   223	/* modalias, so userspace can autoload this module when RSI is available */
 > 224	static const struct __maybe_unused platform_device_id arm_cca_match[] = {
   225		{ RSI_PDEV_NAME, 0},
   226		{ }
   227	};
   228	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


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

* Re: [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
  2024-12-03  0:01 ` [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading Jeremy Linton
  2024-12-03  1:22   ` Gavin Shan
  2024-12-03  6:03   ` kernel test robot
@ 2024-12-03  6:16   ` kernel test robot
  2 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2024-12-03  6:16 UTC (permalink / raw)
  To: Jeremy Linton, linux-arm-kernel
  Cc: oe-kbuild-all, gshan, steven.price, sami.mujawar, suzuki.poulose,
	will, catalin.marinas, linux-kernel, Jeremy Linton

Hi Jeremy,

kernel test robot noticed the following build warnings:

[auto build test WARNING on arm64/for-next/core]
[also build test WARNING on linus/master v6.13-rc1 next-20241128]
[cannot apply to kvmarm/next soc/for-next arm/for-next arm/fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jeremy-Linton/arm64-rsi-Add-automatic-arm-cca-guest-module-loading/20241203-080347
base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
patch link:    https://lore.kernel.org/r/20241203000156.72451-2-jeremy.linton%40arm.com
patch subject: [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
config: arm64-randconfig-001-20241203 (https://download.01.org/0day-ci/archive/20241203/202412031328.ybzEAJ4U-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241203/202412031328.ybzEAJ4U-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412031328.ybzEAJ4U-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/virt/coco/arm-cca-guest/arm-cca-guest.c:224:55: warning: 'arm_cca_match' defined but not used [-Wunused-const-variable=]
     224 | static const struct __maybe_unused platform_device_id arm_cca_match[] = {
         |                                                       ^~~~~~~~~~~~~


vim +/arm_cca_match +224 drivers/virt/coco/arm-cca-guest/arm-cca-guest.c

   222	
   223	/* modalias, so userspace can autoload this module when RSI is available */
 > 224	static const struct __maybe_unused platform_device_id arm_cca_match[] = {
   225		{ RSI_PDEV_NAME, 0},
   226		{ }
   227	};
   228	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


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

* Re: [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
  2024-12-03  6:03   ` kernel test robot
@ 2024-12-03  8:56     ` Gavin Shan
  2024-12-03 15:30       ` Jeremy Linton
  0 siblings, 1 reply; 8+ messages in thread
From: Gavin Shan @ 2024-12-03  8:56 UTC (permalink / raw)
  To: kernel test robot, Jeremy Linton, linux-arm-kernel
  Cc: llvm, oe-kbuild-all, steven.price, sami.mujawar, suzuki.poulose,
	will, catalin.marinas, linux-kernel



On 12/3/24 4:03 PM, kernel test robot wrote:
> Hi Jeremy,
> 
> kernel test robot noticed the following build warnings:
> 
> [auto build test WARNING on arm64/for-next/core]
> [also build test WARNING on linus/master v6.13-rc1 next-20241128]
> [cannot apply to kvmarm/next soc/for-next arm/for-next arm/fixes]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Jeremy-Linton/arm64-rsi-Add-automatic-arm-cca-guest-module-loading/20241203-080347
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
> patch link:    https://lore.kernel.org/r/20241203000156.72451-2-jeremy.linton%40arm.com
> patch subject: [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
> config: arm64-randconfig-004-20241203 (https://download.01.org/0day-ci/archive/20241203/202412031348.bp5i3ws2-lkp@intel.com/config)
> compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 592c0fe55f6d9a811028b5f3507be91458ab2713)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241203/202412031348.bp5i3ws2-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202412031348.bp5i3ws2-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>>> drivers/virt/coco/arm-cca-guest/arm-cca-guest.c:224:21: warning: attribute declaration must precede definition [-Wignored-attributes]
>       224 | static const struct __maybe_unused platform_device_id arm_cca_match[] = {
>           |                     ^
>     include/linux/compiler_attributes.h:356:56: note: expanded from macro '__maybe_unused'
>       356 | #define __maybe_unused                  __attribute__((__unused__))
>           |                                                        ^
>     include/linux/mod_devicetable.h:607:8: note: previous definition is here
>       607 | struct platform_device_id {
>           |        ^
>>> drivers/virt/coco/arm-cca-guest/arm-cca-guest.c:224:55: warning: unused variable 'arm_cca_match' [-Wunused-const-variable]
>       224 | static const struct __maybe_unused platform_device_id arm_cca_match[] = {
>           |                                                       ^~~~~~~~~~~~~
>     2 warnings generated.
> 
> 
> vim +224 drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
> 
>     222	
>     223	/* modalias, so userspace can autoload this module when RSI is available */
>   > 224	static const struct __maybe_unused platform_device_id arm_cca_match[] = {
>     225		{ RSI_PDEV_NAME, 0},
>     226		{ }
>     227	};
>     228	
> 

The definition may have to be something like below, to avoid the compiling warning.

static const struct platform_device_id __maybe_unused arm_cca_match[] = {
        ...
};

Thanks,
Gavin



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

* Re: [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
  2024-12-03  8:56     ` Gavin Shan
@ 2024-12-03 15:30       ` Jeremy Linton
  2024-12-05  2:08         ` Gavin Shan
  0 siblings, 1 reply; 8+ messages in thread
From: Jeremy Linton @ 2024-12-03 15:30 UTC (permalink / raw)
  To: Gavin Shan, kernel test robot, linux-arm-kernel
  Cc: llvm, oe-kbuild-all, steven.price, sami.mujawar, suzuki.poulose,
	will, catalin.marinas, linux-kernel

On 12/3/24 2:56 AM, Gavin Shan wrote:
> 
> 
> On 12/3/24 4:03 PM, kernel test robot wrote:
>> Hi Jeremy,
>>
>> kernel test robot noticed the following build warnings:
>>
>> [auto build test WARNING on arm64/for-next/core]
>> [also build test WARNING on linus/master v6.13-rc1 next-20241128]
>> [cannot apply to kvmarm/next soc/for-next arm/for-next arm/fixes]
>> [If your patch is applied to the wrong git tree, kindly drop us a note.
>> And when submitting patch, we suggest to use '--base' as documented in
>> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>>
>> url:    https://github.com/intel-lab-lkp/linux/commits/Jeremy-Linton/ 
>> arm64-rsi-Add-automatic-arm-cca-guest-module-loading/20241203-080347
>> base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/ 
>> linux.git for-next/core
>> patch link:    https://lore.kernel.org/r/20241203000156.72451-2- 
>> jeremy.linton%40arm.com
>> patch subject: [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest 
>> module loading
>> config: arm64-randconfig-004-20241203 (https://download.01.org/0day- 
>> ci/archive/20241203/202412031348.bp5i3ws2-lkp@intel.com/config)
>> compiler: clang version 20.0.0git (https://github.com/llvm/llvm- 
>> project 592c0fe55f6d9a811028b5f3507be91458ab2713)
>> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/ 
>> archive/20241203/202412031348.bp5i3ws2-lkp@intel.com/reproduce)
>>
>> If you fix the issue in a separate patch/commit (i.e. not just a new 
>> version of
>> the same patch/commit), kindly add following tags
>> | Reported-by: kernel test robot <lkp@intel.com>
>> | Closes: https://lore.kernel.org/oe-kbuild-all/202412031348.bp5i3ws2- 
>> lkp@intel.com/
>>
>> All warnings (new ones prefixed by >>):
>>
>>>> drivers/virt/coco/arm-cca-guest/arm-cca-guest.c:224:21: warning: 
>>>> attribute declaration must precede definition [-Wignored-attributes]
>>       224 | static const struct __maybe_unused platform_device_id 
>> arm_cca_match[] = {
>>           |                     ^
>>     include/linux/compiler_attributes.h:356:56: note: expanded from 
>> macro '__maybe_unused'
>>       356 | #define __maybe_unused                  
>> __attribute__((__unused__))
>>           |                                                        ^
>>     include/linux/mod_devicetable.h:607:8: note: previous definition 
>> is here
>>       607 | struct platform_device_id {
>>           |        ^
>>>> drivers/virt/coco/arm-cca-guest/arm-cca-guest.c:224:55: warning: 
>>>> unused variable 'arm_cca_match' [-Wunused-const-variable]
>>       224 | static const struct __maybe_unused platform_device_id 
>> arm_cca_match[] = {
>>           |                                                       
>> ^~~~~~~~~~~~~
>>     2 warnings generated.
>>
>>
>> vim +224 drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
>>
>>     222
>>     223    /* modalias, so userspace can autoload this module when RSI 
>> is available */
>>   > 224    static const struct __maybe_unused platform_device_id 
>> arm_cca_match[] = {
>>     225        { RSI_PDEV_NAME, 0},
>>     226        { }
>>     227    };
>>     228
>>
> 
> The definition may have to be something like below, to avoid the 
> compiling warning.
> 
> static const struct platform_device_id __maybe_unused arm_cca_match[] = {

I should have tested this with clang rather than copy/pasting the 
utilization from somewhere else! It looks like a number of other kernel 
users are putting it before the '=', but its sorta annoying because it 
seems like the kind of warning that should be suppressed globally for 
this case (module device description in module that can be built in).



>         ...
> };
> 
> Thanks,
> Gavin
> 



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

* Re: [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
  2024-12-03 15:30       ` Jeremy Linton
@ 2024-12-05  2:08         ` Gavin Shan
  0 siblings, 0 replies; 8+ messages in thread
From: Gavin Shan @ 2024-12-05  2:08 UTC (permalink / raw)
  To: Jeremy Linton, kernel test robot, linux-arm-kernel
  Cc: llvm, oe-kbuild-all, steven.price, sami.mujawar, suzuki.poulose,
	will, catalin.marinas, linux-kernel


On 12/4/24 1:30 AM, Jeremy Linton wrote:
> On 12/3/24 2:56 AM, Gavin Shan wrote:
>> On 12/3/24 4:03 PM, kernel test robot wrote:
>>> Hi Jeremy,
>>>
>>> kernel test robot noticed the following build warnings:
>>>
>>> [auto build test WARNING on arm64/for-next/core]
>>> [also build test WARNING on linus/master v6.13-rc1 next-20241128]
>>> [cannot apply to kvmarm/next soc/for-next arm/for-next arm/fixes]
>>> [If your patch is applied to the wrong git tree, kindly drop us a note.
>>> And when submitting patch, we suggest to use '--base' as documented in
>>> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>>>
>>> url:    https://github.com/intel-lab-lkp/linux/commits/Jeremy-Linton/ arm64-rsi-Add-automatic-arm-cca-guest-module-loading/20241203-080347
>>> base:   https://git.kernel.org/pub/scm/linux/kernel/git/arm64/ linux.git for-next/core
>>> patch link:    https://lore.kernel.org/r/20241203000156.72451-2- jeremy.linton%40arm.com
>>> patch subject: [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
>>> config: arm64-randconfig-004-20241203 (https://download.01.org/0day- ci/archive/20241203/202412031348.bp5i3ws2-lkp@intel.com/config)
>>> compiler: clang version 20.0.0git (https://github.com/llvm/llvm- project 592c0fe55f6d9a811028b5f3507be91458ab2713)
>>> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/ archive/20241203/202412031348.bp5i3ws2-lkp@intel.com/reproduce)
>>>
>>> If you fix the issue in a separate patch/commit (i.e. not just a new version of
>>> the same patch/commit), kindly add following tags
>>> | Reported-by: kernel test robot <lkp@intel.com>
>>> | Closes: https://lore.kernel.org/oe-kbuild-all/202412031348.bp5i3ws2- lkp@intel.com/
>>>
>>> All warnings (new ones prefixed by >>):
>>>
>>>>> drivers/virt/coco/arm-cca-guest/arm-cca-guest.c:224:21: warning: attribute declaration must precede definition [-Wignored-attributes]
>>>       224 | static const struct __maybe_unused platform_device_id arm_cca_match[] = {
>>>           |                     ^
>>>     include/linux/compiler_attributes.h:356:56: note: expanded from macro '__maybe_unused'
>>>       356 | #define __maybe_unused __attribute__((__unused__))
>>>           |                                                        ^
>>>     include/linux/mod_devicetable.h:607:8: note: previous definition is here
>>>       607 | struct platform_device_id {
>>>           |        ^
>>>>> drivers/virt/coco/arm-cca-guest/arm-cca-guest.c:224:55: warning: unused variable 'arm_cca_match' [-Wunused-const-variable]
>>>       224 | static const struct __maybe_unused platform_device_id arm_cca_match[] = {
>>>           | ^~~~~~~~~~~~~
>>>     2 warnings generated.
>>>
>>>
>>> vim +224 drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
>>>
>>>     222
>>>     223    /* modalias, so userspace can autoload this module when RSI is available */
>>>   > 224    static const struct __maybe_unused platform_device_id arm_cca_match[] = {
>>>     225        { RSI_PDEV_NAME, 0},
>>>     226        { }
>>>     227    };
>>>     228
>>>
>>
>> The definition may have to be something like below, to avoid the compiling warning.
>>
>> static const struct platform_device_id __maybe_unused arm_cca_match[] = {
> 
> I should have tested this with clang rather than copy/pasting the utilization from somewhere else! It looks like a number of other kernel users are putting it before the '=', but its sorta annoying because it seems like the kind of warning that should be suppressed globally for this case (module device description in module that can be built in).
> 
> 

I think it also work by putting '__maybe_unused' before '='. It's also my personaly preferred style.
However, I don't see how the pattern 'struct __maybe_unused platform_device_id arm_cca_match[]' can
work because the affective scope of '__maybe_unused' is ambiguous to the compiler: 'struct platform_device_id'
or 'arm_cca_match[]'.

> 
>>         ...
>> };
>>

Thanks,
Gavin




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

end of thread, other threads:[~2024-12-05  2:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03  0:01 [PATCH v2 0/1] arm64: CCA TSM module autoloading Jeremy Linton
2024-12-03  0:01 ` [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading Jeremy Linton
2024-12-03  1:22   ` Gavin Shan
2024-12-03  6:03   ` kernel test robot
2024-12-03  8:56     ` Gavin Shan
2024-12-03 15:30       ` Jeremy Linton
2024-12-05  2:08         ` Gavin Shan
2024-12-03  6:16   ` kernel test robot

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