Skip to contentSkip to conversation

um: Various build fixes for allyesconfig

PATCH In review Peter Foley 2 participants 6 messages Jan 13, 2023 User-mode Linux (UML)

lore
Share & tools
lore
#0 lore raw

cover um: Various build fixes for allyesconfig

Fix some build failures I ran across when trying to build an allyesconfig kernel for ARCH=um.

To: Richard Weinberger <[email protected]>
To: Anton Ivanov <[email protected]>
To: Johannes Berg <[email protected]>

---
Peter Foley (4):
um: Make the definition of cpu_data more compatible
um: Avoid pcap multiple definition errors
um: Prevent building modules incompatible with MODVERSIONS
um: Use CFLAGS_vmlinux

 arch/um/Makefile                        | 3 +--
 arch/um/drivers/Kconfig                 | 2 ++
 arch/um/drivers/pcap_kern.c             | 4 ++--
 arch/um/include/asm/processor-generic.h | 2 +-
 arch/um/kernel/um_arch.c                | 2 +-
 5 files changed, 7 insertions(+), 6 deletions(-)

---
base-commit: d9fc1511728c15df49ff18e49a494d00f78b7cd4
change-id: 20230112-um-3f06b1bbbbb0

Best regards,

Signature · 1 line
Peter Foley <[email protected]>
#1 lore raw

PATCH 1/4 um: Make the definition of cpu_data more compatible

Match the x86 implementation to improve build errors. Noticed when building allyesconfig.

e.g.
../arch/um/include/asm/processor-generic.h:94:19: error: called object is not a function or function pointer
94 | #define cpu_data (&boot_cpu_data)

      |                  ~^~~~~~~~~~~~~~~

../drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_topology.c:2157:16: note: in expansion of macro ‘cpu_data’
2157 | return cpu_data(first_cpu_of_numa_node).apicid;

---
 arch/um/include/asm/processor-generic.h | 2 +-
 arch/um/kernel/um_arch.c                | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/um/include/asm/processor-generic.h +1 -1
