├── .bintray_descriptor.json ├── .clang-format ├── .clang_complete ├── .gitignore ├── .gitmodules ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README-hermitcore.md ├── README.md ├── arch └── x86 │ ├── CMakeLists.txt │ ├── include │ └── asm │ │ ├── apic.h │ │ ├── atomic.h │ │ ├── atomic32.h │ │ ├── atomic64.h │ │ ├── gdt.h │ │ ├── idt.h │ │ ├── io.h │ │ ├── irq.h │ │ ├── irqflags.h │ │ ├── isrs.h │ │ ├── limits.h │ │ ├── multiboot.h │ │ ├── page.h │ │ ├── pci.h │ │ ├── processor.h │ │ ├── stddef.h │ │ ├── string.h │ │ ├── tasks.h │ │ ├── tasks_types.h │ │ ├── time.h │ │ ├── tss.h │ │ ├── uart.h │ │ └── uhyve.h │ ├── kernel │ ├── apic.c │ ├── boot.asm │ ├── entry.asm │ ├── gdt.c │ ├── idt.c │ ├── irq.c │ ├── isrs.c │ ├── pci.c │ ├── pcihdr.h │ ├── processor.c │ ├── signal.c │ ├── syscall.c │ ├── tasks.c │ ├── timer.c │ └── uart.c │ ├── libkern │ └── string.asm │ ├── loader │ ├── CMakeLists.txt │ ├── entry.asm │ ├── include │ │ ├── ctype.h │ │ ├── elf.h │ │ ├── io.h │ │ ├── limits.h │ │ ├── multiboot.h │ │ ├── page.h │ │ ├── stdarg.h │ │ ├── stddef.h │ │ ├── stdio.h │ │ ├── string.h │ │ └── uart.h │ ├── link.ld │ ├── main.c │ ├── page.c │ ├── printf.c │ ├── stdio.c │ ├── string.c │ ├── strstr.c │ ├── strtol.c │ └── uart.c │ └── mm │ ├── hbmemory.c │ ├── memory.c │ ├── page.c │ └── vma.c ├── cmake ├── HermitCore-Application.cmake ├── HermitCore-Configuration.cmake ├── HermitCore-Paths.cmake ├── HermitCore-Toolchain-x86-bootstrap.cmake ├── HermitCore-Toolchain-x86.cmake ├── HermitCore-Utils.cmake ├── HermitCore.cmake ├── README.md ├── golang │ ├── CMakeDetermineGoCompiler.cmake │ ├── CMakeGoCompiler.cmake.in │ ├── CMakeGoInformation.cmake │ └── CMakeTestGoCompiler.cmake └── local-cmake.sh ├── config ├── bzImage ├── ifcfg-mmnif ├── initrd.cpio ├── linux_config ├── linux_config_centos7 └── linux_config_fc23 ├── docker └── Dockerfile ├── drivers └── net │ ├── e1000.c │ ├── e1000.h │ ├── mmnif.c │ ├── mmnif.h │ ├── rtl8139.c │ ├── rtl8139.h │ ├── uhyve-net.c │ ├── uhyve-net.h │ ├── util.c │ ├── util.h │ ├── vioif.c │ └── vioif.h ├── img ├── demo.gif ├── hermitcore_logo.png └── hermitcore_logo.svg ├── include ├── hermit │ ├── CMakeLists.txt │ ├── config.asm.in │ ├── config.h.in │ ├── ctype.h │ ├── dequeue.h │ ├── errno.h │ ├── hermitux_profiler.h │ ├── hermitux_syscalls.h │ ├── ioctl.h │ ├── islelock.h │ ├── logging.h │ ├── mailbox.h │ ├── mailbox_types.h │ ├── malloc.h │ ├── memory.h │ ├── minifs.h │ ├── processor.h │ ├── rcce.h │ ├── semaphore.h │ ├── semaphore_types.h │ ├── signal.h │ ├── spinlock.h │ ├── spinlock_types.h │ ├── stdarg.h │ ├── stddef.h │ ├── stdio.h │ ├── stdlib.h │ ├── string.h │ ├── syscall-config.h │ ├── syscall.h │ ├── tasks.h │ ├── tasks_types.h │ ├── time.h │ ├── virtio_config.h │ ├── virtio_ids.h │ ├── virtio_net.h │ ├── virtio_pci.h │ ├── virtio_ring.h │ ├── virtio_types.h │ └── vma.h ├── netinet │ ├── in.h │ └── tcp.h ├── stdarg.h ├── stddef.h ├── stdlib.h ├── string.h └── sys │ ├── ipc.h │ ├── poll.h │ ├── shm.h │ └── uio.h ├── kernel ├── hermitux_profiler.c ├── main.c ├── minifs.c ├── syscall.c ├── syscalls │ ├── accept.c │ ├── access.c │ ├── arch_prctl.c │ ├── bind.c │ ├── brk.c │ ├── chdir.c │ ├── clock_getres.c │ ├── clock_gettime.c │ ├── clone.c │ ├── close.c │ ├── connect.c │ ├── creat.c │ ├── dup2.c │ ├── exit.c │ ├── exit_group.c │ ├── fcntl.c │ ├── fdatasync.c │ ├── fstat.c │ ├── fsync.c │ ├── futex.c │ ├── get_robust_list.c │ ├── get_ticks.c │ ├── getcwd.c │ ├── getdents.c │ ├── getdents64.c │ ├── getegid.c │ ├── geteuid.c │ ├── getgid.c │ ├── gethostname.c │ ├── getpeername.c │ ├── getpid.c │ ├── getppid.c │ ├── getpriority.c │ ├── getrandom.c │ ├── getrlimit.c │ ├── getsockname.c │ ├── getsockopt.c │ ├── gettid.c │ ├── gettimeofday.c │ ├── getuid.c │ ├── ioctl.c │ ├── kill.c │ ├── listen.c │ ├── lseek.c │ ├── lstat.c │ ├── madvise.c │ ├── mincore.c │ ├── mkdir.c │ ├── mmap.c │ ├── mprotect.c │ ├── mremap.c │ ├── msleep.c │ ├── munmap.c │ ├── nanosleep.c │ ├── newfstatat.c │ ├── open.c │ ├── openat.c │ ├── pipe.c │ ├── poll.c │ ├── pread64.c │ ├── prlimit64.c │ ├── pwrite64.c │ ├── rcce_fini.c │ ├── rcce_init.c │ ├── rcce_malloc.c │ ├── read.c │ ├── readlink.c │ ├── readv.c │ ├── recvfrom.c │ ├── rename.c │ ├── rmdir.c │ ├── rseq.c │ ├── rt_sigaction.c │ ├── sbrk.c │ ├── sched_getaffinity.c │ ├── sched_setaffinity.c │ ├── sched_yield.c │ ├── select.c │ ├── sem_cancelablewait.c │ ├── sem_destroy.c │ ├── sem_init.c │ ├── sem_post.c │ ├── sem_timedwait.c │ ├── sem_wait.c │ ├── sendfile.c │ ├── sendto.c │ ├── set_robust_list.c │ ├── set_tid_address.c │ ├── sethostname.c │ ├── setpriority.c │ ├── setrlimit.c │ ├── setsid.c │ ├── setsockopt.c │ ├── shutdown.c │ ├── sigaltstack.c │ ├── signal.c │ ├── socket.c │ ├── socket_recv.c │ ├── socket_send.c │ ├── spinlock_destroy.c │ ├── spinlock_init.c │ ├── spinlock_lock.c │ ├── spinlock_unlock.c │ ├── stat.c │ ├── sync.c │ ├── syncfs.c │ ├── sysinfo.c │ ├── tgkill.c │ ├── time.c │ ├── tkill.c │ ├── umask.c │ ├── uname.c │ ├── unlink.c │ ├── write.c │ ├── writev.c │ └── yield.c ├── tasks.c └── timer.c ├── libkern ├── printf.c ├── sprintf.c ├── stdio.c ├── string.c ├── strstr.c ├── strtol.c └── strtoul.c ├── mm ├── malloc.c └── vma.c ├── tests.sh ├── tools ├── CMakeLists.txt ├── demo_ircce.sh ├── demo_kvm.sh ├── demo_omp.sh ├── init.sh ├── mini_gzip.c ├── mini_gzip.h ├── miniz.c ├── miniz.h ├── proxy.c ├── proxy.h ├── queue.h ├── uhyve-cpu.h ├── uhyve-elf.c ├── uhyve-elf.h ├── uhyve-gdb.c ├── uhyve-gdb.h ├── uhyve-msr.h ├── uhyve-net.c ├── uhyve-net.h ├── uhyve-profiler.c ├── uhyve-profiler.h ├── uhyve-seccomp.c ├── uhyve-seccomp.h ├── uhyve-syscalls.h ├── uhyve.c ├── uhyve.h └── utils.c └── usr ├── benchmarks ├── CMakeLists.txt ├── RCCE_pingping.c ├── RCCE_pingpong.c ├── basic.c ├── bt.b │ ├── CMakeLists.txt │ ├── add.c │ ├── adi.c │ ├── bt.c │ ├── c_print_results.c │ ├── c_timers.c │ ├── error.c │ ├── exact_rhs.c │ ├── exact_solution.c │ ├── header.h │ ├── initialize.c │ ├── npbparams.h │ ├── print_results.c │ ├── print_results.h │ ├── rhs.c │ ├── set_constants.c │ ├── solve_subs.c │ ├── timers.h │ ├── type.h │ ├── verify.c │ ├── work_lhs.h │ ├── wtime.c │ ├── wtime.h │ ├── x_solve.c │ ├── y_solve.c │ └── z_solve.c ├── cg.b │ ├── CMakeLists.txt │ ├── c_print_results.c │ ├── c_timers.c │ ├── cg.c │ ├── globals.h │ ├── npbparams.h │ ├── print_results.c │ ├── print_results.h │ ├── randdp.c │ ├── randdp.h │ ├── timers.h │ ├── type.h │ ├── wtime.c │ └── wtime.h ├── ep.b │ ├── CMakeLists.txt │ ├── c_print_results.c │ ├── c_timers.c │ ├── ep.c │ ├── globals.h │ ├── npbparams.h │ ├── print_results.c │ ├── print_results.h │ ├── randdp.c │ ├── randdp.h │ ├── res.txt │ ├── timers.h │ ├── type.h │ ├── wtime.c │ └── wtime.h ├── hg.c ├── hist.c ├── hist.h ├── init.c ├── init.h ├── is.b │ ├── CMakeLists.txt │ ├── c_print_results.c │ ├── c_timers.c │ ├── is.c │ ├── npbparams.h │ ├── res.txt │ ├── wtime.c │ └── wtime.h ├── mg.b │ ├── CMakeLists.txt │ ├── c_print_results.c │ ├── c_timers.c │ ├── globals.h │ ├── mg.c │ ├── npbparams.h │ ├── print_results.c │ ├── print_results.h │ ├── randdp.c │ ├── randdp.h │ ├── res.txt │ ├── timers.h │ ├── type.h │ ├── wtime.c │ └── wtime.h ├── netio.c ├── opt.c ├── opt.h ├── rdtsc.c ├── rdtsc.h ├── report.c ├── report.h ├── run.c ├── run.h ├── setup.c ├── setup.h ├── sp.b │ ├── CMakeLists.txt │ ├── add.c │ ├── adi.c │ ├── c_print_results.c │ ├── c_timers.c │ ├── error.c │ ├── exact_rhs.c │ ├── exact_solution.c │ ├── globals.h │ ├── header.h │ ├── initialize.c │ ├── ninvr.c │ ├── npbparams.h │ ├── pinvr.c │ ├── print_results.c │ ├── print_results.h │ ├── randdp.c │ ├── randdp.h │ ├── res.txt │ ├── rhs.c │ ├── set_constants.c │ ├── sp.c │ ├── timers.h │ ├── txinvr.c │ ├── type.h │ ├── tzetar.c │ ├── verify.c │ ├── wtime.c │ ├── wtime.h │ ├── x_solve.c │ ├── y_solve.c │ └── z_solve.c ├── stream.c └── ua.b │ ├── CMakeLists.txt │ ├── adapt.c │ ├── c_print_results.c │ ├── c_timers.c │ ├── convect.c │ ├── diffuse.c │ ├── globals.h │ ├── header.h │ ├── mason.c │ ├── move.c │ ├── npbparams.h │ ├── precond.c │ ├── print_results.c │ ├── print_results.h │ ├── randdp.c │ ├── randdp.h │ ├── res.txt │ ├── setup.c │ ├── timers.h │ ├── transfer.c │ ├── type.h │ ├── ua.c │ ├── utils.c │ ├── verify.c │ ├── wtime.c │ └── wtime.h ├── gdb ├── README.txt ├── hermit-gdb.py └── hermit │ ├── __init__.py │ └── tasks.py ├── ircce ├── CMakeLists.txt ├── RCCE.h ├── RCCE_admin.c ├── RCCE_bcast.c ├── RCCE_comm.c ├── RCCE_debug.c ├── RCCE_debug.h ├── RCCE_flags.c ├── RCCE_get.c ├── RCCE_lib.h ├── RCCE_malloc.c ├── RCCE_put.c ├── RCCE_qsort.c ├── RCCE_recv.c ├── RCCE_reduce.c ├── RCCE_send.c ├── RCCE_synch.c ├── iRCCE.h ├── iRCCE_admin.c ├── iRCCE_atomic.c ├── iRCCE_get.c ├── iRCCE_irecv.c ├── iRCCE_isend.c ├── iRCCE_lib.h ├── iRCCE_mcast.c ├── iRCCE_put.c ├── iRCCE_srecv.c ├── iRCCE_ssend.c ├── iRCCE_synch.c ├── iRCCE_waitlist.c ├── rte_memcpy.h └── syscall.h ├── libgomp ├── Makefile ├── affinity.c ├── alloc.c ├── bar.c ├── bar.h ├── barrier.c ├── config.h ├── critical.c ├── env.c ├── error.c ├── fortran.c ├── hashtab.h ├── iter.c ├── iter_ull.c ├── libgomp.h ├── libgomp.spec ├── libgomp_f.h ├── libgomp_g.h ├── lock.c ├── loop.c ├── loop_ull.c ├── mutex.c ├── mutex.h ├── omp-lock.h ├── omp.h ├── omp_lib.h ├── omp_lib.h.in ├── ordered.c ├── parallel.c ├── proc.c ├── ptrlock.c ├── ptrlock.h ├── sections.c ├── sem.c ├── sem.h ├── single.c ├── task.c ├── team.c ├── time.c └── work.c ├── openmpbench ├── .gitignore ├── CMakeLists.txt ├── Licence.txt ├── README.txt ├── arraybench.c ├── arraybench.h ├── common.c ├── common.h ├── schedbench.c ├── schedbench.h ├── syncbench.c ├── syncbench.h ├── taskbench.c └── taskbench.h ├── tests ├── CMakeLists.txt ├── RCCE_minimum.c ├── argv_envp.c ├── hello++.cpp ├── hello-minimal.c ├── hello.c ├── hellof.f90 ├── hermitux.c ├── jacobi.c ├── linker.ld ├── pi.go ├── server.go ├── signals.c ├── syscall_tester.c ├── test-malloc-mt.c ├── test-malloc.c ├── thr_hello.c └── timing.c └── xray ├── CMakeLists.txt ├── LICENSE ├── README.md ├── browser.c ├── demangle.c ├── hashtable.c ├── libxray.spec ├── parsesymbols.c ├── report.c ├── stringpool.c ├── symtable.c ├── tools ├── conv2kcg.py └── report.xray ├── xray.c ├── xray.h ├── xray.odt └── xray_priv.h /.bintray_descriptor.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": { 3 | "name": "libhermit", 4 | "repo": "hermitcore", 5 | "subject": "rwth-os", 6 | "website_url": "http://www.hermitcore.org", 7 | "issue_tracker_url": "https://github.com/RWTH-OS/HermitCore/issues", 8 | "vcs_url": "https://github.com/RWTH-OS/HermitCore.git", 9 | "github_release_notes_file": "RELEASE", 10 | "licenses": ["Revised BSD"], 11 | "public_download_numbers": false, 12 | "public_stats": false 13 | }, 14 | 15 | "version": { 16 | "name": "0.2.6", 17 | "desc": "HermitCore's kernel as libOS", 18 | "gpgSign": false 19 | }, 20 | 21 | "files": 22 | [ 23 | { 24 | "includePattern": "build/(libhermit[^/]*deb$)", "uploadPattern": "$1", 25 | "matrixParams": { 26 | "deb_distribution": "vivid", 27 | "deb_component": "main", 28 | "deb_architecture": "amd64", 29 | "override": 1} 30 | }, 31 | {"includePattern": "build/(libhermit[^/]*rpm$)", "uploadPattern": "$1", "override": 1}, 32 | {"includePattern": "build/(libhermit[^/]*tar.bz2$)", "uploadPattern": "$1", "override": 1} 33 | ], 34 | "publish": true 35 | } 36 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | DisableFormat: true 2 | -------------------------------------------------------------------------------- /.clang_complete: -------------------------------------------------------------------------------- 1 | -Ihermit/include 2 | -Ihermit/arch/x86/include 3 | -Ihermit/lwip/src/include 4 | -Ihermit/lwip/src/include/ipv4 5 | -Ihermit/drivers 6 | -nostdinc 7 | -ffreestanding 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | prefix 3 | tags 4 | *.pcap 5 | *.config 6 | *.creator 7 | *.user 8 | *.files 9 | *.includes 10 | *.pyc 11 | *.callgrind 12 | *.xray 13 | *.o 14 | *.ko 15 | **/build/* 16 | .idea/* 17 | qemu-vlan0.pcap 18 | cmake/cmake-3.7.2-Linux-x86_64/* 19 | 20 | usr/tests 21 | usr/gdb/core 22 | cscope.out 23 | tools/.proxy.c.swp 24 | 25 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lwip"] 2 | path = lwip 3 | url = https://github.com/ssrg-vt/lwip-hermitux.git 4 | branch = hermit 5 | [submodule "usr/libomp"] 6 | path = usr/libomp 7 | url = https://github.com/ssrg-vt/libomp_oss-hermitux.git 8 | branch = hermit 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2010-2017, RWTH Aachen University, Germany 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hermitux Kernel 2 | 3 | This repository contains the sources for the kernel of HermiTux, a unikernel 4 | that is binary compatible with Linux applications. To try HermiTux please 5 | follow this link: 6 | 7 | https://github.com/ssrg-vt/hermitux 8 | -------------------------------------------------------------------------------- /arch/x86/kernel/pcihdr.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssrg-vt/hermitux-kernel/ff53acc13a223da8ef04f890a3e9b9ad0643fe3e/arch/x86/kernel/pcihdr.h -------------------------------------------------------------------------------- /arch/x86/libkern/string.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Written by the Chair for Operating Systems, RWTH Aachen University 3 | ; 4 | ; NO Copyright (C) 2010-2011, Stefan Lankes 5 | ; consider these trivial functions to be public domain. 6 | ; 7 | ; These functions are distributed on an "AS IS" BASIS, 8 | ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | ; 10 | 11 | %include "hermit/config.asm" 12 | 13 | %ifdef CONFIG_X86_32 14 | [BITS 32] 15 | %else 16 | [BITS 64] 17 | %endif 18 | SECTION .text 19 | global strcpy 20 | strcpy: 21 | %ifdef CONFIG_X86_32 22 | push ebp 23 | mov ebp, esp 24 | push edi 25 | push esi 26 | 27 | mov esi, [ebp+12] 28 | mov edi, [ebp+8] 29 | %else 30 | push rdi 31 | %endif 32 | 33 | L1: 34 | lodsb 35 | stosb 36 | test al, al 37 | jne L1 38 | 39 | %ifdef CONFIG_X86_32 40 | mov eax, [ebp+8] 41 | pop esi 42 | pop edi 43 | pop ebp 44 | %else 45 | pop rax 46 | %endif 47 | ret 48 | 49 | global strncpy 50 | strncpy: 51 | %ifdef CONFIG_X86_32 52 | push ebp 53 | mov ebp, esp 54 | push edi 55 | push esi 56 | 57 | mov ecx, [ebp+16] 58 | mov esi, [ebp+12] 59 | mov edi, [ebp+8] 60 | 61 | L2: 62 | dec ecx 63 | %else 64 | push rdi 65 | mov rcx, rdx 66 | 67 | L2: 68 | dec rcx 69 | %endif 70 | js L3 71 | lodsb 72 | stosb 73 | test al, al 74 | jne L1 75 | rep 76 | stosb 77 | 78 | L3: 79 | %ifdef CONFIG_X86_32 80 | mov eax, [ebp+8] 81 | pop esi 82 | pop edi 83 | pop ebp 84 | %else 85 | pop rax 86 | %endif 87 | ret 88 | 89 | SECTION .note.GNU-stack noalloc noexec nowrite progbits 90 | -------------------------------------------------------------------------------- /arch/x86/loader/link.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf64-x86-64") 2 | OUTPUT_ARCH("i386:x86-64") 3 | ENTRY(start) 4 | phys = 0x000000100000; 5 | 6 | SECTIONS 7 | { 8 | kernel_start = phys; 9 | .mboot phys : AT(ADDR(.mboot)) { 10 | *(.mboot) 11 | } 12 | .text ALIGN(4096) : AT(ADDR(.text)) { 13 | *(.text) 14 | } 15 | .rodata ALIGN(4096) : AT(ADDR(.rodata)) { 16 | *(.rodata) 17 | *(.rodata.*) 18 | } 19 | .data ALIGN(4096) : AT(ADDR(.data)) { 20 | *(.data) 21 | } 22 | .bss ALIGN(4096) : AT(ADDR(.bss)) { 23 | bss_start = .; 24 | *(.bss) 25 | } 26 | bss_end = .; 27 | kernel_end = .; 28 | } 29 | -------------------------------------------------------------------------------- /cmake/HermitCore-Application.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/HermitCore.cmake) 2 | include_guard() 3 | 4 | add_compile_options(${HERMIT_APP_FLAGS}) 5 | 6 | # link against and include locally built libraries instead of the ones 7 | # supplied with the toolchain, if built from top-level 8 | link_directories(${LOCAL_PREFIX_ARCH_LIB_DIR}) 9 | include_directories(BEFORE ${LOCAL_PREFIX_ARCH_INCLUDE_DIR}) 10 | 11 | # Pierre: hack, FIXME later 12 | include_directories(BEFORE ${HERMIT_ROOT}/prefix/x86_64-hermit/include) 13 | -------------------------------------------------------------------------------- /cmake/HermitCore-Configuration.cmake: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION "0.2.6" CACHE STRING 2 | "HermitCore current version") 3 | 4 | set(MAX_CORES "64" CACHE STRING 5 | "Maximum number of cores that can be managed") 6 | 7 | set(MAX_TASKS "((MAX_CORES * 2) + 2)" CACHE STRING 8 | "Maximum number of tasks") 9 | 10 | set(MAX_ISLE "8" CACHE STRING 11 | "Maximum number of NUMA isles") 12 | 13 | set(MAX_FNAME "128" CACHE STRING 14 | "Define the maximum length of a file name") 15 | 16 | set(KERNEL_STACK_SIZE 8192 CACHE STRING 17 | "Kernel stack size in bytes") 18 | 19 | #set(DEFAULT_STACK_SIZE 262144 CACHE STRING 20 | set(DEFAULT_STACK_SIZE 524288 CACHE STRING 21 | "Task stack size in bytes") 22 | 23 | set(MAX_ARGC_ENVC 128 CACHE STRING 24 | "Maximum number of command line parameters and enviroment variables 25 | forwarded to uhyve") 26 | 27 | option(NO_NET 28 | "Disable networking" OFF) 29 | 30 | option(NO_IRCCE 31 | "Disable IRCCE" OFF) 32 | 33 | option(NO_SIGNAL 34 | "Disable signal support" OFF) 35 | 36 | option(DYNAMIC_TICKS 37 | "Don't use a periodic timer event to keep track of time" OFF) 38 | 39 | option(SAVE_FPU 40 | "Save FPU registers on context switch" ON) 41 | 42 | option(HAVE_ARCH_MEMSET "Use machine specific version of memset" OFF) 43 | option(HAVE_ARCH_MEMCPY "Use machine specific version of memcpy" OFF) 44 | option(HAVE_ARCH_STRLEN "Use machine specific version of strlen" OFF) 45 | option(HAVE_ARCH_STRCPY "Use machine specific version of strcpy" OFF) 46 | option(HAVE_ARCH_STRNCPY "Use machine specific version of strncpy" OFF) 47 | -------------------------------------------------------------------------------- /cmake/HermitCore-Paths.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/HermitCore-Utils.cmake) 2 | # no include guard here because we have to include this file twice to correctly 3 | # set CMAKE_INSTALL_PREFIX 4 | 5 | # root of HermitCore project 6 | set(HERMIT_ROOT ${CMAKE_CURRENT_LIST_DIR}/..) 7 | 8 | # set default install prefix if user doesn't specify one 9 | if(${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT}) 10 | # See CMake docs for reference: 11 | # https://cmake.org/cmake/help/v3.7/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.html 12 | set(CMAKE_INSTALL_PREFIX /opt/hermit CACHE PATH "..." FORCE) 13 | endif() 14 | 15 | # we install 3rd party libraries to an intermediate directory and relocate 16 | # them here later when installing the whole project 17 | if(NOT LOCAL_PREFIX_BASE_DIR) 18 | # will be injected into external project because CMAKE_BINARY_DIR will be 19 | # different there 20 | set(LOCAL_PREFIX_BASE_DIR ${CMAKE_BINARY_DIR}/local_prefix) 21 | endif() 22 | 23 | # during build process libraries and external projects will be deployed into 24 | # this directory structure 25 | set(LOCAL_PREFIX_DIR ${LOCAL_PREFIX_BASE_DIR}/${CMAKE_INSTALL_PREFIX}) 26 | set(LOCAL_PREFIX_ARCH_DIR ${LOCAL_PREFIX_DIR}/${TARGET_ARCH}) 27 | set(LOCAL_PREFIX_ARCH_INCLUDE_DIR ${LOCAL_PREFIX_ARCH_DIR}/include) 28 | 29 | # when building applications within the HermitCore project (tests, ...) they 30 | # will link prefarably against libraries in this directory in order to test 31 | # changes in the kernel 32 | set(LOCAL_PREFIX_ARCH_LIB_DIR ${LOCAL_PREFIX_ARCH_DIR}/lib) 33 | 34 | # generated configs will be put here 35 | set(GENERATED_CONFIG_DIR ${CMAKE_BINARY_DIR}/include) 36 | -------------------------------------------------------------------------------- /cmake/HermitCore-Toolchain-x86-bootstrap.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/HermitCore-Toolchain-x86.cmake) 2 | include_guard() 3 | 4 | set(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "") 5 | set(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "") 6 | 7 | # bootstrap toolchain cannot compile neither Go nor Fortran 8 | unset(CMAKE_Go_COMPILER) 9 | unset(CMAKE_Fortran_COMPILER) 10 | -------------------------------------------------------------------------------- /cmake/HermitCore-Toolchain-x86.cmake: -------------------------------------------------------------------------------- 1 | include(${CMAKE_CURRENT_LIST_DIR}/HermitCore-Utils.cmake) 2 | include_guard() 3 | 4 | # let user provide a different path to the toolchain 5 | set_default(TOOLCHAIN_BIN_DIR /opt/hermit/bin) 6 | 7 | set(TARGET_ARCH x86_64-hermit) 8 | 9 | set(CMAKE_SYSTEM_NAME Generic) 10 | 11 | # point CMake to our toolchain 12 | set(CMAKE_C_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_ARCH}-gcc) 13 | set(CMAKE_CXX_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_ARCH}-g++) 14 | set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_ARCH}-gfortran) 15 | set(CMAKE_Go_COMPILER ${TOOLCHAIN_BIN_DIR}/${TARGET_ARCH}-gccgo) 16 | 17 | # hinting the prefix and location is needed in order to correctly detect 18 | # binutils 19 | set(_CMAKE_TOOLCHAIN_PREFIX "${TARGET_ARCH}-") 20 | set(_CMAKE_TOOLCHAIN_LOCATION ${TOOLCHAIN_BIN_DIR}) 21 | 22 | option(HAVE_ARCH_MEMSET "Use machine specific version of memset" ON) 23 | option(HAVE_ARCH_MEMCPY "Use machine specific version of memcpy" ON) 24 | option(HAVE_ARCH_STRLEN "Use machine specific version of strlen" ON) 25 | option(HAVE_ARCH_STRCPY "Use machine specific version of strcpy" ON) 26 | option(HAVE_ARCH_STRNCPY "Use machine specific version of strncpy" ON) 27 | -------------------------------------------------------------------------------- /cmake/golang/CMakeDetermineGoCompiler.cmake: -------------------------------------------------------------------------------- 1 | # Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | # file Copyright.txt or https://cmake.org/licensing for details. 3 | 4 | # determine the compiler to use for Go programs 5 | # NOTE, a generator may set CMAKE_Go_COMPILER before 6 | # loading this file to force a compiler. 7 | 8 | if(NOT CMAKE_Go_COMPILER) 9 | # prefer the environment variable CC 10 | if(NOT $ENV{GO_COMPILER} STREQUAL "") 11 | get_filename_component(CMAKE_Go_COMPILER_INIT $ENV{GO_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_Go_FLAGS_ENV_INIT) 12 | if(CMAKE_Go_FLAGS_ENV_INIT) 13 | set(CMAKE_Go_COMPILER_ARG1 "${CMAKE_Go_FLAGS_ENV_INIT}" CACHE STRING "First argument to Go compiler") 14 | endif() 15 | if(NOT EXISTS ${CMAKE_Go_COMPILER_INIT}) 16 | message(SEND_ERROR "Could not find compiler set in environment variable GO_COMPILER:\n$ENV{GO_COMPILER}.") 17 | endif() 18 | endif() 19 | 20 | set(Go_BIN_PATH 21 | $ENV{GOPATH} 22 | $ENV{GOROOT} 23 | $ENV{GOROOT}/../bin 24 | $ENV{GO_COMPILER} 25 | /usr/bin 26 | /usr/local/bin 27 | ) 28 | # if no compiler has been specified yet, then look for one 29 | if(CMAKE_Go_COMPILER_INIT) 30 | set(CMAKE_Go_COMPILER ${CMAKE_Go_COMPILER_INIT} CACHE PATH "Go Compiler") 31 | else() 32 | find_program(CMAKE_Go_COMPILER 33 | NAMES go 34 | PATHS ${Go_BIN_PATH} 35 | ) 36 | endif() 37 | endif() 38 | mark_as_advanced(CMAKE_Go_COMPILER) 39 | 40 | # configure variables set in this file for fast reload later on 41 | configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeGoCompiler.cmake.in 42 | ${CMAKE_PLATFORM_INFO_DIR}/CMakeGoCompiler.cmake @ONLY) 43 | set(CMAKE_Go_COMPILER_ENV_VAR "GO_COMPILER") 44 | -------------------------------------------------------------------------------- /cmake/golang/CMakeGoCompiler.cmake.in: -------------------------------------------------------------------------------- 1 | # Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | # file Copyright.txt or https://cmake.org/licensing for details. 3 | 4 | set(CMAKE_Go_COMPILER "@CMAKE_Go_COMPILER@") 5 | set(CMAKE_Go_COMPILER_LOADED 1) 6 | 7 | set(CMAKE_Go_SOURCE_FILE_EXTENSIONS go) 8 | set(CMAKE_Go_LINKER_PREFERENCE 40) 9 | set(CMAKE_Go_OUTPUT_EXTENSION .6) 10 | set(CMAKE_Go_OUTPUT_EXTENSION_REPLACE 1) 11 | set(CMAKE_Go_COMPILER_ENV_VAR "GO_COMPILER") 12 | -------------------------------------------------------------------------------- /cmake/golang/CMakeGoInformation.cmake: -------------------------------------------------------------------------------- 1 | # Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | # file Copyright.txt or https://cmake.org/licensing for details. 3 | 4 | # This should be included before the _INIT variables are 5 | # used to initialize the cache. Since the rule variables 6 | # have if blocks on them, users can still define them here. 7 | # But, it should still be after the platform file so changes can 8 | # be made to those values. 9 | 10 | if(CMAKE_USER_MAKE_RULES_OVERRIDE) 11 | # Save the full path of the file so try_compile can use it. 12 | include(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override) 13 | set(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}") 14 | endif() 15 | 16 | if(CMAKE_USER_MAKE_RULES_OVERRIDE_Go) 17 | # Save the full path of the file so try_compile can use it. 18 | include(${CMAKE_USER_MAKE_RULES_OVERRIDE_Go} RESULT_VARIABLE _override) 19 | set(CMAKE_USER_MAKE_RULES_OVERRIDE_Go "${_override}") 20 | endif() 21 | 22 | # refer: /usr/share/cmake-3.7/Modules/CMakeCInformation.cmake 23 | 24 | if(NOT CMAKE_Go_COMPILE_OBJECT) 25 | set(CMAKE_Go_COMPILE_OBJECT " -o -c ") 26 | endif() 27 | 28 | if(NOT CMAKE_Go_LINK_EXECUTABLE) 29 | set(CMAKE_Go_LINK_EXECUTABLE " -pthread -o ") 30 | endif() 31 | -------------------------------------------------------------------------------- /cmake/golang/CMakeTestGoCompiler.cmake: -------------------------------------------------------------------------------- 1 | # Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | # file Copyright.txt or https://cmake.org/licensing for details. 3 | 4 | set(CMAKE_Go_COMPILER_WORKS 1 CACHE INTERNAL "") 5 | -------------------------------------------------------------------------------- /config/bzImage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssrg-vt/hermitux-kernel/ff53acc13a223da8ef04f890a3e9b9ad0643fe3e/config/bzImage -------------------------------------------------------------------------------- /config/ifcfg-mmnif: -------------------------------------------------------------------------------- 1 | DEVICE=mmnif 2 | BOOTPROTO=none 3 | ONBOOT=yes 4 | NETWORK=192.168.28.0 5 | NETMASK=255.255.255.0 6 | IPADDR=192.168.28.1 7 | NM_CONTROLLED=yes 8 | -------------------------------------------------------------------------------- /config/initrd.cpio: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssrg-vt/hermitux-kernel/ff53acc13a223da8ef04f890a3e9b9ad0643fe3e/config/initrd.cpio -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | #Download base image ubuntu 16.04 2 | FROM ubuntu:16.04 3 | 4 | # Update Software repository 5 | RUN apt-get -qq update 6 | 7 | # add https support 8 | RUN apt-get install -y apt-transport-https 9 | 10 | # add path to hermitcore packets 11 | RUN echo "deb https://dl.bintray.com/rwth-os/hermitcore vivid main" | tee -a /etc/apt/sources.list 12 | 13 | # Update Software repository 14 | RUN apt-get -qq update 15 | 16 | # Install required packets from ubuntu repository 17 | RUN apt-get install -y curl wget vim nano git binutils autoconf automake make cmake qemu-system-x86 nasm gcc 18 | RUN apt-get install -y --allow-unauthenticated binutils-hermit libhermit newlib-hermit pthread-embedded-hermit gcc-hermit 19 | 20 | ENV PATH="/opt/hermit/bin:${PATH}" 21 | ENV EDITOR=vim 22 | 23 | CMD echo "This is a HermitCore's toolchain!"; /bin/bash 24 | -------------------------------------------------------------------------------- /img/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssrg-vt/hermitux-kernel/ff53acc13a223da8ef04f890a3e9b9ad0643fe3e/img/demo.gif -------------------------------------------------------------------------------- /img/hermitcore_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssrg-vt/hermitux-kernel/ff53acc13a223da8ef04f890a3e9b9ad0643fe3e/img/hermitcore_logo.png -------------------------------------------------------------------------------- /include/hermit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | 3 | configure_file(config.h.in config.h) 4 | configure_file(config.asm.in config.asm) 5 | 6 | # Show include files in IDE 7 | file(GLOB_RECURSE HERMIT_INCLUDES "*") 8 | add_custom_target(hermit_includes_ide SOURCES ${HERMIT_INCLUDES}) 9 | 10 | # install generated config files when building libhermit for bootstrapping 11 | install(FILES 12 | ${GENERATED_CONFIG_DIR}/hermit/config.h 13 | ${GENERATED_CONFIG_DIR}/hermit/config.asm 14 | DESTINATION ${TARGET_ARCH}/include/hermit/ 15 | COMPONENT bootstrap) 16 | -------------------------------------------------------------------------------- /include/hermit/config.asm.in: -------------------------------------------------------------------------------- 1 | %define MAX_CORES @MAX_CORES@ 2 | %define KERNEL_STACK_SIZE @KERNEL_STACK_SIZE@ 3 | %define SAVE_FPU @SAVE_FPU@ 4 | -------------------------------------------------------------------------------- /include/hermit/config.h.in: -------------------------------------------------------------------------------- 1 | #cmakedefine MAX_CORES (@MAX_CORES@) 2 | #cmakedefine MAX_TASKS (@MAX_TASKS@) 3 | #cmakedefine MAX_ISLE (@MAX_ISLE@) 4 | #cmakedefine KERNEL_STACK_SIZE (@KERNEL_STACK_SIZE@) 5 | #cmakedefine DEFAULT_STACK_SIZE (@DEFAULT_STACK_SIZE@) 6 | #cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" 7 | #cmakedefine MAX_FNAME (@MAX_FNAME@) 8 | 9 | #cmakedefine SAVE_FPU 10 | 11 | #cmakedefine DYNAMIC_TICKS 12 | 13 | /* Define to use machine specific version of memcpy */ 14 | #cmakedefine HAVE_ARCH_MEMCPY 15 | 16 | /* Define to use machine specific version of memset */ 17 | #cmakedefine HAVE_ARCH_MEMSET 18 | 19 | /* Define to use machine specific version of strcpy */ 20 | #cmakedefine HAVE_ARCH_STRCPY 21 | 22 | /* Define to use machine specific version of strlen */ 23 | #cmakedefine HAVE_ARCH_STRLEN 24 | 25 | /* Define to use machine specific version of strncpy */ 26 | #cmakedefine HAVE_ARCH_STRNCPY 27 | -------------------------------------------------------------------------------- /include/hermit/hermitux_profiler.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMITUX_PROFILER_H 2 | #define HERMITUX_PROFILER_H 3 | 4 | int hermitux_profiler_init(void); 5 | 6 | #endif /* HERMITUX_PROFILER_H */ 7 | -------------------------------------------------------------------------------- /include/hermit/hermitux_syscalls.h: -------------------------------------------------------------------------------- 1 | #ifndef HERMITUX_SYSCALLS_H 2 | #define HERMITUX_SYSCALLS_H 3 | 4 | typedef int clockid_t; /* for clock_gettime */ 5 | 6 | typedef long time_t; /* for clock_gettime */ 7 | 8 | struct timespec { /* for clock_gettime */ 9 | time_t tv_sec; 10 | long tv_nsec; 11 | }; 12 | 13 | struct timezone { /* for gettimeofday */ 14 | int tz_minuteswest; 15 | int tz_dsttime; 16 | }; 17 | 18 | #define SEEK_SET 0 /* for lseek */ 19 | #define SEEK_CUR 1 /* for lseek */ 20 | 21 | #endif /* HERMITUX_SYSCALLS_H */ 22 | -------------------------------------------------------------------------------- /include/hermit/ioctl.h: -------------------------------------------------------------------------------- 1 | #ifndef __IOCTL_H__ 2 | #define __IOCTL_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /* Needed for TIOCGWINSZ */ 9 | struct winsize { 10 | unsigned short ws_row; 11 | unsigned short ws_col; 12 | unsigned short ws_xpixel; 13 | unsigned short ws_ypixel; 14 | }; 15 | 16 | #define TIOCGWINSZ 0x00005413 17 | 18 | /* needed for TCGETS */ 19 | #define NCCS 19 20 | 21 | typedef unsigned char cc_t; 22 | typedef uint32_t tcflag_t; 23 | 24 | struct termios { 25 | tcflag_t c_iflag; 26 | tcflag_t c_oflag; 27 | tcflag_t c_cflag; 28 | tcflag_t c_lflag; 29 | cc_t c_line; 30 | cc_t c_cc[NCCS]; 31 | }; 32 | 33 | #define TCGETS 0x00005401 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /include/hermit/minifs.h: -------------------------------------------------------------------------------- 1 | #ifndef MINI_FS_H 2 | #define MINI_FS_H 3 | 4 | #include 5 | 6 | extern char minifs_enabled; 7 | 8 | typedef unsigned mode_t; 9 | 10 | int minifs_init(void); 11 | int minifs_load_from_host(const char *filename, const char *dest); 12 | int minifs_open(const char *pathname, int flags, mode_t mode); 13 | int minifs_creat(const char *pathname, mode_t mode); 14 | int minifs_unlink(const char *pathname); 15 | int minifs_close(int fd); 16 | int minifs_read(int fd, void *buf, size_t count); 17 | int minifs_write(int fd, const void *buf, size_t count); 18 | uint64_t minifs_lseek(int fd, uint64_t offset, int whence); 19 | int minifs_mkdir(const char *pathname, mode_t mode); 20 | int minifs_rmdir(const char *pathname); 21 | /** 22 | * MiniFS implementation of dup2. 23 | * Attempts to follow Linux convention of 24 | * error handling with regards to 25 | * bad file descriptors. 26 | */ 27 | int minifs_dup2(int oldfd, int newfd); 28 | 29 | #endif /* MINI_FS_H */ 30 | -------------------------------------------------------------------------------- /include/hermit/processor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #ifndef __PROCESSOR_H__ 29 | #define __PROCESSOR_H__ 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /include/netinet/in.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by the Chair for Operating Systems, RWTH Aachen University 3 | * 4 | * NO Copyright (C) 2010-2011, Stefan Lankes 5 | * consider these trivial macros to be public domain. 6 | * 7 | * These functions are distributed on an "AS IS" BASIS, 8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | */ 10 | 11 | #ifndef __NETINET_IN_H__ 12 | #define __NETINET_IN_H__ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #ifdef __cplusplus 19 | { 20 | #endif 21 | 22 | typedef uint16_t in_port_t; 23 | 24 | int inet_pton(int af, const char *src, void *dst); 25 | 26 | /** 255.255.255.255 */ 27 | #define IPADDR_NONE ((uint32_t)0xffffffffUL) 28 | /** 127.0.0.1 */ 29 | #define IPADDR_LOOPBACK ((uint32_t)0x7f000001UL) 30 | /** 0.0.0.0 */ 31 | #define IPADDR_ANY ((uint32_t)0x00000000UL) 32 | /** 255.255.255.255 */ 33 | #define IPADDR_BROADCAST ((uint32_t)0xffffffffUL) 34 | 35 | /** 255.255.255.255 */ 36 | #define INADDR_NONE IPADDR_NONE 37 | /** 127.0.0.1 */ 38 | #define INADDR_LOOPBACK IPADDR_LOOPBACK 39 | /** 0.0.0.0 */ 40 | #define INADDR_ANY IPADDR_ANY 41 | /** 255.255.255.255 */ 42 | #define INADDR_BROADCAST IPADDR_BROADCAST 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif /* __NETINET_IN_H__ */ 49 | -------------------------------------------------------------------------------- /include/netinet/tcp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by the Chair for Operating Systems, RWTH Aachen University 3 | * 4 | * NO Copyright (C) 2010-2011, Stefan Lankes 5 | * consider these trivial macros to be public domain. 6 | * 7 | * These functions are distributed on an "AS IS" BASIS, 8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | */ 10 | 11 | #ifndef __NETINET_TCP_H__ 12 | #define __NETINET_TCP_H__ 13 | 14 | #include 15 | 16 | #endif /* __NETINET_TCP_H__ */ 17 | -------------------------------------------------------------------------------- /include/stdarg.h: -------------------------------------------------------------------------------- 1 | #ifndef __ANSI_STDARG_H__ 2 | #define __ANSI_STDARG_H__ 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define __VALIST va_list 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef __ANSI_STDDEF_H__ 2 | #define __ANSI_STDDEF_H__ 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/stdlib.h: -------------------------------------------------------------------------------- 1 | #ifndef __ANSI_STDLIB_H__ 2 | #define __ANSI_STDLIB_H__ 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/string.h: -------------------------------------------------------------------------------- 1 | #ifndef __ANSI_STRING_H__ 2 | #define __ANSI_STRING_H__ 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/sys/uio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Just an empty dummy handler to be POSIX compliant. 3 | */ 4 | #ifndef __SYS_UIO_H__ 5 | #define __SYS_UIO_H__ 6 | 7 | #include 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /kernel/hermitux_profiler.c: -------------------------------------------------------------------------------- 1 | #include "hermit/hermitux_profiler.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /* TODO: we can write a better profiler here: if the kernel and application are 10 | * compiled with -fno-omit-frame-pointer, we can use rbp to unwind the stack 11 | * and get the full call stack: see slide 33 here: 12 | * https://flosch.eu/papers/2017-xensummit-uniprof-slides.pdf 13 | * Basically, rip is the current function, *(rbp+8) is the calling function, 14 | * *((*rbp) + 8) is the function calling the calling one, etc. 15 | */ 16 | 17 | #define IRQ_NUM 33 /* corresponds to irq 1 when injected from kvm */ 18 | #define PAGES_FOR_SAMPLES 256 19 | 20 | extern uint64_t tux_prof_samples; 21 | extern uint64_t tux_prof_samples_num; 22 | 23 | uint64_t *samples; 24 | uint64_t next_id; 25 | uint64_t max_id; 26 | 27 | static void profiler_irq_handler(struct state *s) { 28 | samples[next_id++] = s->rip; 29 | 30 | if(tux_prof_samples_num < max_id) 31 | tux_prof_samples_num++; 32 | 33 | if (next_id >= max_id) { 34 | LOG_WARNING("Profiler sample buffer full, wraping to 0\n"); 35 | next_id = 0; 36 | } 37 | } 38 | 39 | int hermitux_profiler_init(void) { 40 | 41 | /* Allocate memory for samples */ 42 | samples = kmalloc(PAGES_FOR_SAMPLES * PAGE_SIZE); 43 | if(!samples) { 44 | LOG_ERROR("Cannot allocate memory for profiling samples\n"); 45 | return -1; 46 | } 47 | tux_prof_samples = (uint64_t)virt_to_phys((size_t)samples); 48 | 49 | next_id = 0; 50 | max_id = (PAGES_FOR_SAMPLES * PAGE_SIZE) / sizeof(uint64_t); 51 | 52 | /* install profiler irq handler */ 53 | irq_install_handler(IRQ_NUM, profiler_irq_handler); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /kernel/syscalls/accept.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int hermit_accept(int s, struct sockaddr *addr, socklen_t *addrlen); 6 | 7 | int sys_accept(int s, struct sockaddr *addr, socklen_t *addrlen) { 8 | #ifndef NO_NET 9 | return hermit_accept(s, addr, addrlen); 10 | #else 11 | LOG_ERROR("Network disabled, cannot process socket syscall!\n"); 12 | return -ENOSYS; 13 | #endif /* NO_NET */ 14 | 15 | } 16 | -------------------------------------------------------------------------------- /kernel/syscalls/access.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | typedef struct { 8 | const char *pathname; 9 | int mode; 10 | int ret; 11 | } __attribute__((packed)) uhyve_access_t; 12 | 13 | int sys_access(const char *pathname, int mode) { 14 | 15 | if(minifs_enabled) { 16 | LOG_ERROR("access not supported by minifs\n"); 17 | return -ENOSYS; 18 | } 19 | 20 | if(unlikely(!pathname)) { 21 | LOG_ERROR("access: pathname is null\n"); 22 | return -EINVAL; 23 | } 24 | 25 | if(likely(is_uhyve())) { 26 | uhyve_access_t uhyve_args = {(const char*) virt_to_phys((size_t) pathname), 27 | mode, -1}; 28 | uhyve_send(UHYVE_PORT_ACCESS, (unsigned)virt_to_phys((size_t)&uhyve_args)); 29 | return uhyve_args.ret; 30 | } 31 | 32 | /* Qemu not supported for now */ 33 | LOG_ERROR("Syscall not supported with qemu: access\n"); 34 | return -ENOSYS; 35 | } 36 | -------------------------------------------------------------------------------- /kernel/syscalls/arch_prctl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define ARCH_SET_GS 0x1001 6 | #define ARCH_SET_FS 0x1002 7 | #define ARCH_GET_FS 0x1003 8 | #define ARCH_GET_GS 0x1004 9 | 10 | #define ARCH_GET_CPUID 0x1011 11 | #define ARCH_SET_CPUID 0x1012 12 | 13 | #define ARCH_MAP_VDSO_X32 0x2001 14 | #define ARCH_MAP_VDSO_32 0x2002 15 | #define ARCH_MAP_VDSO_64 0x2003 16 | 17 | int sys_arch_prctl(int option, unsigned long *arg2, unsigned long *addr) { 18 | 19 | switch(option) { 20 | case ARCH_SET_GS: 21 | writegs((uint64_t)arg2); 22 | return 0; 23 | 24 | case ARCH_SET_FS: 25 | writefs((uint64_t)arg2); 26 | return 0; 27 | 28 | case ARCH_GET_GS: { 29 | unsigned long gs_val = readgs(); 30 | *arg2 = gs_val; 31 | return 0; 32 | } 33 | 34 | case ARCH_GET_FS: { 35 | unsigned long fs_val = readfs(); 36 | *arg2 = fs_val; 37 | return 0; 38 | } 39 | 40 | case ARCH_GET_CPUID: 41 | LOG_ERROR("arch_prctl option GET_CPUID not implemented\n"); 42 | return -ENOSYS; 43 | 44 | case ARCH_SET_CPUID: 45 | LOG_ERROR("arch_prctl option SET_CPUID not implemented\n"); 46 | return -ENOSYS; 47 | 48 | case ARCH_MAP_VDSO_X32: 49 | LOG_ERROR("arch_prctl option MAP_VDSO_X32 not implemented\n"); 50 | return -ENOSYS; 51 | 52 | case ARCH_MAP_VDSO_32: 53 | LOG_ERROR("arch_prctl option MAP_VDSO_32 not implemented\n"); 54 | return -ENOSYS; 55 | 56 | case ARCH_MAP_VDSO_64: 57 | LOG_ERROR("arch_prctl option MAP_VDSO_64 not implemented\n"); 58 | return -ENOSYS; 59 | 60 | default: 61 | LOG_ERROR("arch_prctl: unknown option 0x%x\n", option); 62 | return -EINVAL; 63 | } 64 | 65 | return -ENOSYS; 66 | } 67 | 68 | -------------------------------------------------------------------------------- /kernel/syscalls/bind.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern int hermit_bind(int fd, struct sockaddr *addr, socklen_t addrlen); 6 | 7 | /* FIXME allow more generic bind, and on different ports */ 8 | int sys_bind(int fd, struct sockaddr *addr, int addrlen) { 9 | #ifndef NO_NET 10 | struct sockaddr_in sa_server; 11 | struct in_addr addr_local; 12 | 13 | addr_local.s_addr = INADDR_ANY; 14 | 15 | in_port_t *port = (in_port_t *) &addr->sa_data; 16 | 17 | memset((char *) &sa_server, 0x00, sizeof(sa_server)); 18 | sa_server.sin_family = AF_INET; 19 | sa_server.sin_addr = addr_local; 20 | 21 | sa_server.sin_port = *port; 22 | return hermit_bind(fd, (struct sockaddr *) &sa_server, sizeof(sa_server)); 23 | //return bind(fd, addr, addrlen); 24 | #else 25 | LOG_ERROR("Network disabled, cannot process bind syscall!\n"); 26 | return -ENOSYS; 27 | #endif /* NO_NET */ 28 | } 29 | -------------------------------------------------------------------------------- /kernel/syscalls/brk.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | extern const void kernel_start; 7 | 8 | ssize_t sys_brk(ssize_t val) { 9 | ssize_t ret; 10 | vma_t* heap = per_core(current_task)->heap; 11 | static spinlock_t heap_lock = SPINLOCK_INIT; 12 | 13 | if(!val) 14 | return heap->end; 15 | 16 | if (BUILTIN_EXPECT(!heap, 0)) { 17 | LOG_ERROR("sys_brk: missing heap!\n"); 18 | do_abort(); 19 | } 20 | 21 | spinlock_lock(&heap_lock); 22 | 23 | ret = heap->end; 24 | 25 | // check heapp boundaries 26 | if ((val >= HEAP_START) && (val < HEAP_START + HEAP_SIZE)) { 27 | heap->end = val; 28 | 29 | // reserve VMA regions 30 | if (PAGE_FLOOR(heap->end) > PAGE_FLOOR(ret)) { 31 | // region is already reserved for the heap, we have to change the 32 | // property 33 | // And also consider a bit more vrtual memory due to over-mapping 34 | vma_free(PAGE_FLOOR(ret), PAGE_CEIL(heap->end) + PAGE_SIZE * OVERMAP, 0); 35 | vma_add(PAGE_FLOOR(ret), PAGE_CEIL(heap->end) + PAGE_SIZE * OVERMAP, VMA_HEAP|VMA_USER); 36 | } 37 | 38 | ret = val; 39 | 40 | } // on failure brk returns the unchanged heap value 41 | 42 | // allocation and mapping of new pages for the heap 43 | // is catched by the pagefault handler 44 | 45 | spinlock_unlock(&heap_lock); 46 | 47 | return ret; 48 | 49 | } 50 | 51 | -------------------------------------------------------------------------------- /kernel/syscalls/chdir.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_chdir(const char *path) { 5 | LOG_WARNING("chdir not implemented, faking success\n"); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /kernel/syscalls/clock_getres.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define CLOCK_REALTIME 0 8 | #define CLOCK_MONOTONIC 1 9 | #define CLOCK_PROCESS_CPUTIME_ID 2 10 | #define CLOCK_THREAD_CPUTIME_ID 3 11 | #define CLOCK_MONOTONIC_RAW 4 12 | #define CLOCK_REALTIME_COARSE 5 13 | #define CLOCK_MONOTONIC_COARSE 6 14 | #define CLOCK_BOOTTIME 7 15 | #define CLOCK_REALTIME_ALARM 8 16 | #define CLOCK_BOOTTIME_ALARM 9 17 | #define CLOCK_SGI_CYCLE 10 18 | #define CLOCK_TAI 11 19 | 20 | int sys_clock_getres(clockid_t id, struct timespec *tp) { 21 | 22 | if(id != CLOCK_REALTIME && id != CLOCK_REALTIME_COARSE && 23 | id != CLOCK_MONOTONIC && id != CLOCK_REALTIME_COARSE && 24 | id != CLOCK_MONOTONIC_RAW && id != CLOCK_BOOTTIME && 25 | id != CLOCK_PROCESS_CPUTIME_ID) { 26 | LOG_ERROR("clock_getres: unsupported clock id %d\n", id); 27 | return -ENOSYS; 28 | } 29 | 30 | if(unlikely(!tp)) { 31 | LOG_ERROR("clocK_getres: tp is null\n"); 32 | return -EINVAL; 33 | } 34 | 35 | /* For now we have a stupid clock_gettime implementation so the resolution 36 | * is 1000 nsec */ 37 | tp->tv_sec = 0; 38 | tp->tv_nsec = 1000; 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /kernel/syscalls/clock_gettime.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define CLOCK_REALTIME 0 8 | #define CLOCK_MONOTONIC 1 9 | #define CLOCK_PROCESS_CPUTIME_ID 2 10 | #define CLOCK_THREAD_CPUTIME_ID 3 11 | #define CLOCK_MONOTONIC_RAW 4 12 | #define CLOCK_REALTIME_COARSE 5 13 | #define CLOCK_MONOTONIC_COARSE 6 14 | #define CLOCK_BOOTTIME 7 15 | #define CLOCK_REALTIME_ALARM 8 16 | #define CLOCK_BOOTTIME_ALARM 9 17 | #define CLOCK_SGI_CYCLE 10 18 | #define CLOCK_TAI 11 19 | 20 | extern unsigned long long syscall_freq; 21 | extern unsigned long long syscall_boot_tsc; 22 | extern unsigned long epoch_offset; 23 | 24 | inline static unsigned long long cgt_rdtsc(void) 25 | { 26 | unsigned int lo, hi; 27 | 28 | asm volatile ("rdtsc" : "=a"(lo), "=d"(hi) :: "memory"); 29 | 30 | return ((unsigned long long)hi << 32ULL | (unsigned long long)lo); 31 | } 32 | 33 | int sys_clock_gettime(clockid_t id, struct timespec *tp) { 34 | 35 | if(id != CLOCK_REALTIME && id != CLOCK_REALTIME_COARSE && 36 | id != CLOCK_MONOTONIC && id != CLOCK_REALTIME_COARSE && 37 | id != CLOCK_MONOTONIC_RAW && id != CLOCK_BOOTTIME && 38 | id != CLOCK_PROCESS_CPUTIME_ID) { 39 | LOG_ERROR("clock_gettime: unsupported clock id\n"); 40 | return -ENOSYS; 41 | } 42 | 43 | if(likely(tp)) { 44 | unsigned long long diff = cgt_rdtsc() - syscall_boot_tsc; 45 | tp->tv_sec = diff/syscall_freq; 46 | tp->tv_nsec = (diff - tp->tv_sec*syscall_freq) / (syscall_freq/1000000000ULL); 47 | if (id == CLOCK_REALTIME) 48 | tp->tv_sec += epoch_offset; 49 | } else { 50 | LOG_ERROR("clock_gettime: timespec parameter is NULL\n"); 51 | return -EINVAL; 52 | } 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /kernel/syscalls/clone.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | /* From Linux sources: */ 8 | #define CLONE_VM 0x00000100 9 | #define CLONE_CHILD_CLEARTID 0x00200000 10 | #define CLONE_CHILD_SETTID 0x01000000 11 | 12 | extern void __clone_entry(struct state *s); 13 | 14 | int sys_clone(unsigned long clone_flags, void *stack, int *ptid, int *ctid, 15 | void *tls, struct state *state) 16 | { 17 | tid_t id; 18 | 19 | /* Unikernel -> do no allow new processes creation */ 20 | if(!(clone_flags & CLONE_VM)) { 21 | LOG_ERROR("clone: unsuported clone method. As a unikernel we do not " 22 | "support fork and support only thread creation with the " 23 | "CLONE_VM flag\n"); 24 | return -ENOSYS; 25 | } 26 | 27 | /* To understand how set/clear_child_tidwork, see the man page for 28 | * set_tid_address */ 29 | void *set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? ctid : NULL; 30 | void *clear_child_tid = (clone_flags & CLONE_CHILD_CLEARTID) ? ctid : NULL; 31 | 32 | /* We will restore fs to the right value when returning in the child */ 33 | state->fs = (uint64_t)tls; 34 | 35 | /* clone_task will take care of copyign state on the stack of the created 36 | * thread and pass it as the parameter of __clone_entry so that we can be 37 | * reetrant */ 38 | int ret = clone_task(&id, (int(*)(void *))__clone_entry, NULL, 39 | per_core(current_task)->prio, set_child_tid, clear_child_tid, 40 | state); 41 | 42 | if(ret) 43 | return ret; 44 | 45 | if(ptid) 46 | *(unsigned int *)ptid = id; 47 | 48 | /* TODO this is probably not the responsibility of the kernel */ 49 | if(clone_flags & CLONE_CHILD_SETTID) 50 | if (ctid) 51 | *(int *)ctid = id; 52 | 53 | return id; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /kernel/syscalls/close.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | extern spinlock_irqsave_t lwip_lock; 9 | extern volatile int libc_sd; 10 | 11 | #ifndef NO_NET 12 | 13 | typedef struct { 14 | int sysnr; 15 | int fd; 16 | } __attribute__((packed)) sys_close_t; 17 | 18 | #endif /* NO_DEV */ 19 | 20 | typedef struct { 21 | int fd; 22 | int ret; 23 | } __attribute__((packed)) uhyve_close_t; 24 | 25 | extern int hermit_close(int fd); 26 | 27 | int sys_close(int fd) 28 | { 29 | 30 | if (likely(is_uhyve())) { 31 | 32 | #ifndef NO_NET 33 | // do we have an LwIP file descriptor? 34 | if (fd & LWIP_FD_BIT) { 35 | int ret = hermit_close(fd); 36 | if (ret < 0) 37 | return -errno; 38 | 39 | return ret; 40 | } 41 | #endif 42 | 43 | if(minifs_enabled) 44 | return minifs_close(fd); 45 | 46 | uhyve_close_t uhyve_close = {fd, -1}; 47 | 48 | uhyve_send(UHYVE_PORT_CLOSE, (unsigned)virt_to_phys((size_t) &uhyve_close)); 49 | 50 | return uhyve_close.ret; 51 | } 52 | 53 | #ifndef NO_NET 54 | 55 | int ret, s; 56 | sys_close_t sysargs = {__NR_close, fd}; 57 | 58 | // do we have an LwIP file descriptor? 59 | if (fd & LWIP_FD_BIT) { 60 | ret = lwip_close(fd & ~LWIP_FD_BIT); 61 | if (ret < 0) 62 | return -errno; 63 | 64 | return 0; 65 | } 66 | 67 | spinlock_irqsave_lock(&lwip_lock); 68 | if (libc_sd < 0) { 69 | ret = 0; 70 | goto out; 71 | } 72 | 73 | s = libc_sd; 74 | ret = lwip_write(s, &sysargs, sizeof(sysargs)); 75 | if (ret != sizeof(sysargs)) 76 | goto out; 77 | lwip_read(s, &ret, sizeof(ret)); 78 | 79 | out: 80 | spinlock_irqsave_unlock(&lwip_lock); 81 | 82 | return ret; 83 | 84 | #else /*NO_NET */ 85 | 86 | LOG_ERROR("close: network disabled, cannot use qemu isle\n"); 87 | return -ENOSYS; 88 | 89 | #endif /* NO_NET */ 90 | } 91 | 92 | 93 | -------------------------------------------------------------------------------- /kernel/syscalls/connect.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern int hermit_connect(int s, const struct sockaddr *name, socklen_t namelen); 6 | 7 | int sys_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) { 8 | 9 | #ifndef NO_NET 10 | return hermit_connect(sockfd, addr, addrlen); 11 | #else 12 | LOG_ERROR("Network disabled, cannot process socket syscall!\n"); 13 | return -ENOSYS; 14 | #endif /* NO_NET */ 15 | 16 | } 17 | -------------------------------------------------------------------------------- /kernel/syscalls/creat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | typedef struct { 8 | char *path; 9 | int mode; 10 | int ret; 11 | } __attribute__((packed)) uhyve_creat_t; 12 | 13 | int sys_creat(const char *path, int mode) { 14 | uhyve_creat_t arg; 15 | 16 | if(minifs_enabled) 17 | return minifs_creat(path, mode); 18 | 19 | arg.path = (char *)virt_to_phys((size_t)path); 20 | arg.mode = mode; 21 | arg.ret = -1; 22 | 23 | uhyve_send(UHYVE_PORT_CREAT, (unsigned)virt_to_phys((size_t)&arg)); 24 | 25 | return arg.ret; 26 | } 27 | -------------------------------------------------------------------------------- /kernel/syscalls/dup2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | extern int hermit_dup2(int oldfd, int newfd); 9 | 10 | typedef struct { 11 | int oldfd; 12 | int newfd; 13 | int ret; 14 | } __attribute__ ((packed)) uhyve_dup2_t; 15 | 16 | 17 | int sys_dup2(int oldfd, int newfd) 18 | { 19 | if (unlikely(newfd == oldfd)) 20 | return newfd; 21 | 22 | #ifndef NO_NET 23 | if ((oldfd & LWIP_FD_BIT) || (newfd & LWIP_FD_BIT)) { 24 | LOG_ERROR("dup2: sockets not supported\n"); 25 | return -ENOSYS; 26 | } 27 | #endif 28 | 29 | if (likely(is_uhyve())) { 30 | 31 | if (minifs_enabled) 32 | return minifs_dup2(oldfd, newfd); 33 | 34 | uhyve_dup2_t uhyve_args = {oldfd, newfd, -1}; 35 | uhyve_send(UHYVE_PORT_DUP2, (unsigned)virt_to_phys((size_t)&uhyve_args)); 36 | return uhyve_args.ret; 37 | } 38 | 39 | LOG_ERROR("dup2: not supported with qemu isle\n"); 40 | return -ENOSYS; 41 | } -------------------------------------------------------------------------------- /kernel/syscalls/exit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | void NORETURN do_sys_exit(int arg); 9 | 10 | extern readyqueues_t *readyqueues; 11 | 12 | #ifndef NO_NET 13 | 14 | extern spinlock_irqsave_t lwip_lock; 15 | extern volatile int libc_sd; 16 | 17 | 18 | typedef struct { 19 | int sysnr; 20 | int arg; 21 | } __attribute__((packed)) sys_exit_t; 22 | 23 | #endif /* NO_NET */ 24 | 25 | /** @brief To be called by the systemcall to exit tasks */ 26 | void NORETURN sys_exit(int arg) 27 | { 28 | if (is_uhyve() && per_core(current_task)->is_main_thread) 29 | uhyve_send(UHYVE_PORT_EXIT, (unsigned) virt_to_phys((size_t) &arg)); 30 | #ifndef NO_NET 31 | else { 32 | sys_exit_t sysargs = {__NR_exit, arg}; 33 | 34 | spinlock_irqsave_lock(&lwip_lock); 35 | if (libc_sd >= 0) 36 | { 37 | int s = libc_sd; 38 | 39 | lwip_write(s, &sysargs, sizeof(sysargs)); 40 | libc_sd = -1; 41 | 42 | spinlock_irqsave_unlock(&lwip_lock); 43 | 44 | // switch to LwIP thread 45 | reschedule(); 46 | 47 | lwip_close(s); 48 | } else { 49 | spinlock_irqsave_unlock(&lwip_lock); 50 | } 51 | } 52 | #endif /* NO_NET */ 53 | 54 | do_exit(arg); 55 | } 56 | -------------------------------------------------------------------------------- /kernel/syscalls/exit_group.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | void NORETURN do_sys_exit(int arg); 9 | 10 | extern readyqueues_t *readyqueues; 11 | 12 | #ifndef NO_NET 13 | 14 | extern spinlock_irqsave_t lwip_lock; 15 | extern volatile int libc_sd; 16 | 17 | typedef struct { 18 | int sysnr; 19 | int arg; 20 | } __attribute__((packed)) sys_exit_t; 21 | 22 | #endif /* NO_NET */ 23 | 24 | /** @brief To be called by the systemcall to exit tasks */ 25 | void NORETURN sys_exit_group(int arg) 26 | { 27 | if (is_uhyve() && per_core(current_task)->is_main_thread) 28 | uhyve_send(UHYVE_PORT_EXIT, (unsigned) virt_to_phys((size_t) &arg)); 29 | #ifndef NO_NET 30 | else { 31 | sys_exit_t sysargs = {__NR_exit, arg}; 32 | 33 | spinlock_irqsave_lock(&lwip_lock); 34 | if (libc_sd >= 0) 35 | { 36 | int s = libc_sd; 37 | 38 | lwip_write(s, &sysargs, sizeof(sysargs)); 39 | libc_sd = -1; 40 | 41 | spinlock_irqsave_unlock(&lwip_lock); 42 | 43 | // switch to LwIP thread 44 | reschedule(); 45 | 46 | lwip_close(s); 47 | } else { 48 | spinlock_irqsave_unlock(&lwip_lock); 49 | } 50 | } 51 | #endif /* NO_NET */ 52 | 53 | do_exit(arg); 54 | } 55 | -------------------------------------------------------------------------------- /kernel/syscalls/fcntl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #define F_DUPFD 0 8 | #define F_GETFD 1 9 | #define F_SETFD 2 10 | #define F_GETFL 3 11 | #define F_SETFL 4 12 | #define F_GETLK 5 13 | #define F_SETLK 6 14 | #define F_SETLKW 7 15 | #define F_SETOWN 8 16 | #define F_GETOWN 9 17 | #define F_SETSIG 10 18 | #define F_GETSIG 11 19 | 20 | #define F_SETOWN_EX 15 21 | #define F_GETOWN_EX 16 22 | 23 | #define F_GETOWNER_UIDS 17 24 | 25 | extern int hermit_fcntl(int s, int cmd, int val); 26 | 27 | typedef struct { 28 | int fd; 29 | unsigned int cmd; 30 | unsigned long arg; 31 | int ret; 32 | } __attribute__((packed)) uhyve_fcntl_t; 33 | 34 | 35 | int sys_fcntl(int fd, unsigned int cmd, unsigned long arg) { 36 | uhyve_fcntl_t u_arg; 37 | #ifndef NO_NET 38 | if(likely(is_uhyve())) { 39 | int ret; 40 | 41 | // do we have an LwIP file descriptor? 42 | if (fd & LWIP_FD_BIT) { 43 | ret = hermit_fcntl(fd, cmd, arg); 44 | if (ret < 0) 45 | return -errno; 46 | 47 | return ret; 48 | } 49 | 50 | switch(cmd) { 51 | case F_GETFL: 52 | case F_GETFD: 53 | case F_SETFD: 54 | u_arg.fd = fd; 55 | u_arg.cmd = cmd; 56 | u_arg.arg = arg; 57 | u_arg.ret = -1; 58 | uhyve_send(UHYVE_PORT_FCNTL, virt_to_phys((size_t)&u_arg)); 59 | return u_arg.ret; 60 | 61 | default: 62 | LOG_WARNING("fcntl: currently unsupported - faking succes " 63 | "(fd %d, cmd %d)\n", fd, cmd); 64 | return 0; 65 | 66 | } 67 | 68 | } 69 | #endif 70 | 71 | LOG_ERROR("fcntl: not supported with qemu isle\n"); 72 | return -ENOSYS; 73 | } 74 | 75 | -------------------------------------------------------------------------------- /kernel/syscalls/fdatasync.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | typedef struct { 8 | int fd; 9 | int ret; 10 | } __attribute__((packed)) uhyve_fsync_t; 11 | 12 | int sys_fdatasync(int fd) { 13 | uhyve_fsync_t arg; 14 | 15 | if(minifs_enabled) 16 | return 0; 17 | 18 | arg.fd = fd; 19 | arg.ret = -1; 20 | 21 | uhyve_send(UHYVE_PORT_FDATASYNC, (unsigned)virt_to_phys((size_t)&arg)); 22 | return arg.ret; 23 | } 24 | -------------------------------------------------------------------------------- /kernel/syscalls/fstat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | typedef unsigned int dev_t; 8 | typedef unsigned int ino_t; 9 | typedef unsigned mode_t; 10 | typedef unsigned int nlink_t; 11 | typedef unsigned int uid_t; 12 | typedef unsigned short gid_t; 13 | typedef long blksize_t; 14 | typedef long blkcnt_t; 15 | 16 | struct stat { 17 | dev_t st_dev; 18 | ino_t st_ino; 19 | nlink_t st_nlink; 20 | 21 | mode_t st_mode; 22 | uid_t st_uid; 23 | gid_t st_gid; 24 | unsigned int __pad0; 25 | dev_t st_rdev; 26 | off_t st_size; 27 | blksize_t st_blksize; 28 | blkcnt_t st_blocks; 29 | 30 | struct timespec st_atim; 31 | struct timespec st_mtim; 32 | struct timespec st_ctim; 33 | long __unused[3]; 34 | }; 35 | 36 | typedef struct { 37 | int fd; 38 | int ret; 39 | struct stat *st; 40 | } __attribute__ ((packed)) uhyve_fstat_t; 41 | 42 | int sys_fstat(int fd, struct stat *buf) 43 | { 44 | if(minifs_enabled) { 45 | LOG_ERROR("fstat: not supported with minifs\n"); 46 | return -ENOSYS; 47 | } 48 | 49 | if(unlikely(!buf)) { 50 | LOG_ERROR("fstat: called with buf argument null\n"); 51 | return -EINVAL; 52 | } 53 | 54 | if(likely(is_uhyve())) { 55 | uhyve_fstat_t uhyve_args = {fd, -1, 56 | (struct stat *)virt_to_phys((size_t)buf)}; 57 | 58 | uhyve_send(UHYVE_PORT_FSTAT, 59 | (unsigned)virt_to_phys((size_t)&uhyve_args)); 60 | 61 | return uhyve_args.ret; 62 | } 63 | 64 | /* qemu not supported yet */ 65 | LOG_ERROR("fstat: not supported with qemu isle\n"); 66 | return -ENOSYS; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /kernel/syscalls/fsync.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | typedef struct { 8 | int fd; 9 | int ret; 10 | } __attribute__((packed)) uhyve_fsync_t; 11 | 12 | int sys_fsync(int fd) { 13 | uhyve_fsync_t arg; 14 | 15 | if(minifs_enabled) 16 | return 0; 17 | 18 | arg.fd = fd; 19 | arg.ret = -1; 20 | 21 | uhyve_send(UHYVE_PORT_FSYNC, (unsigned)virt_to_phys((size_t)&arg)); 22 | return arg.ret; 23 | } 24 | -------------------------------------------------------------------------------- /kernel/syscalls/get_robust_list.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | long sys_get_robust_list(int pid, void *head_ptr, size_t *len_ptr) { 6 | 7 | if(unlikely(!head_ptr || !len_ptr)) { 8 | LOG_ERROR("get_robust_list: some parameter(s) is (are) null\n"); 9 | return -EINVAL; 10 | } 11 | 12 | LOG_ERROR("get_robust_list: unsuported syscall\n"); 13 | 14 | /* TODO */ 15 | return -ENOSYS; 16 | } 17 | -------------------------------------------------------------------------------- /kernel/syscalls/get_ticks.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* This is not a Linux syscall */ 5 | 6 | size_t sys_get_ticks(void) 7 | { 8 | return get_clock_tick(); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /kernel/syscalls/getcwd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | extern uint8_t minifs_enabled; 7 | char *minifs_slash = "/"; 8 | 9 | typedef struct { 10 | char *buf; 11 | size_t size; 12 | int ret; 13 | } __attribute__ ((packed)) uhyve_getcwd_t; 14 | 15 | int sys_getcwd(char *buf, size_t size) { 16 | 17 | if(unlikely(!buf || size == 0)) { 18 | LOG_ERROR("getcwd: buf is null or size is zero\n"); 19 | return -EINVAL; 20 | } 21 | 22 | if(likely(is_uhyve())) { 23 | 24 | if(minifs_enabled) { 25 | if(strlen(minifs_slash) > size-1) { 26 | LOG_ERROR("getcwd: size too small\n"); 27 | return -EINVAL; 28 | } 29 | strcpy(buf, minifs_slash); 30 | return 0; 31 | } 32 | 33 | uhyve_getcwd_t uhyve_args = {(char *)virt_to_phys((size_t)buf), size, -1}; 34 | uhyve_send(UHYVE_PORT_GETCWD, (unsigned)virt_to_phys((size_t)&uhyve_args)); 35 | return uhyve_args.ret; 36 | } 37 | 38 | /* Qemu not supported yet */ 39 | return -ENOSYS; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /kernel/syscalls/getdents.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | struct linux_dirent { 7 | unsigned long d_ino; 8 | unsigned long d_off; 9 | unsigned short d_reclen; 10 | char *d_name; 11 | char pad; 12 | char d_type; 13 | }; 14 | 15 | typedef struct { 16 | int fd; 17 | struct linux_dirent *dirp; 18 | unsigned int count; 19 | int ret; 20 | } __attribute__((packed)) uhyve_getdeents_t; 21 | 22 | int sys_getdents(unsigned int fd, struct linux_dirent *dirp, 23 | unsigned int count) { 24 | 25 | if(fd & LWIP_FD_BIT) 26 | return -EINVAL; 27 | 28 | if(minifs_enabled) { 29 | LOG_ERROR("getdents not supported by minifs\n"); 30 | return -ENOSYS; 31 | } 32 | 33 | /* The host will write in dirp and we cannot assume it is contiguous in 34 | * physical memory so we need to use a physically contiguous temp buffer */ 35 | struct linux_dirent *tmp_dirp = kmalloc(count); 36 | if(!tmp_dirp) 37 | return -ENOMEM; 38 | 39 | uhyve_getdeents_t arg = {fd, (void *)virt_to_phys((size_t)tmp_dirp), 40 | count, -1}; 41 | uhyve_send(UHYVE_PORT_GETDENTS, (unsigned)virt_to_phys((size_t)&arg)); 42 | 43 | if(arg.ret < 0) 44 | goto out; 45 | 46 | memcpy(dirp, tmp_dirp, count); 47 | kfree(tmp_dirp); 48 | 49 | out: 50 | return arg.ret; 51 | } 52 | -------------------------------------------------------------------------------- /kernel/syscalls/getdents64.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | struct linux_dirent64 { 7 | uint64_t d_ino; /* 64-bit inode number */ 8 | uint64_t d_off; /* 64-bit offset to next structure */ 9 | unsigned short d_reclen; /* Size of this dirent */ 10 | unsigned char d_type; /* File type */ 11 | char d_name[]; /* Filename (null-terminated) */ 12 | }; 13 | 14 | typedef struct { 15 | int fd; 16 | struct linux_dirent64 *dirp; 17 | unsigned int count; 18 | int ret; 19 | } __attribute__((packed)) uhyve_getdeents64_t; 20 | 21 | int sys_getdents64(unsigned int fd, struct linux_dirent64 *dirp, 22 | unsigned int count) { 23 | 24 | if(fd & LWIP_FD_BIT) 25 | return -EINVAL; 26 | 27 | if(minifs_enabled) { 28 | LOG_ERROR("getdents64 not supported by minifs\n"); 29 | return -ENOSYS; 30 | } 31 | 32 | /* The host will write in dirp and we cannot assume it is contiguous in 33 | * physical memory so we need to use a physically contiguous temp buffer */ 34 | struct linux_dirent64 *tmp_dirp = kmalloc(count); 35 | if(!tmp_dirp) 36 | return -ENOMEM; 37 | 38 | uhyve_getdeents64_t arg = {fd, (void *)virt_to_phys((size_t)tmp_dirp), 39 | count, -1}; 40 | uhyve_send(UHYVE_PORT_GETDENTS64, (unsigned)virt_to_phys((size_t)&arg)); 41 | 42 | if(arg.ret < 0) 43 | goto out; 44 | 45 | memcpy(dirp, tmp_dirp, count); 46 | kfree(tmp_dirp); 47 | 48 | out: 49 | return arg.ret; 50 | } 51 | -------------------------------------------------------------------------------- /kernel/syscalls/getegid.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sys_getegid(void) { 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /kernel/syscalls/geteuid.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sys_geteuid(void) { 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /kernel/syscalls/getgid.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sys_getgid(void) { 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /kernel/syscalls/gethostname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* This is not a Linux syscall */ 6 | 7 | extern char hermitux_hostname[]; 8 | 9 | int sys_gethostname(char *name, size_t len) 10 | { 11 | 12 | if(unlikely(!name)) { 13 | LOG_ERROR("gethostname: name is null\n"); 14 | return -EINVAL; 15 | } 16 | 17 | strncpy(name, hermitux_hostname, len); 18 | return 0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /kernel/syscalls/getpeername.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern int hermit_getpeername(int s, struct sockaddr *name, socklen_t *namelen); 6 | 7 | int sys_getpeername(int s, struct sockaddr *name, socklen_t *namelen) { 8 | #ifndef NO_NET 9 | return hermit_getpeername(s, name, namelen); 10 | #else 11 | LOG_ERROR("Network disabled, cannot process socket syscall!\n"); 12 | return -ENOSYS; 13 | #endif /* NO_NET */ 14 | 15 | } 16 | -------------------------------------------------------------------------------- /kernel/syscalls/getpid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | tid_t sys_getpid(void) { 5 | task_t* task = per_core(current_task); 6 | return task->id; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /kernel/syscalls/getppid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | tid_t sys_getppid(void) 5 | { 6 | task_t* task = per_core(current_task); 7 | 8 | return task->parent; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /kernel/syscalls/getpriority.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | typedef unsigned id_t; 7 | 8 | #define PRIO_PROCESS 0 9 | #define PRIO_PGRP 1 10 | #define PRIO_USER 2 11 | 12 | extern task_t task_table[]; 13 | extern spinlock_irqsave_t table_lock; 14 | 15 | int sys_getpriority(int which, id_t who) { 16 | task_t *task; 17 | int hermitux_prio = -1; 18 | long linux_prio = -21; 19 | 20 | if(unlikely(which != PRIO_PROCESS && which != PRIO_PGRP && 21 | which != PRIO_USER)) { 22 | LOG_ERROR("getpriority: 'which' is invalid\n"); 23 | return -EINVAL; 24 | } 25 | 26 | if(!who) { 27 | /* Return the priority of the calling process */ 28 | task = per_core(current_task); 29 | hermitux_prio = task->prio; 30 | } else { 31 | spinlock_irqsave_lock(&table_lock); 32 | if(task_table[who].status != TASK_INVALID) 33 | hermitux_prio = task_table[who].prio; 34 | spinlock_irqsave_unlock(&table_lock); 35 | } 36 | 37 | if(hermitux_prio == -1) { 38 | LOG_ERROR("getpriority: could not find task %u\n", who); 39 | return -EINVAL; 40 | } 41 | 42 | /* Mapping of Hermitux to Linux priorities: 43 | * system: (low) ----> (high) 44 | * htux: 0 ---------> 31 45 | * linux: 20 -------->-20 46 | */ 47 | linux_prio = -(4* hermitux_prio)/3 + (64/3); 48 | 49 | /* as done by Linux, avoid returning a negative value and convert nice 50 | * value [19,-20] to rlimit style value [1,40]. The C library will take care 51 | * of translating it back */ 52 | return (19 - linux_prio + 1); 53 | } 54 | 55 | /* TODO: remove this ? */ 56 | int sys_getprio(tid_t* id) 57 | { 58 | task_t* task; 59 | 60 | if(!id) { 61 | LOG_ERROR("getprio: id is null\n"); 62 | return -EINVAL; 63 | } 64 | 65 | task = per_core(current_task); 66 | 67 | if (!id || (task->id == *id)) 68 | return task->prio; 69 | 70 | return -EINVAL; 71 | } 72 | 73 | -------------------------------------------------------------------------------- /kernel/syscalls/getrandom.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_getrandom(void *buf, unsigned long int buflen, unsigned int flags) { 5 | LOG_WARNING("syscall getrandom (318) unsupported, faking\n"); 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /kernel/syscalls/getsockname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern int hermit_getsockname(int s, struct sockaddr *name, socklen_t *namelen); 6 | 7 | int sys_getsockname(int s, struct sockaddr *name, socklen_t *namelen) { 8 | #ifndef NO_NET 9 | return hermit_getsockname(s, name, namelen); 10 | #else 11 | LOG_ERROR("Network disabled, cannot process socket syscall!\n"); 12 | return -ENOSYS; 13 | #endif /* NO_NET */ 14 | 15 | } 16 | -------------------------------------------------------------------------------- /kernel/syscalls/getsockopt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | extern int hermit_getsockopt(int s, int level, int optname, void *optval, 5 | socklen_t *optlen); 6 | 7 | int sys_getsockopt(int s, int level, int optname, void *optval, 8 | socklen_t *optlen) { 9 | 10 | #ifndef NO_NET 11 | return hermit_getsockopt(s, level, optname, optval, optlen); 12 | #else 13 | LOG_ERROR("Network disabled, cannot process socket syscall!\n"); 14 | return -ENOSYS; 15 | #endif /* NO_NET */ 16 | 17 | } 18 | -------------------------------------------------------------------------------- /kernel/syscalls/gettid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_gettid(void) 5 | { 6 | task_t* task = per_core(current_task); 7 | 8 | return task->id; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /kernel/syscalls/gettimeofday.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | extern unsigned long long syscall_freq; 7 | extern unsigned long long syscall_boot_tsc; 8 | 9 | inline static unsigned long long gtod_rdtsc(void) 10 | { 11 | unsigned int lo, hi; 12 | 13 | asm volatile ("rdtsc" : "=a"(lo), "=d"(hi) :: "memory"); 14 | 15 | return ((unsigned long long)hi << 32ULL | (unsigned long long)lo); 16 | } 17 | 18 | int sys_gettimeofday(struct timeval *tv, struct timezone *tz) { 19 | 20 | if(unlikely(tz)) { 21 | LOG_ERROR("gettimeofday: tz should be null\n"); 22 | return -EINVAL; 23 | } 24 | 25 | if(likely(tv)) { 26 | unsigned long long diff = gtod_rdtsc() - syscall_boot_tsc; 27 | tv->tv_sec = diff/syscall_freq; 28 | tv->tv_usec = (diff - tv->tv_sec*syscall_freq) / (syscall_freq/1000000ULL); 29 | 30 | return 0; 31 | } 32 | 33 | LOG_ERROR("gettimeofday: tv is null\n"); 34 | return -EINVAL; 35 | } 36 | -------------------------------------------------------------------------------- /kernel/syscalls/getuid.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sys_getuid(void) { 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /kernel/syscalls/ioctl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) { 6 | 7 | switch(cmd) { 8 | case TIOCGWINSZ: 9 | { 10 | struct winsize *res = (struct winsize *)arg; 11 | /* Quick hack, mimic what linux is reporting */ 12 | res->ws_row = 24; 13 | res->ws_col = 80; 14 | res->ws_xpixel = 0; 15 | res->ws_ypixel = 0; 16 | return 0; 17 | } 18 | 19 | case TCGETS: 20 | { 21 | /* hack again */ 22 | struct termios *res = (struct termios *)arg; 23 | res->c_iflag = 0x4500; 24 | res->c_oflag = 0x5; 25 | res->c_cflag = 0xbf; 26 | res->c_lflag = 0x8a3b; 27 | res->c_line = 0x0; 28 | res->c_cc[0] = 0x3; 29 | res->c_cc[1] = 0x1c; 30 | res->c_cc[2] = 0x7f; 31 | res->c_cc[3] = 0x15; 32 | res->c_cc[4] = 0x4; 33 | res->c_cc[5] = 0x0; 34 | res->c_cc[6] = 0x1; 35 | res->c_cc[7] = 0x0; 36 | res->c_cc[8] = 0x11; 37 | res->c_cc[9] = 0x13; 38 | res->c_cc[10] = 0x1a; 39 | res->c_cc[11] = 0x0; 40 | res->c_cc[12] = 0x12; 41 | res->c_cc[13] = 0xf; 42 | res->c_cc[14] = 0x17; 43 | res->c_cc[15] = 0x16; 44 | res->c_cc[16] = 0x0; 45 | res->c_cc[17] = 0x0; 46 | res->c_cc[18] = 0x0; 47 | 48 | return 0; 49 | } 50 | 51 | default: 52 | LOG_ERROR("unsupported ioctl command 0x%x\n", cmd); 53 | return -ENOSYS; 54 | } 55 | 56 | /* should not come here */ 57 | return -ENOSYS; 58 | } 59 | -------------------------------------------------------------------------------- /kernel/syscalls/kill.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | extern dequeue_t *signal_queue; 8 | 9 | int hermit_sys_kill(tid_t dest, int signum); 10 | 11 | int sys_kill(tid_t dest, int signum) 12 | { 13 | if(unlikely(signum < 0)) { 14 | LOG_ERROR("kill: signum is 0\n"); 15 | return -EINVAL; 16 | } 17 | return hermit_sys_kill(dest, signum); 18 | } 19 | 20 | int hermit_sys_kill(tid_t dest, int signum) 21 | { 22 | task_t* task; 23 | if(BUILTIN_EXPECT(get_task(dest, &task), 0)) { 24 | LOG_ERROR("Trying to send signal %d to invalid task %d\n", signum, dest); 25 | return -ENOENT; 26 | } 27 | 28 | const tid_t dest_core = task->last_core; 29 | 30 | LOG_DEBUG("Send signal %d from task %d (core %d) to task %d (core %d)\n", 31 | signum, per_core(current_task)->id, CORE_ID, dest, dest_core); 32 | 33 | if(task == per_core(current_task)) { 34 | LOG_DEBUG(" Deliver signal to itself, call handler immediately\n"); 35 | 36 | if(task->signal_handler) { 37 | task->signal_handler(signum); 38 | } 39 | return 0; 40 | } 41 | 42 | sig_t signal = {dest, signum}; 43 | if(dequeue_push(&signal_queue[dest_core], &signal)) { 44 | LOG_ERROR(" Cannot push signal to task's signal queue, dropping it\n"); 45 | return -ENOMEM; 46 | } 47 | 48 | // send IPI to destination core 49 | LOG_DEBUG(" Send signal IPI (%d) to core %d\n", SIGNAL_IRQ, dest_core); 50 | apic_send_ipi(dest_core, SIGNAL_IRQ); 51 | 52 | return 0; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /kernel/syscalls/listen.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define SOMAXCONN 512 6 | extern int hermit_listen(int s, int backlog); 7 | 8 | int sys_listen(int s, int backlog) { 9 | #ifndef NO_NET 10 | if(backlog > SOMAXCONN) 11 | return -EINVAL; 12 | return hermit_listen(s, backlog); 13 | #else 14 | LOG_ERROR("Network disabled, cannot process socket syscall!\n"); 15 | return -ENOSYS; 16 | #endif /* NO_NET */ 17 | 18 | } 19 | -------------------------------------------------------------------------------- /kernel/syscalls/lseek.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | extern spinlock_irqsave_t lwip_lock; 9 | extern volatile int libc_sd; 10 | 11 | #ifndef NO_NET 12 | 13 | typedef struct { 14 | int sysnr; 15 | int fd; 16 | off_t offset; 17 | int whence; 18 | } __attribute__((packed)) sys_lseek_t; 19 | 20 | #endif /* NO_NET */ 21 | 22 | typedef struct { 23 | int fd; 24 | off_t offset; 25 | int whence; 26 | } __attribute__((packed)) uhyve_lseek_t; 27 | 28 | off_t sys_lseek(int fd, off_t offset, int whence) 29 | { 30 | 31 | if (likely(is_uhyve())) { 32 | 33 | if(minifs_enabled) 34 | return minifs_lseek(fd, offset, whence); 35 | 36 | uhyve_lseek_t uhyve_lseek = { fd, offset, whence }; 37 | 38 | outportl(UHYVE_PORT_LSEEK, (unsigned)virt_to_phys((size_t) &uhyve_lseek)); 39 | 40 | return uhyve_lseek.offset; 41 | } 42 | 43 | #ifndef NO_NET 44 | off_t off; 45 | sys_lseek_t sysargs = {__NR_lseek, fd, offset, whence}; 46 | int s; 47 | 48 | spinlock_irqsave_lock(&lwip_lock); 49 | 50 | if (libc_sd < 0) { 51 | spinlock_irqsave_unlock(&lwip_lock); 52 | return -ENOSYS; 53 | } 54 | 55 | s = libc_sd; 56 | lwip_write(s, &sysargs, sizeof(sysargs)); 57 | lwip_read(s, &off, sizeof(off)); 58 | 59 | spinlock_irqsave_unlock(&lwip_lock); 60 | 61 | return off; 62 | #endif /* NO_NET */ 63 | 64 | LOG_ERROR("lseek: network disabled, cannot use qemu isle\n"); 65 | return -ENOSYS; 66 | } 67 | 68 | -------------------------------------------------------------------------------- /kernel/syscalls/madvise.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define MADV_NORMAL 0 5 | #define MADV_RANDOM 1 6 | #define MADV_SEQUENTIAL 2 7 | #define MADV_WILLNEED 3 8 | #define MADV_DONTNEED 4 9 | #define MADV_FREE 8 10 | #define MADV_REMOVE 9 11 | #define MADV_DONTFORK 10 12 | #define MADV_DOFORK 11 13 | #define MADV_MERGEABLE 12 14 | #define MADV_UNMERGEABLE 13 15 | #define MADV_HUGEPAGE 14 16 | #define MADV_NOHUGEPAGE 15 17 | #define MADV_DONTDUMP 16 18 | #define MADV_DODUMP 17 19 | #define MADV_HWPOISON 100 20 | #define MADV_SOFT_OFFLINE 101 21 | 22 | int sys_madvise(unsigned long start, size_t len_in, int behavior) { 23 | 24 | switch(behavior) { 25 | case MADV_NORMAL: 26 | case MADV_RANDOM: 27 | case MADV_SEQUENTIAL: 28 | case MADV_WILLNEED: 29 | case MADV_DONTNEED: 30 | LOG_WARNING("madivse: NORMAL/RANDOM/SEQUENTIAL/WILLNEED/DONTNEED " 31 | "not supported\n"); 32 | return 0; 33 | 34 | case MADV_DONTFORK: 35 | case MADV_DOFORK: 36 | LOG_WARNING("madivse: DO(N)TFORK not supported as we do not " 37 | "support fork"); 38 | return 0; 39 | 40 | default: 41 | LOG_ERROR("madvise: unsupported command\n"); 42 | return -ENOSYS; 43 | } 44 | 45 | /* Should not come here */ 46 | return -ENOSYS; 47 | } 48 | -------------------------------------------------------------------------------- /kernel/syscalls/mincore.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* TODO */ 5 | int sys_mincore(unsigned long start, size_t len, unsigned char *vec) { 6 | return -ENOSYS; 7 | } 8 | -------------------------------------------------------------------------------- /kernel/syscalls/mkdir.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | typedef unsigned short umode_t; 8 | 9 | typedef struct { 10 | const char *pathname; 11 | umode_t mode; 12 | int ret; 13 | } __attribute__ ((packed)) uhyve_mkdir_t; 14 | 15 | int sys_mkdir(const char *pathname, umode_t mode) { 16 | 17 | if(unlikely(!pathname)) { 18 | LOG_ERROR("mkdir: pathname is null\n"); 19 | return -EINVAL; 20 | } 21 | 22 | if(likely(is_uhyve())) { 23 | 24 | if(minifs_enabled) 25 | return minifs_mkdir(pathname, mode); 26 | 27 | uhyve_mkdir_t args = {(const char *)virt_to_phys((size_t)pathname), 28 | mode, 0}; 29 | uhyve_send(UHYVE_PORT_MKDIR, (unsigned)virt_to_phys((size_t)&args)); 30 | return args.ret; 31 | } 32 | 33 | /* qemu not supported yet */ 34 | LOG_ERROR("mkdir: qemu isle not supported\n"); 35 | return -ENOSYS; 36 | } 37 | -------------------------------------------------------------------------------- /kernel/syscalls/mprotect.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | long sys_mprotect(size_t addr, size_t len, unsigned long prot) { 5 | 6 | LOG_WARNING("mprotect: unsupported syscall, faking success, " 7 | "addr: %p, len: 0x%llx, prot: %d\n", addr, len, prot); 8 | 9 | /* FIXME */ 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /kernel/syscalls/mremap.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define MAP_FIXED 0x10 5 | 6 | size_t sys_mremap(unsigned long addr, unsigned long old_len, unsigned long new_len, 7 | unsigned long flags, unsigned long new_addr) { 8 | 9 | uint64_t ret; 10 | 11 | if(flags & MAP_FIXED) { 12 | LOG_ERROR("mremap: no support for MAP_FIXED\n"); 13 | return -ENOSYS; 14 | } 15 | 16 | ret = sys_mmap((unsigned long)NULL, new_len, 0x0, flags, 0x0, 0x0); 17 | 18 | memcpy((void *)ret, (void *)addr, old_len); 19 | 20 | sys_munmap(addr, old_len); 21 | 22 | return ret; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /kernel/syscalls/msleep.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* Not a Linux syscall */ 6 | 7 | void sys_msleep(unsigned int ms) 8 | { 9 | if (ms * TIMER_FREQ / 1000 > 0) 10 | timer_wait(ms * TIMER_FREQ / 1000); 11 | else if (ms > 0) 12 | udelay(ms * 1000); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /kernel/syscalls/munmap.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int sys_munmap(size_t viraddr, size_t len) { 8 | uint32_t npages = PAGE_CEIL(len) >> PAGE_BITS; 9 | int ret; 10 | 11 | if (BUILTIN_EXPECT(!viraddr, 0)) 12 | return -EINVAL; 13 | if (BUILTIN_EXPECT(!len, 0)) 14 | return -EINVAL; 15 | 16 | /* Free virtual address space */ 17 | ret = vma_free((size_t)viraddr, (size_t)viraddr+npages*PAGE_SIZE, 1); 18 | 19 | if(ret < 0) { 20 | LOG_ERROR("munmap: cannot free VMA\n"); 21 | return ret; 22 | } 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /kernel/syscalls/nanosleep.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int ns_timer_wait(unsigned int ticks); 9 | void ns_udelay(uint32_t usecs); 10 | 11 | /* TODO here I don't take care of rem, I don't think signal interruption 12 | * is possible ... */ 13 | int sys_nanosleep(struct timespec *req, struct timespec *rem) { 14 | unsigned long long int ms; 15 | 16 | if(unlikely(!req)) { 17 | LOG_ERROR("nanosleep: req is null\n"); 18 | return -EINVAL; 19 | } 20 | 21 | ms = req->tv_sec * 1000 + req->tv_nsec / 1000000; 22 | 23 | if (ms * TIMER_FREQ / 1000 > 0) 24 | timer_wait(ms * TIMER_FREQ / 1000); 25 | else if (ms > 0) 26 | udelay(ms * 1000); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /kernel/syscalls/newfstatat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | typedef unsigned int dev_t; 8 | typedef unsigned int ino_t; 9 | typedef unsigned mode_t; 10 | typedef unsigned int nlink_t; 11 | typedef unsigned int uid_t; 12 | typedef unsigned short gid_t; 13 | typedef long blksize_t; 14 | typedef long blkcnt_t; 15 | 16 | struct stat { 17 | dev_t st_dev; 18 | ino_t st_ino; 19 | nlink_t st_nlink; 20 | 21 | mode_t st_mode; 22 | uid_t st_uid; 23 | gid_t st_gid; 24 | unsigned int __pad0; 25 | dev_t st_rdev; 26 | off_t st_size; 27 | blksize_t st_blksize; 28 | blkcnt_t st_blocks; 29 | 30 | struct timespec st_atim; 31 | struct timespec st_mtim; 32 | struct timespec st_ctim; 33 | long __unused[3]; 34 | }; 35 | 36 | typedef struct { 37 | int dirfd; 38 | const char* name; 39 | struct stat *st; 40 | int flag; 41 | int ret; 42 | } __attribute__((packed)) uhyve_newfstatat_t; 43 | 44 | 45 | int sys_newfstatat(int dirfd, const char *name, struct stat *buf, int flag) 46 | { 47 | if(minifs_enabled) { 48 | LOG_ERROR("newfstatat: not supported with minifs\n"); 49 | return -ENOSYS; 50 | } 51 | 52 | if(unlikely(!buf)) { 53 | LOG_ERROR("newfstatat: called with buf argument null\n"); 54 | return -EINVAL; 55 | } 56 | 57 | if(likely(is_uhyve())) { 58 | uhyve_newfstatat_t uhyve_args = {dirfd, 59 | (char *)virt_to_phys((size_t)name), 60 | (struct stat *)virt_to_phys((size_t)buf), 61 | flag, -1}; 62 | 63 | uhyve_send(UHYVE_PORT_NEWFSTATAT, 64 | (unsigned)virt_to_phys((size_t)&uhyve_args)); 65 | 66 | return uhyve_args.ret; 67 | } 68 | 69 | /* qemu not supported yet */ 70 | LOG_ERROR("newfstatat: not supported with qemu isle\n"); 71 | return -ENOSYS; 72 | } 73 | -------------------------------------------------------------------------------- /kernel/syscalls/openat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | typedef struct { 8 | int dirfd; 9 | const char* name; 10 | int flags; 11 | int mode; 12 | int ret; 13 | } __attribute__((packed)) uhyve_openat_t; 14 | 15 | int sys_openat(int dirfd, const char *pathname, int flags, int mode) { 16 | 17 | if(unlikely(!pathname)) { 18 | LOG_ERROR("openat: pathname is null\n"); 19 | return -EINVAL; 20 | } 21 | 22 | if(minifs_enabled) { 23 | LOG_ERROR("openat: unsupported with minifs\n"); 24 | return -ENOSYS; 25 | } 26 | 27 | if (likely(is_uhyve())) { 28 | uhyve_openat_t arg = {dirfd, 29 | (const char *)virt_to_phys((size_t)pathname), flags, mode, -1}; 30 | uhyve_send(UHYVE_PORT_OPENAT, virt_to_phys((size_t)&arg)); 31 | 32 | return arg.ret; 33 | 34 | } else { 35 | LOG_ERROR("openat: not supported with qemu isle\n"); 36 | return -ENOSYS; 37 | } 38 | 39 | LOG_ERROR("openat: only support absolute pathnames (asked %s)\n", 40 | pathname); 41 | return -ENOSYS; 42 | } 43 | -------------------------------------------------------------------------------- /kernel/syscalls/pipe.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | typedef struct { 8 | int *filedes; 9 | int ret; 10 | } uhyve_pipe_t; 11 | 12 | int sys_pipe(int *filedes) 13 | { 14 | if(minifs_enabled) { 15 | LOG_ERROR("pipe: not supported with minifs\n"); 16 | return -ENOSYS; 17 | } 18 | 19 | if(unlikely(!filedes)) { 20 | LOG_ERROR("pipe: called with null argument\n"); 21 | return -EINVAL; 22 | } 23 | 24 | if(likely(is_uhyve())) { 25 | uhyve_pipe_t uhyve_args = {(int *)virt_to_phys((size_t)filedes), -1 }; 26 | 27 | uhyve_send(UHYVE_PORT_PIPE, 28 | (unsigned)virt_to_phys((size_t)&uhyve_args)); 29 | 30 | return uhyve_args.ret; 31 | } 32 | 33 | /* qemu not supported yet */ 34 | LOG_ERROR("pipe: not supported with qemu isle\n"); 35 | return -ENOSYS; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /kernel/syscalls/poll.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern int block_current_task(void); 4 | 5 | struct pollfd { 6 | int fd; 7 | short events; 8 | short revents; 9 | }; 10 | 11 | int sys_poll(struct pollfd *ufds, unsigned int nfds, int timeout_msecs) { 12 | /* FIXME dummy implementation */ 13 | return block_current_task(); 14 | } 15 | -------------------------------------------------------------------------------- /kernel/syscalls/pread64.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | size_t sys_pread64(int fd, void *buf, size_t count, off_t offset) { 5 | int ret = -1; 6 | 7 | if(fd & LWIP_FD_BIT) { 8 | LOG_ERROR("pread64 not supported on a socket\n"); 9 | return -ENOSYS; 10 | } 11 | 12 | /* Save the offset */ 13 | uint64_t prev_offset = sys_lseek(fd, 0x0, SEEK_CUR); 14 | if(prev_offset == (uint64_t)-1) { 15 | LOG_ERROR("pread64: cannot get offset\n"); 16 | return -1; 17 | } 18 | 19 | /* Set the offset */ 20 | if(sys_lseek(fd, offset, SEEK_SET) == (uint64_t)-1) { 21 | LOG_ERROR("pread64: cannot set offset\n"); 22 | ret = -1; 23 | goto out; 24 | } 25 | 26 | ret = sys_read(fd, buf, count); 27 | 28 | /* Set the offset back */ 29 | if(sys_lseek(fd, prev_offset, SEEK_SET) == (uint64_t)-1) { 30 | LOG_ERROR("pread64: cannot set back offset\n"); 31 | ret = -1; 32 | goto out; 33 | } 34 | 35 | out: 36 | return ret; 37 | } 38 | -------------------------------------------------------------------------------- /kernel/syscalls/pwrite64.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | size_t sys_pwrite64(int fd, const void *buf, size_t count, off_t offset) { 5 | int ret = -1; 6 | 7 | if(fd & LWIP_FD_BIT) { 8 | LOG_ERROR("pwrite64 not supported on a socket\n"); 9 | return -ENOSYS; 10 | } 11 | 12 | /* Save the offset */ 13 | uint64_t prev_offset = sys_lseek(fd, 0x0, SEEK_CUR); 14 | if(prev_offset == (uint64_t)-1) { 15 | LOG_ERROR("pwrite64: cannot get offset\n"); 16 | return -1; 17 | } 18 | 19 | /* Set the offset */ 20 | if(sys_lseek(fd, offset, SEEK_SET) == (uint64_t)-1) { 21 | LOG_ERROR("pwrite64: cannot set offset\n"); 22 | ret = -1; 23 | goto out; 24 | } 25 | 26 | ret = sys_write(fd, buf, count); 27 | 28 | /* Set the offset back */ 29 | if(sys_lseek(fd, prev_offset, SEEK_SET) == (uint64_t)-1) { 30 | LOG_ERROR("pwrite64: cannot set back offset\n"); 31 | ret = -1; 32 | goto out; 33 | } 34 | 35 | out: 36 | return ret; 37 | } 38 | -------------------------------------------------------------------------------- /kernel/syscalls/rcce_fini.c: -------------------------------------------------------------------------------- 1 | #ifndef NO_IRCCE 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | extern int32_t isle; 11 | 12 | int sys_rcce_fini(int session_id) 13 | { 14 | int i, j; 15 | int ret = 0; 16 | 17 | // we have to free the MPB 18 | 19 | if (is_single_kernel()) 20 | return -ENOSYS; 21 | 22 | if (session_id <= 0) 23 | return -EINVAL; 24 | 25 | islelock_lock(rcce_lock); 26 | 27 | for(i=0; i= MAX_RCCE_SESSIONS) { 34 | ret = -EINVAL; 35 | goto out; 36 | } 37 | 38 | if (rcce_mpb[i].mpb[isle]) { 39 | if (is_hbmem_available()) 40 | hbmem_put_pages(rcce_mpb[i].mpb[isle], RCCE_MPB_SIZE / PAGE_SIZE); 41 | else 42 | put_pages(rcce_mpb[i].mpb[isle], RCCE_MPB_SIZE / PAGE_SIZE); 43 | } 44 | rcce_mpb[i].mpb[isle] = 0; 45 | 46 | for(j=0; (j= MAX_ISLE) 52 | rcce_mpb[i].id = 0; 53 | 54 | out: 55 | islelock_unlock(rcce_lock); 56 | 57 | return ret; 58 | } 59 | 60 | #endif /* NO_IRCCE */ 61 | -------------------------------------------------------------------------------- /kernel/syscalls/rcce_init.c: -------------------------------------------------------------------------------- 1 | #ifndef NO_IRCCE 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | extern int32_t isle; 11 | 12 | int sys_rcce_init(int session_id) 13 | { 14 | int i, err = 0; 15 | size_t paddr = 0; 16 | 17 | if (is_single_kernel()) 18 | return -ENOSYS; 19 | 20 | if (session_id <= 0) 21 | return -EINVAL; 22 | 23 | islelock_lock(rcce_lock); 24 | 25 | for(i=0; i=MAX_RCCE_SESSIONS) 33 | { 34 | for(i=0; i= MAX_RCCE_SESSIONS) 44 | { 45 | err = -EINVAL; 46 | goto out; 47 | } 48 | 49 | if (is_hbmem_available()) 50 | paddr = hbmem_get_pages(RCCE_MPB_SIZE / PAGE_SIZE); 51 | else 52 | paddr = get_pages(RCCE_MPB_SIZE / PAGE_SIZE); 53 | if (BUILTIN_EXPECT(!paddr, 0)) 54 | { 55 | err = -ENOMEM; 56 | goto out; 57 | } 58 | 59 | rcce_mpb[i].mpb[isle] = paddr; 60 | 61 | out: 62 | islelock_unlock(rcce_lock); 63 | 64 | LOG_INFO("Create MPB for session %d at 0x%zx, using of slot %d\n", session_id, paddr, i); 65 | 66 | return err; 67 | } 68 | 69 | #endif /* NO_IRCCE */ 70 | -------------------------------------------------------------------------------- /kernel/syscalls/rcce_malloc.c: -------------------------------------------------------------------------------- 1 | #ifndef NO_IRCCE 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | extern int32_t isle; 12 | 13 | size_t sys_rcce_malloc(int session_id, int ue) 14 | { 15 | size_t vaddr = 0; 16 | int i, counter = 0; 17 | 18 | if (is_single_kernel()) 19 | return -ENOSYS; 20 | 21 | if (session_id <= 0) 22 | return -EINVAL; 23 | 24 | // after 120 retries (= 120*300 ms) we give up 25 | do { 26 | for(i=0; i= MAX_RCCE_SESSIONS) { 33 | counter++; 34 | timer_wait((300*TIMER_FREQ)/1000); 35 | } 36 | } while((i >= MAX_RCCE_SESSIONS) && (counter < 120)); 37 | 38 | LOG_DEBUG("i = %d, counter = %d, max %d\n", i, counter, MAX_RCCE_SESSIONS); 39 | 40 | // create new session 41 | if (i >= MAX_RCCE_SESSIONS) 42 | goto out; 43 | 44 | vaddr = vma_alloc(RCCE_MPB_SIZE, VMA_READ|VMA_WRITE|VMA_USER|VMA_CACHEABLE); 45 | if (BUILTIN_EXPECT(!vaddr, 0)) 46 | goto out; 47 | 48 | if (page_map(vaddr, rcce_mpb[i].mpb[ue], RCCE_MPB_SIZE / PAGE_SIZE, PG_RW|PG_USER|PG_PRESENT)) { 49 | vma_free(vaddr, vaddr + 2*PAGE_SIZE, 0); 50 | goto out; 51 | } 52 | 53 | LOG_INFO("Map MPB of session %d at 0x%zx, using of slot %d, isle %d\n", session_id, vaddr, i, ue); 54 | 55 | if (isle == ue) 56 | memset((void*)vaddr, 0x0, RCCE_MPB_SIZE); 57 | 58 | return vaddr; 59 | 60 | out: 61 | LOG_ERROR("Didn't find a valid MPB for session %d, isle %d\n", session_id, ue); 62 | 63 | return 0; 64 | } 65 | 66 | #endif /* NO_IRCCE */ 67 | -------------------------------------------------------------------------------- /kernel/syscalls/readlink.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | typedef struct { 9 | char *path; 10 | char* buf; 11 | int bufsz; 12 | ssize_t ret; 13 | } __attribute__((packed)) uhyve_readlink_t; 14 | 15 | int sys_readlink(char *path, char *buf, int bufsiz) { 16 | 17 | if(minifs_enabled) { 18 | LOG_ERROR("readlink (%s) currently not supported with minifs\n", 19 | path); 20 | return -ENOSYS; 21 | } 22 | 23 | if(unlikely(!path || !buf)) { 24 | LOG_ERROR("readlink: path or buf is null\n"); 25 | return -EINVAL; 26 | } 27 | 28 | if (likely(is_uhyve())) { 29 | /* Let's get a physically contiguous buffer to avoid any issue with 30 | * the host filling it */ 31 | char *phys_buf = kmalloc(bufsiz); 32 | if(!phys_buf) 33 | return -ENOMEM; 34 | 35 | uhyve_readlink_t args = {(char *) virt_to_phys((size_t) path), 36 | (char*) virt_to_phys((size_t) phys_buf), bufsiz, -1}; 37 | 38 | uhyve_send(UHYVE_PORT_READLINK, (unsigned)virt_to_phys((size_t)&args)); 39 | memcpy(buf, phys_buf, bufsiz); 40 | 41 | kfree(phys_buf); 42 | return args.ret; 43 | } 44 | 45 | LOG_INFO("readlink: not supported with qemu isle\n"); 46 | return -ENOSYS; 47 | } 48 | -------------------------------------------------------------------------------- /kernel/syscalls/readv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | extern spinlock_t readwritev_spinlock; 8 | 9 | typedef struct { 10 | int fd; 11 | char* buf; 12 | size_t len; 13 | ssize_t ret; 14 | } __attribute__((packed)) uhyve_read_t; 15 | 16 | 17 | int sys_readv(int fd, const struct iovec *iov, unsigned long vlen) { 18 | int i, bytes_read, total_bytes_read; 19 | 20 | #ifndef NO_NET 21 | // do we have an LwIP file descriptor? 22 | if (fd & LWIP_FD_BIT) 23 | return -ENOSYS; 24 | 25 | #endif 26 | 27 | if(unlikely(!iov)) { 28 | LOG_ERROR("readv: iov is null\n"); 29 | return -EINVAL; 30 | } 31 | 32 | bytes_read = total_bytes_read = 0; 33 | 34 | /* readv is supposed to be atomic */ 35 | spinlock_lock(&readwritev_spinlock); 36 | for(i=0; i 2) 44 | bytes_read = minifs_read(fd, iov[i].iov_base, iov[i].iov_len); 45 | else { 46 | uhyve_read_t args = {fd, 47 | (char *) virt_to_phys((size_t)(iov[i].iov_base)), 48 | iov[i].iov_len}; 49 | 50 | uhyve_send(UHYVE_PORT_READ, (unsigned)virt_to_phys((size_t)&args)); 51 | bytes_read = args.ret; 52 | } 53 | 54 | if(unlikely(bytes_read < 0)) 55 | goto out; 56 | 57 | total_bytes_read += bytes_read; 58 | } 59 | 60 | out: 61 | spinlock_unlock(&readwritev_spinlock); 62 | return total_bytes_read; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /kernel/syscalls/recvfrom.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int hermit_recvfrom(int s, void *mem, size_t len, int flags, 6 | struct sockaddr *from, socklen_t *fromlen); 7 | 8 | int sys_recvfrom(int s, void *mem, size_t len, int flags, 9 | struct sockaddr *from, socklen_t *fromlen) { 10 | #ifndef NO_NET 11 | return hermit_recvfrom(s, mem, len, flags, from, fromlen); 12 | #else 13 | LOG_ERROR("Network disabled, cannot process socket syscall!\n"); 14 | return -ENOSYS; 15 | #endif /* NO_NET */ 16 | 17 | } 18 | -------------------------------------------------------------------------------- /kernel/syscalls/rename.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | typedef struct { 8 | char *oldpath; 9 | char *newpath; 10 | int ret; 11 | } __attribute__((packed)) uhyve_rename_t; 12 | 13 | int sys_rename(const char *oldpath, const char *newpath) { 14 | uhyve_rename_t arg; 15 | 16 | arg.oldpath = (char *)virt_to_phys((size_t)oldpath); 17 | arg.newpath = (char *)virt_to_phys((size_t)newpath); 18 | arg.ret = -1; 19 | 20 | uhyve_send(UHYVE_PORT_RENAME, (unsigned)virt_to_phys((size_t)&arg)); 21 | 22 | return arg.ret; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /kernel/syscalls/rmdir.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | typedef struct { 8 | const char *pathname; 9 | int ret; 10 | } __attribute__ ((packed)) uhyve_rmdir_t; 11 | 12 | int sys_rmdir(const char *pathname) { 13 | 14 | if(unlikely(!pathname)) { 15 | LOG_ERROR("rmdir: pathname is null\n"); 16 | return -EINVAL; 17 | } 18 | 19 | if(likely(is_uhyve())) { 20 | 21 | if(minifs_enabled) 22 | return minifs_rmdir(pathname); 23 | 24 | uhyve_rmdir_t args = {(const char *)virt_to_phys((size_t)pathname), 0}; 25 | uhyve_send(UHYVE_PORT_RMDIR, (unsigned)virt_to_phys((size_t)&args)); 26 | return args.ret; 27 | } 28 | 29 | /* not implemented for qemu yet */ 30 | LOG_ERROR("rmdir: not supported with qemu isle\n"); 31 | return -ENOSYS; 32 | } 33 | -------------------------------------------------------------------------------- /kernel/syscalls/rseq.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_rseq(void *rseq, uint32_t rseq_len, int flags, uint32_t sig ) { 5 | LOG_WARNING("syscall rseq (334) unsupported, faking\n"); 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /kernel/syscalls/rt_sigaction.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | typedef void * siginfo_t; 5 | typedef void * sigset_t; 6 | 7 | struct sigaction { 8 | union { 9 | void (*sa_handler)(int); 10 | void (*sa_sigaction)(int, siginfo_t *, void *); 11 | }; 12 | sigset_t sa_mask; 13 | int sa_flags; 14 | void (*sa_restorer)(void); 15 | }; 16 | 17 | #define MAX_SIGNUM 32 18 | 19 | struct sigaction *installed_sigactions[MAX_SIGNUM]; 20 | 21 | int sys_rt_sigaction(int signum, struct sigaction *act, 22 | struct sigaction *oldact) { 23 | 24 | if(oldact) 25 | oldact = installed_sigactions[signum]; 26 | 27 | if(act) { 28 | signal_handler_t sa = act->sa_handler; 29 | hermit_signal(sa); 30 | installed_sigactions[signum] = act; 31 | } 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /kernel/syscalls/sbrk.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | extern const void kernel_start; 7 | 8 | /* sbrk is not a Linux system call */ 9 | 10 | ssize_t sys_sbrk(ssize_t incr) 11 | { 12 | ssize_t ret; 13 | vma_t* heap = per_core(current_task)->heap; 14 | static spinlock_t heap_lock = SPINLOCK_INIT; 15 | 16 | if (BUILTIN_EXPECT(!heap, 0)) { 17 | LOG_ERROR("sys_sbrk: missing heap!\n"); 18 | do_abort(); 19 | } 20 | 21 | spinlock_lock(&heap_lock); 22 | 23 | ret = heap->end; 24 | 25 | // check heapp boundaries 26 | if ((heap->end >= HEAP_START) && (heap->end+incr < HEAP_START + HEAP_SIZE)) { 27 | heap->end += incr; 28 | 29 | // reserve VMA regions 30 | if (PAGE_FLOOR(heap->end) > PAGE_FLOOR(ret)) { 31 | // region is already reserved for the heap, we have to change the 32 | // property 33 | vma_free(PAGE_FLOOR(ret), PAGE_CEIL(heap->end), 0); 34 | vma_add(PAGE_FLOOR(ret), PAGE_CEIL(heap->end), VMA_HEAP|VMA_USER); 35 | } 36 | } else ret = -ENOMEM; 37 | 38 | // allocation and mapping of new pages for the heap 39 | // is catched by the pagefault handler 40 | 41 | spinlock_unlock(&heap_lock); 42 | 43 | return ret; 44 | } 45 | -------------------------------------------------------------------------------- /kernel/syscalls/sched_getaffinity.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | /* Code from the musl C Library */ 7 | typedef struct cpu_set_t { unsigned long __bits[128/sizeof(long)]; } cpu_set_t; 8 | 9 | #define __CPU_op_S(i, size, set, op) ( (i)/8U >= (size) ? 0 : \ 10 | (((unsigned long *)(set))[(i)/8/sizeof(long)] op (1UL<<((i)%(8*sizeof(long))))) ) 11 | #define CPU_ZERO_S(size,set) memset((void *)set,0,size) 12 | #define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t),set) 13 | #define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=) 14 | #define CPU_SET(i, set) CPU_SET_S(i,sizeof(cpu_set_t),set) 15 | 16 | extern task_t task_table[]; 17 | extern spinlock_irqsave_t table_lock; 18 | 19 | int sys_sched_getaffinity(int pid, unsigned int len, 20 | unsigned long *user_mask_ptr) { 21 | cpu_set_t *ptr = (cpu_set_t *)user_mask_ptr; 22 | int core_id = -1; 23 | 24 | if(unlikely(!user_mask_ptr)) { 25 | LOG_ERROR("sched_getaffinity: user_mask_ptr is NULL\n"); 26 | return -EINVAL; 27 | } 28 | 29 | if(!pid) { 30 | task_t *task = per_core(current_task); 31 | core_id = task->last_core; 32 | } else { 33 | spinlock_irqsave_lock(&table_lock); 34 | if(task_table[pid].status != TASK_INVALID) 35 | core_id = task_table[pid].last_core; 36 | spinlock_irqsave_unlock(&table_lock); 37 | } 38 | 39 | if(core_id == -1) { 40 | LOG_ERROR("sched_getaffinity: cannot find task %d\n", pid); 41 | return -EINVAL; 42 | } 43 | 44 | CPU_ZERO(ptr); 45 | CPU_SET(core_id, ptr); 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /kernel/syscalls/sched_setaffinity.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_sched_setaffinity(int pid, unsigned int len, 5 | unsigned long *user_mask_ptr) { 6 | /* FIXME */ 7 | LOG_ERROR("sched_setaffinity: unsupported syscall\n"); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /kernel/syscalls/sched_yield.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_sched_yield(void) { 5 | 6 | #if 0 7 | check_workqueues(); 8 | #else 9 | if (BUILTIN_EXPECT(go_down, 0)) 10 | shutdown_system(); 11 | check_scheduling(); 12 | #endif 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /kernel/syscalls/select.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | extern int hermit_select(int maxfdp1, fd_set *readset, fd_set *writeset, 5 | fd_set *exceptset, struct timeval *timeout); 6 | 7 | int sys_select(int maxfdp1, fd_set *readset, fd_set *writeset, 8 | fd_set *exceptset, struct timeval *timeout) { 9 | 10 | #ifndef NO_NET 11 | return hermit_select(maxfdp1, readset, writeset, exceptset, timeout); 12 | #else 13 | LOG_ERROR("Network disabled, cannot process bind syscall!\n"); 14 | return -ENOSYS; 15 | #endif /* NO_NET */ 16 | } 17 | -------------------------------------------------------------------------------- /kernel/syscalls/sem_cancelablewait.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_sem_cancelablewait(sem_t* sem, unsigned int ms) 5 | { 6 | if (BUILTIN_EXPECT(!sem, 0)) 7 | return -EINVAL; 8 | 9 | return sem_wait(sem, ms); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /kernel/syscalls/sem_destroy.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_sem_destroy(sem_t* sem) 5 | { 6 | int ret; 7 | 8 | if (BUILTIN_EXPECT(!sem, 0)) 9 | return -EINVAL; 10 | 11 | ret = sem_destroy(sem); 12 | if (!ret) 13 | kfree(sem); 14 | 15 | return ret; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /kernel/syscalls/sem_init.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_sem_init(sem_t** sem, unsigned int value) 5 | { 6 | int ret; 7 | 8 | if (BUILTIN_EXPECT(!sem, 0)) 9 | return -EINVAL; 10 | 11 | *sem = (sem_t*) kmalloc(sizeof(sem_t)); 12 | if (BUILTIN_EXPECT(!(*sem), 0)) 13 | return -ENOMEM; 14 | 15 | ret = sem_init(*sem, value); 16 | if (ret) { 17 | kfree(*sem); 18 | *sem = NULL; 19 | } 20 | 21 | return ret; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /kernel/syscalls/sem_post.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_sem_post(sem_t* sem) 5 | { 6 | if (BUILTIN_EXPECT(!sem, 0)) 7 | return -EINVAL; 8 | 9 | return sem_post(sem); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /kernel/syscalls/sem_timedwait.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_sem_timedwait(sem_t *sem, unsigned int ms) 5 | { 6 | if (BUILTIN_EXPECT(!sem, 0)) 7 | return -EINVAL; 8 | 9 | return sem_wait(sem, ms); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /kernel/syscalls/sem_wait.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_sem_wait(sem_t* sem) 5 | { 6 | if (BUILTIN_EXPECT(!sem, 0)) 7 | return -EINVAL; 8 | 9 | return sem_wait(sem, 0); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /kernel/syscalls/sendfile.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define BUF_SIZE 1024 5 | 6 | size_t sys_sendfile(int out_fd, int in_fd, off_t *offset, size_t count) { 7 | char buf[BUF_SIZE]; 8 | uint64_t bytes_sent = 0; 9 | int ret = -1; 10 | uint64_t prev_offset = 0; 11 | 12 | if(offset) { 13 | /* Save the old offset for in_fd. It is not needed for out_fd as, if it 14 | * is a file (and not a socket), it is normal for sendfile to update its 15 | * offset */ 16 | uint64_t prev_offset = sys_lseek(in_fd, 0x0, SEEK_CUR); 17 | if(prev_offset == (uint64_t)-1) { 18 | LOG_ERROR("sendfile: cannot get in_fd offset\n"); 19 | return -1; 20 | } 21 | 22 | /* Set the offset */ 23 | if(sys_lseek(in_fd, *offset, SEEK_SET) == (uint64_t)-1) { 24 | LOG_ERROR("sendfile: cannot set offset\n"); 25 | ret = -1; 26 | goto out; 27 | } 28 | } 29 | 30 | while(count) { 31 | int bytes_read = sys_read(in_fd, buf, BUF_SIZE); 32 | if(bytes_read < 0) { 33 | LOG_ERROR("sendfile: issue reading\n"); 34 | ret = -1; 35 | goto out; 36 | } 37 | 38 | int bytes_written = sys_write(out_fd, buf, bytes_read); 39 | if(bytes_written < 0) { 40 | LOG_ERROR("sendfile: issue writing\n"); 41 | ret = -1; 42 | goto out; 43 | } 44 | 45 | bytes_sent += bytes_written; 46 | count -= bytes_written; 47 | 48 | if(bytes_read < BUF_SIZE) 49 | break; 50 | } 51 | 52 | /* restore offset for in_fd */ 53 | if(offset) { 54 | uint64_t end_offset = sys_lseek(in_fd, 0x0, SEEK_CUR); 55 | *offset = end_offset; 56 | sys_lseek(in_fd, prev_offset, SEEK_SET); 57 | } 58 | 59 | out: 60 | return ret; 61 | } 62 | -------------------------------------------------------------------------------- /kernel/syscalls/sendto.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern int hermit_sendto(int s, const void *dataptr, size_t size, int flags, 6 | const struct sockaddr *to, socklen_t tolen); 7 | 8 | int sys_sendto(int s, const void *dataptr, size_t size, int flags, 9 | const struct sockaddr *to, socklen_t tolen) { 10 | #ifndef NO_NET 11 | return hermit_sendto(s, dataptr, size, flags, to, tolen); 12 | #else 13 | LOG_ERROR("Network disabled, cannot process socket syscall!\n"); 14 | return -ENOSYS; 15 | #endif /* NO_NET */ 16 | 17 | } 18 | -------------------------------------------------------------------------------- /kernel/syscalls/set_robust_list.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | char *ptr = NULL; 6 | 7 | /* Fake implementation */ 8 | long sys_set_robust_list(void *head, size_t len) { 9 | /* TODO */ 10 | LOG_WARNING("set_robust_list: syscall not supported, faking success\n"); 11 | ptr = head; 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /kernel/syscalls/set_tid_address.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | long sys_set_tid_address(int *tidptr) { 5 | task_t* curr_task = per_core(current_task); 6 | curr_task->clear_child_tid = tidptr; 7 | 8 | return curr_task->id; 9 | } 10 | -------------------------------------------------------------------------------- /kernel/syscalls/sethostname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern char hermitux_hostname[]; 6 | extern size_t hermitux_hostname_len; 7 | 8 | int sys_sethostname(char *name, size_t len) 9 | { 10 | if(unlikely(!name)) { 11 | LOG_ERROR("sethostname: name is null\n"); 12 | return -EINVAL; 13 | } 14 | 15 | if(unlikely(len < hermitux_hostname_len)) { 16 | LOG_WARNING("sethostname: name too big, should be < %u, truncating " 17 | "name\n, hostname_len"); 18 | len = hermitux_hostname_len; 19 | } 20 | 21 | strncpy(hermitux_hostname, name, len); 22 | return 0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /kernel/syscalls/setpriority.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | typedef unsigned id_t; 7 | 8 | #define PRIO_PROCESS 0 9 | #define PRIO_PGRP 1 10 | #define PRIO_USER 2 11 | 12 | extern task_t task_table[]; 13 | extern spinlock_irqsave_t table_lock; 14 | 15 | int sys_setpriority(int which, id_t who, int prio) { 16 | int hermitux_prio = -1; 17 | task_t *task; 18 | 19 | if(unlikely(which != PRIO_PROCESS && which != PRIO_PGRP && 20 | which != PRIO_USER)) { 21 | LOG_ERROR("setpriority: 'which' is invalid\n"); 22 | return -EINVAL; 23 | } 24 | 25 | if(unlikely(prio < -20 || prio > 20)) { 26 | LOG_ERROR("setpriority: bad value for prio\n"); 27 | return -EINVAL; 28 | } 29 | 30 | /* Mapping of Linux to Hermitux priorities: 31 | * system: (low) ----> (high) 32 | * htux: 0 ---------> 31 33 | * linux: 20 -------->-20 34 | */ 35 | hermitux_prio = -(3*prio)/4 + 16; 36 | 37 | LOG_INFO("setprio:\n"); 38 | LOG_INFO(" LINUX:%d\n", prio); 39 | LOG_INFO(" HTUX:%d\n", hermitux_prio); 40 | 41 | if(!who) { 42 | /* Set the priority of the calling process */ 43 | task = per_core(current_task); 44 | task->prio = hermitux_prio; 45 | } else { 46 | int done = 0; 47 | spinlock_irqsave_lock(&table_lock); 48 | if(task_table[who].status != TASK_INVALID) { 49 | done = 1; 50 | task_table[who].prio = hermitux_prio; 51 | } 52 | spinlock_irqsave_unlock(&table_lock); 53 | 54 | if(!done) { 55 | LOG_ERROR("setpriority: could not find task %u\n", who); 56 | return -EINVAL; 57 | } 58 | } 59 | 60 | return 0; 61 | } 62 | 63 | /* TODO remove this ? */ 64 | int sys_setprio(tid_t* id, int prio) 65 | { 66 | return -ENOSYS; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /kernel/syscalls/setrlimit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_setrlimit(int resource, const struct rlimit *rlim) { 5 | LOG_ERROR("setrlimit: syscall not supported\n"); 6 | return -ENOSYS; 7 | } 8 | -------------------------------------------------------------------------------- /kernel/syscalls/setsid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_setsid(void) { 5 | task_t* task = per_core(current_task); 6 | return task->id; 7 | } 8 | -------------------------------------------------------------------------------- /kernel/syscalls/setsockopt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern int hermit_setsockopt(int fd, int level, int optname, char *optval, 6 | socklen_t optlen); 7 | 8 | int sys_setsockopt(int fd, int level, int optname, char *optval, socklen_t optlen) { 9 | 10 | #ifndef NO_NET 11 | return hermit_setsockopt(fd, level, optname, optval, optlen); 12 | #else 13 | LOG_ERROR("Network disabled, cannot process socket syscall!\n"); 14 | return -ENOSYS; 15 | #endif /* NO_NET */ 16 | } 17 | -------------------------------------------------------------------------------- /kernel/syscalls/shutdown.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern int hermit_shutdown(int socket, int how); 6 | 7 | int sys_shutdown(int socket, int how) { 8 | #ifndef NO_NET 9 | return hermit_shutdown(socket, how); 10 | #else 11 | LOG_ERROR("Network disabled, cannot process socket syscall!\n"); 12 | return -ENOSYS; 13 | #endif /* NO_NET */ 14 | 15 | } 16 | -------------------------------------------------------------------------------- /kernel/syscalls/sigaltstack.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* TODO */ 5 | long sys_sigaltstack(const stack_t *ss, stack_t *oss) { 6 | return -ENOSYS; 7 | } 8 | -------------------------------------------------------------------------------- /kernel/syscalls/signal.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* signal is not a Linux syscall */ 6 | 7 | int sig_hermit_signal(signal_handler_t handler); 8 | 9 | int sys_signal(signal_handler_t handler) 10 | { 11 | return sig_hermit_signal(handler); 12 | } 13 | 14 | int sig_hermit_signal(signal_handler_t handler) 15 | { 16 | task_t* curr_task = per_core(current_task); 17 | curr_task->signal_handler = handler; 18 | 19 | return 0; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /kernel/syscalls/socket.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern int hermit_socket(int domain, int type, int protocol); 6 | 7 | int sys_socket(int domain, int type, int protocol) { 8 | int ret; 9 | #ifndef NO_NET 10 | ret = hermit_socket(domain, type, protocol); 11 | return ret; 12 | #else 13 | LOG_ERROR("Network disabled, cannot process socket syscall!\n"); 14 | return -ENOSYS; 15 | #endif /* NO_NET */ 16 | 17 | } 18 | -------------------------------------------------------------------------------- /kernel/syscalls/socket_recv.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static inline int socket_recv(int fd, void* buf, size_t len) 4 | { 5 | int ret, sz = 0; 6 | 7 | do { 8 | ret = lwip_read(fd, (char*)buf + sz, len-sz); 9 | if (ret >= 0) 10 | sz += ret; 11 | else 12 | return ret; 13 | } while(sz < len); 14 | 15 | return len; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /kernel/syscalls/socket_send.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static inline int socket_send(int fd, const void* buf, size_t len) 4 | { 5 | int ret, sz = 0; 6 | 7 | do { 8 | ret = lwip_write(fd, (char*)buf + sz, len-sz); 9 | if (ret >= 0) 10 | sz += ret; 11 | else 12 | return ret; 13 | } while(sz < len); 14 | 15 | return len; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /kernel/syscalls/spinlock_destroy.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_spinlock_destroy(spinlock_t* lock) 5 | { 6 | int ret; 7 | 8 | if (BUILTIN_EXPECT(!lock, 0)) 9 | return -EINVAL; 10 | 11 | ret = spinlock_destroy(lock); 12 | if (!ret) 13 | kfree(lock); 14 | 15 | return ret; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /kernel/syscalls/spinlock_init.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_spinlock_init(spinlock_t** lock) 5 | { 6 | int ret; 7 | 8 | if (BUILTIN_EXPECT(!lock, 0)) 9 | return -EINVAL; 10 | 11 | *lock = (spinlock_t*) kmalloc(sizeof(spinlock_t)); 12 | if (BUILTIN_EXPECT(!(*lock), 0)) 13 | return -ENOMEM; 14 | 15 | ret = spinlock_init(*lock); 16 | if (ret) { 17 | kfree(*lock); 18 | *lock = NULL; 19 | } 20 | 21 | return ret; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /kernel/syscalls/spinlock_lock.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_spinlock_lock(spinlock_t* lock) 5 | { 6 | if (BUILTIN_EXPECT(!lock, 0)) 7 | return -EINVAL; 8 | 9 | return spinlock_lock(lock); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /kernel/syscalls/spinlock_unlock.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_spinlock_unlock(spinlock_t* lock) 5 | { 6 | if (BUILTIN_EXPECT(!lock, 0)) 7 | return -EINVAL; 8 | 9 | return spinlock_unlock(lock); 10 | } 11 | 12 | -------------------------------------------------------------------------------- /kernel/syscalls/sync.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int sys_sync(void) { 8 | 9 | if(minifs_enabled) 10 | return 0; 11 | 12 | uhyve_send(UHYVE_PORT_SYNC, 0x0); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /kernel/syscalls/syncfs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | typedef struct { 8 | int fd; 9 | int ret; 10 | } __attribute__((packed)) uhyve_fsync_t; 11 | 12 | int sys_syncfs(int fd) { 13 | uhyve_fsync_t arg; 14 | 15 | if(minifs_enabled) 16 | return 0; 17 | 18 | arg.fd = fd; 19 | arg.ret = -1; 20 | 21 | uhyve_send(UHYVE_PORT_FSYNC, (unsigned)virt_to_phys((size_t)&arg)); 22 | return arg.ret; 23 | } 24 | -------------------------------------------------------------------------------- /kernel/syscalls/sysinfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | struct sysinfo { 7 | long uptime; /* Seconds since boot */ 8 | unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ 9 | unsigned long totalram; /* Total usable main memory size */ 10 | unsigned long freeram; /* Available memory size */ 11 | unsigned long sharedram; /* Amount of shared memory */ 12 | unsigned long bufferram; /* Memory used by buffers */ 13 | unsigned long totalswap; /* Total swap space size */ 14 | unsigned long freeswap; /* Swap space still available */ 15 | unsigned short procs; /* Number of current processes */ 16 | unsigned long totalhigh; /* Total high memory size */ 17 | unsigned long freehigh; /* Available high memory size */ 18 | unsigned int mem_unit; /* Memory unit size in bytes */ 19 | char _f[20-2*sizeof(long)-sizeof(int)]; 20 | /* Padding to 64 bytes */ 21 | }; 22 | 23 | extern atomic_int64_t total_pages; 24 | extern atomic_int64_t total_available_pages; 25 | 26 | int sys_sysinfo(struct sysinfo *info) { 27 | 28 | if(unlikely(!info)) { 29 | LOG_ERROR("sysinfo: info is null\n"); 30 | return -EINVAL; 31 | } 32 | 33 | /* uptime */ 34 | info->uptime = get_clock_tick() / TIMER_FREQ; 35 | 36 | /* LOAD TODO */ 37 | info->loads[0] = 0; 38 | info->loads[1] = 0; 39 | info->loads[3] = 0; 40 | 41 | /* RAM */ 42 | info->totalram = atomic_int64_read(&total_pages) * PAGE_SIZE; 43 | info->freeram = atomic_int64_read(&total_available_pages) * PAGE_SIZE; 44 | info->sharedram = 0; 45 | info->bufferram = 0; 46 | 47 | /* swap */ 48 | info->totalswap = 0; 49 | info->freeswap = 0; 50 | 51 | /* processes: just 1, we are in a unikernel */ 52 | info->procs = 1; 53 | 54 | /* High memory */ 55 | info->totalhigh = 0; 56 | info->freehigh = 0; 57 | 58 | /* units */ 59 | info->mem_unit = 1; 60 | 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /kernel/syscalls/tgkill.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | extern dequeue_t *signal_queue; 8 | 9 | int hermit_sys_tgkill(tid_t dest, int signum); 10 | 11 | int sys_tgkill(int tgid, int tid, int sig) { 12 | if(unlikely(sig < 0)) { 13 | LOG_ERROR("tgkill: signal is 0\n"); 14 | return -EINVAL; 15 | } 16 | 17 | return hermit_sys_tgkill(tid, sig); 18 | 19 | } 20 | 21 | int hermit_sys_tgkill(tid_t dest, int signum) 22 | { 23 | task_t* task; 24 | if(BUILTIN_EXPECT(get_task(dest, &task), 0)) { 25 | LOG_ERROR("Trying to send signal %d to invalid task %d\n", signum, dest); 26 | return -ENOENT; 27 | } 28 | 29 | const tid_t dest_core = task->last_core; 30 | 31 | LOG_DEBUG("Send signal %d from task %d (core %d) to task %d (core %d)\n", 32 | signum, per_core(current_task)->id, CORE_ID, dest, dest_core); 33 | 34 | if(task == per_core(current_task)) { 35 | LOG_DEBUG(" Deliver signal to itself, call handler immediately\n"); 36 | 37 | if(task->signal_handler) { 38 | task->signal_handler(signum); 39 | } 40 | return 0; 41 | } 42 | 43 | sig_t signal = {dest, signum}; 44 | if(dequeue_push(&signal_queue[dest_core], &signal)) { 45 | LOG_ERROR(" Cannot push signal to task's signal queue, dropping it\n"); 46 | return -ENOMEM; 47 | } 48 | 49 | // send IPI to destination core 50 | LOG_DEBUG(" Send signal IPI (%d) to core %d\n", SIGNAL_IRQ, dest_core); 51 | apic_send_ipi(dest_core, SIGNAL_IRQ); 52 | 53 | return 0; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /kernel/syscalls/time.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern unsigned long long syscall_boot_tsc; 4 | extern unsigned long long syscall_freq; 5 | extern unsigned long epoch_offset; 6 | 7 | inline static unsigned long long t_rdtsc(void) 8 | { 9 | unsigned int lo, hi; 10 | 11 | asm volatile ("rdtsc" : "=a"(lo), "=d"(hi) :: "memory"); 12 | 13 | return ((unsigned long long)hi << 32ULL | (unsigned long long)lo); 14 | } 15 | 16 | int sys_time(long *tloc) { 17 | 18 | long sec; 19 | 20 | unsigned long long diff = t_rdtsc() - syscall_boot_tsc; 21 | sec = diff/syscall_freq; 22 | 23 | sec += epoch_offset; 24 | 25 | if(tloc) 26 | *tloc = sec; 27 | 28 | return sec; 29 | } 30 | -------------------------------------------------------------------------------- /kernel/syscalls/tkill.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | extern dequeue_t *signal_queue; 8 | 9 | int hermit_sys_tkill(tid_t dest, int signum); 10 | 11 | int sys_tkill(int tid, int sig) { 12 | if(unlikely(sig < 0)) { 13 | LOG_ERROR("tkill: signal is 0\n"); 14 | return -EINVAL; 15 | } 16 | 17 | return hermit_sys_tkill(tid, sig); 18 | 19 | } 20 | 21 | int hermit_sys_tkill(tid_t dest, int signum) 22 | { 23 | task_t* task; 24 | if(BUILTIN_EXPECT(get_task(dest, &task), 0)) { 25 | LOG_ERROR("Trying to send signal %d to invalid task %d\n", signum, dest); 26 | return -ENOENT; 27 | } 28 | 29 | const tid_t dest_core = task->last_core; 30 | 31 | LOG_DEBUG("Send signal %d from task %d (core %d) to task %d (core %d)\n", 32 | signum, per_core(current_task)->id, CORE_ID, dest, dest_core); 33 | 34 | if(task == per_core(current_task)) { 35 | LOG_DEBUG(" Deliver signal to itself, call handler immediately\n"); 36 | 37 | if(task->signal_handler) { 38 | task->signal_handler(signum); 39 | } 40 | return 0; 41 | } 42 | 43 | sig_t signal = {dest, signum}; 44 | if(dequeue_push(&signal_queue[dest_core], &signal)) { 45 | LOG_ERROR(" Cannot push signal to task's signal queue, dropping it\n"); 46 | return -ENOMEM; 47 | } 48 | 49 | // send IPI to destination core 50 | LOG_DEBUG(" Send signal IPI (%d) to core %d\n", SIGNAL_IRQ, dest_core); 51 | apic_send_ipi(dest_core, SIGNAL_IRQ); 52 | 53 | return 0; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /kernel/syscalls/umask.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int sys_umask(int mask) { 5 | return mask & 0777; 6 | } 7 | -------------------------------------------------------------------------------- /kernel/syscalls/uname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern char hermitux_hostname[]; 5 | extern size_t hermitux_hostname_len; 6 | 7 | struct utsname { 8 | char sysname[65]; 9 | char nodename[65]; 10 | char release[65]; 11 | char version[65]; 12 | char machine[65]; 13 | char domainname[65]; 14 | }; 15 | 16 | int sys_uname(struct utsname *buf) { 17 | if(unlikely(!buf)) { 18 | LOG_ERROR("uname: buf is null\n"); 19 | return -EINVAL; 20 | } 21 | 22 | memset(buf , 0x0, sizeof(struct utsname)); 23 | strcpy(buf->sysname, "HermiTux"); 24 | strcpy(buf->nodename, hermitux_hostname); 25 | strcpy(buf->release, "4.9.0-4-amd64"); /* Faking Linux here for compat with glibc */ 26 | strcpy(buf->version, "0.1-may-2018"); 27 | strcpy(buf->machine, "x86_64"); 28 | strcpy(buf->domainname, ""); 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /kernel/syscalls/unlink.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | extern spinlock_irqsave_t lwip_lock; 9 | extern volatile int libc_sd; 10 | 11 | typedef struct { 12 | const char* pathname; 13 | int ret; 14 | } __attribute__((packed)) uhyve_unlink_t; 15 | 16 | 17 | int sys_unlink(const char *pathname) { 18 | 19 | if(unlikely(!pathname)) { 20 | LOG_ERROR("unlink: pathname is null\n"); 21 | return -EINVAL; 22 | } 23 | 24 | #ifndef NO_NET 25 | int s, sysnr, i, len, ret; 26 | #endif /* NO_NET */ 27 | 28 | if(is_uhyve()) { 29 | 30 | if(minifs_enabled) 31 | return minifs_unlink(pathname); 32 | 33 | uhyve_unlink_t uhyve_args = { (const char *) virt_to_phys((size_t) pathname), 0}; 34 | uhyve_send(UHYVE_PORT_UNLINK, (unsigned)virt_to_phys((size_t)&uhyve_args)); 35 | return uhyve_args.ret; 36 | } 37 | 38 | #ifndef NO_NET 39 | 40 | spinlock_irqsave_lock(&lwip_lock); 41 | s = libc_sd; 42 | 43 | sysnr = __NR_unlink; 44 | lwip_write(s, &sysnr, sizeof(sysnr)); 45 | 46 | len = strlen(pathname); 47 | lwip_write(s, &len, sizeof(len)); 48 | 49 | i=0; 50 | while(i < len) 51 | { 52 | ret = lwip_write(s, (char*)pathname+i, len-i); 53 | if (ret < 0) { 54 | spinlock_irqsave_unlock(&lwip_lock); 55 | return ret; 56 | } 57 | 58 | i += ret; 59 | } 60 | 61 | ret = lwip_read(s, &i, sizeof(i)); 62 | if (ret < 0) 63 | i = ret; 64 | 65 | spinlock_irqsave_unlock(&lwip_lock); 66 | 67 | return i; 68 | 69 | #endif /* NO_NET */ 70 | LOG_ERROR("unlink: network disabled, cannot use qemu isle\n"); 71 | return -ENOSYS; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /kernel/syscalls/writev.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | extern spinlock_t readwritev_spinlock; 8 | 9 | typedef struct { 10 | int fd; 11 | const char* buf; 12 | size_t len; 13 | int ret; 14 | } __attribute__((packed)) uhyve_write_t; 15 | 16 | int sys_writev(int fd, const struct iovec *iov, unsigned long vlen) { 17 | int i, bytes_written, total_bytes_written; 18 | 19 | #ifndef NO_NET 20 | // do we have an LwIP file descriptor? 21 | if (fd & LWIP_FD_BIT) { 22 | return -ENOSYS; 23 | } 24 | 25 | #endif 26 | 27 | if(unlikely(!iov)) { 28 | LOG_ERROR("writev: iov is null\n"); 29 | return -EINVAL; 30 | } 31 | 32 | if(unlikely(!is_uhyve())) { 33 | LOG_ERROR("writev: only supported with uhyve isle\n"); 34 | return -ENOSYS; 35 | } 36 | 37 | bytes_written = total_bytes_written = 0; 38 | 39 | /* writev is supposed to be atomic */ 40 | spinlock_lock(&readwritev_spinlock); 41 | for(i=0; i 2) 50 | bytes_written = minifs_write(fd, iov[i].iov_base, iov[i].iov_len); 51 | else { 52 | uhyve_write_t args = {fd, 53 | (const char *) virt_to_phys((size_t)(iov[i].iov_base)), 54 | iov[i].iov_len, -1}; 55 | 56 | uhyve_send(UHYVE_PORT_WRITE, (unsigned)virt_to_phys((size_t)&args)); 57 | bytes_written = args.ret; 58 | } 59 | 60 | if(bytes_written < 0) 61 | goto out; 62 | 63 | total_bytes_written += bytes_written; 64 | } 65 | 66 | out: 67 | spinlock_unlock(&readwritev_spinlock); 68 | return total_bytes_written; 69 | } 70 | 71 | 72 | -------------------------------------------------------------------------------- /kernel/syscalls/yield.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /* not a Linux syscall */ 5 | 6 | void sys_yield(void) 7 | { 8 | #if 0 9 | check_workqueues(); 10 | #else 11 | if (BUILTIN_EXPECT(go_down, 0)) 12 | shutdown_system(); 13 | check_scheduling(); 14 | #endif 15 | } 16 | 17 | -------------------------------------------------------------------------------- /kernel/timer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, Stefan Lankes, RWTH Aachen University 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | 30 | struct itimerval; 31 | 32 | int getitimer(int which, struct itimerval *value) 33 | { 34 | return 0; 35 | } 36 | 37 | int setitimer(int which, const struct itimerval *restrict value, struct itimerval * ovalue) 38 | { 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # do not use this script 4 | # it is written only for internal tests via Travis CI 5 | 6 | TDIR=build/local_prefix/opt/hermit/x86_64-hermit/extra 7 | FILES="$TDIR/tests/hello $TDIR/tests/hellof $TDIR/tests/hello++ $TDIR/tests/thr_hello $TDIR/tests/pi $TDIR/benchmarks/stream $TDIR/benchmarks/basic $TDIR/tests/signals $TDIR/tests/test-malloc $TDIR/tests/test-malloc-mt $TDIR/tests/argv_envp" 8 | PROXY=build/local_prefix/opt/hermit/bin/proxy 9 | 10 | for f in $FILES; do echo "check $f..."; HERMIT_ISLE=qemu HERMIT_CPUS=1 HERMIT_KVM=0 HERMIT_VERBOSE=1 timeout --kill-after=5m 5m $PROXY $f || exit 1; done 11 | 12 | for f in $FILES; do echo "check $f..."; HERMIT_ISLE=qemu HERMIT_CPUS=2 HERMIT_KVM=0 HERMIT_VERBOSE=1 timeout --kill-after=5m 5m $PROXY $f || exit 1; done 13 | 14 | # test echo server at port 8000 15 | HERMIT_ISLE=qemu HERMIT_CPUS=1 HERMIT_KVM=0 HERMIT_VERBOSE=1 HERMIT_APP_PORT=8000 $PROXY $TDIR/tests/server & 16 | sleep 10 17 | curl http://127.0.0.1:8000/help 18 | sleep 1 19 | curl http://127.0.0.1:8000/hello 20 | sleep 1 21 | 22 | # kill server 23 | kill $! 24 | 25 | # test connection via netio 26 | wget http://web.ars.de/wp-content/uploads/2017/04/netio132.zip 27 | unzip netio132.zip 28 | HERMIT_ISLE=qemu HERMIT_CPUS=2 HERMIT_KVM=0 HERMIT_VERBOSE=1 HERMIT_APP_PORT=18767 $PROXY $TDIR/benchmarks/netio & 29 | sleep 1 30 | chmod a+rx bin/linux-x86_64 31 | bin/linux-x86_64 -t -b 4k localhost 32 | sleep 1 33 | 34 | # kill server 35 | kill $! 36 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | project(hermit_tools) 3 | 4 | include(../cmake/HermitCore-Paths.cmake) 5 | 6 | add_compile_options(-std=c99) 7 | 8 | add_executable(proxy proxy.c utils.c uhyve.c uhyve-net.c uhyve-elf.c mini_gzip.c miniz.c uhyve-gdb.c uhyve-seccomp.c uhyve-profiler.c) 9 | target_compile_options(proxy PUBLIC -pthread) 10 | target_compile_options(proxy PUBLIC -DMAX_ARGC_ENVC=${MAX_ARGC_ENVC}) 11 | target_link_libraries(proxy -pthread -lseccomp) 12 | target_link_libraries(proxy -static) 13 | 14 | install(TARGETS proxy 15 | DESTINATION bin) 16 | 17 | install(FILES init.sh 18 | DESTINATION tools) 19 | 20 | # Show include files in IDE 21 | file(GLOB_RECURSE TOOLS_INCLUDES "*.h") 22 | add_custom_target(tools_includes_ide SOURCES ${TOOLS_INCLUDES}) 23 | -------------------------------------------------------------------------------- /tools/demo_kvm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # do not use this script 4 | # it is written only for internal reasons 5 | 6 | MYPROMPT="~ > " 7 | 8 | clear 9 | echo -n $MYPROMPT 10 | echo -e " \e[92m# HermitCore is also usable as a classical unikernel. By setting the\e[39m" | randtype -m 2 -t 18,6000 11 | echo -n $MYPROMPT 12 | echo -e " \e[92m# environment variable HERMIT_ISLE to qemu, the application will be started\e[39m" | randtype -m 2 -t 18,6000 13 | echo -n $MYPROMPT 14 | echo -e " \e[92m# within a virtual machine. The boot time is about 1s.\e[39m" | randtype -m 0 -t 18,6000 15 | echo -n $MYPROMPT 16 | echo " HERMIT_ISLE=qemu time hermit/usr/tests/hello" | randtype -m 0 -t 18,6000 17 | HERMIT_ISLE=qemu time hermit/usr/tests/hello 18 | echo -n $MYPROMPT 19 | echo -e " \e[92m# The variable HERMIT_CPUS defines the number of virtual cores, while\e[39m" | randtype -m 2 -t 18,6000 20 | echo -n $MYPROMPT 21 | echo -e " \e[92m# HERMIT_MEM specifies the memory size of the virtual machine.\e[39m" | randtype -m 1 -t 18,6000 22 | echo -n $MYPROMPT 23 | echo " HERMIT_ISLE=qemu HERMIT_CPUS=4 HERMIT_MEM=1G hermit/usr/benchmarks/stream" | randtype -m 1 -t 18,6000 24 | HERMIT_ISLE=qemu HERMIT_CPUS=4 HERMIT_MEM=1G hermit/usr/benchmarks/stream 25 | echo -n $MYPROMPT 26 | echo -e " \e[92m# HermitCore's kernel messages are published by setting the environment\e[39m" | randtype -m 1 -t 18,6000 27 | echo -n $MYPROMPT 28 | echo -e " \e[92m# HERMIT_VERBOSE to 1.\e[39m" | randtype -m 1 -t 18,6000 29 | echo -n $MYPROMPT 30 | echo " HERMIT_ISLE=qemu HERMIT_CPUS=4 HERMIT_VERBOSE=1 hermit/usr/benchmarks/stream" | randtype -m 1 -t 18,6000 31 | HERMIT_ISLE=qemu HERMIT_CPUS=4 HERMIT_VERBOSE=1 hermit/usr/benchmarks/stream 32 | #echo $MYPROMPT 33 | echo -n $MYPROMPT 34 | echo -e " \e[92mHermitCore (\e[31mhttp://www.hermitcore.org\e[92m) is an experimental platform.\e[39m" | randtype -m 1 -t 18,6000 35 | echo -n $MYPROMPT 36 | echo -e " \e[92mBut try it out and send us a feedback!\e[39m" | randtype -m 1 -t 18,6000 37 | 38 | -------------------------------------------------------------------------------- /tools/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PROXY=/hermit/bin/proxy 4 | 5 | ELF_OSABI_OFFSET=7 6 | ELF_OSABI="\\x42" 7 | 8 | # Network 9 | /sbin/ifconfig lo 127.0.0.1 netmask 255.0.0.0 up 10 | /sbin/ifconfig eth0 up 10.0.2.15 netmask 255.255.255.0 up 11 | /sbin/ifconfig mmnif up 192.168.28.1 netmask 255.255.255.0 up 12 | /sbin/route add default gw 10.0.2.2 13 | /bin/hostname -F /etc/hostname 14 | echo "Network setup completed" 15 | 16 | # Load binfmt_misc kernel module and mount pseudo FS 17 | test -d /lib/modules && modprobe binfmt_misc 18 | grep binfmt_misc /proc/mounts || mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc 19 | 20 | # Register new format 21 | echo ":hermit:M:$ELF_OSABI_OFFSET:$ELF_OSABI::$PROXY:" > /proc/sys/fs/binfmt_misc/register 22 | 23 | # Startup completed 24 | sleep 1 && echo -e '\nWelcome to HermitCore (http://www.hermitcore.org/)!' 25 | 26 | /bin/sh 27 | -------------------------------------------------------------------------------- /tools/mini_gzip.h: -------------------------------------------------------------------------------- 1 | #ifndef _MINI_GZIP_H_ 2 | #define _MINI_GZIP_H_ 3 | 4 | #define MAX_PATH_LEN 1024 5 | #define MINI_GZ_MIN(a, b) ((a) < (b) ? (a) : (b)) 6 | 7 | struct mini_gzip { 8 | size_t total_len; 9 | size_t data_len; 10 | size_t chunk_size; 11 | 12 | uint32_t magic; 13 | #define MINI_GZIP_MAGIC 0xbeebb00b 14 | 15 | uint16_t fcrc; 16 | uint16_t fextra_len; 17 | 18 | uint8_t *hdr_ptr; 19 | uint8_t *fextra_ptr; 20 | uint8_t *fname_ptr; 21 | uint8_t *fcomment_ptr; 22 | 23 | uint8_t *data_ptr; 24 | uint8_t pad[3]; 25 | }; 26 | 27 | /* mini_gzip.c */ 28 | extern int mini_gz_start(struct mini_gzip *gz_ptr, void *mem, size_t mem_len); 29 | extern void mini_gz_chunksize_set(struct mini_gzip *gz_ptr, int chunk_size); 30 | extern void mini_gz_init(struct mini_gzip *gz_ptr); 31 | extern int mini_gz_unpack(struct mini_gzip *gz_ptr, void *mem_out, size_t mem_out_len); 32 | 33 | #define func_fprintf fprintf 34 | #define func_fflush fflush 35 | 36 | #define MINI_GZ_STREAM stderr 37 | 38 | #ifdef MINI_GZ_DEBUG 39 | #define GZAS(comp, ...) do { \ 40 | if (!((comp))) { \ 41 | func_fprintf(MINI_GZ_STREAM, "Error: "); \ 42 | func_fprintf(MINI_GZ_STREAM, __VA_ARGS__); \ 43 | func_fprintf(MINI_GZ_STREAM, ", %s:%d\n", __func__, __LINE__); \ 44 | func_fflush(MINI_GZ_STREAM); \ 45 | exit(1); \ 46 | } \ 47 | } while (0) 48 | 49 | #define GZDBG(...) do { \ 50 | func_fprintf(MINI_GZ_STREAM, "%s:%d ", __func__, __LINE__); \ 51 | func_fprintf(MINI_GZ_STREAM, __VA_ARGS__); \ 52 | func_fprintf(MINI_GZ_STREAM, "\n"); \ 53 | } while (0) 54 | #else /* MINI_GZ_DEBUG */ 55 | #define GZAS(comp, ...) 56 | #define GZDBG(...) 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /tools/miniz.h: -------------------------------------------------------------------------------- 1 | #define MINIZ_HEADER_FILE_ONLY 2 | #include "miniz.c" 3 | -------------------------------------------------------------------------------- /tools/uhyve-msr.h: -------------------------------------------------------------------------------- 1 | #ifndef UHYVE_MSR_H 2 | #define UHYVE_MSR_H 3 | 4 | /* Starting from Linux 4.12, /msr-index.h is not anymore exported to userspace, 5 | * so let's put the defines needed for uhyve here */ 6 | 7 | 8 | #define _EFER_LME 8 /* Long mode enable */ 9 | #define EFER_LME (1<<_EFER_LME) 10 | #define EFER_LMA (1<< 10) 11 | 12 | #define MSR_IA32_APICBASE 0x0000001b 13 | #define MSR_IA32_MISC_ENABLE 0x000001a0 14 | 15 | #define MSR_IA32_SYSENTER_CS 0x00000174 16 | #define MSR_IA32_SYSENTER_ESP 0x00000175 17 | #define MSR_IA32_SYSENTER_EIP 0x00000176 18 | 19 | #define MSR_IA32_CR_PAT 0x00000277 20 | 21 | #define MSR_IA32_TSC 0x00000010 22 | 23 | #define MSR_EFER 0xc0000080 /* extended feature register */ 24 | #define MSR_STAR 0xc0000081 /* legacy mode SYSCALL target */ 25 | #define MSR_LSTAR 0xc0000082 /* long mode SYSCALL target */ 26 | #define MSR_CSTAR 0xc0000083 /* compat mode SYSCALL target */ 27 | #define MSR_SYSCALL_MASK 0xc0000084 /* EFLAGS mask for syscall */ 28 | #define MSR_FS_BASE 0xc0000100 /* 64bit FS base */ 29 | #define MSR_GS_BASE 0xc0000101 /* 64bit GS base */ 30 | #define MSR_KERNEL_GS_BASE 0xc0000102 /* SwapGS GS shadow */ 31 | #define MSR_TSC_AUX 0xc0000103 /* Auxiliary TSC */ 32 | 33 | 34 | #endif /* UHYVE_MSR_H */ 35 | -------------------------------------------------------------------------------- /tools/uhyve-net.h: -------------------------------------------------------------------------------- 1 | #ifndef __UHYVE_NET_H__ 2 | #define __UHYVE_NET_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | /* network interface */ 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | extern int netfd; 25 | 26 | // UHYVE_PORT_NETINFO 27 | typedef struct { 28 | /* OUT */ 29 | char mac_str[18]; 30 | } __attribute__((packed)) uhyve_netinfo_t; 31 | 32 | // UHYVE_PORT_NETWRITE 33 | typedef struct { 34 | /* IN */ 35 | const void* data; 36 | size_t len; 37 | /* OUT */ 38 | int ret; 39 | } __attribute__((packed)) uhyve_netwrite_t; 40 | 41 | // UHYVE_PORT_NETREAD 42 | typedef struct { 43 | /* IN */ 44 | void* data; 45 | /* IN / OUT */ 46 | size_t len; 47 | /* OUT */ 48 | int ret; 49 | } __attribute__((packed)) uhyve_netread_t; 50 | 51 | // UHYVE_PORT_NETSTAT 52 | typedef struct { 53 | /* IN */ 54 | int status; 55 | } __attribute__((packed)) uhyve_netstat_t; 56 | 57 | int uhyve_net_init(const char *hermit_netif); 58 | char* uhyve_get_mac(void); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /tools/uhyve-profiler.h: -------------------------------------------------------------------------------- 1 | #ifndef UHYVE_PROFILER_H 2 | #define UHYVE_RPOFILER_H 3 | 4 | int uhyve_profiler_init(int sample_freq); 5 | int uhyve_profiler_exit(void); 6 | 7 | #endif /* UHYVE_PROFILER_H */ 8 | -------------------------------------------------------------------------------- /tools/uhyve-seccomp.h: -------------------------------------------------------------------------------- 1 | #ifndef UHYVE_SECCOMP_H 2 | #define UHYVE_SECCOMP_H 3 | 4 | int uhyve_seccomp_init(int vm_fd); 5 | int uhyve_seccomp_load(void); 6 | int uhyve_seccomp_add_vcpu_fd(int vcpu_fd); 7 | 8 | #endif /* UHYVE_SECCOMP_H */ 9 | -------------------------------------------------------------------------------- /usr/benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | include(../../cmake/HermitCore-Application.cmake) 3 | 4 | project(hermit_benchmarks C) 5 | 6 | add_executable(basic basic.c) 7 | target_link_libraries(basic pthread) 8 | 9 | add_executable(hg hg.c hist.c rdtsc.c run.c init.c opt.c report.c setup.c) 10 | 11 | if(NOT ${NO_NET}) 12 | add_executable(netio netio.c) 13 | endif(NOT ${NO_NET}) 14 | 15 | if(NOT ${NO_IRCCE}) 16 | add_executable(RCCE_pingpong RCCE_pingpong.c) 17 | target_link_libraries(RCCE_pingpong ircce) 18 | endif(NOT ${NO_IRCCE}) 19 | 20 | add_executable(stream stream.c) 21 | target_compile_options(stream PRIVATE -fopenmp) 22 | target_link_libraries(stream -fopenmp) 23 | 24 | add_subdirectory (ua.b) 25 | add_subdirectory (cg.b) 26 | add_subdirectory (ep.b) 27 | add_subdirectory (bt.b) 28 | add_subdirectory (is.b) 29 | add_subdirectory (mg.b) 30 | add_subdirectory (sp.b) 31 | 32 | # deployment 33 | install_local_targets(extra/benchmarks) 34 | -------------------------------------------------------------------------------- /usr/benchmarks/bt.b/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB srcs *.c) 2 | add_executable(bt.b ${srcs}) 3 | 4 | target_compile_options(bt.b PRIVATE -O3 -mcmodel=medium) 5 | target_link_libraries(bt.b -lm) 6 | 7 | install_local_targets(extra/benchmarks/npb) 8 | -------------------------------------------------------------------------------- /usr/benchmarks/bt.b/c_timers.c: -------------------------------------------------------------------------------- 1 | #include "wtime.h" 2 | #include 3 | 4 | /* Prototype */ 5 | void wtime( double * ); 6 | 7 | 8 | /*****************************************************************/ 9 | /****** E L A P S E D _ T I M E ******/ 10 | /*****************************************************************/ 11 | static double elapsed_time( void ) 12 | { 13 | double t; 14 | 15 | wtime( &t ); 16 | return( t ); 17 | } 18 | 19 | 20 | static double start[64], elapsed[64]; 21 | 22 | /*****************************************************************/ 23 | /****** T I M E R _ C L E A R ******/ 24 | /*****************************************************************/ 25 | void timer_clear( int n ) 26 | { 27 | elapsed[n] = 0.0; 28 | } 29 | 30 | 31 | /*****************************************************************/ 32 | /****** T I M E R _ S T A R T ******/ 33 | /*****************************************************************/ 34 | void timer_start( int n ) 35 | { 36 | start[n] = elapsed_time(); 37 | } 38 | 39 | 40 | /*****************************************************************/ 41 | /****** T I M E R _ S T O P ******/ 42 | /*****************************************************************/ 43 | void timer_stop( int n ) 44 | { 45 | double t, now; 46 | 47 | now = elapsed_time(); 48 | t = now - start[n]; 49 | elapsed[n] += t; 50 | 51 | } 52 | 53 | 54 | /*****************************************************************/ 55 | /****** T I M E R _ R E A D ******/ 56 | /*****************************************************************/ 57 | double timer_read( int n ) 58 | { 59 | return( elapsed[n] ); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /usr/benchmarks/bt.b/npbparams.h: -------------------------------------------------------------------------------- 1 | /* CLASS = B */ 2 | /* 3 | This file is generated automatically by the setparams utility. 4 | It sets the number of processors and the class of the NPB 5 | in this directory. Do not modify it by hand. 6 | */ 7 | #define PROBLEM_SIZE 102 8 | #define NITER_DEFAULT 200 9 | #define DT_DEFAULT 0.0003 10 | 11 | #define CONVERTDOUBLE false 12 | #define COMPILETIME "17 Oct 2017" 13 | #define NPBVERSION "3.3.1" 14 | #define CS1 "../../musl/prefix/bin/musl-gcc" 15 | #define CS2 "$(CC)" 16 | #define CS3 "-static -L../../musl/prefix/lib -lm" 17 | #define CS4 "-I../common -I../../musl/prefix/include" 18 | #define CS5 "-g -Wall -O3 -mcmodel=medium" 19 | #define CS6 "-O3 -mcmodel=medium" 20 | #define CS7 "randdp" 21 | -------------------------------------------------------------------------------- /usr/benchmarks/bt.b/print_results.h: -------------------------------------------------------------------------------- 1 | #ifndef __PRINT_RESULTS_H__ 2 | #define __PRINT_RESULTS_H__ 3 | 4 | void print_results(char *name, char class, int n1, int n2, int n3, int niter, 5 | double t, double mops, char *optype, logical verified, char *npbversion, 6 | char *compiletime, char *cs1, char *cs2, char *cs3, char *cs4, char *cs5, 7 | char *cs6, char *cs7); 8 | 9 | #endif //__PRINT_RESULTS_H__ 10 | -------------------------------------------------------------------------------- /usr/benchmarks/bt.b/timers.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMERS_H__ 2 | #define __TIMERS_H__ 3 | 4 | void timer_clear( int n ); 5 | void timer_start( int n ); 6 | void timer_stop( int n ); 7 | double timer_read( int n ); 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /usr/benchmarks/bt.b/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | typedef enum { false, true } logical; 5 | typedef struct { 6 | double real; 7 | double imag; 8 | } dcomplex; 9 | 10 | 11 | #define min(x,y) ((x) < (y) ? (x) : (y)) 12 | #define max(x,y) ((x) > (y) ? (x) : (y)) 13 | 14 | #endif //__TYPE_H__ 15 | -------------------------------------------------------------------------------- /usr/benchmarks/bt.b/wtime.c: -------------------------------------------------------------------------------- 1 | #include "wtime.h" 2 | #include 3 | #ifndef DOS 4 | #include 5 | #endif 6 | 7 | void wtime(double *t) 8 | { 9 | static int sec = -1; 10 | struct timeval tv; 11 | gettimeofday(&tv, (void *)0); 12 | if (sec < 0) sec = tv.tv_sec; 13 | *t = (tv.tv_sec - sec) + 1.0e-6*tv.tv_usec; 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /usr/benchmarks/bt.b/wtime.h: -------------------------------------------------------------------------------- 1 | /* C/Fortran interface is different on different machines. 2 | * You may need to tweak this. 3 | */ 4 | 5 | 6 | #if defined(IBM) 7 | #define wtime wtime 8 | #elif defined(CRAY) 9 | #define wtime WTIME 10 | #else 11 | #define wtime wtime_ 12 | #endif 13 | -------------------------------------------------------------------------------- /usr/benchmarks/cg.b/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB srcs *.c) 2 | add_executable(cg.b ${srcs}) 3 | 4 | target_compile_options(cg.b PRIVATE -O3 -mcmodel=medium) 5 | target_link_libraries(cg.b -lm) 6 | 7 | install_local_targets(extra/benchmarks/npb) 8 | 9 | -------------------------------------------------------------------------------- /usr/benchmarks/cg.b/c_timers.c: -------------------------------------------------------------------------------- 1 | #include "wtime.h" 2 | #include 3 | 4 | /* Prototype */ 5 | void wtime( double * ); 6 | 7 | 8 | /*****************************************************************/ 9 | /****** E L A P S E D _ T I M E ******/ 10 | /*****************************************************************/ 11 | static double elapsed_time( void ) 12 | { 13 | double t; 14 | 15 | wtime( &t ); 16 | return( t ); 17 | } 18 | 19 | 20 | static double start[64], elapsed[64]; 21 | 22 | /*****************************************************************/ 23 | /****** T I M E R _ C L E A R ******/ 24 | /*****************************************************************/ 25 | void timer_clear( int n ) 26 | { 27 | elapsed[n] = 0.0; 28 | } 29 | 30 | 31 | /*****************************************************************/ 32 | /****** T I M E R _ S T A R T ******/ 33 | /*****************************************************************/ 34 | void timer_start( int n ) 35 | { 36 | start[n] = elapsed_time(); 37 | } 38 | 39 | 40 | /*****************************************************************/ 41 | /****** T I M E R _ S T O P ******/ 42 | /*****************************************************************/ 43 | void timer_stop( int n ) 44 | { 45 | double t, now; 46 | 47 | now = elapsed_time(); 48 | t = now - start[n]; 49 | elapsed[n] += t; 50 | 51 | } 52 | 53 | 54 | /*****************************************************************/ 55 | /****** T I M E R _ R E A D ******/ 56 | /*****************************************************************/ 57 | double timer_read( int n ) 58 | { 59 | return( elapsed[n] ); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /usr/benchmarks/cg.b/npbparams.h: -------------------------------------------------------------------------------- 1 | /* CLASS = B */ 2 | /* 3 | This file is generated automatically by the setparams utility. 4 | It sets the number of processors and the class of the NPB 5 | in this directory. Do not modify it by hand. 6 | */ 7 | #define NA 75000 8 | #define NONZER 13 9 | #define NITER 75 10 | #define SHIFT 60.0 11 | #define RCOND 1.0e-1 12 | 13 | #define CONVERTDOUBLE false 14 | #define COMPILETIME "17 Oct 2017" 15 | #define NPBVERSION "3.3.1" 16 | #define CS1 "../../musl/prefix/bin/musl-gcc" 17 | #define CS2 "$(CC)" 18 | #define CS3 "-static -L../../musl/prefix/lib -lm" 19 | #define CS4 "-I../common -I../../musl/prefix/include" 20 | #define CS5 "-g -Wall -O3 -mcmodel=medium" 21 | #define CS6 "-O3 -mcmodel=medium" 22 | #define CS7 "randdp" 23 | -------------------------------------------------------------------------------- /usr/benchmarks/cg.b/print_results.h: -------------------------------------------------------------------------------- 1 | #ifndef __PRINT_RESULTS_H__ 2 | #define __PRINT_RESULTS_H__ 3 | 4 | void print_results(char *name, char class, int n1, int n2, int n3, int niter, 5 | double t, double mops, char *optype, logical verified, char *npbversion, 6 | char *compiletime, char *cs1, char *cs2, char *cs3, char *cs4, char *cs5, 7 | char *cs6, char *cs7); 8 | 9 | #endif //__PRINT_RESULTS_H__ 10 | -------------------------------------------------------------------------------- /usr/benchmarks/cg.b/randdp.h: -------------------------------------------------------------------------------- 1 | #ifndef __RANDDP_H__ 2 | #define __RANDDP_H__ 3 | 4 | double randlc( double *x, double a ); 5 | void vranlc( int n, double *x, double a, double y[] ); 6 | 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /usr/benchmarks/cg.b/timers.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMERS_H__ 2 | #define __TIMERS_H__ 3 | 4 | void timer_clear( int n ); 5 | void timer_start( int n ); 6 | void timer_stop( int n ); 7 | double timer_read( int n ); 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /usr/benchmarks/cg.b/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | typedef enum { false, true } logical; 5 | typedef struct { 6 | double real; 7 | double imag; 8 | } dcomplex; 9 | 10 | 11 | #define min(x,y) ((x) < (y) ? (x) : (y)) 12 | #define max(x,y) ((x) > (y) ? (x) : (y)) 13 | 14 | #endif //__TYPE_H__ 15 | -------------------------------------------------------------------------------- /usr/benchmarks/cg.b/wtime.c: -------------------------------------------------------------------------------- 1 | #include "wtime.h" 2 | #include 3 | #ifndef DOS 4 | #include 5 | #endif 6 | 7 | void wtime(double *t) 8 | { 9 | static int sec = -1; 10 | struct timeval tv; 11 | gettimeofday(&tv, (void *)0); 12 | if (sec < 0) sec = tv.tv_sec; 13 | *t = (tv.tv_sec - sec) + 1.0e-6*tv.tv_usec; 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /usr/benchmarks/cg.b/wtime.h: -------------------------------------------------------------------------------- 1 | /* C/Fortran interface is different on different machines. 2 | * You may need to tweak this. 3 | */ 4 | 5 | 6 | #if defined(IBM) 7 | #define wtime wtime 8 | #elif defined(CRAY) 9 | #define wtime WTIME 10 | #else 11 | #define wtime wtime_ 12 | #endif 13 | -------------------------------------------------------------------------------- /usr/benchmarks/ep.b/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB srcs *.c) 2 | add_executable(ep.b ${srcs}) 3 | 4 | target_compile_options(ep.b PRIVATE -O3 -mcmodel=medium) 5 | target_link_libraries(ep.b -lm) 6 | 7 | install_local_targets(extra/benchmarks/npb) 8 | 9 | -------------------------------------------------------------------------------- /usr/benchmarks/ep.b/c_timers.c: -------------------------------------------------------------------------------- 1 | #include "wtime.h" 2 | #include 3 | 4 | /* Prototype */ 5 | void wtime( double * ); 6 | 7 | 8 | /*****************************************************************/ 9 | /****** E L A P S E D _ T I M E ******/ 10 | /*****************************************************************/ 11 | static double elapsed_time( void ) 12 | { 13 | double t; 14 | 15 | wtime( &t ); 16 | return( t ); 17 | } 18 | 19 | 20 | static double start[64], elapsed[64]; 21 | 22 | /*****************************************************************/ 23 | /****** T I M E R _ C L E A R ******/ 24 | /*****************************************************************/ 25 | void timer_clear( int n ) 26 | { 27 | elapsed[n] = 0.0; 28 | } 29 | 30 | 31 | /*****************************************************************/ 32 | /****** T I M E R _ S T A R T ******/ 33 | /*****************************************************************/ 34 | void timer_start( int n ) 35 | { 36 | start[n] = elapsed_time(); 37 | } 38 | 39 | 40 | /*****************************************************************/ 41 | /****** T I M E R _ S T O P ******/ 42 | /*****************************************************************/ 43 | void timer_stop( int n ) 44 | { 45 | double t, now; 46 | 47 | now = elapsed_time(); 48 | t = now - start[n]; 49 | elapsed[n] += t; 50 | 51 | } 52 | 53 | 54 | /*****************************************************************/ 55 | /****** T I M E R _ R E A D ******/ 56 | /*****************************************************************/ 57 | double timer_read( int n ) 58 | { 59 | return( elapsed[n] ); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /usr/benchmarks/ep.b/npbparams.h: -------------------------------------------------------------------------------- 1 | /* CLASS = B */ 2 | /* 3 | This file is generated automatically by the setparams utility. 4 | It sets the number of processors and the class of the NPB 5 | in this directory. Do not modify it by hand. 6 | */ 7 | #define CLASS 'B' 8 | #define M 30 9 | 10 | #define CONVERTDOUBLE false 11 | #define COMPILETIME "17 Oct 2017" 12 | #define NPBVERSION "3.3.1" 13 | #define CS1 "../../musl/prefix/bin/musl-gcc" 14 | #define CS2 "$(CC)" 15 | #define CS3 "-static -L../../musl/prefix/lib -lm" 16 | #define CS4 "-I../common -I../../musl/prefix/include" 17 | #define CS5 "-g -Wall -O3 -mcmodel=medium" 18 | #define CS6 "-O3 -mcmodel=medium" 19 | #define CS7 "randdp" 20 | -------------------------------------------------------------------------------- /usr/benchmarks/ep.b/print_results.h: -------------------------------------------------------------------------------- 1 | #ifndef __PRINT_RESULTS_H__ 2 | #define __PRINT_RESULTS_H__ 3 | 4 | void print_results(char *name, char class, int n1, int n2, int n3, int niter, 5 | double t, double mops, char *optype, logical verified, char *npbversion, 6 | char *compiletime, char *cs1, char *cs2, char *cs3, char *cs4, char *cs5, 7 | char *cs6, char *cs7); 8 | 9 | #endif //__PRINT_RESULTS_H__ 10 | -------------------------------------------------------------------------------- /usr/benchmarks/ep.b/randdp.h: -------------------------------------------------------------------------------- 1 | #ifndef __RANDDP_H__ 2 | #define __RANDDP_H__ 3 | 4 | double randlc( double *x, double a ); 5 | void vranlc( int n, double *x, double a, double y[] ); 6 | 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /usr/benchmarks/ep.b/res.txt: -------------------------------------------------------------------------------- 1 | KVM 2 | Time in seconds = 79.25 3 | Time in seconds = 82.98 4 | Time in seconds = 82.82 5 | UHYVE 6 | Time in seconds = 79.25 7 | Time in seconds = 77.23 8 | Time in seconds = 77.33 9 | -------------------------------------------------------------------------------- /usr/benchmarks/ep.b/timers.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMERS_H__ 2 | #define __TIMERS_H__ 3 | 4 | void timer_clear( int n ); 5 | void timer_start( int n ); 6 | void timer_stop( int n ); 7 | double timer_read( int n ); 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /usr/benchmarks/ep.b/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | typedef enum { false, true } logical; 5 | typedef struct { 6 | double real; 7 | double imag; 8 | } dcomplex; 9 | 10 | 11 | #define min(x,y) ((x) < (y) ? (x) : (y)) 12 | #define max(x,y) ((x) > (y) ? (x) : (y)) 13 | 14 | #endif //__TYPE_H__ 15 | -------------------------------------------------------------------------------- /usr/benchmarks/ep.b/wtime.c: -------------------------------------------------------------------------------- 1 | #include "wtime.h" 2 | #include 3 | #ifndef DOS 4 | #include 5 | #endif 6 | 7 | void wtime(double *t) 8 | { 9 | static int sec = -1; 10 | struct timeval tv; 11 | gettimeofday(&tv, (void *)0); 12 | if (sec < 0) sec = tv.tv_sec; 13 | *t = (tv.tv_sec - sec) + 1.0e-6*tv.tv_usec; 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /usr/benchmarks/ep.b/wtime.h: -------------------------------------------------------------------------------- 1 | /* C/Fortran interface is different on different machines. 2 | * You may need to tweak this. 3 | */ 4 | 5 | 6 | #if defined(IBM) 7 | #define wtime wtime 8 | #elif defined(CRAY) 9 | #define wtime WTIME 10 | #else 11 | #define wtime wtime_ 12 | #endif 13 | -------------------------------------------------------------------------------- /usr/benchmarks/hg.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: main.c 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 14:59:20 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #include "opt.h" 20 | #include "init.h" 21 | #include "setup.h" 22 | #include "run.h" 23 | #include "report.h" 24 | 25 | #include 26 | #include 27 | 28 | struct opt opts = {0}; 29 | struct result results = {0}; 30 | 31 | int main(int argc, char *argv[]) 32 | { 33 | printf("hourglass\n"); 34 | 35 | opt(argc, argv, &opts); 36 | init(&opts); 37 | 38 | report_params(&opts); 39 | 40 | setup(&opts); 41 | run(&opts, &results); 42 | setdown(&opts); 43 | 44 | report(&opts, &results); 45 | 46 | run_free(&opts, &results); 47 | 48 | deinit(&opts); 49 | 50 | return EXIT_SUCCESS; 51 | } 52 | -------------------------------------------------------------------------------- /usr/benchmarks/hist.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: hist.c 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 26.07.2014 20:02:34 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #include "hist.h" 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | static const struct opt *opts; 27 | static uint32_t *hists; 28 | 29 | uint32_t *hist_alloc(const struct opt *opt) 30 | { 31 | opts = opt; 32 | hists = calloc(opt->hist_cnt, sizeof(uint32_t)); 33 | hist_reset(); 34 | return hists; 35 | } 36 | 37 | int hist_reset(void) 38 | { 39 | unsigned i; 40 | for (i=0; ihist_cnt; i++) { 41 | hists[i] = 0; 42 | } 43 | return 0; 44 | } 45 | 46 | void hist_add(uint64_t t) 47 | { 48 | t /= opts->hist_width; 49 | if (t > opts->hist_cnt-1) t = opts->hist_cnt-1; 50 | hists[t]++; 51 | } 52 | 53 | int hist_print(void) 54 | { 55 | unsigned i; 56 | unsigned max=0; 57 | const size_t bar_width = 30; 58 | char bar[bar_width+1]; 59 | 60 | for (i=0; ihist_cnt; i++) { 61 | if (hists[i] > max) max = hists[i]; 62 | } 63 | max = (unsigned)ceil(log10((double)max)); 64 | if (max == 0) max = 1; 65 | memset(bar, '*', bar_width); 66 | bar[bar_width] = 0; 67 | 68 | printf("Histogram (%u bins with %u ticks each)\n", opts->hist_cnt, opts->hist_width); 69 | for (i=0; ihist_cnt; i++) { 70 | printf(" %5u : %5u..%5u : %-10u %s\n", i, 71 | (unsigned)(i*opts->hist_width), 72 | (unsigned)((i+1)*opts->hist_width-1), 73 | (unsigned)(hists[i]), 74 | (char*)bar+(unsigned)(bar_width-((log10(hists[i]+1.)*bar_width)/max))); 75 | } 76 | return 0; 77 | } 78 | 79 | -------------------------------------------------------------------------------- /usr/benchmarks/hist.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: hist.h 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 26.07.2014 20:02:48 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #ifndef __HIST_H__ 20 | #define __HIST_H__ 21 | 22 | #include "opt.h" 23 | 24 | #include 25 | 26 | uint32_t *hist_alloc(const struct opt *opt); 27 | int hist_reset(void); 28 | void hist_add(uint64_t t); 29 | int hist_print(void); 30 | 31 | #endif // __HIST_H__ 32 | -------------------------------------------------------------------------------- /usr/benchmarks/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: init.c 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:06:05 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #include "init.h" 20 | #include "rdtsc.h" 21 | 22 | 23 | int init(struct opt *opt) 24 | { 25 | /* 26 | * initialize (if required) 27 | * e.g. read number of processors available or cache parameters 28 | */ 29 | 30 | opt->tps = rdtsc_ticks_per_sec(); // does not work reliably... 31 | //opt->tps = 2530000000; 32 | 33 | 34 | return 0; 35 | } 36 | 37 | 38 | 39 | int deinit(struct opt *opt) 40 | { 41 | /* 42 | * de-initialize (if required) 43 | * e.g. free allocated resources 44 | */ 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /usr/benchmarks/init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: init.h 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:05:13 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #ifndef __INIT_H__ 20 | #define __INIT_H__ 21 | 22 | #include "opt.h" 23 | 24 | int init(struct opt *opt); 25 | int deinit(struct opt *opt); 26 | 27 | #endif // __INIT_H__ 28 | -------------------------------------------------------------------------------- /usr/benchmarks/is.b/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB srcs *.c) 2 | add_executable(is.b ${srcs}) 3 | 4 | target_compile_options(is.b PRIVATE -O3 -mcmodel=medium) 5 | target_link_libraries(is.b -lm) 6 | 7 | install_local_targets(extra/benchmarks/npb) 8 | 9 | -------------------------------------------------------------------------------- /usr/benchmarks/is.b/c_timers.c: -------------------------------------------------------------------------------- 1 | #include "wtime.h" 2 | #include 3 | 4 | /* Prototype */ 5 | void wtime( double * ); 6 | 7 | 8 | /*****************************************************************/ 9 | /****** E L A P S E D _ T I M E ******/ 10 | /*****************************************************************/ 11 | static double elapsed_time( void ) 12 | { 13 | double t; 14 | 15 | wtime( &t ); 16 | return( t ); 17 | } 18 | 19 | 20 | static double start[64], elapsed[64]; 21 | 22 | /*****************************************************************/ 23 | /****** T I M E R _ C L E A R ******/ 24 | /*****************************************************************/ 25 | void timer_clear( int n ) 26 | { 27 | elapsed[n] = 0.0; 28 | } 29 | 30 | 31 | /*****************************************************************/ 32 | /****** T I M E R _ S T A R T ******/ 33 | /*****************************************************************/ 34 | void timer_start( int n ) 35 | { 36 | start[n] = elapsed_time(); 37 | } 38 | 39 | 40 | /*****************************************************************/ 41 | /****** T I M E R _ S T O P ******/ 42 | /*****************************************************************/ 43 | void timer_stop( int n ) 44 | { 45 | double t, now; 46 | 47 | now = elapsed_time(); 48 | t = now - start[n]; 49 | elapsed[n] += t; 50 | 51 | } 52 | 53 | 54 | /*****************************************************************/ 55 | /****** T I M E R _ R E A D ******/ 56 | /*****************************************************************/ 57 | double timer_read( int n ) 58 | { 59 | return( elapsed[n] ); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /usr/benchmarks/is.b/npbparams.h: -------------------------------------------------------------------------------- 1 | #define CLASS 'B' 2 | /* 3 | This file is generated automatically by the setparams utility. 4 | It sets the number of processors and the class of the NPB 5 | in this directory. Do not modify it by hand. */ 6 | 7 | #define COMPILETIME "11 Oct 2017" 8 | #define NPBVERSION "3.3.1" 9 | #define CC "../../musl/prefix/bin/musl-gcc" 10 | #define CFLAGS "-g -Wall -O3 -mcmodel=medium" 11 | #define CLINK "$(CC)" 12 | #define CLINKFLAGS "-O3 -mcmodel=medium" 13 | #define C_LIB "-static -L../../musl/prefix/lib -lm" 14 | #define C_INC "-I../common -I../../musl/prefix/include" 15 | -------------------------------------------------------------------------------- /usr/benchmarks/is.b/res.txt: -------------------------------------------------------------------------------- 1 | KVM 2 | Time in seconds = 1.16 3 | Time in seconds = 1.32 4 | Time in seconds = 1.28 5 | 6 | UHYVE 7 | Time in seconds = 1.25 8 | Time in seconds = 1.35 9 | Time in seconds = 1.29 10 | -------------------------------------------------------------------------------- /usr/benchmarks/is.b/wtime.c: -------------------------------------------------------------------------------- 1 | #include "wtime.h" 2 | #include 3 | #ifndef DOS 4 | #include 5 | #endif 6 | 7 | void wtime(double *t) 8 | { 9 | static int sec = -1; 10 | struct timeval tv; 11 | gettimeofday(&tv, (void *)0); 12 | if (sec < 0) sec = tv.tv_sec; 13 | *t = (tv.tv_sec - sec) + 1.0e-6*tv.tv_usec; 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /usr/benchmarks/is.b/wtime.h: -------------------------------------------------------------------------------- 1 | /* C/Fortran interface is different on different machines. 2 | * You may need to tweak this. 3 | */ 4 | 5 | 6 | #if defined(IBM) 7 | #define wtime wtime 8 | #elif defined(CRAY) 9 | #define wtime WTIME 10 | #else 11 | #define wtime wtime_ 12 | #endif 13 | -------------------------------------------------------------------------------- /usr/benchmarks/mg.b/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB srcs *.c) 2 | add_executable(mg.b ${srcs}) 3 | 4 | target_compile_options(mg.b PRIVATE -O3 -mcmodel=medium) 5 | target_link_libraries(mg.b -lm) 6 | 7 | install_local_targets(extra/benchmarks/npb) 8 | 9 | -------------------------------------------------------------------------------- /usr/benchmarks/mg.b/c_timers.c: -------------------------------------------------------------------------------- 1 | #include "wtime.h" 2 | #include 3 | 4 | /* Prototype */ 5 | void wtime( double * ); 6 | 7 | 8 | /*****************************************************************/ 9 | /****** E L A P S E D _ T I M E ******/ 10 | /*****************************************************************/ 11 | static double elapsed_time( void ) 12 | { 13 | double t; 14 | 15 | wtime( &t ); 16 | return( t ); 17 | } 18 | 19 | 20 | static double start[64], elapsed[64]; 21 | 22 | /*****************************************************************/ 23 | /****** T I M E R _ C L E A R ******/ 24 | /*****************************************************************/ 25 | void timer_clear( int n ) 26 | { 27 | elapsed[n] = 0.0; 28 | } 29 | 30 | 31 | /*****************************************************************/ 32 | /****** T I M E R _ S T A R T ******/ 33 | /*****************************************************************/ 34 | void timer_start( int n ) 35 | { 36 | start[n] = elapsed_time(); 37 | } 38 | 39 | 40 | /*****************************************************************/ 41 | /****** T I M E R _ S T O P ******/ 42 | /*****************************************************************/ 43 | void timer_stop( int n ) 44 | { 45 | double t, now; 46 | 47 | now = elapsed_time(); 48 | t = now - start[n]; 49 | elapsed[n] += t; 50 | 51 | } 52 | 53 | 54 | /*****************************************************************/ 55 | /****** T I M E R _ R E A D ******/ 56 | /*****************************************************************/ 57 | double timer_read( int n ) 58 | { 59 | return( elapsed[n] ); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /usr/benchmarks/mg.b/npbparams.h: -------------------------------------------------------------------------------- 1 | /* CLASS = B */ 2 | /* 3 | This file is generated automatically by the setparams utility. 4 | It sets the number of processors and the class of the NPB 5 | in this directory. Do not modify it by hand. 6 | */ 7 | #define NX_DEFAULT 256 8 | #define NY_DEFAULT 256 9 | #define NZ_DEFAULT 256 10 | #define NIT_DEFAULT 20 11 | #define LM 8 12 | #define LT_DEFAULT 8 13 | #define DEBUG_DEFAULT 0 14 | #define NDIM1 8 15 | #define NDIM2 8 16 | #define NDIM3 8 17 | #define ONE 1 18 | 19 | #define CONVERTDOUBLE false 20 | #define COMPILETIME "17 Oct 2017" 21 | #define NPBVERSION "3.3.1" 22 | #define CS1 "../../musl/prefix/bin/musl-gcc" 23 | #define CS2 "$(CC)" 24 | #define CS3 "-static -L../../musl/prefix/lib -lm" 25 | #define CS4 "-I../common -I../../musl/prefix/include" 26 | #define CS5 "-g -Wall -O3 -mcmodel=medium" 27 | #define CS6 "-O3 -mcmodel=medium" 28 | #define CS7 "randdp" 29 | -------------------------------------------------------------------------------- /usr/benchmarks/mg.b/print_results.h: -------------------------------------------------------------------------------- 1 | #ifndef __PRINT_RESULTS_H__ 2 | #define __PRINT_RESULTS_H__ 3 | 4 | void print_results(char *name, char class, int n1, int n2, int n3, int niter, 5 | double t, double mops, char *optype, logical verified, char *npbversion, 6 | char *compiletime, char *cs1, char *cs2, char *cs3, char *cs4, char *cs5, 7 | char *cs6, char *cs7); 8 | 9 | #endif //__PRINT_RESULTS_H__ 10 | -------------------------------------------------------------------------------- /usr/benchmarks/mg.b/randdp.h: -------------------------------------------------------------------------------- 1 | #ifndef __RANDDP_H__ 2 | #define __RANDDP_H__ 3 | 4 | double randlc( double *x, double a ); 5 | void vranlc( int n, double *x, double a, double y[] ); 6 | 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /usr/benchmarks/mg.b/res.txt: -------------------------------------------------------------------------------- 1 | KVM 2 | Time in seconds = 3.27 3 | Time in seconds = 3.27 4 | Time in seconds = 3.11 5 | UHYVE 6 | Time in seconds = 3.26 7 | Time in seconds = 3.14 8 | Time in seconds = 3.18 9 | -------------------------------------------------------------------------------- /usr/benchmarks/mg.b/timers.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMERS_H__ 2 | #define __TIMERS_H__ 3 | 4 | void timer_clear( int n ); 5 | void timer_start( int n ); 6 | void timer_stop( int n ); 7 | double timer_read( int n ); 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /usr/benchmarks/mg.b/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | typedef enum { false, true } logical; 5 | typedef struct { 6 | double real; 7 | double imag; 8 | } dcomplex; 9 | 10 | 11 | #define min(x,y) ((x) < (y) ? (x) : (y)) 12 | #define max(x,y) ((x) > (y) ? (x) : (y)) 13 | 14 | #endif //__TYPE_H__ 15 | -------------------------------------------------------------------------------- /usr/benchmarks/mg.b/wtime.c: -------------------------------------------------------------------------------- 1 | #include "wtime.h" 2 | #include 3 | #ifndef DOS 4 | #include 5 | #endif 6 | 7 | void wtime(double *t) 8 | { 9 | static int sec = -1; 10 | struct timeval tv; 11 | gettimeofday(&tv, (void *)0); 12 | if (sec < 0) sec = tv.tv_sec; 13 | *t = (tv.tv_sec - sec) + 1.0e-6*tv.tv_usec; 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /usr/benchmarks/mg.b/wtime.h: -------------------------------------------------------------------------------- 1 | /* C/Fortran interface is different on different machines. 2 | * You may need to tweak this. 3 | */ 4 | 5 | 6 | #if defined(IBM) 7 | #define wtime wtime 8 | #elif defined(CRAY) 9 | #define wtime WTIME 10 | #else 11 | #define wtime wtime_ 12 | #endif 13 | -------------------------------------------------------------------------------- /usr/benchmarks/opt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: opt.h 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:02:15 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #ifndef __OPT_H__ 20 | #define __OPT_H__ 21 | 22 | #include 23 | 24 | struct opt { 25 | unsigned secs; 26 | enum {stat, hist, list} mode; 27 | uint64_t tps; 28 | uint64_t threshold; 29 | 30 | unsigned hist_cnt; 31 | unsigned hist_width; 32 | 33 | unsigned list_cnt; 34 | }; 35 | 36 | int opt(int argc, char *argv[], struct opt *opt); 37 | 38 | #endif // __OPT_H__ 39 | -------------------------------------------------------------------------------- /usr/benchmarks/report.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: report.h 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:11:07 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #ifndef __REPORT_H__ 20 | #define __REPORT_H__ 21 | 22 | #include "run.h" 23 | #include "opt.h" 24 | 25 | int report_params(const struct opt *opt); 26 | int report(const struct opt *opt, const struct result *result); 27 | 28 | #endif // __REPORT_H__ 29 | -------------------------------------------------------------------------------- /usr/benchmarks/run.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: run.h 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:08:43 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #ifndef __RUN_H__ 20 | #define __RUN_H__ 21 | 22 | #include "opt.h" 23 | 24 | #include 25 | struct res_list { 26 | uint64_t time; 27 | uint64_t gap; 28 | }; 29 | 30 | struct result { 31 | uint64_t dummy; 32 | 33 | uint64_t min; 34 | uint64_t max; 35 | uint64_t sum; 36 | uint64_t cnt; 37 | uint64_t t_min; 38 | uint64_t t_max; 39 | 40 | uint32_t *hist; 41 | struct res_list *list; 42 | 43 | }; 44 | 45 | int run(const struct opt *opt, struct result *result); 46 | int run_free(const struct opt *opt, struct result *result); 47 | 48 | 49 | #endif // __RUN_H__ 50 | 51 | -------------------------------------------------------------------------------- /usr/benchmarks/setup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: setup.c 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:07:43 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #include "setup.h" 20 | 21 | 22 | int setup(struct opt *opt) 23 | { 24 | /* 25 | * set up run-time environment for benchmark 26 | * depending on opt 27 | * e.g. create cpu-set, move IRQs, etc. 28 | */ 29 | 30 | 31 | return 0; 32 | } 33 | 34 | int setdown(struct opt *opt) 35 | { 36 | /* 37 | * undo things from setup() 38 | */ 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /usr/benchmarks/setup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ===================================================================================== 3 | * 4 | * Filename: setup.h 5 | * 6 | * Description: 7 | * 8 | * Version: 1.0 9 | * Created: 25.07.2014 15:06:59 10 | * Revision: none 11 | * Compiler: gcc 12 | * 13 | * Author: Georg Wassen (gw) (), 14 | * Company: 15 | * 16 | * ===================================================================================== 17 | */ 18 | 19 | #ifndef __SETUP_H__ 20 | #define __SETUP_H__ 21 | 22 | #include "opt.h" 23 | 24 | int setup(struct opt *opt); 25 | int setdown(struct opt *opt); 26 | 27 | #endif // __SETUP_H__ 28 | -------------------------------------------------------------------------------- /usr/benchmarks/sp.b/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB srcs *.c) 2 | add_executable(sp.b ${srcs}) 3 | 4 | target_compile_options(sp.b PRIVATE -O3 -mcmodel=medium) 5 | target_link_libraries(sp.b -lm) 6 | 7 | install_local_targets(extra/benchmarks/npb) 8 | 9 | -------------------------------------------------------------------------------- /usr/benchmarks/sp.b/c_timers.c: -------------------------------------------------------------------------------- 1 | #include "wtime.h" 2 | #include 3 | 4 | /* Prototype */ 5 | void wtime( double * ); 6 | 7 | 8 | /*****************************************************************/ 9 | /****** E L A P S E D _ T I M E ******/ 10 | /*****************************************************************/ 11 | static double elapsed_time( void ) 12 | { 13 | double t; 14 | 15 | wtime( &t ); 16 | return( t ); 17 | } 18 | 19 | 20 | static double start[64], elapsed[64]; 21 | 22 | /*****************************************************************/ 23 | /****** T I M E R _ C L E A R ******/ 24 | /*****************************************************************/ 25 | void timer_clear( int n ) 26 | { 27 | elapsed[n] = 0.0; 28 | } 29 | 30 | 31 | /*****************************************************************/ 32 | /****** T I M E R _ S T A R T ******/ 33 | /*****************************************************************/ 34 | void timer_start( int n ) 35 | { 36 | start[n] = elapsed_time(); 37 | } 38 | 39 | 40 | /*****************************************************************/ 41 | /****** T I M E R _ S T O P ******/ 42 | /*****************************************************************/ 43 | void timer_stop( int n ) 44 | { 45 | double t, now; 46 | 47 | now = elapsed_time(); 48 | t = now - start[n]; 49 | elapsed[n] += t; 50 | 51 | } 52 | 53 | 54 | /*****************************************************************/ 55 | /****** T I M E R _ R E A D ******/ 56 | /*****************************************************************/ 57 | double timer_read( int n ) 58 | { 59 | return( elapsed[n] ); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /usr/benchmarks/sp.b/npbparams.h: -------------------------------------------------------------------------------- 1 | /* CLASS = B */ 2 | /* 3 | This file is generated automatically by the setparams utility. 4 | It sets the number of processors and the class of the NPB 5 | in this directory. Do not modify it by hand. 6 | */ 7 | #define PROBLEM_SIZE 102 8 | #define NITER_DEFAULT 400 9 | #define DT_DEFAULT 0.001 10 | 11 | #define CONVERTDOUBLE false 12 | #define COMPILETIME "17 Oct 2017" 13 | #define NPBVERSION "3.3.1" 14 | #define CS1 "../../musl/prefix/bin/musl-gcc" 15 | #define CS2 "$(CC)" 16 | #define CS3 "-static -L../../musl/prefix/lib -lm" 17 | #define CS4 "-I../common -I../../musl/prefix/include" 18 | #define CS5 "-g -Wall -O3 -mcmodel=medium" 19 | #define CS6 "-O3 -mcmodel=medium" 20 | #define CS7 "randdp" 21 | -------------------------------------------------------------------------------- /usr/benchmarks/sp.b/print_results.h: -------------------------------------------------------------------------------- 1 | #ifndef __PRINT_RESULTS_H__ 2 | #define __PRINT_RESULTS_H__ 3 | 4 | void print_results(char *name, char class, int n1, int n2, int n3, int niter, 5 | double t, double mops, char *optype, logical verified, char *npbversion, 6 | char *compiletime, char *cs1, char *cs2, char *cs3, char *cs4, char *cs5, 7 | char *cs6, char *cs7); 8 | 9 | #endif //__PRINT_RESULTS_H__ 10 | -------------------------------------------------------------------------------- /usr/benchmarks/sp.b/randdp.h: -------------------------------------------------------------------------------- 1 | #ifndef __RANDDP_H__ 2 | #define __RANDDP_H__ 3 | 4 | double randlc( double *x, double a ); 5 | void vranlc( int n, double *x, double a, double y[] ); 6 | 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /usr/benchmarks/sp.b/res.txt: -------------------------------------------------------------------------------- 1 | KVM 2 | Time in seconds = 79.98 3 | Time in seconds = 82.35 4 | Time in seconds = 83.12 5 | UHYVE 6 | Time in seconds = 80.65 7 | Time in seconds = 80.70 8 | Time in seconds = 79.74 9 | -------------------------------------------------------------------------------- /usr/benchmarks/sp.b/timers.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMERS_H__ 2 | #define __TIMERS_H__ 3 | 4 | void timer_clear( int n ); 5 | void timer_start( int n ); 6 | void timer_stop( int n ); 7 | double timer_read( int n ); 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /usr/benchmarks/sp.b/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | typedef enum { false, true } logical; 5 | typedef struct { 6 | double real; 7 | double imag; 8 | } dcomplex; 9 | 10 | 11 | #define min(x,y) ((x) < (y) ? (x) : (y)) 12 | #define max(x,y) ((x) > (y) ? (x) : (y)) 13 | 14 | #endif //__TYPE_H__ 15 | -------------------------------------------------------------------------------- /usr/benchmarks/sp.b/wtime.c: -------------------------------------------------------------------------------- 1 | #include "wtime.h" 2 | #include 3 | #ifndef DOS 4 | #include 5 | #endif 6 | 7 | void wtime(double *t) 8 | { 9 | static int sec = -1; 10 | struct timeval tv; 11 | gettimeofday(&tv, (void *)0); 12 | if (sec < 0) sec = tv.tv_sec; 13 | *t = (tv.tv_sec - sec) + 1.0e-6*tv.tv_usec; 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /usr/benchmarks/sp.b/wtime.h: -------------------------------------------------------------------------------- 1 | /* C/Fortran interface is different on different machines. 2 | * You may need to tweak this. 3 | */ 4 | 5 | 6 | #if defined(IBM) 7 | #define wtime wtime 8 | #elif defined(CRAY) 9 | #define wtime WTIME 10 | #else 11 | #define wtime wtime_ 12 | #endif 13 | -------------------------------------------------------------------------------- /usr/benchmarks/ua.b/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB srcs *.c) 2 | add_executable(ua.b ${srcs}) 3 | 4 | target_compile_options(ua.b PRIVATE -O3 -mcmodel=medium) 5 | target_link_libraries(ua.b -lm) 6 | 7 | install_local_targets(extra/benchmarks/npb) 8 | 9 | -------------------------------------------------------------------------------- /usr/benchmarks/ua.b/c_timers.c: -------------------------------------------------------------------------------- 1 | #include "wtime.h" 2 | #include 3 | 4 | /* Prototype */ 5 | void wtime( double * ); 6 | 7 | 8 | /*****************************************************************/ 9 | /****** E L A P S E D _ T I M E ******/ 10 | /*****************************************************************/ 11 | static double elapsed_time( void ) 12 | { 13 | double t; 14 | 15 | wtime( &t ); 16 | return( t ); 17 | } 18 | 19 | 20 | static double start[64], elapsed[64]; 21 | 22 | /*****************************************************************/ 23 | /****** T I M E R _ C L E A R ******/ 24 | /*****************************************************************/ 25 | void timer_clear( int n ) 26 | { 27 | elapsed[n] = 0.0; 28 | } 29 | 30 | 31 | /*****************************************************************/ 32 | /****** T I M E R _ S T A R T ******/ 33 | /*****************************************************************/ 34 | void timer_start( int n ) 35 | { 36 | start[n] = elapsed_time(); 37 | } 38 | 39 | 40 | /*****************************************************************/ 41 | /****** T I M E R _ S T O P ******/ 42 | /*****************************************************************/ 43 | void timer_stop( int n ) 44 | { 45 | double t, now; 46 | 47 | now = elapsed_time(); 48 | t = now - start[n]; 49 | elapsed[n] += t; 50 | 51 | } 52 | 53 | 54 | /*****************************************************************/ 55 | /****** T I M E R _ R E A D ******/ 56 | /*****************************************************************/ 57 | double timer_read( int n ) 58 | { 59 | return( elapsed[n] ); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /usr/benchmarks/ua.b/npbparams.h: -------------------------------------------------------------------------------- 1 | /* CLASS = B */ 2 | /* 3 | This file is generated automatically by the setparams utility. 4 | It sets the number of processors and the class of the NPB 5 | in this directory. Do not modify it by hand. 6 | */ 7 | #define LELT 8800 8 | 9 | #define LMOR 334600 10 | 11 | #define REFINE_MAX 7 12 | 13 | #define FRE_DEFAULT 5 14 | 15 | #define NITER_DEFAULT 200 16 | 17 | #define NMXH_DEFAULT 10 18 | 19 | #define CLASS_DEFAULT 'B' 20 | 21 | #define ALPHA_DEFAULT 0.076e0 22 | 23 | 24 | #define CONVERTDOUBLE false 25 | #define COMPILETIME "18 Oct 2017" 26 | #define NPBVERSION "3.3.1" 27 | #define CS1 "../../musl/prefix/bin/musl-gcc" 28 | #define CS2 "$(CC)" 29 | #define CS3 "-static -L../../musl/prefix/lib -lm" 30 | #define CS4 "-I../common -I../../musl/prefix/include" 31 | #define CS5 "-g -Wall -O3 -mcmodel=medium" 32 | #define CS6 "-O3 -mcmodel=medium" 33 | #define CS7 "randdp" 34 | -------------------------------------------------------------------------------- /usr/benchmarks/ua.b/print_results.h: -------------------------------------------------------------------------------- 1 | #ifndef __PRINT_RESULTS_H__ 2 | #define __PRINT_RESULTS_H__ 3 | 4 | void print_results(char *name, char class, int n1, int n2, int n3, int niter, 5 | double t, double mops, char *optype, logical verified, char *npbversion, 6 | char *compiletime, char *cs1, char *cs2, char *cs3, char *cs4, char *cs5, 7 | char *cs6, char *cs7); 8 | 9 | #endif //__PRINT_RESULTS_H__ 10 | -------------------------------------------------------------------------------- /usr/benchmarks/ua.b/randdp.h: -------------------------------------------------------------------------------- 1 | #ifndef __RANDDP_H__ 2 | #define __RANDDP_H__ 3 | 4 | double randlc( double *x, double a ); 5 | void vranlc( int n, double *x, double a, double y[] ); 6 | 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /usr/benchmarks/ua.b/res.txt: -------------------------------------------------------------------------------- 1 | KVM 2 | Time in seconds = 59.80 3 | Time in seconds = 61.41 4 | Time in seconds = 60.11 5 | UHYVE 6 | Time in seconds = 53.79 7 | Time in seconds = 52.33 8 | Time in seconds = 52.17 9 | -------------------------------------------------------------------------------- /usr/benchmarks/ua.b/timers.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMERS_H__ 2 | #define __TIMERS_H__ 3 | 4 | void timer_clear( int n ); 5 | void timer_start( int n ); 6 | void timer_stop( int n ); 7 | double timer_read( int n ); 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /usr/benchmarks/ua.b/type.h: -------------------------------------------------------------------------------- 1 | #ifndef __TYPE_H__ 2 | #define __TYPE_H__ 3 | 4 | typedef enum { false, true } logical; 5 | typedef struct { 6 | double real; 7 | double imag; 8 | } dcomplex; 9 | 10 | 11 | #define min(x,y) ((x) < (y) ? (x) : (y)) 12 | #define max(x,y) ((x) > (y) ? (x) : (y)) 13 | 14 | #endif //__TYPE_H__ 15 | -------------------------------------------------------------------------------- /usr/benchmarks/ua.b/wtime.c: -------------------------------------------------------------------------------- 1 | #include "wtime.h" 2 | #include 3 | #ifndef DOS 4 | #include 5 | #endif 6 | 7 | void wtime(double *t) 8 | { 9 | static int sec = -1; 10 | struct timeval tv; 11 | gettimeofday(&tv, (void *)0); 12 | if (sec < 0) sec = tv.tv_sec; 13 | *t = (tv.tv_sec - sec) + 1.0e-6*tv.tv_usec; 14 | } 15 | 16 | 17 | -------------------------------------------------------------------------------- /usr/benchmarks/ua.b/wtime.h: -------------------------------------------------------------------------------- 1 | /* C/Fortran interface is different on different machines. 2 | * You may need to tweak this. 3 | */ 4 | 5 | 6 | #if defined(IBM) 7 | #define wtime wtime 8 | #elif defined(CRAY) 9 | #define wtime WTIME 10 | #else 11 | #define wtime wtime_ 12 | #endif 13 | -------------------------------------------------------------------------------- /usr/gdb/hermit-gdb.py: -------------------------------------------------------------------------------- 1 | # 2 | # gdb helper commands and functions for Linux kernel debugging 3 | # 4 | # loader module 5 | # 6 | # Copyright (c) Siemens AG, 2012, 2013 7 | # 8 | # Authors: 9 | # Jan Kiszka 10 | # 11 | # This work is licensed under the terms of the GNU GPL version 2. 12 | # 13 | 14 | import os 15 | 16 | sys.path.insert(0, os.path.dirname(__file__)) 17 | 18 | try: 19 | gdb.parse_and_eval("0") 20 | gdb.execute("", to_string=True) 21 | except: 22 | gdb.write("NOTE: gdb 7.2 or later required for Linux helper scripts to " 23 | "work.\n") 24 | else: 25 | import hermit.tasks 26 | -------------------------------------------------------------------------------- /usr/gdb/hermit/__init__.py: -------------------------------------------------------------------------------- 1 | # nothing to do for the initialization of this package 2 | -------------------------------------------------------------------------------- /usr/ircce/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | include(../../cmake/HermitCore.cmake) 3 | 4 | project(hermit_ircce C) 5 | 6 | add_compile_options(${HERMIT_APP_FLAGS}) 7 | 8 | file(GLOB SOURCES *.c) 9 | 10 | add_library(ircce STATIC ${SOURCES}) 11 | 12 | # deployment 13 | install(TARGETS ircce 14 | DESTINATION ${TARGET_ARCH}/lib) 15 | install(FILES 16 | iRCCE.h iRCCE_lib.h RCCE_debug.h RCCE.h RCCE_lib.h rte_memcpy.h 17 | DESTINATION 18 | ${TARGET_ARCH}/include) 19 | -------------------------------------------------------------------------------- /usr/ircce/RCCE_debug.h: -------------------------------------------------------------------------------- 1 | /************************************************************** 2 | * Change the RCCE_debug_xxx values to get debug info. * 3 | * Change RCCE_comm_init_val to 1 to see what happens if * 4 | * the comm buffers are not properly initialized at startup . * 5 | **************************************************************/ 6 | 7 | int RCCE_debug_synch=0; 8 | int RCCE_debug_comm=0; 9 | int RCCE_debug_debug=0; 10 | int RCCE_debug_RPC=0; 11 | int RCCE_comm_init_val=0; 12 | // 13 | // Copyright 2010 Intel Corporation 14 | // 15 | // Licensed under the Apache License, Version 2.0 (the "License"); 16 | // you may not use this file except in compliance with the License. 17 | // You may obtain a copy of the License at 18 | // 19 | // http://www.apache.org/licenses/LICENSE-2.0 20 | // 21 | // Unless required by applicable law or agreed to in writing, software 22 | // distributed under the License is distributed on an "AS IS" BASIS, 23 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24 | // See the License for the specific language governing permissions and 25 | // limitations under the License. 26 | // 27 | -------------------------------------------------------------------------------- /usr/libgomp/Makefile: -------------------------------------------------------------------------------- 1 | NEWLIB = ../x86/x86_64-hermit 2 | MAKE = make 3 | ARFLAGS_FOR_TARGET = rsv 4 | CP = cp 5 | C_source = $(wildcard *.c) 6 | NAME = libgomp.a 7 | OBJS = $(C_source:.c=.o) 8 | 9 | # 10 | # Prettify output 11 | V = 0 12 | ifeq ($V,0) 13 | Q = @ 14 | P = > /dev/null 15 | endif 16 | 17 | # other implicit rules 18 | %.o : %.c 19 | @echo [CC] $@ 20 | $Q$(CC_FOR_TARGET) -c $(CFLAGS_FOR_TARGET) -o $@ $< 21 | 22 | default: all 23 | 24 | all: $(NAME) 25 | 26 | $(NAME): $(OBJS) 27 | $Q$(AR_FOR_TARGET) $(ARFLAGS_FOR_TARGET) $@ $(OBJS) 28 | $Q$(CP) $@ $(NEWLIB)/lib 29 | $Q$(CP) libgomp.spec $(NEWLIB)/lib 30 | $Q$(CP) omp.h $(NEWLIB)/include 31 | 32 | clean: 33 | @echo Cleaning examples 34 | $Q$(RM) $(NAME) *.o *~ 35 | 36 | veryclean: 37 | @echo Propper cleaning examples 38 | $Q$(RM) $(NAME) *.o *~ 39 | 40 | depend: 41 | $Q$(CC_FOR_TARGET) -MM $(CFLAGS_FOR_TARGET) *.c > Makefile.dep 42 | 43 | -include Makefile.dep 44 | # DO NOT DELETE 45 | -------------------------------------------------------------------------------- /usr/libgomp/barrier.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005-2015 Free Software Foundation, Inc. 2 | Contributed by Richard Henderson . 3 | 4 | This file is part of the GNU Offloading and Multi Processing Library 5 | (libgomp). 6 | 7 | Libgomp is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 3, or (at your option) 10 | any later version. 11 | 12 | Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY 13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 | more details. 16 | 17 | Under Section 7 of GPL version 3, you are granted additional 18 | permissions described in the GCC Runtime Library Exception, version 19 | 3.1, as published by the Free Software Foundation. 20 | 21 | You should have received a copy of the GNU General Public License and 22 | a copy of the GCC Runtime Library Exception along with this program; 23 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24 | . */ 25 | 26 | /* This file handles the BARRIER construct. */ 27 | 28 | #include "libgomp.h" 29 | 30 | 31 | void 32 | GOMP_barrier (void) 33 | { 34 | struct gomp_thread *thr = gomp_thread (); 35 | struct gomp_team *team = thr->ts.team; 36 | 37 | /* It is legal to have orphaned barriers. */ 38 | if (team == NULL) 39 | return; 40 | 41 | gomp_team_barrier_wait (&team->barrier); 42 | } 43 | 44 | bool 45 | GOMP_barrier_cancel (void) 46 | { 47 | struct gomp_thread *thr = gomp_thread (); 48 | struct gomp_team *team = thr->ts.team; 49 | 50 | /* The compiler transforms to barrier_cancel when it sees that the 51 | barrier is within a construct that can cancel. Thus we should 52 | never have an orphaned cancellable barrier. */ 53 | return gomp_team_barrier_wait_cancel (&team->barrier); 54 | } 55 | -------------------------------------------------------------------------------- /usr/libgomp/libgomp.spec: -------------------------------------------------------------------------------- 1 | # This spec file is read by gcc when linking. It is used to specify the 2 | # standard libraries we need in order to link with libgomp. 3 | *link_gomp: -lgomp 4 | -------------------------------------------------------------------------------- /usr/libgomp/mutex.c: -------------------------------------------------------------------------------- 1 | /* Everything is in the header. */ 2 | -------------------------------------------------------------------------------- /usr/libgomp/mutex.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2005-2015 Free Software Foundation, Inc. 2 | Contributed by Richard Henderson . 3 | 4 | This file is part of the GNU Offloading and Multi Processing Library 5 | (libgomp). 6 | 7 | Libgomp is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 3, or (at your option) 10 | any later version. 11 | 12 | Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY 13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 | more details. 16 | 17 | Under Section 7 of GPL version 3, you are granted additional 18 | permissions described in the GCC Runtime Library Exception, version 19 | 3.1, as published by the Free Software Foundation. 20 | 21 | You should have received a copy of the GNU General Public License and 22 | a copy of the GCC Runtime Library Exception along with this program; 23 | see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 24 | . */ 25 | 26 | /* This is the default PTHREADS implementation of a mutex synchronization 27 | mechanism for libgomp. This type is private to the library. */ 28 | 29 | #ifndef GOMP_MUTEX_H 30 | #define GOMP_MUTEX_H 1 31 | 32 | #include 33 | 34 | typedef pthread_mutex_t gomp_mutex_t; 35 | 36 | #define GOMP_MUTEX_INIT_0 0 37 | 38 | static inline void gomp_mutex_init (gomp_mutex_t *mutex) 39 | { 40 | pthread_mutex_init (mutex, NULL); 41 | } 42 | 43 | static inline void gomp_mutex_lock (gomp_mutex_t *mutex) 44 | { 45 | pthread_mutex_lock (mutex); 46 | } 47 | 48 | static inline void gomp_mutex_unlock (gomp_mutex_t *mutex) 49 | { 50 | pthread_mutex_unlock (mutex); 51 | } 52 | 53 | static inline void gomp_mutex_destroy (gomp_mutex_t *mutex) 54 | { 55 | pthread_mutex_destroy (mutex); 56 | } 57 | 58 | #endif /* GOMP_MUTEX_H */ 59 | -------------------------------------------------------------------------------- /usr/libgomp/omp-lock.h: -------------------------------------------------------------------------------- 1 | /* This header is used during the build process to find the size and 2 | alignment of the public OpenMP locks, so that we can export data 3 | structures without polluting the namespace. 4 | 5 | In this default POSIX implementation, we used to map the two locks to the 6 | same PTHREADS primitive, but for OpenMP 3.0 sem_t needs to be used 7 | instead, as pthread_mutex_unlock should not be called by different 8 | thread than the one that called pthread_mutex_lock. */ 9 | 10 | #include 11 | #include 12 | 13 | typedef pthread_mutex_t omp_lock_25_t; 14 | typedef struct { pthread_mutex_t lock; int count; } omp_nest_lock_25_t; 15 | #ifdef HAVE_BROKEN_POSIX_SEMAPHORES 16 | /* If we don't have working semaphores, we'll make all explicit tasks 17 | tied to the creating thread. */ 18 | typedef pthread_mutex_t omp_lock_t; 19 | typedef struct { pthread_mutex_t lock; int count; void *owner; } omp_nest_lock_t; 20 | #else 21 | typedef sem_t omp_lock_t; 22 | typedef struct { sem_t lock; int count; void *owner; } omp_nest_lock_t; 23 | #endif 24 | -------------------------------------------------------------------------------- /usr/libgomp/ptrlock.c: -------------------------------------------------------------------------------- 1 | /* Everything is in the header. */ 2 | -------------------------------------------------------------------------------- /usr/openmpbench/.gitignore: -------------------------------------------------------------------------------- 1 | *.map 2 | *.xray 3 | -------------------------------------------------------------------------------- /usr/openmpbench/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | include(../../cmake/HermitCore-Application.cmake) 3 | 4 | project(hermit_openmpbench C) 5 | 6 | add_executable(syncbench syncbench.c common.c) 7 | target_link_libraries(syncbench PUBLIC -fopenmp) 8 | 9 | add_executable(taskbench taskbench.c common.c) 10 | target_link_libraries(taskbench PUBLIC -fopenmp) 11 | 12 | add_library(common_sched STATIC common.c) 13 | target_compile_definitions(common_sched PUBLIC -DSCHEDBENCH) 14 | target_compile_options(common_sched PUBLIC -fopenmp) 15 | target_link_libraries(common_sched PUBLIC -fopenmp) 16 | 17 | add_executable(schedbench schedbench.c) 18 | target_link_libraries(schedbench common_sched) 19 | 20 | # deployment: exclude common_sched 21 | install_local_targets(extra/benchmarks common_sched) 22 | -------------------------------------------------------------------------------- /usr/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | include(../../cmake/HermitCore-Application.cmake) 3 | 4 | project(hermit_tests C CXX Fortran Go) 5 | 6 | #add_executable(hello hello.c) 7 | #add_executable(hello-minimal hello-minimal.c) 8 | #add_executable(argv_envp argv_envp.c) 9 | #add_executable(timing timing.c) 10 | #add_executable(jacobi jacobi.c) 11 | #add_executable(hello++ hello++.cpp) 12 | # add_executable(hellof hellof.f90) 13 | # add_executable(pi pi.go) 14 | 15 | add_executable(hermitux hermitux.c linker.ld) 16 | set_target_properties(hermitux PROPERTIES LINK_DEPENDS ${CMAKE_SOURCE_DIR}/linker.ld) 17 | set_target_properties(hermitux PROPERTIES LINK_DEPENDS ${LOCAL_PREFIX_ARCH_LIB_DIR}/libhermit.a) 18 | target_link_libraries(hermitux -Wl,-T,${CMAKE_SOURCE_DIR}/linker.ld) 19 | 20 | #add_executable(test-malloc test-malloc.c) 21 | #add_executable(test-malloc-mt test-malloc-mt.c) 22 | #target_compile_options(test-malloc-mt PRIVATE -pthread) 23 | #target_link_libraries(test-malloc-mt pthread) 24 | 25 | # add_executable(server server.go) 26 | # target_link_libraries(server netgo) 27 | 28 | #if(NOT ${NO_IRCCE}) 29 | #add_executable(RCCE_minimum RCCE_minimum.c) 30 | #target_link_libraries(RCCE_minimum ircce) 31 | #endif(NOT ${NO_IRCCE}) 32 | 33 | #add_executable(thr_hello thr_hello.c) 34 | #target_compile_options(thr_hello PRIVATE -pthread) 35 | #target_link_libraries(thr_hello pthread) 36 | 37 | #add_executable(signals signals.c) 38 | #target_compile_options(signals PRIVATE -pthread) 39 | #target_link_libraries(signals pthread) 40 | 41 | #add_executable(syscall_tester syscall_tester.c) 42 | 43 | # deployment 44 | install_local_targets(extra/tests) 45 | -------------------------------------------------------------------------------- /usr/tests/argv_envp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | extern char **environ; 6 | 7 | int main(int argc, char **argv) { 8 | int i; 9 | 10 | printf("argc: %d\n", argc); 11 | for(i=0; i 29 | #include 30 | 31 | using namespace std; 32 | 33 | int main(int argc, char** argv) 34 | { 35 | cout << "Hello World from g++!!!" << endl; 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /usr/tests/hello-minimal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, Stefan Lankes, RWTH Aachen University 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * * Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * * Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * * Neither the name of the University nor the names of its contributors 13 | * may be used to endorse or promote products derived from this 14 | * software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | 30 | int main(int argc, char** argv) 31 | { 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /usr/tests/hellof.f90: -------------------------------------------------------------------------------- 1 | ! 2 | ! Copyright (c) 2015, Stefan Lankes, RWTH Aachen University 3 | ! All rights reserved. 4 | ! 5 | ! Redistribution and use in source and binary forms, with or without 6 | ! modification, are permitted provided that the following conditions are met: 7 | ! * Redistributions of source code must retain the above copyright 8 | ! notice, this list of conditions and the following disclaimer. 9 | ! * Redistributions in binary form must reproduce the above copyright 10 | ! notice, this list of conditions and the following disclaimer in the 11 | ! documentation and/or other materials provided with the distribution. 12 | ! * Neither the name of the University nor the names of its contributors 13 | ! may be used to endorse or promote products derived from this 14 | ! software without specific prior written permission. 15 | ! 16 | ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ! ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | ! WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | ! DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY 20 | ! DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | ! (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | ! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ! ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | ! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | ! SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | ! 27 | 28 | program hellof 29 | print *, "HelloWorld from gfortran!" 30 | end program hellof 31 | -------------------------------------------------------------------------------- /usr/tests/server.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. 2 | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ 3 | 4 | // The original code was published at http://www.gopl.io, see page 21. 5 | 6 | // This is an "echo" server that displays request parameters. 7 | 8 | package main 9 | 10 | import ( 11 | "fmt" 12 | "log" 13 | "net/http" 14 | ) 15 | 16 | func main() { 17 | fmt.Println("This is an \"echo\" server that displays request parameters.") 18 | fmt.Println("Start the server and send a http request to it (e.g.") 19 | fmt.Println("curl http://localhost:8000/help). The server uses port 8000.") 20 | fmt.Println("If KVM is implicitly started by our proxy, please open the port by") 21 | fmt.Println("setting the environment variable HERMIT_APP_PORT to 8000.") 22 | 23 | http.HandleFunc("/", handler) 24 | log.Fatal(http.ListenAndServe(":8000", nil)) 25 | } 26 | 27 | //!+handler 28 | // handler echoes the HTTP request. 29 | func handler(w http.ResponseWriter, r *http.Request) { 30 | fmt.Fprintf(w, "%s %s %s\n", r.Method, r.URL, r.Proto) 31 | for k, v := range r.Header { 32 | fmt.Fprintf(w, "Header[%q] = %q\n", k, v) 33 | } 34 | fmt.Fprintf(w, "Host = %q\n", r.Host) 35 | fmt.Fprintf(w, "RemoteAddr = %q\n", r.RemoteAddr) 36 | if err := r.ParseForm(); err != nil { 37 | log.Print(err) 38 | } 39 | for k, v := range r.Form { 40 | fmt.Fprintf(w, "Form[%q] = %q\n", k, v) 41 | } 42 | } 43 | //!-handler 44 | -------------------------------------------------------------------------------- /usr/tests/test-malloc-mt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #ifndef NUM_THREADS 9 | #define NUM_THREADS 3 10 | #endif 11 | 12 | #ifndef NUM_ITER 13 | #define NUM_ITER 10000 14 | #endif 15 | 16 | #ifndef SIZE 17 | #define SIZE 16384 18 | #endif 19 | 20 | __thread void* buf; 21 | 22 | static void* perform_work( void* argument ) 23 | { 24 | int passed_in_value; 25 | 26 | passed_in_value = *( ( int* )argument ); 27 | printf( "Hello World! It's me, thread %d with argument %d!\n", getpid(), passed_in_value ); 28 | 29 | /* optionally: insert more useful stuff here */ 30 | for(int i=0; i 2 | #include 3 | #include 4 | #include 5 | 6 | #ifndef NUM_ITER 7 | #define NUM_ITER 100000 8 | #endif 9 | 10 | #ifndef SIZE 11 | #define SIZE 16*1024 12 | #endif 13 | 14 | void* buf; 15 | 16 | int main(int argc, char** argv) 17 | { 18 | /* optionally: insert more useful stuff here */ 19 | 20 | for(int i=0; i 2 | #include 3 | 4 | #define MAX_THREADS 2 5 | 6 | void* thread_func(void* arg) 7 | { 8 | int id = *((int*) arg); 9 | 10 | printf("Hello Thread!!! id = %d\n", id); 11 | 12 | return 0; 13 | } 14 | 15 | int main(int argc, char** argv) 16 | { 17 | pthread_t threads[MAX_THREADS]; 18 | int i, ret, param[MAX_THREADS]; 19 | 20 | for(i=0; i 2 | #include 3 | #include 4 | 5 | int main(void) { 6 | struct timeval start, stop, res; 7 | 8 | gettimeofday(&start, NULL); 9 | sys_msleep(10000); 10 | gettimeofday(&stop, NULL); 11 | 12 | timersub(&stop, &start, &res); 13 | 14 | printf("%ld.%06ld\n", res.tv_sec, res.tv_usec); 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /usr/xray/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | include(../../cmake/HermitCore.cmake) 3 | 4 | project(hermit_xray C) 5 | 6 | add_compile_options(${HERMIT_APP_FLAGS}) 7 | 8 | file(GLOB SOURCES *.c) 9 | 10 | add_library(xray STATIC ${SOURCES}) 11 | 12 | target_compile_definitions(xray 13 | PUBLIC 14 | -DXRAY -DXRAY_ANNOTATE 15 | -DXRAY_NO_DEMANGLE 16 | -DXRAY_DISABLE_BROWSER_INTEGRATION) 17 | 18 | # deployment 19 | install(TARGETS xray 20 | DESTINATION ${TARGET_ARCH}/lib) 21 | install(FILES libxray.spec 22 | DESTINATION ${TARGET_ARCH}/lib) 23 | install(FILES xray.h 24 | DESTINATION ${TARGET_ARCH}/include) 25 | -------------------------------------------------------------------------------- /usr/xray/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011, The Chromium Authors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /usr/xray/demangle.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 | * Use of this source code is governed by a BSD-style license that can be 3 | * found in the LICENSE file. */ 4 | 5 | #include "xray_priv.h" 6 | 7 | /* Note name demangling requires linking against libstdc++ */ 8 | /* If your platform does not support __cxa_demangle, re-compile XRay with: */ 9 | /* -DXRAY_NO_DEMANGLE */ 10 | 11 | #if !defined(XRAY_NO_DEMANGLE) 12 | extern 13 | char* __cxa_demangle(const char* __mangled_name, char* __output_buffer, 14 | size_t* __length, int* __status); 15 | #endif 16 | 17 | const char* XRayDemangle(char* demangle, size_t size, const char* symbol) { 18 | #if !defined(XRAY_NO_DEMANGLE) 19 | int stat; 20 | __cxa_demangle(symbol, demangle, &size, &stat); 21 | if (stat == 0) 22 | return demangle; 23 | #endif 24 | return symbol; 25 | } 26 | -------------------------------------------------------------------------------- /usr/xray/libxray.spec: -------------------------------------------------------------------------------- 1 | # Do we really need this? Does this even what we want? 2 | *link_xray: -lxray 3 | 4 | -------------------------------------------------------------------------------- /usr/xray/xray.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssrg-vt/hermitux-kernel/ff53acc13a223da8ef04f890a3e9b9ad0643fe3e/usr/xray/xray.odt --------------------------------------------------------------------------------