diff mbox series

[v4,2/4] arch/x86: Move internal setup_data structures into setup_data.h

Message ID 20240108095903.8427-3-tzimmermann@suse.de (mailing list archive)
State Handled Elsewhere
Headers show
Series arch/x86: Remove unnecessary dependencies on bootparam.h | expand

Commit Message

Thomas Zimmermann Jan. 8, 2024, 9:57 a.m. UTC
The type definition of struct pci_setup_rom in <asm/pci.h> requires
struct setup_data from <asm/bootparam.h>. Many drivers include
<linux/pci.h>, but do not use boot parameters. Changes to bootparam.h
or its included header files could easily trigger a large, unnecessary
rebuild of the kernel.

Moving struct pci_setup_rom into its own header file avoids including
<asm/bootparam.h> in <asm/pci.h>. Moving struct_efi_setup_data allows
to unify duplicated definition of the data structure in a single place.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 arch/x86/boot/compressed/efi.h    |  9 ---------
 arch/x86/include/asm/efi.h        |  9 ---------
 arch/x86/include/asm/pci.h        | 13 -------------
 arch/x86/include/asm/setup_data.h | 32 +++++++++++++++++++++++++++++++
 4 files changed, 32 insertions(+), 31 deletions(-)
 create mode 100644 arch/x86/include/asm/setup_data.h

Comments

