Skip to content

Commit

Permalink
um: nommu: plug nommu code into build system
Browse files Browse the repository at this point in the history
Add nommu kernel for um build.  defconfig is also provided.

Signed-off-by: Hajime Tazaki <thehajime@gmail.com>
  • Loading branch information
thehajime committed Sep 11, 2024
1 parent ea64597 commit 2abc14c
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 4 deletions.
13 changes: 11 additions & 2 deletions arch/um/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ config UML
select ARCH_SUPPORTS_LTO_CLANG_THIN
select TRACE_IRQFLAGS_SUPPORT
select TTY # Needed for line.c
select HAVE_ARCH_VMAP_STACK
select HAVE_ARCH_VMAP_STACK if MMU
select HAVE_RUST if X86_64
select UACCESS_MEMCPY if !MMU
select GENERIC_STRNLEN_USER if !MMU
select GENERIC_STRNCPY_FROM_USER if !MMU

config MMU
bool
bool "MMU-based Paged Memory Management Support"
default y

config UML_DMA_EMULATION
Expand Down Expand Up @@ -186,8 +189,14 @@ config MAGIC_SYSRQ
The keys are documented in <file:Documentation/admin-guide/sysrq.rst>. Don't say Y
unless you really know what this hack does.

config ARCH_FORCE_MAX_ORDER
int "Order of maximal physically contiguous allocations"
default "10" if MMU
default "16" if !MMU

config KERNEL_STACK_ORDER
int "Kernel stack size order"
default 3 if !MMU
default 2 if 64BIT
range 2 10 if 64BIT
default 1 if !64BIT
Expand Down
6 changes: 6 additions & 0 deletions arch/um/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) $(CC_FLAGS_
CLEAN_FILES += linux x.i gmon.out
MRPROPER_FILES += $(HOST_DIR)/include/generated

ifeq ($(CONFIG_MMU),y)
UTS_MACHINE := "um"
else
UTS_MACHINE := "um\(nommu\)"
endif

archclean:
@find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
-o -name '*.gcov' \) -type f -print | xargs rm -f
Expand Down
64 changes: 64 additions & 0 deletions arch/um/configs/x86_64_nommu_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
CONFIG_SYSVIPC=y
CONFIG_POSIX_MQUEUE=y
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y
CONFIG_BSD_PROCESS_ACCT=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_LOG_BUF_SHIFT=14
CONFIG_CGROUPS=y
CONFIG_BLK_CGROUP=y
CONFIG_CGROUP_SCHED=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CGROUP_CPUACCT=y
# CONFIG_PID_NS is not set
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
# CONFIG_MMU is not set
CONFIG_HOSTFS=y
CONFIG_MAGIC_SYSRQ=y
CONFIG_SSL=y
CONFIG_NULL_CHAN=y
CONFIG_PORT_CHAN=y
CONFIG_PTY_CHAN=y
CONFIG_TTY_CHAN=y
CONFIG_CON_CHAN="pts"
CONFIG_SSL_CHAN="pts"
CONFIG_UML_SOUND=m
CONFIG_UML_NET=y
CONFIG_UML_NET_ETHERTAP=y
CONFIG_UML_NET_TUNTAP=y
CONFIG_UML_NET_SLIP=y
CONFIG_UML_NET_DAEMON=y
CONFIG_UML_NET_MCAST=y
CONFIG_UML_NET_SLIRP=y
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
CONFIG_IOSCHED_BFQ=m
CONFIG_BINFMT_MISC=m
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
CONFIG_INET=y
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_BLK_DEV_UBD=y
CONFIG_BLK_DEV_LOOP=m
CONFIG_BLK_DEV_NBD=m
CONFIG_DUMMY=m
CONFIG_TUN=m
CONFIG_PPP=m
CONFIG_SLIP=m
CONFIG_LEGACY_PTY_COUNT=32
CONFIG_UML_RANDOM=y
CONFIG_SOUND=m
CONFIG_EXT4_FS=y
CONFIG_REISERFS_FS=y
CONFIG_QUOTA=y
CONFIG_AUTOFS_FS=m
CONFIG_ISO9660_FS=m
CONFIG_JOLIET=y
CONFIG_NLS=y
CONFIG_DEBUG_KERNEL=y
CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
CONFIG_FRAME_WARN=1024
CONFIG_IPV6=y
3 changes: 3 additions & 0 deletions arch/um/include/shared/common-offsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ DEFINE(UML_CONFIG_64BIT, CONFIG_64BIT);
#ifdef CONFIG_UML_TIME_TRAVEL_SUPPORT
DEFINE(UML_CONFIG_UML_TIME_TRAVEL_SUPPORT, CONFIG_UML_TIME_TRAVEL_SUPPORT);
#endif
#ifdef CONFIG_MMU
DEFINE(UML_CONFIG_MMU, CONFIG_MMU);
#endif

/* for stub */
DEFINE(UML_STUB_FIELD_OFFSET, offsetof(struct stub_data, offset));
Expand Down
3 changes: 2 additions & 1 deletion arch/um/os-Linux/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ void setup_machinename(char *machine_out)
}
# endif
#endif
strcpy(machine_out, host.machine);
strcat(machine_out, "/");
strcat(machine_out, host.machine);
}

void setup_hostinfo(char *buf, int len)
Expand Down
22 changes: 21 additions & 1 deletion arch/x86/um/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ else
BITS := 64
endif

obj-y = bugs_$(BITS).o delay.o fault.o ldt.o \
obj-y = bugs_$(BITS).o delay.o fault.o \
ptrace_$(BITS).o ptrace_user.o setjmp_$(BITS).o signal.o \
stub_$(BITS).o stub_segv.o \
sys_call_table_$(BITS).o sysrq_$(BITS).o tls_$(BITS).o \
mem_$(BITS).o subarch.o os-Linux/
obj-$(CONFIG_MMU) += ldt.o

ifeq ($(CONFIG_X86_32),y)

Expand All @@ -33,6 +34,25 @@ subarch-y = ../lib/csum-partial_64.o ../lib/memcpy_64.o \
../lib/memmove_64.o ../lib/memset_64.o
subarch-$(CONFIG_PREEMPTION) += ../entry/thunk_64.o


ifneq ($(CONFIG_MMU),y)

# used by zpoline.c to translate syscall/sysenter instructions
inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
quiet_cmd_inat_tables = GEN $@
cmd_inat_tables = $(AWK) -f $(inat_tables_script) $(inat_tables_maps) > $@

$(obj)/../lib/inat-tables.c: $(inat_tables_script) $(inat_tables_maps)
$(call cmd,inat_tables)
$(obj)/../lib/inat.o: $(obj)/../lib/inat-tables.c
clean-files := $(obj)/../lib/inat-tables.c

obj-y += do_syscall_64.o entry_$(BITS).o zpoline.o
subarch-y += ../lib/insn.o ../lib/inat.o

endif

endif

subarch-$(CONFIG_MODULES) += ../kernel/module.o
Expand Down

0 comments on commit 2abc14c

Please sign in to comment.