Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] rump hypcall integration for LKL #255

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
12 changes: 12 additions & 0 deletions arch/lkl/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ config 64BIT
config BIG_ENDIAN
def_bool n

config KALLSYMS_BASE_RELATIVE
def_bool n

config TTY
def_bool n

config GENERIC_CSUM
def_bool y

Expand All @@ -58,6 +64,12 @@ config RWSEM_GENERIC_SPINLOCK
bool
default y

config PCI
bool "PCI support"
select NO_GENERIC_PCI_IOPORT_MAP
select GENERIC_PCI_IOMAP
default y

source init/Kconfig

source net/Kconfig
Expand Down
38 changes: 37 additions & 1 deletion arch/lkl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,60 @@ else
$(error Unrecognized platform: $(OUTPUT_FORMAT))
endif

ifeq ($(OUTPUT_FORMAT),elf32-littlearm)
CFLAGS_ABI :=-mabi=aapcs-linux -mno-thumb-interwork -mfpu=vfp
KBUILD_CFLAGS += $(CFLAGS_ABI)
endif

ifneq (,$(filter $(OUTPUT_FORMAT),elf64-x86-64-freebsd))
NPROC=$(shell sysctl -n hw.ncpu)
else
NPROC=$(shell nproc)
endif

LDFLAGS_vmlinux += -r

ifeq ($(buildrump),yes)
# objcopy trick is taken from rumpkernel
GCCSYMBOLS=__umoddi3|__udivdi3|__aeabi_idiv|__aeabi_idivmod|__aeabi_llsl
GCCSYMBOLS:=$(GCCSYMBOLS)|__aeabi_llsr|__aeabi_uidiv|__aeabi_uidivmod|__aeabi_uldivmod
GCCATOMIC=__sync_synchronize|__sync_fetch_and_sub_4|__sync_fetch_and_add_4
GCCATOMIC:=$(GCCATOMIC)|__sync_fetch_and_and_4|__sync_fetch_and_or_4
VMLINUX_SYMS=__start___ex_table|__stop___ex_table|boot_cmdline
EXP_SYMRENAME=rump|RUMP|bmk_|lib_|nuse_|lkl_|__tls|__initcall_start
EXP_SYMRENAME:=$(EXP_SYMRENAME)|__initcall_end|__gcov|_end|_GLOBAL_OFFSET_TABLE|__assert13
EXP_SYMRENAME:=$(EXP_SYMRENAME)|${GCCSYMBOLS}|${GCCATOMIC}'${_SYMQUIRK}'
EXP_SYMRENAME:=$(EXP_SYMRENAME)${RUMP_SYM_NORENAME:D|${RUMP_SYM_NORENAME}}|${VMLINUX_SYMS}

define make_ns_symbols
${Q}echo " OBJCPY " $1 $2; \
${NM} -go $1 | awk ' \
$$NF!~/^'${_PQ}'(${EXP_SYMRENAME})/ \
{s=$$NF;sub(/^'${_PQ}'/, "&rumpns_", s); print $$NF, s}'\
| sort | uniq > $2.renametab; \
$(OBJCOPY) -R .eh_frame -L __start___ex_table \
-L __stop___ex_table --preserve-dates \
--redefine-syms $2.renametab $1 $2; \
rm -f $2.renametab
endef
else
LKL_ENTRY_POINTS := lkl_start_kernel lkl_sys_halt lkl_syscall lkl_trigger_irq \
lkl_get_free_irq lkl_put_irq lkl_create_syscall_thread \
lkl_stop_syscall_thread lkl_is_running
define make_ns_symbols
$(OBJCOPY) -R .eh_frame -R .syscall_defs $(foreach sym,$(LKL_ENTRY_POINTS),\
-G$(prefix)$(sym)) vmlinux lkl.o
endef
endif

core-y += arch/lkl/kernel/
core-y += arch/lkl/mm/
core-y += arch/lkl/drivers/

all: lkl.o

