Skip to content

Commit 57e4554

Browse files
committed
linux: add linux rump kernel build
build-rr.sh adds new -r option to switch what rump kernel is used: NetBSD is the default one and add Linux one for the alternative in this patch. Although there are several limitations (listed below) in this stage, this would be a first step toward supporting alternate rump kernel across different ones. Limitations: - no xen execution support (build should be fine) - no i486 build support - TLS is not properly implemented: tests are failed and uses TEST_LESS env for the minimum test - CXX is always false: CXX=false should be added to build linux rump kernel - no libz support - no cookfs (/rootfs) support - rumprun-packages needs more work: current test on travis is only build test and the executions might have various issues.
1 parent bbfbaf4 commit 57e4554

File tree

33 files changed

+735
-72
lines changed

33 files changed

+735
-72
lines changed

.gitmodules

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
[submodule "buildrump.sh"]
22
path = buildrump.sh
3-
url = https://github.com/rumpkernel/buildrump.sh
3+
url = https://github.com/libos-nuse/buildrump.sh
44
[submodule "src-netbsd"]
55
path = src-netbsd
66
url = https://github.com/rumpkernel/src-netbsd
7+
[submodule "linux"]
8+
path = linux
9+
url = https://github.com/libos-nuse/lkl-linux.git
10+
[submodule "musl"]
11+
path = musl
12+
url = https://github.com/libos-nuse/musl.git

.travis.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,33 @@ before_script:
1111
- sudo apt-get install --only-upgrade binutils gcc -y
1212

1313
env:
14-
- PLATFORM=hw MACHINE=x86_64 TESTS=qemu EXTRAFLAGS=
15-
- PLATFORM=hw MACHINE=i486 ELF=elf TESTS=qemu EXTRAFLAGS='-- -F ACLFLAGS=-m32 -F ACLFLAGS=-march=i686'
16-
- PLATFORM=xen MACHINE=x86_64 TESTS=none EXTRAFLAGS=
17-
- PLATFORM=xen MACHINE=i486 ELF=elf TESTS=none EXTRAFLAGS='-- -F ACLFLAGS=-m32'
18-
- PLATFORM=hw MACHINE=x86_64 TESTS=qemu EXTRAFLAGS= CXX='false'
19-
- PLATFORM=hw MACHINE=x86_64 TESTS=none KERNONLY=-k EXTRAFLAGS=
20-
- PLATFORM=xen MACHINE=x86_64 TESTS=none KERNONLY=-k EXTRAFLAGS=
14+
- PLATFORM=hw MACHINE=x86_64 TESTS=qemu RUMPKERNEL="-r netbsd" EXTRAFLAGS=
15+
- PLATFORM=hw MACHINE=i486 ELF=elf TESTS=qemu RUMPKERNEL="-r netbsd" EXTRAFLAGS='-- -F ACLFLAGS=-m32 -F ACLFLAGS=-march=i686'
16+
- PLATFORM=xen MACHINE=x86_64 TESTS=none RUMPKERNEL="-r netbsd" EXTRAFLAGS=
17+
- PLATFORM=xen MACHINE=i486 ELF=elf TESTS=none RUMPKERNEL="-r netbsd" EXTRAFLAGS='-- -F ACLFLAGS=-m32'
18+
- PLATFORM=hw MACHINE=x86_64 TESTS=qemu RUMPKERNEL="-r netbsd" EXTRAFLAGS= CXX='false'
19+
- PLATFORM=hw MACHINE=x86_64 TESTS=none RUMPKERNEL="-r netbsd" KERNONLY=-k EXTRAFLAGS=
20+
- PLATFORM=xen MACHINE=x86_64 TESTS=none RUMPKERNEL="-r netbsd" KERNONLY=-k EXTRAFLAGS=
21+
- PLATFORM=hw MACHINE=x86_64 TESTS=qemu RUMPKERNEL="-r linux" EXTRAFLAGS= TEST_LESS=1
22+
- PLATFORM=hw MACHINE=i486 ELF=elf TESTS=qemu RUMPKERNEL="-r linux" EXTRAFLAGS='-- -F ACLFLAGS=-m32 -F ACLFLAGS=-march=i686' TEST_LESS=1
23+
- PLATFORM=xen MACHINE=x86_64 TESTS=none RUMPKERNEL="-r linux" EXTRAFLAGS=
24+
- PLATFORM=xen MACHINE=i486 ELF=elf TESTS=none RUMPKERNEL="-r linux" EXTRAFLAGS='-- -F ACLFLAGS=-m32'
25+
- PLATFORM=hw MACHINE=x86_64 TESTS=qemu RUMPKERNEL="-r linux" EXTRAFLAGS= CXX='false' TEST_LESS=1
26+
- PLATFORM=hw MACHINE=x86_64 TESTS=none RUMPKERNEL="-r linux" KERNONLY=-k EXTRAFLAGS=
27+
- PLATFORM=xen MACHINE=x86_64 TESTS=none RUMPKERNEL="-r linux" KERNONLY=-k EXTRAFLAGS=
28+
29+
matrix:
30+
allow_failures:
31+
# no CXX
32+
- env: PLATFORM=hw MACHINE=x86_64 TESTS=qemu RUMPKERNEL="-r linux" EXTRAFLAGS= TEST_LESS=1
33+
- env: PLATFORM=xen MACHINE=x86_64 TESTS=none RUMPKERNEL="-r linux" EXTRAFLAGS=
34+
# no i486 build yet
35+
- env: PLATFORM=hw MACHINE=i486 ELF=elf TESTS=qemu RUMPKERNEL="-r linux" EXTRAFLAGS='-- -F ACLFLAGS=-m32 -F ACLFLAGS=-march=i686' TEST_LESS=1
36+
- env: PLATFORM=xen MACHINE=i486 ELF=elf TESTS=none RUMPKERNEL="-r linux" EXTRAFLAGS='-- -F ACLFLAGS=-m32'
2137

