From patchwork Tue Oct 6 09:44:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hajime Tazaki X-Patchwork-Id: 1377330 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=d2TUmLBL; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=OO87hkx0; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C5CKB2PWFz9sTK for ; Tue, 6 Oct 2020 20:46:22 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Smh+Q50ydR6D05B1HYUz9WhF/oiEAqXiUk5HTkD1lMk=; b=d2TUmLBL1z+nu/SJjpI3JuvwJ fUnTJJLWRAegS9X51IZYq1laBrA+/vSPm2Cy7lgxyrwVCZRCOZf7GEaEVxvFyS/Vuf5u5VXV9bNZ7 Ap6aWjhsgL+hza/rxxlhdN5AjBRZlNfrei+zM3Jnf/+JeSAHijrYFCIv9qsSLhZtMXqajR6Pl70Qx 536u4t7yDNSUhh7+gXBw7jKr38ysd+N02+BjU6qhj6Ed0/wXPKfNueHw8dDUQCb9YxE6Eiy1bWEv4 rNAFmZ654jSvu2aOc+jZZVu/cJAV2pHcOfURrQn8KI7Lh09XiCNEFb3EkVLSuSvxigKLhu0lhwd4/ rL24K6m/Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPjY3-0000AN-5R; Tue, 06 Oct 2020 09:46:19 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kPjY0-00009C-OM for linux-um@lists.infradead.org; Tue, 06 Oct 2020 09:46:17 +0000 Received: by mail-pj1-x1044.google.com with SMTP id ds1so1286833pjb.5 for ; Tue, 06 Oct 2020 02:46:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rH4gei9MPvx6IQYMRAhuOETSp1Podm8Z71dGBNsbxHU=; b=OO87hkx0Fkvh8sCQ2mngO/0j2s+yoaZkbPem8w9Dve0mw/rhD19f888Hh99Fe3IZTw 5EGq3n3a0S/9d6N7o+h9Bgf4MqHDAp0Nz1I1E/8y3rpAJvqUN8Pgc3pXMYarbQ0no7Hl HHWbB0yQsj8VNHsBZvTfLbA5iFP7m/2xftV+G7JIgUfbR8n+BIblt2/OlU2UnZhQHG0B Jk9K2wTt25mNK790O8xnls3sQ/IXm3Us7ul6s9YIUlqxU6JmoTzrxjwqOojFXY8+my+f ADC3pVtzXEAjetVUMYff3xQRdiN1+0FVotl2ShQfDInubwglrhwMP95Ap9J7Py2E9aIr 6pcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rH4gei9MPvx6IQYMRAhuOETSp1Podm8Z71dGBNsbxHU=; b=Bv81oYHdfcUeqOlMp+1rachmRqoRp3fwDSIEevGWhnIWmZBOYgUmJbzvhA/OHi+Yi1 rLe+ExJkQdPc6RJHY0KdmfK1C5mZ49fjBLYFszDVq1RvGOC325/uhflPg8zxQhJCtY7N oGoj7o9FawSbx0+dgxTYNhqplkZhlYj5HWl18N9RbSu71/7nhE16NX/EnCEpXjjIpph6 3LbQURckNP+TyLuGBcuKNxl2mjRkXLUtKpNmal8nriNNspEYqhm2hYeTEO4Mz8S5KsHm AvMuKQNdmEz68jR3M+thSEvKZnXa0csvAYI4CpntNFxA10KRkcm1WgwL9j9R2Uuxk4xf rtqg== X-Gm-Message-State: AOAM533e1gWJGGBSfHci29idG/MBcKlQanxGykjeXG8wNAlU/OQqIUee AYnnt3VlqB/l4gym07cflks= X-Google-Smtp-Source: ABdhPJx8E2x1lx0f38YgFzshBcQjfxbFVLPcUHE/c8D9fr3FNLDNCApc3QVfIFJR8gwudfT5ctdnMQ== X-Received: by 2002:a17:90a:d57:: with SMTP id 23mr3470735pju.232.1601977574887; Tue, 06 Oct 2020 02:46:14 -0700 (PDT) Received: from earth-mac.local (219x123x138x129.ap219.ftth.ucom.ne.jp. [219.123.138.129]) by smtp.gmail.com with ESMTPSA id j12sm2227595pjd.36.2020.10.06.02.46.13 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Oct 2020 02:46:14 -0700 (PDT) Received: by earth-mac.local (Postfix, from userid 501) id 1DF1420390F50C; Tue, 6 Oct 2020 18:46:12 +0900 (JST) From: Hajime Tazaki To: linux-um@lists.infradead.org, jdike@addtoit.com, richard@nod.at, anton.ivanov@cambridgegreys.com Subject: [RFC v7 16/21] um: nommu: plug in the build system Date: Tue, 6 Oct 2020 18:44:25 +0900 Message-Id: <714783a8d1d6aace7d0e315fc12ffc60b5867ada.1601960644.git.thehajime@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201006_054616_805078_F4F630B3 X-CRM114-Status: GOOD ( 18.47 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1044 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [thehajime[at]gmail.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tavi.purdila@gmail.com, linux-kernel-library@freelists.org, linux-arch@vger.kernel.org, Hajime Tazaki , retrage01@gmail.com Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Basic Makefiles for building library of nommu mode. Add a new architecture specific target for installing the resulting library files and headers. To make nommu binaries build, UML introduced an additional option, UMMODE variable, to switch the output file of build: kernel (default), or library (nommu). Those modes are not able to be ON at the same time. To build on library mode, users do the following: make defconfig ARCH=um UMMODE=library make ARCH=um UMMODE=library Signed-off-by: Octavian Purdila Signed-off-by: Hajime Tazaki --- arch/um/Kconfig | 17 ++++++++++++++--- arch/um/Makefile | 12 +++++++++++- arch/um/kernel/Makefile | 14 +++++++++----- arch/um/nommu/um/Kconfig | 37 +++++++++++++++++++++++++++++++++++++ arch/um/nommu/um/Makefile | 4 ++++ 5 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 arch/um/nommu/um/Kconfig create mode 100644 arch/um/nommu/um/Makefile diff --git a/arch/um/Kconfig b/arch/um/Kconfig index e41d31d0d875..df7daceb095c 100644 --- a/arch/um/Kconfig +++ b/arch/um/Kconfig @@ -22,9 +22,20 @@ config UML select TTY # Needed for line.c select MODULE_REL_CRCS if MODVERSIONS +config UMMODE_LIB + bool "UML mode: library mode" + default y if "$(UMMODE)" = "library" + help + This mode switches a mode to build a library of UML (Linux + Kernel Library/LKL). This switch is exclusive to "kernel mode" + of UML, which is traditional mode of UML. + + For more detail about LKL, see + . + config MMU bool - default y + default y if !UMMODE_LIB config NO_IOMEM def_bool y @@ -45,12 +56,12 @@ config LOCKDEP_SUPPORT config STACKTRACE_SUPPORT bool - default y + default y if MMU select STACKTRACE config GENERIC_CALIBRATE_DELAY bool - default y + default y if MMU config HZ int diff --git a/arch/um/Makefile b/arch/um/Makefile index 8be7bc479442..ee35bd030bf8 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -17,6 +17,10 @@ else KBUILD_DEFCONFIG := $(SUBARCH)_defconfig endif +ifeq ($(UMMODE),library) + SUBARCH := um/nommu +endif + ARCH_DIR := arch/um OS := $(shell uname -s) # We require bash because the vmlinux link and loader script cpp use bash @@ -97,8 +101,14 @@ KBUILD_CFLAGS += $(KERNEL_DEFINES) LDFLAGS_vmlinux += -r INSTALL_PATH=$(objtree)/tools/um +ifeq ($(UMMODE),library) +all: install + $(Q)$(MAKE) -C $(srctree)/tools/um +install: linux.o um_headers_install +else all: linux install: linux.o +endif @echo " INSTALL $(INSTALL_PATH)/lib/$<" @mkdir -p $(INSTALL_PATH)/lib/ @cp $< $(INSTALL_PATH)/lib/ @@ -111,7 +121,7 @@ linux: linux.o linux.o: vmlinux @echo ' LINK $@' - $(Q)$(OBJCOPY) -R .eh_frame $< $@ + $(Q)$(OBJCOPY) -R .eh_frame -L sem_init -L sem_post -L sem_wait -L sem_destroy $< $@ $(Q)mkdir -p $(objtree)/tools/um/lib define archhelp diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index 9b63831a69e1..01605ed439cb 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile @@ -14,17 +14,21 @@ CPPFLAGS_vmlinux.lds := -DSTART=$(LDS_START) \ $(LDS_EXTRA) extra-y := vmlinux.lds -obj-y = config.o exec.o exitcode.o irq.o ksyms.o mem.o \ - physmem.o process.o ptrace.o reboot.o sigio.o \ - signal.o syscall.o sysrq.o time.o tlb.o trap.o \ - um_arch.o umid.o maccess.o kmsg_dump.o skas/ +obj-y = config.o exitcode.o irq.o ksyms.o \ + process.o reboot.o sigio.o \ + signal.o syscall.o time.o \ + um_arch.o umid.o maccess.o kmsg_dump.o + +ifdef CONFIG_MMU +obj-y += exec.o mem.o physmem.o ptrace.o sysrq.o tlb.o trap.o skas/ +endif obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o obj-$(CONFIG_GPROF) += gprof_syms.o obj-$(CONFIG_GCOV) += gmon_syms.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-$(CONFIG_STACKTRACE) += stacktrace.o -obj-y += user_syms.o +obj-$(CONFIG_MMU) += user_syms.o USER_OBJS := config.o diff --git a/arch/um/nommu/um/Kconfig b/arch/um/nommu/um/Kconfig new file mode 100644 index 000000000000..20b3eaccb6f0 --- /dev/null +++ b/arch/um/nommu/um/Kconfig @@ -0,0 +1,37 @@ +config UML_NOMMU + def_bool y + depends on !SMP && !MMU + select UACCESS_MEMCPY + select ARCH_THREAD_STACK_ALLOCATOR + select ARCH_HAS_SYSCALL_WRAPPER + +config 64BIT + bool + default y + +config GENERIC_CSUM + def_bool y + +config GENERIC_ATOMIC64 + bool + default y if !64BIT + +config SECCOMP + bool + default n + +config GENERIC_HWEIGHT + def_bool y + +config GENERIC_CALIBRATE_DELAY + bool + default n + +config STACKTRACE_SUPPORT + bool + default n + +# XXX: need this to work well with tap13.py +config PRINTK_TIME + bool + default y diff --git a/arch/um/nommu/um/Makefile b/arch/um/nommu/um/Makefile new file mode 100644 index 000000000000..b580e0fe97b5 --- /dev/null +++ b/arch/um/nommu/um/Makefile @@ -0,0 +1,4 @@ +include/generated/user_constants.h: $(srctree)/arch/um/nommu/um/user_constants.h + $(Q)cp -f $^ $@ + +obj-y = bootmem.o console.o cpu.o delay.o setup.o syscalls.o threads.o unimplemented.o