kernel test robot Jan. 9, 2024, 12:28 a.m. UTC | #1
Hi Thomas,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/x86/core]
[also build test WARNING on efi/next tip/master tip/auto-latest linus/master v6.7 next-20240108]
[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/Thomas-Zimmermann/arch-x86-Move-UAPI-setup-structures-into-setup_data-h/20240108-180158
base:   tip/x86/core
patch link:    https://lore.kernel.org/r/20240108095903.8427-3-tzimmermann%40suse.de
patch subject: [PATCH v4 2/4] arch/x86: Move internal setup_data structures into setup_data.h
config: x86_64-rhel-8.3-bpf (https://download.01.org/0day-ci/archive/20240109/202401090800.UOBEKB3W-lkp@intel.com/config)
compiler: ClangBuiltLinux clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240109/202401090800.UOBEKB3W-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/202401090800.UOBEKB3W-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from arch/x86/realmode/rm/wakemain.c:3:
   In file included from arch/x86/boot/boot.h:24:
   In file included from arch/x86/include/asm/setup.h:10:
   In file included from arch/x86/include/asm/page_types.h:7:
   In file included from include/linux/mem_encrypt.h:17:
   In file included from arch/x86/include/asm/mem_encrypt.h:18:
   In file included from arch/x86/include/uapi/asm/bootparam.h:5:
>> arch/x86/include/asm/setup_data.h:10:20: warning: field 'data' with variable sized type 'struct setup_data' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
      10 |         struct setup_data data;
         |                           ^
   1 warning generated.


vim +10 arch/x86/include/asm/setup_data.h

     8	
     9	struct pci_setup_rom {
  > 10		struct setup_data data;
    11		uint16_t vendor;
    12		uint16_t devid;
    13		uint64_t pcilen;
    14		unsigned long segment;
    15		unsigned long bus;
    16		unsigned long device;
    17		unsigned long function;
    18		uint8_t romdata[];
    19	};
    20
Nathan Chancellor Jan. 9, 2024, 5:58 p.m. UTC | #2
On Tue, Jan 09, 2024 at 08:28:59AM +0800, kernel test robot wrote:
> Hi Thomas,
> 
> kernel test robot noticed the following build warnings:
> 
> [auto build test WARNING on tip/x86/core]
> [also build test WARNING on efi/next tip/master tip/auto-latest linus/master v6.7 next-20240108]
> [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/Thomas-Zimmermann/arch-x86-Move-UAPI-setup-structures-into-setup_data-h/20240108-180158
> base:   tip/x86/core
> patch link:    https://lore.kernel.org/r/20240108095903.8427-3-tzimmermann%40suse.de
> patch subject: [PATCH v4 2/4] arch/x86: Move internal setup_data structures into setup_data.h
> config: x86_64-rhel-8.3-bpf (https://download.01.org/0day-ci/archive/20240109/202401090800.UOBEKB3W-lkp@intel.com/config)
> compiler: ClangBuiltLinux clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240109/202401090800.UOBEKB3W-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/202401090800.UOBEKB3W-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>    In file included from arch/x86/realmode/rm/wakemain.c:3:
>    In file included from arch/x86/boot/boot.h:24:
>    In file included from arch/x86/include/asm/setup.h:10:
>    In file included from arch/x86/include/asm/page_types.h:7:
>    In file included from include/linux/mem_encrypt.h:17:
>    In file included from arch/x86/include/asm/mem_encrypt.h:18:
>    In file included from arch/x86/include/uapi/asm/bootparam.h:5:
> >> arch/x86/include/asm/setup_data.h:10:20: warning: field 'data' with variable sized type 'struct setup_data' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
>       10 |         struct setup_data data;
>          |                           ^
>    1 warning generated.

I think this warning is expected. This structure is now included in the
realmode part of arch/x86, which has its own set of build flags,
including -Wall, which includes -Wgnu on clang. The kernel obviously
uses GNU extensions and states this clearly with '-std=gnu11', so
-Wno-gnu is unconditionally added to KBUILD_CFLAGS for clang. It seems
that same treatment is needed for REALMODE_CFLAGS, which also matches
arch/x86/boot/compressed/Makefile, see commit 6c3b56b19730 ("x86/boot:
Disable Clang warnings about GNU extensions"):

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 1a068de12a56..24076db59783 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -53,6 +53,9 @@ REALMODE_CFLAGS += -fno-stack-protector
 REALMODE_CFLAGS += -Wno-address-of-packed-member
 REALMODE_CFLAGS += $(cc_stack_align4)
 REALMODE_CFLAGS += $(CLANG_FLAGS)
+ifdef CONFIG_CC_IS_CLANG
+REALMODE_CFLAGS += -Wno-gnu
+endif
 export REALMODE_CFLAGS
 
 # BITS is used as extension for files which are available in a 32 bit
Thomas Zimmermann Jan. 11, 2024, 9:50 a.m. UTC | #3
Hi

Am 09.01.24 um 18:58 schrieb Nathan Chancellor:
> On Tue, Jan 09, 2024 at 08:28:59AM +0800, kernel test robot wrote:
>> Hi Thomas,
>>
>> kernel test robot noticed the following build warnings:
>>
>> [auto build test WARNING on tip/x86/core]
>> [also build test WARNING on efi/next tip/master tip/auto-latest linus/master v6.7 next-20240108]
>> [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/Thomas-Zimmermann/arch-x86-Move-UAPI-setup-structures-into-setup_data-h/20240108-180158
>> base:   tip/x86/core
>> patch link:    https://lore.kernel.org/r/20240108095903.8427-3-tzimmermann%40suse.de
>> patch subject: [PATCH v4 2/4] arch/x86: Move internal setup_data structures into setup_data.h
>> config: x86_64-rhel-8.3-bpf (https://download.01.org/0day-ci/archive/20240109/202401090800.UOBEKB3W-lkp@intel.com/config)
>> compiler: ClangBuiltLinux clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
>> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240109/202401090800.UOBEKB3W-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/202401090800.UOBEKB3W-lkp@intel.com/
>>
>> All warnings (new ones prefixed by >>):
>>
>>     In file included from arch/x86/realmode/rm/wakemain.c:3:
>>     In file included from arch/x86/boot/boot.h:24:
>>     In file included from arch/x86/include/asm/setup.h:10:
>>     In file included from arch/x86/include/asm/page_types.h:7:
>>     In file included from include/linux/mem_encrypt.h:17:
>>     In file included from arch/x86/include/asm/mem_encrypt.h:18:
>>     In file included from arch/x86/include/uapi/asm/bootparam.h:5:
>>>> arch/x86/include/asm/setup_data.h:10:20: warning: field 'data' with variable sized type 'struct setup_data' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
>>        10 |         struct setup_data data;
>>           |                           ^
>>     1 warning generated.
> 
> I think this warning is expected. This structure is now included in the
> realmode part of arch/x86, which has its own set of build flags,
> including -Wall, which includes -Wgnu on clang. The kernel obviously
> uses GNU extensions and states this clearly with '-std=gnu11', so
> -Wno-gnu is unconditionally added to KBUILD_CFLAGS for clang. It seems
> that same treatment is needed for REALMODE_CFLAGS, which also matches
> arch/x86/boot/compressed/Makefile, see commit 6c3b56b19730 ("x86/boot:
> Disable Clang warnings about GNU extensions"):
> 
> diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> index 1a068de12a56..24076db59783 100644
> --- a/arch/x86/Makefile
> +++ b/arch/x86/Makefile
> @@ -53,6 +53,9 @@ REALMODE_CFLAGS += -fno-stack-protector
>   REALMODE_CFLAGS += -Wno-address-of-packed-member
>   REALMODE_CFLAGS += $(cc_stack_align4)
>   REALMODE_CFLAGS += $(CLANG_FLAGS)
> +ifdef CONFIG_CC_IS_CLANG
> +REALMODE_CFLAGS += -Wno-gnu
> +endif

Thanks. Shall I include this change in the patchset?

Best regards
Thomas

>   export REALMODE_CFLAGS
>   
>   # BITS is used as extension for files which are available in a 32 bit
Nathan Chancellor Jan. 11, 2024, 10:41 p.m. UTC | #4
On Thu, Jan 11, 2024 at 10:50:43AM +0100, Thomas Zimmermann wrote:
> Hi
> 
> Am 09.01.24 um 18:58 schrieb Nathan Chancellor:
> > On Tue, Jan 09, 2024 at 08:28:59AM +0800, kernel test robot wrote:
> > > Hi Thomas,
> > > 
> > > kernel test robot noticed the following build warnings:
> > > 
> > > [auto build test WARNING on tip/x86/core]
> > > [also build test WARNING on efi/next tip/master tip/auto-latest linus/master v6.7 next-20240108]
> > > [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/Thomas-Zimmermann/arch-x86-Move-UAPI-setup-structures-into-setup_data-h/20240108-180158
> > > base:   tip/x86/core
> > > patch link:    https://lore.kernel.org/r/20240108095903.8427-3-tzimmermann%40suse.de
> > > patch subject: [PATCH v4 2/4] arch/x86: Move internal setup_data structures into setup_data.h
> > > config: x86_64-rhel-8.3-bpf (https://download.01.org/0day-ci/archive/20240109/202401090800.UOBEKB3W-lkp@intel.com/config)
> > > compiler: ClangBuiltLinux clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
> > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240109/202401090800.UOBEKB3W-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/202401090800.UOBEKB3W-lkp@intel.com/
> > > 
> > > All warnings (new ones prefixed by >>):
> > > 
> > >     In file included from arch/x86/realmode/rm/wakemain.c:3:
> > >     In file included from arch/x86/boot/boot.h:24:
> > >     In file included from arch/x86/include/asm/setup.h:10:
> > >     In file included from arch/x86/include/asm/page_types.h:7:
> > >     In file included from include/linux/mem_encrypt.h:17:
> > >     In file included from arch/x86/include/asm/mem_encrypt.h:18:
> > >     In file included from arch/x86/include/uapi/asm/bootparam.h:5:
> > > > > arch/x86/include/asm/setup_data.h:10:20: warning: field 'data' with variable sized type 'struct setup_data' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
> > >        10 |         struct setup_data data;
> > >           |                           ^
> > >     1 warning generated.
> > 
> > I think this warning is expected. This structure is now included in the
> > realmode part of arch/x86, which has its own set of build flags,
> > including -Wall, which includes -Wgnu on clang. The kernel obviously
> > uses GNU extensions and states this clearly with '-std=gnu11', so
> > -Wno-gnu is unconditionally added to KBUILD_CFLAGS for clang. It seems
> > that same treatment is needed for REALMODE_CFLAGS, which also matches
> > arch/x86/boot/compressed/Makefile, see commit 6c3b56b19730 ("x86/boot:
> > Disable Clang warnings about GNU extensions"):
> > 
> > diff --git a/arch/x86/Makefile b/arch/x86/Makefile
> > index 1a068de12a56..24076db59783 100644
> > --- a/arch/x86/Makefile
> > +++ b/arch/x86/Makefile
> > @@ -53,6 +53,9 @@ REALMODE_CFLAGS += -fno-stack-protector
> >   REALMODE_CFLAGS += -Wno-address-of-packed-member
> >   REALMODE_CFLAGS += $(cc_stack_align4)
> >   REALMODE_CFLAGS += $(CLANG_FLAGS)
> > +ifdef CONFIG_CC_IS_CLANG
> > +REALMODE_CFLAGS += -Wno-gnu
> > +endif
> 
> Thanks. Shall I include this change in the patchset?

Yes, I think so to keep the build clean.

> Best regards
> Thomas
> 
> >   export REALMODE_CFLAGS
> >   # BITS is used as extension for files which are available in a 32 bit
> 
> -- 
> Thomas Zimmermann
> Graphics Driver Developer
> SUSE Software Solutions Germany GmbH
> Frankenstrasse 146, 90461 Nuernberg, Germany
> GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
> HRB 36809 (AG Nuernberg)
diff mbox series

Patch

diff --git a/arch/x86/boot/compressed/efi.h b/arch/x86/boot/compressed/efi.h
index 866c0af8b5b9..b22300970f97 100644
--- a/arch/x86/boot/compressed/efi.h
+++ b/arch/x86/boot/compressed/efi.h
@@ -97,15 +97,6 @@  typedef struct {
 	u32 tables;
 } efi_system_table_32_t;
 
-/* kexec external ABI */
-struct efi_setup_data {
-	u64 fw_vendor;
-	u64 __unused;
-	u64 tables;
-	u64 smbios;
-	u64 reserved[8];
-};
-
 struct efi_unaccepted_memory {
 	u32 version;
 	u32 unit_size;
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index c4555b269a1b..a5d7a83e4c2a 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -143,15 +143,6 @@  extern void efi_free_boot_services(void);
 void arch_efi_call_virt_setup(void);
 void arch_efi_call_virt_teardown(void);
 
-/* kexec external ABI */
-struct efi_setup_data {
-	u64 fw_vendor;
-	u64 __unused;
-	u64 tables;
-	u64 smbios;
-	u64 reserved[8];
-};
-
 extern u64 efi_setup;
 
 #ifdef CONFIG_EFI
diff --git a/arch/x86/include/asm/pci.h b/arch/x86/include/asm/pci.h
index f6100df3652e..b3ab80a03365 100644
--- a/arch/x86/include/asm/pci.h
+++ b/arch/x86/include/asm/pci.h
@@ -10,7 +10,6 @@ 
 #include <linux/numa.h>
 #include <asm/io.h>
 #include <asm/memtype.h>
-#include <asm/setup_data.h>
 
 struct pci_sysdata {
 	int		domain;		/* PCI domain */
@@ -124,16 +123,4 @@  cpumask_of_pcibus(const struct pci_bus *bus)
 }
 #endif
 
-struct pci_setup_rom {
-	struct setup_data data;
-	uint16_t vendor;
-	uint16_t devid;
-	uint64_t pcilen;
-	unsigned long segment;
-	unsigned long bus;
-	unsigned long device;
-	unsigned long function;
-	uint8_t romdata[];
-};
-
 #endif /* _ASM_X86_PCI_H */
diff --git a/arch/x86/include/asm/setup_data.h b/arch/x86/include/asm/setup_data.h
new file mode 100644
index 000000000000..77c51111a893
--- /dev/null
+++ b/arch/x86/include/asm/setup_data.h
@@ -0,0 +1,32 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_X86_SETUP_DATA_H
+#define _ASM_X86_SETUP_DATA_H
+
+#include <uapi/asm/setup_data.h>
+
+#ifndef __ASSEMBLY__
+
+struct pci_setup_rom {
+	struct setup_data data;
+	uint16_t vendor;
+	uint16_t devid;
+	uint64_t pcilen;
+	unsigned long segment;
+	unsigned long bus;
+	unsigned long device;
+	unsigned long function;
+	uint8_t romdata[];
+};
+
+/* kexec external ABI */
+struct efi_setup_data {
+	u64 fw_vendor;
+	u64 __unused;
+	u64 tables;
+	u64 smbios;
+	u64 reserved[8];
+};
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* _ASM_X86_SETUP_DATA_H */