2238
script:
2339
- git submodule update --init
24-
- ./build-rr.sh -o myobj -j16 -qq ${KERNONLY} ${PLATFORM} ${EXTRAFLAGS}
40+
- ./build-rr.sh -o myobj -j16 -qq ${RUMPKERNEL} ${KERNONLY} ${PLATFORM} ${EXTRAFLAGS}
2541
- . ./myobj/config
2642
- ./tests/buildtests.sh ${KERNONLY}
2743
- ./tests/runtests.sh ${TESTS}

app-tools/rumprun

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ run_qemu ()
691691
if [ -n "$opt_interactive" ]; then
692692
${qemucmd} -append "${json_coma}"
693693
else
694-
qemucmd="${qemucmd} -display none"
694+
qemucmd="${qemucmd} -display none -vga none"
695695
${qemucmd} -append "${json_coma}" 1>/dev/null 2>&1 &
696696
echo qemu:$!
697697
fi
@@ -703,7 +703,13 @@ bake_iso ()
703703
[ -z "${DUMPCMD}" ] || die -D not supported by iso. Use -T.
704704

705705
type xorriso >/dev/null || die bake_iso needs xorriso
706-
type grub-mkrescue >/dev/null || die bake_iso needs grub-mkrescue
706+
if type grub-mkrescue 2>/dev/null >/dev/null; then
707+
MKRESCUE=grub-mkrescue
708+
elif type grub2-mkrescue 2>/dev/null >/dev/null; then
709+
MKRESCUE=grub2-mkrescue
710+
else
711+
die bake_iso needs grub-mkrescue or grub2-mkrescue
712+
fi
707713

708714
store_blkspec=json_store_iso_blkspec
709715
store_netspec=json_store_netspec
@@ -777,7 +783,7 @@ bake_iso ()
777783
$(basename $1) >> "${ISODIR}/boot/grub/grub.cfg"
778784
cp ${bootimage} "${ISODIR}/boot"
779785
cp "${TMPDIR}/json.cfg" "${ISODIR}"
780-
grub-mkrescue -o ${opt_name} "${ISODIR}"
786+
${MKRESCUE} -o ${opt_name} "${ISODIR}"
781787
}
782788

