Hugetlbfs file mappings are handled differently than regular files: - pager_req_create will tell us the file is in a hugetlbfs - allocate memory upfront, we need to fail if not enough memory - the memory needs to be given again if another process maps the same file This implementation still has some hacks, in particular, the memory needs to be freed when all mappings are done and the file has been deleted/closed by all processes. We cannot know when the file is closed/unlinked easily, so clean up memory when all processes have exited. To test, install libhugetlbfs and link a program with the additional LDFLAGS += -B /usr/share/libhugetlbfs -Wl,--hugetlbfs-align Then run with HUGETLB_ELFMAP=RW set, you can check this works with HUGETLB_DEBUG=1 HUGETLB_VERBOSE=2 Change-Id: I327920ff06efd82e91b319b27319f41912169af1
86 lines
2.4 KiB
Makefile
86 lines
2.4 KiB
Makefile
# Makefile.build.in COPYRIGHT FUJITSU LIMITED 2015-2016
|
|
ARCH = @ARCH@
|
|
VPATH=@abs_srcdir@
|
|
SRC=$(VPATH)
|
|
IHKDIR=$(IHKBASE)/$(TARGETDIR)
|
|
OBJS = init.o mem.o debug.o mikc.o listeners.o ap.o syscall.o cls.o host.o
|
|
OBJS += process.o copy.o waitq.o futex.o timer.o plist.o fileobj.o shmobj.o
|
|
OBJS += zeroobj.o procfs.o devobj.o sysfs.o xpmem.o profile.o freeze.o
|
|
OBJS += rbtree.o hugefileobj.o
|
|
OBJS += pager.o
|
|
# POSTK_DEBUG_ARCH_DEP_18 coredump arch separation.
|
|
DEPSRCS=$(wildcard $(SRC)/*.c)
|
|
|
|
# OBJS added gencore.o
|
|
ifeq ($(ARCH), arm64)
|
|
OBJS += gencore.o
|
|
DEPSRCS += $(SRC)/../arch/arm64/kernel/gencore.c
|
|
endif
|
|
|
|
CFLAGS += -I$(SRC)/include -I@abs_builddir@/../ -I@abs_builddir@/include -D__KERNEL__ -g -fno-omit-frame-pointer -fno-inline -fno-inline-small-functions
|
|
ifneq ($(ARCH), arm64)
|
|
CFLAGS += -mcmodel=large -mno-red-zone -mno-sse
|
|
endif
|
|
LDFLAGS += -e arch_start
|
|
IHKOBJ = ihk/ihk.o
|
|
|
|
# POSTK_DEBUG_ARCH_DEP_24
|
|
ifeq ($(ARCH), arm64)
|
|
default: all
|
|
endif
|
|
|
|
ifeq ($(ARCH), arm64)
|
|
include @abs_builddir@/config/config.$(TARGET)
|
|
else
|
|
include $(SRC)/config/config.$(TARGET)
|
|
endif
|
|
include @abs_builddir@/../../ihk/cokernel/Makefile.common
|
|
|
|
# CFLAGS += -I$(SRC)/../arch/$(IHKARCH)/kernel/include -I$(SRC)/../lib/include
|
|
|
|
OBJDUMP ?= objdump
|
|
OBJCOPY ?= objcopy
|
|
|
|
# POSTK_DEBUG_ARCH_DEP_26
|
|
ifeq ($(ARCH), arm64)
|
|
SUBCMD_OPTS = TARGET=$(TARGET) O=$(CURDIR)/ihk CC=$(CC) LD=$(LD) OBJCOPY=$(OBJCOPY) SRC=$(SRC) ARCH=$(ARCH)
|
|
else
|
|
SUBCMD_OPTS = TARGET=$(TARGET) O=$(CURDIR)/ihk CC=$(CC) LD=$(LD) SRC=$(SRC)
|
|
endif
|
|
|
|
ld_kern_cmd_base = $(LD) $(LDFLAGS) -o $@.elf $^
|
|
mkimage_cmd_base = [ -f $(SRC)/script/mkimage.$(TARGET) ] && CC=$(CC) LD=$(LD) LDFLAGS="$(LDFLAGS_MKIMAGE)" OBJDUMP=$(OBJDUMP) OBJCOPY=$(OBJCOPY) sh $(SRC)/script/mkimage.$(TARGET) '$@.elf' '$@' '$(SRC)' || cp $@.elf $@
|
|
|
|
ld_kern_cmd = $(call echo_cmd,LDKERN,$@)$(ld_kern_cmd_base)
|
|
mkimage_cmd = $(call echo_cmd,MKIMAGE,$@)$(mkimage_cmd_base)
|
|
|
|
all: depend kernel.img
|
|
|
|
kernel.img: $(OBJS) $(IHKOBJ)
|
|
$(ld_kern_cmd)
|
|
$(mkimage_cmd)
|
|
|
|
clean:
|
|
$(rm_cmd) $(OBJS) kernel.img kernel.img.elf Makefile.dep
|
|
@$(submake) -C $(IHKBASE) $(SUBCMD_OPTS) clean
|
|
|
|
depend: Makefile.dep
|
|
|
|
Makefile.dep:
|
|
$(call dep_cmd,$(DEPSRCS))
|
|
|
|
$(IHKOBJ): FORCE
|
|
@mkdir -p $(dir $(IHKOBJ))
|
|
+$(call echo_cmd,BUILD IHK,$(TARGET))$(submake) -C $(IHKBASE) $(SUBCMD_OPTS) prepare
|
|
+$(call echo_cmd,BUILD IHK,$(TARGET))$(submake) -C $(IHKBASE) $(SUBCMD_OPTS)
|
|
|
|
%.o: $(SRC)/%.c
|
|
$(cc_cmd)
|
|
|
|
gencore.o: ../arch/arm64/kernel/gencore.c
|
|
$(cc_cmd)
|
|
|
|
FORCE:
|
|
|
|
-include Makefile.dep
|