index bb5f06480da9..7414154b8e9a 100644
@@ -91,7 +91,7 @@ struct cpuinfo_um {
 
 extern struct cpuinfo_um boot_cpu_data;
 
-#define cpu_data (&boot_cpu_data)
+#define cpu_data(cpu)    boot_cpu_data
 #define current_cpu_data boot_cpu_data
 #define cache_line_size()	(boot_cpu_data.cache_alignment)
 
arch/um/kernel/um_arch.c +1 -1
index 786b44dc20c9..8dcda617b8bf 100644
@@ -96,7 +96,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 
 static void *c_start(struct seq_file *m, loff_t *pos)
 {
-	return *pos < nr_cpu_ids ? cpu_data + *pos : NULL;
+	return *pos < nr_cpu_ids ? &boot_cpu_data + *pos : NULL;
 }
 
 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
Signature · 6 lines
2.39.0

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
#2 lore raw

PATCH 2/4 um: Avoid pcap multiple definition errors

In reply to Peter Foley

Change the function name in pcap_kern to avoid conflicting with libpcap.a.

e.g.
ld: /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../lib64/libpcap.a(pcap.o): in function `pcap_init':
(.text+0x7f0): multiple definition of `pcap_init'; arch/um/drivers/pcap_kern.o:pcap_kern.c:(.text.unlikely+0x0): first defined here

---
 arch/um/drivers/pcap_kern.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/um/drivers/pcap_kern.c +2 -2
index cfe4cb17694c..25ee2c97ca21 100644
@@ -15,7 +15,7 @@ struct pcap_init {
 	char *filter;
 };
 
-void pcap_init(struct net_device *dev, void *data)
+void pcap_init_kern(struct net_device *dev, void *data)
 {
 	struct uml_net_private *pri;
 	struct pcap_data *ppri;
@@ -44,7 +44,7 @@ static int pcap_write(int fd, struct sk_buff *skb, struct uml_net_private *lp)
 }
 
 static const struct net_kern_info pcap_kern_info = {
-	.init			= pcap_init,
+	.init			= pcap_init_kern,
 	.protocol		= eth_protocol,
 	.read			= pcap_read,
 	.write			= pcap_write,
Signature · 6 lines
2.39.0

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
#3 lore raw

PATCH 3/4 um: Prevent building modules incompatible with MODVERSIONS

In reply to Peter Foley

The manual ld invocation in arch/um/drivers doesn't play nicely with genksyms. Given the problematic modules are deprecated anyway, just prevent building them when using MODVERSIONS.

e.g.
MODPOST Module.symvers arch/um/drivers/.pcap.o.cmd: No such file or directory

---
 arch/um/drivers/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
arch/um/drivers/Kconfig +2 -0
index a4f0a19fbe14..36911b1fddcf 100644
@@ -261,6 +261,7 @@ config UML_NET_VECTOR
 config UML_NET_VDE
 	bool "VDE transport (obsolete)"
 	depends on UML_NET
+	depends on !MODVERSIONS
 	select MAY_HAVE_RUNTIME_DEPS
 	help
 	  This User-Mode Linux network transport allows one or more running
@@ -309,6 +310,7 @@ config UML_NET_MCAST
 config UML_NET_PCAP
 	bool "pcap transport (obsolete)"
 	depends on UML_NET
+	depends on !MODVERSIONS
 	select MAY_HAVE_RUNTIME_DEPS
 	help
 	  The pcap transport makes a pcap packet stream on the host look
Signature · 6 lines
2.39.0

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
#4 lore raw

PATCH 4/4 um: Use CFLAGS_vmlinux

In reply to Peter Foley

link-vmlinux.sh doesn't use LDFLAGS_vmlinux when linking the kernel for UML. Move the LDFLAGS_EXESTACK options into CFLAGS_vmlinux so they're actually respected.

e.g.
/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: warning: .tmp_vmlinux.kallsyms3.o: missing .note.GNU-stack section implies executable stack /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: warning: vmlinux has a LOAD segment with RWX permissions

---
 arch/um/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/um/Makefile +1 -2
index f1d4d67157be..93dfb23bd263 100644
@@ -139,11 +139,10 @@ ifeq ($(CONFIG_LD_IS_BFD),y)
 LDFLAGS_EXECSTACK += $(call ld-option,--no-warn-rwx-segments)
 endif
 
-LD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS),-Wl,$(opt))
+LD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS) $(LDFLAGS_EXECSTACK),-Wl,$(opt))
 
 # Used by link-vmlinux.sh which has special support for um link
 export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
-export LDFLAGS_vmlinux := $(LDFLAGS_EXECSTACK)
 
 # When cleaning we don't include .config, so we don't include
 # TT or skas makefiles and don't clean skas_ptregs.h.
Signature · 6 lines
2.39.0

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Reviewed-by on v1 4/4
#5 lore raw

Re: [PATCH 4/4] um: Use CFLAGS_vmlinux

Quoted 10 lines · Peter Foley

link-vmlinux.sh doesn't use LDFLAGS_vmlinux when linking the kernel for UML. Move the LDFLAGS_EXESTACK options into CFLAGS_vmlinux so they're actually respected.

e.g.
/usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: warning: .tmp_vmlinux.kallsyms3.o: missing .note.GNU-stack section implies executable stack /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker /usr/lib/gcc/x86_64-pc-linux-gnu/12/../../../../x86_64-pc-linux-gnu/bin/ld: warning: vmlinux has a LOAD segment with RWX permissions
---

Thanks very much for fixing this -- the LDFLAGS/CFLAGS fun here always trips me up!

Cheers,
-- David

Quoted 24 lines
 arch/um/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/um/Makefile +1 -3
index f1d4d67157be..93dfb23bd263 100644
@@ -139,11 +139,10 @@ ifeq ($(CONFIG_LD_IS_BFD),y)
 LDFLAGS_EXECSTACK += $(call ld-option,--no-warn-rwx-segments)
 endif
 
-LD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS),-Wl,$(opt))
+LD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS) $(LDFLAGS_EXECSTACK),-Wl,$(opt))
 
 # Used by link-vmlinux.sh which has special support for um link
 export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
-export LDFLAGS_vmlinux := $(LDFLAGS_EXECSTACK)
 
 # When cleaning we don't include .config, so we don't include
 # TT or skas makefiles and don't clean skas_ptregs.h.
 
--

2.39.0

Quoted 4 lines

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um