783789
make_ec2 ()

app-tools/rumprun-bake.conf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,17 @@ conf hw_generic
149149
_pciether \
150150
_usb
151151
fnoc
152+
153+
conf hw_lkl
154+
create "LKL generic (a.k.a all) targets"
155+
add -llkl
156+
add -lrumprun_base
157+
add -lrumpdev_linux_pci
158+
fnoc
159+
160+
conf xen_pv_lkl
161+
create "Xen with paravirtualized I/O drivers with LKL"
162+
add -llkl
163+
add -lrumprun_base
164+
add -lrumpdev_linux_pci
165+
fnoc

build-rr.sh

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ helpme ()
4949
printf "\t-o: use non-default object directory\n"
5050
printf "\t-k: build kernel only, without libc or tools\n"
5151
printf "\t-s: specify alternative src-netbsd location\n\n"
52+
printf "\t-r: type of rump kernel [netbsd|linux]. default netbsd\n\n\n"
5253
printf "\tbuildrump.sh opts are passed to buildrump.sh\n"
5354
printf "\n"
5455
printf "The toolchain is picked up from the environment. See the\n"
@@ -96,14 +97,16 @@ parseargs ()
9697
KERNONLY=false
9798
RROBJ=
9899
RUMPSRC=src-netbsd
100+
LKLSRC=linux
101+
RUMPKERNEL=netbsd
99102
STDJ=-j4
100103
EXTSRC=
101104

102105
DObuild=false
103106
DOinstall=false
104107

105108
orignargs=$#
106-
while getopts '?d:hj:ko:qs:' opt; do
109+
while getopts '?d:hj:kr:o:qs:' opt; do
107110
case "$opt" in
108111
'j')
109112
[ -z "$(echo ${OPTARG} | tr -d '[0-9]')" ] \
@@ -116,6 +119,14 @@ parseargs ()
116119
'k')
117120
KERNONLY=true
118121
;;
122+
'r')
123+
RUMPKERNEL="${OPTARG}"
124+
if [ ${RUMPKERNEL} != "netbsd" -a ${RUMPKERNEL} != "linux" ]; then
125+
echo '>> ERROR:'
126+
echo '>> -r option (RUMPKERNEL) must be netbsd or linux'
127+
exit 1
128+
fi
129+
;;
119130
'o')
120131
RROBJ="${OPTARG}"
121132
;;
@@ -180,6 +191,8 @@ parseargs ()
180191
DOinstall=true
181192
fi
182193

194+
. rumpkernel/${RUMPKERNEL}.sh
195+
183196
case ${RUMPSRC} in
184197
/*)
185198
;;
@@ -190,6 +203,7 @@ parseargs ()
190203

191204
export RUMPSRC
192205
export BUILD_QUIET
206+
export RUMPKERNEL
193207

194208
ARGSSHIFT=$((${orignargs} - $#))
195209
}
@@ -297,6 +311,9 @@ setvars ()
297311
abspath RRDEST
298312
abspath RROBJ
299313
abspath RUMPSRC
314+
abspath LKLSRC
315+
export RROBJ
316+
export LKLSRC
300317
}
301318

302319
checktools ()
@@ -357,7 +374,7 @@ buildrump ()
357374
-s ${RUMPSRC} -T ${RUMPTOOLS} -o ${BROBJ} -d ${STAGING} \
358375
-V MKPIC=no -V RUMP_CURLWP=__thread \
359376
-V RUMP_KERNEL_IS_LIBC=1 -V BUILDRUMP_SYSROOT=yes \
360-
${extracflags} "$@" tools
377+
${extracflags} -l ${RUMPKERNEL} "$@" tools
361378

362379
echo '>>'
363380
echo '>> Now that we have the appropriate tools, performing'
@@ -367,7 +384,7 @@ buildrump ()
367384
RUMPMAKE=$(pwd)/${RUMPTOOLS}/rumpmake
368385

369386
TOOLTUPLE=$(${RUMPMAKE} -f bsd.own.mk \
370-
-V '${MACHINE_GNU_PLATFORM:S/--netbsd/-rumprun-netbsd/}')
387+
-V '${MACHINE_GNU_PLATFORM:S/--netbsd/-rumprun-${RUMPKERNEL}/}')
371388

372389
[ $(${RUMPMAKE} -f bsd.own.mk -V '${_BUILDRUMP_CXX}') != 'yes' ] \
373390
|| HAVECXX=true
@@ -406,7 +423,7 @@ EOF
406423
# build rump kernel
407424
${BUILDRUMP}/buildrump.sh ${BUILD_QUIET} ${STDJ} -k \
408425
-s ${RUMPSRC} -T ${RUMPTOOLS} -o ${BROBJ} -d ${STAGING} \
409-
"$@" build kernelheaders install
426+
-l ${RUMPKERNEL} "$@" build kernelheaders install
410427

411428
echo '>>'
412429
echo '>> Rump kernel components built. Proceeding to build'
@@ -421,33 +438,6 @@ buildapptools ()
421438
${MAKE} -C app-tools BUILDRR=true install
422439
}
423440

424-
builduserspace ()
425-
{
426-
427-
usermtree ${STAGING}
428-
429-
LIBS="$(stdlibs ${RUMPSRC})"
430-
! ${HAVECXX} || LIBS="${LIBS} $(stdlibsxx ${RUMPSRC})"
431-
432-
userincludes ${RUMPSRC} ${LIBS} $(pwd)/lib/librumprun_tester
433-
for lib in ${LIBS}; do
434-
makeuserlib ${lib}
435-
done
436-
}
437-
438-
buildpci ()
439-
{
440-
441-
if eval ${PLATFORM_PCI_P}; then
442-
(
443-
cd ${PLATFORMDIR}/pci
444-
${RUMPMAKE} ${STDJ} obj
445-
${RUMPMAKE} ${STDJ} dependall
446-
${RUMPMAKE} ${STDJ} install
447-
)
448-
fi
449-
}
450-
451441
wraponetool ()
452442
{
453443

@@ -476,6 +466,7 @@ makeconfig ()
476466
echo "TOOLTUPLE=${quote}${TOOLTUPLE}${quote}" >> ${1}
477467
echo "KERNONLY=${quote}${KERNONLY}${quote}" >> ${1}
478468
echo "PLATFORM=${quote}${PLATFORM}${quote}" >> ${1}
469+
echo "RUMPKERNEL=${quote}${RUMPKERNEL}${quote}" >> ${1}
479470

480471
echo "RRDEST=${quote}${RRDEST}${quote}" >> ${1}
481472
echo "RROBJ=${quote}${RROBJ}${quote}" >> ${1}
@@ -517,7 +508,7 @@ dobuild ()
517508

518509
# do final build of the platform bits
519510
( cd ${PLATFORMDIR} \
520-
&& ${MAKE} BUILDRR=true \
511+
&& ${MAKE} BUILDRR=true RUMPKERNEL=${RUMPKERNEL} \
521512
&& ${MAKE} BUILDRR=true install || exit 1)
522513
[ $? -eq 0 ] || die platform make failed!
523514
}
@@ -543,11 +534,19 @@ doinstall ()
543534
# first, move things to where we want them to be
544535
cd ${STAGING}
545536
rm -rf lib/pkgconfig
546-
find lib -maxdepth 1 -name librump\*.a \
547-
-exec mv -f '{}' rumprun-${MACHINE_GNU_ARCH}/lib/rumprun-${PLATFORM}/ \;
548-
find lib -maxdepth 1 -name \*.a \
549-
-exec mv -f '{}' rumprun-${MACHINE_GNU_ARCH}/lib/ \;
550-
537+
if [ ${RUMPKERNEL} = "netbsd" ] ; then
538+
find lib -maxdepth 1 -name librump\*.a \
539+
-exec mv -f '{}' rumprun-${MACHINE_GNU_ARCH}/lib/rumprun-${PLATFORM}/ \;
540+
find lib -maxdepth 1 -name \*.a \
541+
-exec mv -f '{}' rumprun-${MACHINE_GNU_ARCH}/lib/ \;
542+
elif [ ${RUMPKERNEL} = "linux" ] ; then
543+
find lib -maxdepth 1 -name \*.a \
544+
-exec cp -f '{}' rumprun-${MACHINE_GNU_ARCH}/lib/rumprun-${PLATFORM}/ \;
545+
find lib -maxdepth 1 -name \*.a \
546+
-exec mv -f '{}' rumprun-${MACHINE_GNU_ARCH}/lib/ \;
547+
# FIXME: need to create empty librump.a for linux
548+
ar rc rumprun-${MACHINE_GNU_ARCH}/lib/rumprun-${PLATFORM}/librump.a
549+
fi
551550
# make sure special cases are visible everywhere
552551
for x in c pthread ; do
553552
rm -f rumprun-${MACHINE_GNU_ARCH}/lib/rumprun-${PLATFORM}/lib${x}.a

include/rumprun-base/config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,8 @@ struct rumprun_exec {
4848
TAILQ_HEAD(rumprun_execs, rumprun_exec);
4949
extern struct rumprun_execs rumprun_execs;
5050

51+
#ifndef __arraycount
52+
#define __arraycount(_ar_) (sizeof(_ar_)/sizeof(_ar_[0]))
53+
#endif
54+
5155
#endif /* _BMKCOMMON_RUMPRUN_CONFIG_H_ */