lkl.o: vmlinux
$(OBJCOPY) -R .eh_frame -R .syscall_defs $(foreach sym,$(LKL_ENTRY_POINTS),-G$(prefix)$(sym)) vmlinux lkl.o
$(call make_ns_symbols,vmlinux,lkl.o)

arch/lkl/include/generated/uapi/asm/syscall_defs.h: vmlinux
$(OBJCOPY) -j .syscall_defs -O binary --set-section-flags .syscall_defs=alloc $< $@
Expand Down
9 changes: 7 additions & 2 deletions arch/lkl/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ CONFIG_EXT4_FS_POSIX_ACL=y
CONFIG_EXT4_FS_SECURITY=y
CONFIG_XFS_FS=y
CONFIG_XFS_POSIX_ACL=y
CONFIG_BTRFS_FS=y
CONFIG_BTRFS_FS_POSIX_ACL=y
CONFIG_ISO9660_FS=y
#CONFIG_BTRFS_FS=y
#CONFIG_BTRFS_FS_POSIX_ACL=y
# CONFIG_FILE_LOCKING is not set
# CONFIG_DNOTIFY is not set
# CONFIG_INOTIFY_USER is not set
Expand Down Expand Up @@ -93,3 +94,7 @@ CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_INFO_REDUCED=y
# CONFIG_ENABLE_WARN_DEPRECATED is not set
# CONFIG_ENABLE_MUST_CHECK is not set
CONFIG_PCI=y
CONFIG_NET_CORE=y
CONFIG_VIRTIO_PCI=y
CONFIG_GENERIC_IOMAP=y
13 changes: 13 additions & 0 deletions arch/lkl/drivers/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

obj-y = rumpdev_pci.o

# need to build with
librumpdev_linux_pci.a: ${RUMP_BMK_PCI_HYPERCALLS}
rm -f $@
$(AR) rc $@ ${RUMP_BMK_PCI_HYPERCALLS}

install: librumpdev_linux_pci.a
install -D librumpdev_linux_pci.a ${DESTDIR}/lib/


.PHONY: ${RUMP_BMK_PCI_HYPERCALLS}
43 changes: 43 additions & 0 deletions arch/lkl/drivers/pci_user.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* Reused from src-netbsd/sys/rump/dev/lib/libpci/pci_user.h */
/*
* Possible userfeature macro flags:
*
* RUMPCOMP_USERFEATURE_PCI_DMAFREE:
* Support free'ing DMA memory. If not, panic() when free() is called.
*
* RUMPCOMP_USERFEATURE_PCI_IOSPACE
* Support for PCI I/O space. If yes, rumpcomp_pci_iospace_init()
* must be provided.
*/


void *rumpcomp_pci_map(unsigned long addr, unsigned long len);
int rumpcomp_pci_confread(unsigned int bus, unsigned int dev,
unsigned int fun, int reg, unsigned int *value);
int rumpcomp_pci_confwrite(unsigned int bus, unsigned int dev,
unsigned int fun, int reg, unsigned int value);
int rumpcomp_pci_irq_map(unsigned int bus, unsigned int device,
unsigned int fun, int intrline, unsigned int cookie);
void *rumpcomp_pci_irq_establish(unsigned int cookie,
int (*handler)(void *), void *data);

/* XXX: needs work: support boundary-restricted allocations */
int rumpcomp_pci_dmalloc(size_t size, size_t align,
unsigned long *pap, unsigned long *vap);
#ifdef RUMPCOMP_USERFEATURE_PCI_DMAFREE
void rumpcomp_pci_dmafree(unsigned long mem, size_t size);
#endif

struct rumpcomp_pci_dmaseg {
unsigned long ds_pa;
unsigned long ds_len;
unsigned long ds_vacookie;
};
int rumpcomp_pci_dmamem_map(struct rumpcomp_pci_dmaseg *dss, size_t nseg,
size_t totlen, void **vap);

unsigned long rumpcomp_pci_virt_to_mach(void *virt);

#ifdef RUMPCOMP_USERFEATURE_PCI_IOSPACE
int rumpcomp_pci_iospace_init(void);
#endif
Loading