[PATCH v9 02/10] um: use execveat to create userspace MMs

Berg, Benjamin benjamin.berg at intel.com
Wed Oct 16 01:19:05 PDT 2024


Hi Nathan,

On Tue, 2024-10-15 at 19:34 -0700, Nathan Chancellor wrote:
> On Thu, Sep 19, 2024 at 02:45:03PM +0200, Benjamin Berg wrote:
> ...
> > diff --git a/arch/um/kernel/skas/Makefile
> > b/arch/um/kernel/skas/Makefile
> > index 6f86d53e3d69..fbb61968055f 100644
> > --- a/arch/um/kernel/skas/Makefile
> > +++ b/arch/um/kernel/skas/Makefile
> > @@ -3,14 +3,43 @@
> >  # Copyright (C) 2002 - 2007 Jeff Dike
> > (jdike@{addtoit,linux.intel}.com)
> >  #
> >  
> > -obj-y := stub.o mmu.o process.o syscall.o uaccess.o
> > +obj-y := stub.o mmu.o process.o syscall.o uaccess.o \
> > +	 stub_exe_embed.o
> > +
> > +# Stub executable
> > +
> > +stub_exe_objs-y := stub_exe.o
> > +
> > +stub_exe_objs := $(foreach F,$(stub_exe_objs-y),$(obj)/$F)
> > +
> > +# Object file containing the ELF executable
> > +$(obj)/stub_exe_embed.o: $(src)/stub_exe_embed.S $(obj)/stub_exe
> > +
> > +$(obj)/stub_exe.dbg: $(stub_exe_objs) FORCE
> > +	$(call if_changed,stub_exe)
> > +
> > +$(obj)/stub_exe: OBJCOPYFLAGS := -S
> > +$(obj)/stub_exe: $(obj)/stub_exe.dbg FORCE
> > +	$(call if_changed,objcopy)
> > +
> > +quiet_cmd_stub_exe = STUB_EXE $@
> > +      cmd_stub_exe = $(CC) -nostdlib -o $@ \
> > +			   $(KBUILD_CFLAGS) $(STUB_EXE_LDFLAGS) \
> > +			   $(filter %.o,$^)
> > +
> > +STUB_EXE_LDFLAGS = -n -static
> 
> After this change in -next as commit 32e8eaf263d9 ("um: use execveat
> to
> create userspace MMs"), I am seeing an error when building ARCH=um
> defconfig with clang.
> 
>   $ make -skj"$(nproc)" ARCH=um LLVM=1 mrproper defconfig linux
>   clang: error: unknown argument: '-n'
>   make[7]: *** [arch/um/kernel/skas/Makefile:19:
> arch/um/kernel/skas/stub_exe.dbg] Error 1
>   ...
> 
> I have looked through the GCC manual and options index but I do not
> see
> what '-n' is. Was this intended to be passed to the linker like -Wl,-
> n
> or was there some other option that this should be? If I try dropping
> it, I end up running into another issue, which could be entirely
> unrelated.

Yes, you are right, it was supposed to be passed to the linker and the
only point is to make the elf binary a bit smaller that will be
embedded (the --nmagic ld option).

Anything works for me. We can change it to -Wl,-n if it works or even
just drop it entirely.

Benjamin


>   $ make -skj"$(nproc)" ARCH=um LLVM=1 mrproper defconfig
> arch/um/kernel/skas/
>   /usr/bin/ld: arch/um/kernel/skas/stub_exe.o: in function `_start':
>   arch/um/kernel/skas/stub_exe.c:83:(.ltext+0x15): undefined
> reference to `memset'
>   clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
>   make[7]: *** [arch/um/kernel/skas/Makefile:19:
> arch/um/kernel/skas/stub_exe.dbg] Error 1
> 
> Cheers,
> Nathan
> 
> > +targets += stub_exe.dbg stub_exe $(stub_exe_objs-y)
> > +
> > +# end
> >  
> >  # stub.o is in the stub, so it can't be built with profiling
> >  # GCC hardened also auto-enables -fpic, but we need %ebx so it
> > can't work ->
> >  # disable it
> >  
> >  CFLAGS_stub.o := $(CFLAGS_NO_HARDENING)
> > -UNPROFILE_OBJS := stub.o
> > +CFLAGS_stub_exe.o := $(CFLAGS_NO_HARDENING)
> > +UNPROFILE_OBJS := stub.o stub_exe.o
> >  KCOV_INSTRUMENT := n
> >  
> >  include $(srctree)/arch/um/scripts/Makefile.rules

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


More information about the linux-um mailing list