include/rumprun-base/rumprun.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,20 @@ void rumprun_daemon(void);
4242

4343
extern int rumprun_cold;
4444

45+
#ifndef _STRING
46+
#define _STRING(x) x
47+
#endif
48+
49+
#ifndef __strong_alias
50+
#define __strong_alias(alias,sym) \
51+
__asm(".global " _STRING(#alias) "\n" \
52+
_STRING(#alias) " = " _STRING(#sym));
53+
#endif
54+
55+
#ifndef __weak_alias
56+
#define __weak_alias(alias,sym) \
57+
__asm(".weak " _STRING(#alias) "\n" \
58+
_STRING(#alias) " = " _STRING(#sym));
59+
#endif
60+
4561
#endif /* _RUMPRUN_BASE_RUMPRUN_H_ */

lib/librumprun_base/Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ LIB= rumprun_base
22

33
SRCS= main.c rumprun.c
44
SRCS+= parseargs.c config.c
5-
SRCS+= malloc.c netbsd_initfini.c signals.c
6-
SRCS+= syscall_mman.c syscall_misc.c
7-
SRCS+= __errno.c _lwp.c libc_stubs.c
8-
SRCS+= daemon.c
5+
SRCS+= malloc.c
6+
SRCS+= __errno.c libc_stubs.c
7+
SRCS+= daemon.c syscall_misc.c
8+
9+
.if ${RUMPKERNEL} == "netbsd"
10+
SRCS+= netbsd_initfini.c signals.c
11+
SRCS+= _lwp.c
12+
SRCS+= syscall_mman.c
913
SRCS+= sysproxy.c
1014

1115
# doesn't really belong here, but at the moment we don't have
@@ -14,6 +18,10 @@ SRCS+= platefs.c
1418

1519
INCS= platefs.h
1620
INCSDIR= /usr/include/rumprun
21+
.else
22+
SRCS+= linux_initfini.c
23+
CFLAGS+= -DCONFIG_LKL -DMUSL_LIBC
24+
.endif
1725

1826
WARNS= 5
1927

0 commit comments

Comments
 (0)