linux-um archives
 help / color / mirror / Atom feed
From: "Berg, Benjamin" <benjamin.berg@intel.com>
To: "nathan@kernel.org" <nathan@kernel.org>
Cc: "llvm@lists.linux.dev" <llvm@lists.linux.dev>,
	"linux-um@lists.infradead.org" <linux-um@lists.infradead.org>
Subject: Re: [PATCH v9 02/10] um: use execveat to create userspace MMs
Date: Wed, 16 Oct 2024 08:19:05 +0000	[thread overview]
Message-ID: <0cfc6640941ce432de34522d8ff7e1c35c6dcce9.camel@intel.com> (raw)
In-Reply-To: <20241016023426.GA1115452@thelio-3990X>

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

  reply	other threads:[~2024-10-16  8:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-19 12:45 [PATCH v9 00/10] Increased address space for 64 bit Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 01/10] um: Add generic stub_syscall1 function Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 02/10] um: use execveat to create userspace MMs Benjamin Berg
2024-10-16  2:34   ` Nathan Chancellor
2024-10-16  8:19     ` Berg, Benjamin [this message]
2024-10-17  7:17   ` David Gow
2024-10-17  8:18     ` Johannes Berg
2024-10-17 12:05       ` Benjamin Berg
2024-10-17 23:17         ` David Gow
2024-10-17  9:01     ` Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 03/10] um: Set parent death signal for userspace process Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 04/10] um: Set parent death signal for winch thread/process Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 05/10] um: Add compile time assert that stub fits on a page Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 06/10] um: Calculate stub data address relative to stub code Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 07/10] um: Limit TASK_SIZE to the addressable range Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 08/10] um: Discover host_task_size from envp Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 09/10] um: clear all memory in new userspace processes Benjamin Berg
2024-09-19 12:45 ` [PATCH v9 10/10] um: Switch to 4 level page tables on 64 bit Benjamin Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0cfc6640941ce432de34522d8ff7e1c35c6dcce9.camel@intel.com \
    --to=benjamin.berg@intel.com \
    --cc=linux-um@lists.infradead.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox