├── AUTHORS ├── CHANGES.md ├── GNUmakefile ├── LICENSE ├── Makefile.common ├── README.md ├── RELEASE.md ├── bindings ├── GNUmakefile ├── abort.c ├── bindings.h ├── cmdline.c ├── cpu_aarch64.c ├── cpu_aarch64.h ├── cpu_ppc64.h ├── cpu_vectors_aarch64.S ├── cpu_vectors_x86_64.S ├── cpu_x86_64.c ├── cpu_x86_64.h ├── crt.c ├── crt_init.h ├── exit.c ├── hvt │ ├── bindings.h │ ├── block.c │ ├── console.c │ ├── net.c │ ├── platform.c │ ├── platform_intr.c │ ├── platform_lifecycle.c │ ├── start.c │ ├── time.c │ ├── tscclock.c │ └── yield.c ├── intr.c ├── lib.c ├── log.c ├── mem.c ├── mft.c ├── mft.h ├── muen │ ├── bindings.h │ ├── channel.c │ ├── channel.h │ ├── muen-block.c │ ├── muen-clock.c │ ├── muen-console.c │ ├── muen-net.c │ ├── muen-net.h │ ├── muen-platform_lifecycle.c │ ├── muen-sinfo.c │ ├── muen-yield.c │ ├── muschedinfo.h │ ├── mutimeinfo.h │ ├── reader.c │ ├── reader.h │ ├── sinfo.h │ ├── start.c │ ├── util.h │ ├── writer.c │ └── writer.h ├── printf.c ├── printf.h ├── solo5_hvt.lds ├── solo5_muen.lds ├── solo5_spt.lds ├── solo5_stub.lds ├── solo5_virtio.lds ├── solo5_xen.lds ├── spt │ ├── bindings.c │ ├── bindings.h │ ├── block.c │ ├── net.c │ ├── platform.c │ ├── start.c │ ├── sys_linux_aarch64.c │ ├── sys_linux_ppc64le.c │ └── sys_linux_x86_64.c ├── stub │ └── stubs.c ├── tls.c ├── virtio │ ├── bindings.h │ ├── boot.S │ ├── clock_subr.c │ ├── clock_subr.h │ ├── multiboot.h │ ├── pagetable.S │ ├── pci.c │ ├── platform.c │ ├── platform_intr.c │ ├── pvclock.c │ ├── serial.c │ ├── start.c │ ├── time.c │ ├── tscclock.c │ ├── virtio_blk.c │ ├── virtio_net.c │ ├── virtio_pci.h │ ├── virtio_ring.c │ └── virtio_ring.h └── xen │ ├── bindings.h │ ├── boot.S │ ├── console.c │ ├── evtchn.c │ ├── hypercall-x86_64.h │ ├── hypercall.h │ ├── hypercall_page.S │ ├── pagetable.S │ ├── platform.c │ ├── platform_intr.c │ ├── pvclock.c │ ├── start.c │ ├── stubs.c │ └── time.c ├── configure.sh ├── docs ├── architecture.md ├── building.md └── debugging.md ├── elftool ├── GNUmakefile ├── elftool.c └── json.h ├── include ├── elf_abi.h ├── hvt_abi.h ├── mft_abi.h ├── solo5.h ├── spt_abi.h └── xen │ ├── COPYING │ ├── arch-arm.h │ ├── arch-arm │ ├── hvm │ │ └── save.h │ └── smccc.h │ ├── arch-x86 │ ├── cpufeatureset.h │ ├── cpuid.h │ ├── hvm │ │ ├── save.h │ │ └── start_info.h │ ├── pmu.h │ ├── xen-mca.h │ ├── xen-x86_32.h │ ├── xen-x86_64.h │ └── xen.h │ ├── arch-x86_32.h │ ├── arch-x86_64.h │ ├── argo.h │ ├── callback.h │ ├── device_tree_defs.h │ ├── dom0_ops.h │ ├── domctl.h │ ├── elfnote.h │ ├── errno.h │ ├── event_channel.h │ ├── features.h │ ├── grant_table.h │ ├── hvm │ ├── dm_op.h │ ├── e820.h │ ├── hvm_info_table.h │ ├── hvm_op.h │ ├── hvm_vcpu.h │ ├── hvm_xs_strings.h │ ├── ioreq.h │ ├── params.h │ ├── pvdrivers.h │ └── save.h │ ├── io │ ├── 9pfs.h │ ├── blkif.h │ ├── cameraif.h │ ├── console.h │ ├── displif.h │ ├── fbif.h │ ├── fsif.h │ ├── kbdif.h │ ├── libxenvchan.h │ ├── netif.h │ ├── pciif.h │ ├── protocols.h │ ├── pvcalls.h │ ├── ring.h │ ├── sndif.h │ ├── tpmif.h │ ├── usbif.h │ ├── vscsiif.h │ ├── xenbus.h │ └── xs_wire.h │ ├── kexec.h │ ├── memory.h │ ├── nmi.h │ ├── physdev.h │ ├── platform.h │ ├── pmu.h │ ├── sched.h │ ├── sysctl.h │ ├── tmem.h │ ├── trace.h │ ├── vcpu.h │ ├── version.h │ ├── vm_event.h │ ├── xen-compat.h │ ├── xen.h │ ├── xencomm.h │ ├── xenoprof.h │ └── xsm │ └── flask_op.h ├── opam ├── solo5-cross-aarch64.opam └── solo5.opam ├── scripts ├── gen_version_h.sh ├── opam-release.sh ├── virtio-mkimage │ ├── Dockerfile │ └── solo5-virtio-mkimage.sh └── virtio-run │ └── solo5-virtio-run.sh ├── tenders ├── GNUmakefile ├── common │ ├── block_attach.c │ ├── block_attach.h │ ├── cc.h │ ├── elf.c │ ├── elf.h │ ├── mft.c │ ├── mft.h │ ├── tap_attach.c │ └── tap_attach.h ├── hvt │ ├── hvt.h │ ├── hvt_boot_info.c │ ├── hvt_core.c │ ├── hvt_cpu_aarch64.c │ ├── hvt_cpu_aarch64.h │ ├── hvt_cpu_x86_64.c │ ├── hvt_cpu_x86_64.h │ ├── hvt_dumpcore_freebsd_x86_64.c │ ├── hvt_dumpcore_kvm_aarch64.c │ ├── hvt_dumpcore_kvm_x86_64.c │ ├── hvt_dumpcore_openbsd_x86_64.c │ ├── hvt_freebsd.c │ ├── hvt_freebsd.h │ ├── hvt_freebsd_x86_64.c │ ├── hvt_gdb.h │ ├── hvt_gdb_aarch64.h │ ├── hvt_gdb_freebsd_x86_64.c │ ├── hvt_gdb_kvm_aarch64.c │ ├── hvt_gdb_kvm_x86_64.c │ ├── hvt_gdb_openbsd_x86_64.c │ ├── hvt_gdb_x86_64.h │ ├── hvt_kvm.c │ ├── hvt_kvm.h │ ├── hvt_kvm_aarch64.c │ ├── hvt_kvm_x86_64.c │ ├── hvt_main.c │ ├── hvt_module_blk.c │ ├── hvt_module_dumpcore.c │ ├── hvt_module_gdb.c │ ├── hvt_module_net.c │ ├── hvt_openbsd.c │ ├── hvt_openbsd.h │ ├── hvt_openbsd_x86_64.c │ └── queue.h └── spt │ ├── spt.h │ ├── spt_core.c │ ├── spt_launch_aarch64.S │ ├── spt_launch_ppc64le.S │ ├── spt_launch_x86_64.S │ ├── spt_main.c │ ├── spt_module_block.c │ └── spt_module_net.c ├── tests ├── GNUmakefile ├── Makefile.tests ├── README.md ├── bats-core │ ├── bats │ ├── bats-exec-suite │ ├── bats-exec-test │ ├── bats-format-tap-stream │ └── bats-preprocess ├── config.xl.in ├── run-tests.sh ├── setup-tests.sh ├── test_blk │ ├── GNUmakefile │ ├── manifest.json │ └── test_blk.c ├── test_dumpcore │ ├── GNUmakefile │ ├── manifest.json │ └── test_dumpcore.c ├── test_exception │ ├── GNUmakefile │ ├── manifest.json │ └── test_exception.c ├── test_fpu │ ├── GNUmakefile │ ├── manifest.json │ └── test_fpu.c ├── test_globals │ ├── GNUmakefile │ ├── manifest.json │ └── test_globals.c ├── test_hello │ ├── GNUmakefile │ ├── manifest.json │ └── test_hello.c ├── test_mft_maxdevices │ ├── GNUmakefile │ ├── manifest.json │ └── test_mft_maxdevices.c ├── test_net │ ├── GNUmakefile │ ├── manifest.json │ └── test_net.c ├── test_net_2if │ ├── GNUmakefile │ ├── manifest.json │ └── test_net_2if.c ├── test_notls │ ├── GNUmakefile │ ├── manifest.json │ └── test_notls.c ├── test_output │ ├── GNUmakefile │ ├── manifest.json │ └── test_output.c ├── test_quiet │ ├── GNUmakefile │ ├── manifest.json │ └── test_quiet.c ├── test_rnow │ ├── GNUmakefile │ ├── manifest.json │ └── test_rnow.c ├── test_rnox │ ├── GNUmakefile │ ├── manifest.json │ └── test_rnox.c ├── test_seccomp │ ├── GNUmakefile │ ├── manifest.json │ └── test_seccomp.c ├── test_ssp │ ├── GNUmakefile │ ├── manifest.json │ ├── show_canary.gdb │ └── test_ssp.c ├── test_time │ ├── GNUmakefile │ ├── manifest.json │ └── test_time.c ├── test_tls │ ├── GNUmakefile │ ├── manifest.json │ └── test_tls.c ├── test_wnox │ ├── GNUmakefile │ ├── manifest.json │ └── test_wnox.c ├── test_xnor │ ├── GNUmakefile │ ├── manifest.json │ └── test_xnor.c ├── test_xnow │ ├── GNUmakefile │ ├── manifest.json │ └── test_xnow.c ├── test_zeropage │ ├── GNUmakefile │ ├── manifest.json │ └── test_zeropage.c └── tests.bats └── toolchain ├── GNUmakefile ├── cc.in ├── gen-headers.sh ├── ld.in └── objcopy.in /AUTHORS: -------------------------------------------------------------------------------- 1 | Corporate Contributors 2 | ====================== 3 | 4 | Copyright (c) 2015-2017 IBM 5 | Copyright (c) 2016-2017 Docker, Inc. 6 | Copyright (C) 2017 ARM Ltd. 7 | 8 | Individual Contributors 9 | ======================= 10 | 11 | Adrian-Ken Rueegsegger 12 | Adam Steen 13 | Dan Williams (IBM) 14 | Emery Hemingway (Genode Labs) 15 | Gabriel Jaldon 16 | Hannes Mehnert 17 | Ian Campbell (Docker, Inc.) 18 | Madhuri Yechuri 19 | Martin Lucina (robur.io / Center for the Cultivation of Technology) 20 | Michael LeMay 21 | Nikhil AP 22 | Ricardo Koller (IBM) 23 | Stefan Berger (IBM) 24 | Waldir Pimenta 25 | Wei Chen (ARM) 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 4 | 5 | Permission to use, copy, modify, and/or distribute this software 6 | for any purpose with or without fee is hereby granted, provided 7 | that the above copyright notice and this permission notice appear 8 | in all copies. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | -------------------------------------------------------------------------------- /RELEASE.md: -------------------------------------------------------------------------------- 1 | # Make a release of Solo5 2 | 3 | The usual way to make a release of Solo5 is: 4 | - Make a new branch: `git checkout -b prepare-vX.Y.Z` 5 | - Update CHANGES.md file to include changes 6 | - Do a commit with this file: "Update CHANGES for release vX.Y.Z" 7 | - Push the current branch and make a new pull-request on GitHub 8 | - Waiting review from someone (if the CHANGES.md is clear, etc.) 9 | 10 | If you have some feedbacks: 11 | - Redo the commit with feedbacks 12 | - Redo the tag and `make distrib` 13 | - Push-force on the same branch `prepare-vX.Y.Z` 14 | 15 | Only one commit should contains the diff on `CHANGES.md` 16 | 17 | If everything is ok: 18 | - `git tag vX.Y.Z` 19 | - Execute `./configure.sh` to generate `Makeconf` 20 | - Execute `make distrib` 21 | - Execute `./scripts/opam-release.sh` 22 | - Push the tag: `git push --tags` 23 | - On GitHub, you must create a new release which includes the 24 | `solo5-vX.Y.Z.tar.gz` artifact 25 | - Locally, you can clone `ocaml/opam-repository` and copy OPAM files into 26 | `ocaml/opam-repository/packages` 27 | - Make a pull-request on `ocaml/opam-repository` 28 | - Waiting review and that's all! 29 | -------------------------------------------------------------------------------- /bindings/abort.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | /* 24 | * These functions deliberately do not call printf() or malloc() in order to 25 | * abort as quickly as possible without triggering further errors. 26 | */ 27 | 28 | static void puts(const char *s) 29 | { 30 | (void)platform_puts(s, strlen(s)); 31 | } 32 | 33 | void _assert_fail(const char *file, const char *line, const char *e) 34 | { 35 | puts("Solo5: ABORT: "); 36 | puts(file); 37 | puts(":"); 38 | puts(line); 39 | puts(": Assertion `"); 40 | puts(e); 41 | puts("' failed\n"); 42 | platform_exit(SOLO5_EXIT_ABORT, NULL); 43 | } 44 | 45 | void _abort(const char *file, const char *line, const char *s, void *regs_hint) 46 | { 47 | puts("Solo5: ABORT: "); 48 | puts(file); 49 | puts(":"); 50 | puts(line); 51 | puts(": "); 52 | puts(s); 53 | puts("\n"); 54 | platform_exit(SOLO5_EXIT_ABORT, regs_hint); 55 | } 56 | -------------------------------------------------------------------------------- /bindings/cpu_aarch64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | #ifndef __CPU_AARCH64_H__ 21 | #define __CPU_AARCH64_H__ 22 | 23 | /* memory defines */ 24 | #define PAGE_SIZE 4096 25 | #define PAGE_SHIFT 12 26 | #define PAGE_MASK ~(0xfff) 27 | 28 | #ifndef _BITUL 29 | 30 | #ifdef ASM_FILE 31 | #define _AC(X,Y) X 32 | #define _AT(T,X) X 33 | #else 34 | #define __AC(X,Y) (X##Y) 35 | #define _AC(X,Y) __AC(X,Y) 36 | #define _AT(T,X) ((T)(X)) 37 | #endif 38 | 39 | #define _BITUL(x) (_AC(1,UL) << (x)) 40 | #define _BITULL(x) (_AC(1,ULL) << (x)) 41 | 42 | #endif 43 | 44 | #define ESR_EC_IABT_LOW _AC(0x20, UL) 45 | #define ESR_EC_IABT_CUR _AC(0x21, UL) 46 | #define ESR_EC_DABT_LOW _AC(0x24, UL) 47 | #define ESR_EC_DABT_CUR _AC(0x25, UL) 48 | 49 | #define ESR_EC_SHIFT _AC(26, UL) 50 | #define ESR_EC_MASK (_AC(0x3F, UL) << ESR_EC_SHIFT) 51 | #define ESR_EC(esr) (((esr) & ESR_EC_MASK) >> ESR_EC_SHIFT) 52 | 53 | #ifndef ASM_FILE 54 | 55 | /* 56 | * The remainder of this file is used only from C. 57 | */ 58 | static inline uint64_t cpu_cntvct(void) 59 | { 60 | uint64_t val; 61 | 62 | __asm__ __volatile__("mrs %0, cntvct_el0" : "=r" (val)::); 63 | return val; 64 | } 65 | 66 | static inline uint64_t mul64_32(uint64_t a, uint32_t b, uint8_t s) 67 | { 68 | return (a * b) >> s; 69 | } 70 | #endif /* !ASM_FILE */ 71 | 72 | static inline void cpu_set_tls_base(uint64_t base) 73 | { 74 | __asm__ __volatile("msr tpidr_el0, %0" :: "r"(base)); 75 | } 76 | 77 | #endif /* __CPU_AARCH64_H__ */ 78 | -------------------------------------------------------------------------------- /bindings/cpu_ppc64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | #ifndef __CPU_PPC64_H__ 21 | #define __CPU_PPC64_H__ 22 | 23 | /* memory defines */ 24 | #define PAGE_SIZE (64 * 1024) 25 | #define PAGE_SHIFT 16 26 | #define PAGE_MASK ~(0xffff) 27 | 28 | #define CR0_SO (0x80000000 >> 3) /* summary overflow; 29 | indicates syscall error */ 30 | 31 | #ifndef ASM_FILE 32 | 33 | /* 34 | * The remainder of this file is used only from C. 35 | */ 36 | static inline uint64_t cpu_cntvct(void) 37 | { 38 | uint64_t val; 39 | 40 | __asm__ __volatile__( 41 | "mfspr %0, 268\n" 42 | : "=r" (val) 43 | : 44 | :); 45 | 46 | return val; 47 | } 48 | 49 | static inline void cpu_set_tls_base(uint64_t base) 50 | { 51 | __asm__ __volatile( 52 | "mr 13, %0\n" 53 | : 54 | : "a" (base) 55 | : "r13"); 56 | } 57 | 58 | #endif /* !ASM_FILE */ 59 | 60 | #endif /* __CPU_PPC64_H__ */ 61 | -------------------------------------------------------------------------------- /bindings/crt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | /* 24 | * The stack canary value will be initialised to a pseudo-random value by 25 | * crt_init_early(), keep an easily recognisable "terminator" value here to 26 | * flag if that did not happen as expected. 27 | */ 28 | uintptr_t SSP_GUARD_SYMBOL = 0x00deadbeef0d0a00; 29 | 30 | /* 31 | * Called by compiler-generated code when corruption of the canary value is 32 | * detected. There is very little we can do here safely, so just print a 33 | * message and abort, taking care to make minimal use of the stack. 34 | */ 35 | static const char 36 | stack_chk_fail_message[] = "Solo5: ABORT: Stack corruption detected\n"; 37 | 38 | __attribute__((noreturn)) 39 | void SSP_FAIL_SYMBOL(void) 40 | { 41 | platform_puts(stack_chk_fail_message, sizeof stack_chk_fail_message); 42 | platform_exit(SOLO5_EXIT_ABORT, NULL); 43 | } 44 | -------------------------------------------------------------------------------- /bindings/crt_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | extern uintptr_t SSP_GUARD_SYMBOL; 22 | 23 | #if defined(__x86_64__) 24 | #define READ_CPU_TICKS cpu_rdtsc 25 | #elif defined(__aarch64__) 26 | #define READ_CPU_TICKS cpu_cntvct 27 | #elif defined(__powerpc64__) 28 | #define READ_CPU_TICKS cpu_cntvct 29 | #else 30 | #error Unsupported architecture 31 | #endif 32 | 33 | /* 34 | * This function must be inlined as early as possible once in C code, before 35 | * calling any other functions. The calling function must not return. 36 | */ 37 | 38 | __attribute__((always_inline)) static inline void crt_init_ssp(void) 39 | { 40 | /* 41 | * Initialise the stack canary value. 42 | */ 43 | SSP_GUARD_SYMBOL = READ_CPU_TICKS() + (READ_CPU_TICKS() << 32UL); 44 | SSP_GUARD_SYMBOL &= ~(uintptr_t)0xff00; 45 | } 46 | 47 | /* 48 | * Explicitly disable any accidental use of TLS by setting the arch-specific 49 | * TLS base to zero, thus causing TLS access to point to the zero page. 50 | */ 51 | 52 | __attribute__((always_inline)) static inline void crt_init_tls(void) 53 | { 54 | (void)platform_set_tls_base(0); 55 | } 56 | -------------------------------------------------------------------------------- /bindings/exit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | void solo5_exit(int status) 24 | { 25 | log(INFO, "Solo5: solo5_exit(%d) called\n", status); 26 | platform_exit(status, NULL); 27 | } 28 | 29 | void solo5_abort(void) 30 | { 31 | log(INFO, "Solo5: solo5_abort() called\n"); 32 | platform_exit(SOLO5_EXIT_ABORT, NULL); 33 | } 34 | -------------------------------------------------------------------------------- /bindings/hvt/bindings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * bindings.h: Solo5 bindings, hvt implementation additions. 23 | * 24 | * This header file includes (supersedes) the common bindings.h for the hvt 25 | * implementation. 26 | */ 27 | 28 | #ifndef __HVT_BINDINGS_H__ 29 | #define __HVT_BINDINGS_H__ 30 | 31 | #include "../bindings.h" 32 | #include "hvt_abi.h" 33 | 34 | void time_init(const struct hvt_boot_info *bi); 35 | void console_init(void); 36 | void net_init(const struct hvt_boot_info *bi); 37 | void block_init(const struct hvt_boot_info *bi); 38 | 39 | /* tscclock.c: TSC-based clock */ 40 | uint64_t tscclock_monotonic(void); 41 | int tscclock_init(uint64_t tsc_freq); 42 | uint64_t tscclock_epochoffset(void); 43 | 44 | void process_bootinfo(const void *arg); 45 | 46 | #endif /* __HVT_BINDINGS_H__ */ 47 | -------------------------------------------------------------------------------- /bindings/hvt/console.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | int platform_puts(const char *buf, int n) 24 | { 25 | struct hvt_hc_puts str; 26 | 27 | str.data = (char *)buf; 28 | str.len = n; 29 | 30 | hvt_do_hypercall(HVT_HYPERCALL_PUTS, &str); 31 | 32 | return str.len; 33 | } 34 | 35 | void solo5_console_write(const char *buf, size_t size) 36 | { 37 | (void)platform_puts(buf, size); 38 | } 39 | 40 | void console_init(void) 41 | { 42 | } 43 | -------------------------------------------------------------------------------- /bindings/hvt/net.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | static const struct mft *mft; 24 | 25 | solo5_result_t solo5_net_write(solo5_handle_t handle, const uint8_t *buf, 26 | size_t size) 27 | { 28 | volatile struct hvt_hc_net_write wr; 29 | 30 | wr.handle = handle; 31 | wr.data = buf; 32 | wr.len = size; 33 | wr.ret = 0; 34 | 35 | hvt_do_hypercall(HVT_HYPERCALL_NET_WRITE, &wr); 36 | 37 | return wr.ret; 38 | } 39 | 40 | solo5_result_t solo5_net_read(solo5_handle_t handle, uint8_t *buf, size_t size, 41 | size_t *read_size) 42 | { 43 | volatile struct hvt_hc_net_read rd; 44 | 45 | rd.handle = handle; 46 | rd.data = buf; 47 | rd.len = size; 48 | rd.ret = 0; 49 | 50 | hvt_do_hypercall(HVT_HYPERCALL_NET_READ, &rd); 51 | 52 | *read_size = rd.len; 53 | return rd.ret; 54 | } 55 | 56 | solo5_result_t solo5_net_acquire(const char *name, solo5_handle_t *handle, 57 | struct solo5_net_info *info) 58 | { 59 | unsigned index; 60 | const struct mft_entry *e = 61 | mft_get_by_name(mft, name, MFT_DEV_NET_BASIC, &index); 62 | if (e == NULL) 63 | return SOLO5_R_EINVAL; 64 | assert(e->attached); 65 | 66 | *handle = index; 67 | info->mtu = e->u.net_basic.mtu; 68 | memcpy(info->mac_address, e->u.net_basic.mac, 69 | sizeof info->mac_address); 70 | return SOLO5_R_OK; 71 | } 72 | 73 | void net_init(const struct hvt_boot_info *bi) 74 | { 75 | mft = bi->mft; 76 | } 77 | -------------------------------------------------------------------------------- /bindings/hvt/platform.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | static const char *cmdline; 24 | static uint64_t mem_size; 25 | 26 | void process_bootinfo(const void *arg) 27 | { 28 | const struct hvt_boot_info *bi = arg; 29 | 30 | cmdline = bi->cmdline; 31 | mem_size = bi->mem_size; 32 | } 33 | 34 | const char *platform_cmdline(void) 35 | { 36 | return cmdline; 37 | } 38 | 39 | uint64_t platform_mem_size(void) 40 | { 41 | return mem_size; 42 | } 43 | 44 | int platform_set_tls_base(uint64_t base) 45 | { 46 | cpu_set_tls_base(base); 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /bindings/hvt/platform_intr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | /* 24 | * Interrupts are not used on the hvt platform, hence these are stubs. 25 | */ 26 | 27 | void platform_intr_ack_irq(unsigned irq __attribute__((unused))) 28 | { 29 | } 30 | 31 | void platform_intr_mask_irq(unsigned irq __attribute__((unused))) 32 | { 33 | } 34 | 35 | void platform_intr_clear_irq(unsigned irq __attribute__((unused))) 36 | { 37 | } 38 | -------------------------------------------------------------------------------- /bindings/hvt/platform_lifecycle.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | void platform_init(const void *arg) 24 | { 25 | process_bootinfo(arg); 26 | } 27 | 28 | void platform_exit(int status, void *cookie) 29 | { 30 | struct hvt_hc_halt h; 31 | 32 | h.exit_status = status; 33 | h.cookie = cookie; 34 | 35 | hvt_do_hypercall(HVT_HYPERCALL_HALT, &h); 36 | for(;;); 37 | } 38 | -------------------------------------------------------------------------------- /bindings/hvt/start.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | #include "../crt_init.h" 23 | #include "version.h" 24 | 25 | void _start(const void *arg) 26 | { 27 | crt_init_ssp(); 28 | crt_init_tls(); 29 | 30 | static struct solo5_start_info si; 31 | 32 | console_init(); 33 | cpu_init(); 34 | platform_init(arg); 35 | si.cmdline = cmdline_parse(platform_cmdline()); 36 | 37 | log(INFO, " | ___|\n"); 38 | log(INFO, " __| _ \\ | _ \\ __ \\\n"); 39 | log(INFO, "\\__ \\ ( | | ( | ) |\n"); 40 | log(INFO, "____/\\___/ _|\\___/____/\n"); 41 | log(INFO, "Solo5: Bindings version %s\n", SOLO5_VERSION); 42 | 43 | mem_init(); 44 | time_init(arg); 45 | block_init(arg); 46 | net_init(arg); 47 | 48 | mem_lock_heap(&si.heap_start, &si.heap_size); 49 | solo5_exit(solo5_app_main(&si)); 50 | } 51 | 52 | /* 53 | * Place the .interp section in this module, as it comes first in the link 54 | * order. 55 | */ 56 | DECLARE_ELF_INTERP 57 | 58 | /* 59 | * The "ABI1" Solo5 ELF note is declared in this module. 60 | * 61 | */ 62 | ABI1_NOTE_DECLARE_BEGIN 63 | { 64 | .abi_target = HVT_ABI_TARGET, 65 | .abi_version = HVT_ABI_VERSION 66 | } 67 | ABI1_NOTE_DECLARE_END 68 | 69 | /* 70 | * Pretend that we are an OpenBSD executable. See elf_abi.h for details. 71 | */ 72 | DECLARE_OPENBSD_NOTE 73 | -------------------------------------------------------------------------------- /bindings/hvt/time.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | void time_init(const struct hvt_boot_info *bi) 24 | { 25 | assert(tscclock_init(bi->cpu_cycle_freq) == 0); 26 | } 27 | 28 | uint64_t solo5_clock_monotonic(void) 29 | { 30 | return tscclock_monotonic(); 31 | } 32 | 33 | /* return wall time in nsecs */ 34 | uint64_t solo5_clock_wall(void) 35 | { 36 | struct hvt_hc_walltime t; 37 | hvt_do_hypercall(HVT_HYPERCALL_WALLTIME, &t); 38 | return t.nsecs; 39 | } 40 | -------------------------------------------------------------------------------- /bindings/hvt/yield.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | void solo5_yield(solo5_time_t deadline, solo5_handle_set_t *ready_set) 24 | { 25 | struct hvt_hc_poll t; 26 | uint64_t now; 27 | 28 | now = solo5_clock_monotonic(); 29 | if (deadline <= now) 30 | t.timeout_nsecs = 0; 31 | else 32 | t.timeout_nsecs = deadline - now; 33 | hvt_do_hypercall(HVT_HYPERCALL_POLL, &t); 34 | if (ready_set != NULL) 35 | *ready_set = t.ready_set; 36 | } 37 | -------------------------------------------------------------------------------- /bindings/intr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | #define MAX_IRQ_HANDLER_ENTRIES 8 24 | 25 | struct irq_handler { 26 | int (*handler)(void *); 27 | void *arg; 28 | }; 29 | 30 | struct irq_handler_list { 31 | int num_entries; 32 | struct irq_handler entries[MAX_IRQ_HANDLER_ENTRIES]; 33 | }; 34 | 35 | static struct irq_handler_list irq_handlers[16]; 36 | 37 | void intr_register_irq(unsigned irq, int (*handler)(void *), void *arg) 38 | { 39 | assert(irq < 16); 40 | assert(irq_handlers[irq].num_entries < MAX_IRQ_HANDLER_ENTRIES); 41 | 42 | cpu_intr_disable(); 43 | 44 | int idx = irq_handlers[irq].num_entries; 45 | struct irq_handler *h = &irq_handlers[irq].entries[idx]; 46 | 47 | h->handler = handler; 48 | h->arg = arg; 49 | irq_handlers[irq].num_entries++; 50 | 51 | cpu_intr_enable(); 52 | platform_intr_clear_irq(irq); 53 | } 54 | 55 | void intr_irq_handler(uint64_t irq) 56 | { 57 | int handled = 0; 58 | int i; 59 | 60 | for (i = 0; i < irq_handlers[irq].num_entries; i++) { 61 | struct irq_handler *h = &irq_handlers[irq].entries[i]; 62 | if (h->handler(h->arg) == 1) { 63 | handled = 1; 64 | break; 65 | } 66 | } 67 | 68 | if (!handled) 69 | log(ERROR, "Solo5: unhandled irq %llu\n", (unsigned long long)irq); 70 | else 71 | /* Only ACK the IRQ if handled; we only need to know about an unhandled 72 | * IRQ the first time round. */ 73 | platform_intr_ack_irq(irq); 74 | } 75 | -------------------------------------------------------------------------------- /bindings/log.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | #include "bindings.h" 21 | #include "printf.h" 22 | 23 | static log_level_t log_level = INFO; 24 | 25 | int log(log_level_t level, const char *fmt, ...) 26 | { 27 | if (log_level < level) { 28 | return 0; 29 | } 30 | 31 | va_list args; 32 | size_t size; 33 | /* 34 | * buffer[] might be on an IST stack, so pick an arbitrary-but-not-too-big 35 | * size (4 display lines). 36 | */ 37 | char buffer[320]; 38 | 39 | va_start(args, fmt); 40 | size = vsnprintf(buffer, sizeof buffer, fmt, args); 41 | va_end(args); 42 | 43 | /* 44 | * If the message doesn't fit into the buffer, at least try and tell the 45 | * user about it. 46 | */ 47 | if (size >= sizeof buffer) { 48 | const char trunc[] = "(truncated)\n"; 49 | platform_puts(buffer, sizeof buffer - 1); 50 | platform_puts(trunc, sizeof trunc - 1); 51 | return sizeof buffer - 1; 52 | } else { 53 | platform_puts(buffer, size); 54 | return size; 55 | } 56 | } 57 | 58 | void log_set_level(log_level_t level) 59 | { 60 | log_level = level; 61 | } 62 | -------------------------------------------------------------------------------- /bindings/mft.c: -------------------------------------------------------------------------------- 1 | #include "bindings.h" 2 | 3 | #include "../tenders/common/mft.c" 4 | -------------------------------------------------------------------------------- /bindings/mft.h: -------------------------------------------------------------------------------- 1 | #include "../tenders/common/mft.h" 2 | -------------------------------------------------------------------------------- /bindings/muen/bindings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * bindings.h: Solo5 bindings, muen implementation additions. 23 | * 24 | * This header file includes (supersedes) the common bindings.h for the muen 25 | * implementation. 26 | * 27 | * TODO: Remove the dependency on hvt_abi.h entirely? 28 | */ 29 | 30 | #ifndef __MUEN_BINDINGS_H__ 31 | #define __MUEN_BINDINGS_H__ 32 | 33 | #include "../bindings.h" 34 | #include "hvt_abi.h" 35 | #include "elf_abi.h" 36 | 37 | void time_init(void); 38 | void console_init(void); 39 | void net_init(const struct hvt_boot_info *bi); 40 | void block_init(const struct hvt_boot_info *bi); 41 | 42 | /* muen-clock.c: TSC-based clock */ 43 | uint64_t tscclock_epochoffset(void); 44 | 45 | void process_bootinfo(const void *arg); 46 | 47 | #endif /* __MUEN_BINDINGS_H__ */ 48 | -------------------------------------------------------------------------------- /bindings/muen/channel.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "channel.h" 22 | 23 | inline bool muen_channel_is_active(const struct muchannel * const channel) 24 | { 25 | return channel->hdr.epoch != MUCHANNEL_NULL_EPOCH; 26 | } 27 | -------------------------------------------------------------------------------- /bindings/muen/channel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #ifndef MUEN_CHANNEL_H 22 | #define MUEN_CHANNEL_H 23 | 24 | #include 25 | #include 26 | 27 | /* 28 | * Muen shared memory channels. 29 | * 30 | * Muen shared memory channels are an implementation of the SHMStream Version 2 31 | * IPC protocol (shmstream) as specified by 'SHMStream Version 2 IPC Interface'. 32 | */ 33 | 34 | #define SHMSTREAM20 0x487312b6b79a9b6dULL 35 | #define MUCHANNEL_NULL_EPOCH 0 36 | 37 | struct muchannel_header { 38 | uint64_t transport; 39 | uint64_t epoch; 40 | uint64_t protocol; 41 | uint64_t size; 42 | uint64_t elements; 43 | uint64_t __reserved; 44 | uint64_t wsc; 45 | uint64_t wc; 46 | } __attribute__((packed, aligned(8))); 47 | 48 | struct muchannel { 49 | struct muchannel_header hdr; 50 | char data[]; 51 | }; 52 | 53 | /* 54 | * Returns True if the channe is currently active. 55 | */ 56 | bool muen_channel_is_active(const struct muchannel * const channel); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /bindings/muen/muen-block.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | solo5_result_t solo5_block_acquire(const char *name __attribute__((unused)), 24 | solo5_handle_t *handle __attribute__((unused)), 25 | struct solo5_block_info *info __attribute__((unused))) 26 | { 27 | return SOLO5_R_EUNSPEC; 28 | } 29 | 30 | solo5_result_t solo5_block_write(solo5_handle_t handle __attribute__((unused)), 31 | solo5_off_t offset __attribute__((unused)), 32 | const uint8_t *buf __attribute__((unused)), 33 | size_t size __attribute__((unused))) 34 | { 35 | return SOLO5_R_EUNSPEC; 36 | } 37 | 38 | solo5_result_t solo5_block_read(solo5_handle_t handle __attribute__((unused)), 39 | solo5_off_t offset __attribute__((unused)), 40 | uint8_t *buf __attribute__((unused)), 41 | size_t size __attribute__((unused))) 42 | { 43 | return SOLO5_R_EUNSPEC; 44 | } 45 | 46 | void block_init(const struct hvt_boot_info *bi __attribute__((unused))) 47 | { 48 | } 49 | -------------------------------------------------------------------------------- /bindings/muen/muen-net.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #ifndef MUEN_NET_H 22 | #define MUEN_NET_H 23 | 24 | /* 25 | * Returns True if the network device designated by handle has pending data. 26 | */ 27 | bool muen_net_pending_data(solo5_handle_t handle); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /bindings/muen/muen-platform_lifecycle.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | #include "sinfo.h" 23 | 24 | const struct mft *muen_manifest = NULL; 25 | 26 | extern const struct mft1_note __solo5_mft1_note; 27 | 28 | void trigger_exit_event() 29 | { 30 | const struct muen_resource_type *const 31 | event = muen_get_resource("solo5_exit", MUEN_RES_EVENT); 32 | 33 | if (!event) { 34 | return; 35 | } 36 | 37 | __asm__ __volatile__("vmcall": : "a"(event->data.number) : "memory"); 38 | } 39 | 40 | void platform_init(const void *arg) 41 | { 42 | process_bootinfo(arg); 43 | 44 | /* 45 | * Get the built-in manifest out of the ELF NOTE and validate it. 46 | * Once validated, it is available for access globally by the bindings. 47 | */ 48 | const struct mft *mft; 49 | size_t mft_size; 50 | mft_get_builtin_mft1(&__solo5_mft1_note, &mft, &mft_size); 51 | if (mft_validate(mft, mft_size) != 0) { 52 | log(ERROR, "Solo5: Built-in manifest validation failed. Aborting.\n"); 53 | solo5_abort(); 54 | } 55 | muen_manifest = mft; 56 | } 57 | 58 | void platform_exit(int status __attribute__((unused)), 59 | void *cookie __attribute__((unused))) 60 | { 61 | const char msg[] = "Solo5: Halted\n"; 62 | platform_puts(msg, strlen(msg)); 63 | trigger_exit_event(); 64 | __asm__ __volatile__("cli; hlt"); 65 | for (;;); 66 | } 67 | -------------------------------------------------------------------------------- /bindings/muen/muen-yield.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | #include "muen-net.h" 23 | 24 | void solo5_yield(solo5_time_t deadline, solo5_handle_set_t *ready_set) 25 | { 26 | solo5_handle_set_t tmp_ready_set = 0; 27 | 28 | do { 29 | for (solo5_handle_t i = 0U; i < MFT_MAX_ENTRIES; ++i) { 30 | if (muen_net_pending_data(i)) 31 | tmp_ready_set |= 1UL << i; 32 | } 33 | 34 | if (tmp_ready_set > 0) 35 | break; 36 | 37 | __asm__ __volatile__("pause"); 38 | } while (solo5_clock_monotonic() < deadline); 39 | 40 | if (ready_set) 41 | *ready_set = tmp_ready_set; 42 | } 43 | -------------------------------------------------------------------------------- /bindings/muen/muschedinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #ifndef MUSCHEDINFO_H 22 | #define MUSCHEDINFO_H 23 | 24 | struct scheduling_info_type { 25 | uint64_t tsc_schedule_start; 26 | uint64_t tsc_schedule_end; 27 | } __attribute__((packed)); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /bindings/muen/mutimeinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #ifndef MUTIMEINFO_H 22 | #define MUTIMEINFO_H 23 | 24 | struct time_info_type { 25 | uint64_t tsc_time_base; 26 | uint64_t tsc_tick_rate_hz; 27 | int64_t timezone_microsecs; 28 | } __attribute__((packed)); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /bindings/muen/reader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #ifndef MUEN_CHANNEL_READER_H 22 | #define MUEN_CHANNEL_READER_H 23 | 24 | #include "channel.h" 25 | 26 | enum muchannel_reader_result { 27 | MUCHANNEL_INACTIVE, 28 | MUCHANNEL_INCOMPATIBLE_INTERFACE, 29 | MUCHANNEL_EPOCH_CHANGED, 30 | MUCHANNEL_NO_DATA, 31 | MUCHANNEL_OVERRUN_DETECTED, 32 | MUCHANNEL_SUCCESS 33 | }; 34 | 35 | struct muchannel_reader { 36 | uint64_t epoch; 37 | uint64_t protocol; 38 | uint64_t size; 39 | uint64_t elements; 40 | uint64_t rc; 41 | }; 42 | 43 | /* 44 | * Initialize reader with given protocol. 45 | */ 46 | void muen_channel_init_reader(struct muchannel_reader *reader, uint64_t protocol); 47 | 48 | /* 49 | * Read next element from given channel. 50 | */ 51 | enum muchannel_reader_result muen_channel_read( 52 | const struct muchannel * const channel, 53 | struct muchannel_reader *reader, 54 | void *element); 55 | 56 | /* 57 | * Drain all current channel elements. 58 | */ 59 | void muen_channel_drain(const struct muchannel * const channel, 60 | struct muchannel_reader *reader); 61 | 62 | /* 63 | * Returns True if there is pending data in the channel. 64 | */ 65 | bool muen_channel_has_pending_data(const struct muchannel * const channel, 66 | struct muchannel_reader *reader); 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /bindings/muen/start.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | #include "../crt_init.h" 23 | #include "version.h" 24 | 25 | void _start(void *arg) 26 | { 27 | crt_init_ssp(); 28 | crt_init_tls(); 29 | 30 | static struct solo5_start_info si; 31 | 32 | console_init(); 33 | cpu_init(); 34 | platform_init(arg); 35 | si.cmdline = cmdline_parse(platform_cmdline()); 36 | 37 | log(INFO, " | ___|\n"); 38 | log(INFO, " __| _ \\ | _ \\ __ \\\n"); 39 | log(INFO, "\\__ \\ ( | | ( | ) |\n"); 40 | log(INFO, "____/\\___/ _|\\___/____/\n"); 41 | log(INFO, "Solo5: Bindings version %s\n", SOLO5_VERSION); 42 | 43 | mem_init(); 44 | time_init(); 45 | block_init(arg); 46 | net_init(arg); 47 | 48 | mem_lock_heap(&si.heap_start, &si.heap_size); 49 | solo5_exit(solo5_app_main(&si)); 50 | } 51 | 52 | /* 53 | * Place the .interp section in this module, as it comes first in the link 54 | * order. 55 | */ 56 | DECLARE_ELF_INTERP 57 | 58 | /* 59 | * The "ABI1" Solo5 ELF note is declared in this module. 60 | * 61 | * Solo5/Muen uses ABI version 2 as of Muen commit 2a64844. 62 | */ 63 | ABI1_NOTE_DECLARE_BEGIN 64 | { 65 | .abi_target = MUEN_ABI_TARGET, 66 | .abi_version = 3 67 | } 68 | ABI1_NOTE_DECLARE_END 69 | 70 | /* 71 | * Pretend that we are an OpenBSD executable. See elf_abi.h for details. 72 | */ 73 | DECLARE_OPENBSD_NOTE 74 | -------------------------------------------------------------------------------- /bindings/muen/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #ifndef MUEN_UTIL_H 22 | #define MUEN_UTIL_H 23 | 24 | #include "bindings.h" 25 | 26 | static inline void serialized_copy(const uint64_t * const src, uint64_t *dst) 27 | { 28 | cc_barrier(); 29 | *dst = *src; 30 | cc_barrier(); 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /bindings/muen/writer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | #include "writer.h" 23 | #include "util.h" 24 | 25 | void muen_channel_init_writer(struct muchannel *channel, const uint64_t protocol, 26 | const uint64_t element_size, const uint64_t channel_size, 27 | const uint64_t epoch) 28 | { 29 | uint64_t data_size; 30 | 31 | muen_channel_deactivate(channel); 32 | memset(channel, 0, sizeof(struct muchannel)); 33 | data_size = channel_size - sizeof(struct muchannel_header); 34 | memset(channel->data, 0, data_size); 35 | 36 | channel->hdr.transport = SHMSTREAM20; 37 | channel->hdr.protocol = protocol; 38 | channel->hdr.size = element_size; 39 | channel->hdr.elements = data_size / element_size; 40 | channel->hdr.wsc = 0; 41 | channel->hdr.wc = 0; 42 | 43 | serialized_copy(&epoch, &channel->hdr.epoch); 44 | } 45 | 46 | void muen_channel_deactivate(struct muchannel *channel) 47 | { 48 | channel->hdr.epoch = MUCHANNEL_NULL_EPOCH; 49 | cc_barrier(); 50 | } 51 | 52 | void muen_channel_write(struct muchannel *channel, const void * const element) 53 | { 54 | uint64_t wc, pos, size; 55 | 56 | size = channel->hdr.size; 57 | wc = channel->hdr.wc; 58 | pos = wc % channel->hdr.elements; 59 | 60 | wc++; 61 | 62 | serialized_copy(&wc, &channel->hdr.wsc); 63 | memcpy(channel->data + pos * size, element, size); 64 | serialized_copy(&wc, &channel->hdr.wc); 65 | } 66 | -------------------------------------------------------------------------------- /bindings/muen/writer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #ifndef MUEN_CHANNEL_WRITER_H 22 | #define MUEN_CHANNEL_WRITER_H 23 | 24 | #include "channel.h" 25 | 26 | /** 27 | * Initialize channel with given parameters. 28 | */ 29 | void muen_channel_init_writer(struct muchannel *channel, const uint64_t protocol, 30 | const uint64_t element_size, const uint64_t channel_size, 31 | const uint64_t epoch); 32 | 33 | /** 34 | * Deactivate channel. 35 | */ 36 | void muen_channel_deactivate(struct muchannel *channel); 37 | 38 | /** 39 | * Write element to given channel. 40 | */ 41 | void muen_channel_write(struct muchannel *channel, const void * const element); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /bindings/printf.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // \author (c) Marco Paland (info@paland.com) 3 | // 2014-2018, PALANDesign Hannover, Germany 4 | // 5 | // \license The MIT License (MIT) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | // \brief Tiny printf, sprintf and snprintf implementation, optimized for speed on 26 | // embedded systems with a very limited resources. 27 | // Use this instead of bloated standard/newlib printf. 28 | // These routines are thread safe and reentrant. 29 | // 30 | /////////////////////////////////////////////////////////////////////////////// 31 | 32 | #ifndef _PRINTF_H_ 33 | #define _PRINTF_H_ 34 | 35 | #include 36 | #include 37 | 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | 44 | /** 45 | * Tiny snprintf/vsnprintf implementation 46 | * \param buffer A pointer to the buffer where to store the formatted string 47 | * \param count The maximum number of characters to store in the buffer, including a terminating null character 48 | * \param format A string that specifies the format of the output 49 | * \return The number of characters that are WRITTEN into the buffer, not counting the terminating null character 50 | * If the formatted string is truncated the buffer size (count) is returned 51 | */ 52 | int snprintf(char* buffer, size_t count, const char* format, ...); 53 | int vsnprintf(char* buffer, size_t count, const char* format, va_list va); 54 | 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | 61 | #endif // _PRINTF_H_ 62 | -------------------------------------------------------------------------------- /bindings/spt/bindings.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | void solo5_console_write(const char *buf, size_t size) 24 | { 25 | (void)sys_write(SYS_STDOUT, buf, size); 26 | } 27 | 28 | /* solo5_exit is in exit.c */ 29 | 30 | /* solo5_abort is in abort.c */ 31 | 32 | solo5_time_t solo5_clock_monotonic(void) 33 | { 34 | struct sys_timespec ts; 35 | 36 | int rc = sys_clock_gettime(SYS_CLOCK_MONOTONIC, &ts); 37 | assert(rc == 0); 38 | return (ts.tv_sec * NSEC_PER_SEC) + ts.tv_nsec; 39 | } 40 | 41 | solo5_time_t solo5_clock_wall(void) 42 | { 43 | struct sys_timespec ts; 44 | 45 | int rc = sys_clock_gettime(SYS_CLOCK_REALTIME, &ts); 46 | assert(rc == 0); 47 | return (ts.tv_sec * NSEC_PER_SEC) + ts.tv_nsec; 48 | } 49 | 50 | /* solo5_set_tls_base is in tls.c */ 51 | -------------------------------------------------------------------------------- /bindings/spt/platform.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | static const char *cmdline; 24 | static uint64_t mem_size; 25 | 26 | void platform_init(const void *arg) 27 | { 28 | const struct spt_boot_info *bi = arg; 29 | 30 | cmdline = bi->cmdline; 31 | mem_size = bi->mem_size; 32 | } 33 | 34 | const char *platform_cmdline(void) 35 | { 36 | return cmdline; 37 | } 38 | 39 | uint64_t platform_mem_size(void) 40 | { 41 | return mem_size; 42 | } 43 | 44 | void platform_exit(int status, void *cookie __attribute__((unused))) 45 | { 46 | sys_exit_group(status); 47 | } 48 | 49 | int platform_puts(const char *buf, int n) 50 | { 51 | (void)sys_write(SYS_STDOUT, buf, n); 52 | return n; 53 | } 54 | 55 | int platform_set_tls_base(uint64_t base) 56 | { 57 | #if defined(__x86_64__) 58 | /* In x86 we need to ask the host kernel to change %fs for us. */ 59 | return sys_arch_prctl(SYS_ARCH_SET_FS, base); 60 | #elif defined(__aarch64__) 61 | cpu_set_tls_base(base); 62 | return 0; 63 | #elif defined(__powerpc64__) 64 | cpu_set_tls_base(base); 65 | return 0; 66 | #else 67 | #error Unsupported architecture 68 | #endif 69 | } 70 | -------------------------------------------------------------------------------- /bindings/spt/start.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | #include "../crt_init.h" 23 | #include "version.h" 24 | 25 | void _start(void *arg) 26 | { 27 | crt_init_ssp(); 28 | crt_init_tls(); 29 | 30 | static struct solo5_start_info si; 31 | 32 | platform_init(arg); 33 | si.cmdline = cmdline_parse(platform_cmdline()); 34 | 35 | log(INFO, " | ___|\n"); 36 | log(INFO, " __| _ \\ | _ \\ __ \\\n"); 37 | log(INFO, "\\__ \\ ( | | ( | ) |\n"); 38 | log(INFO, "____/\\___/ _|\\___/____/\n"); 39 | log(INFO, "Solo5: Bindings version %s\n", SOLO5_VERSION); 40 | 41 | mem_init(); 42 | block_init(arg); 43 | net_init(arg); 44 | 45 | mem_lock_heap(&si.heap_start, &si.heap_size); 46 | solo5_exit(solo5_app_main(&si)); 47 | } 48 | 49 | /* 50 | * Place the .interp section in this module, as it comes first in the link 51 | * order. 52 | */ 53 | DECLARE_ELF_INTERP 54 | 55 | /* 56 | * The "ABI1" Solo5 ELF note is declared in this module. 57 | */ 58 | ABI1_NOTE_DECLARE_BEGIN 59 | { 60 | .abi_target = SPT_ABI_TARGET, 61 | .abi_version = SPT_ABI_VERSION 62 | } 63 | ABI1_NOTE_DECLARE_END 64 | 65 | /* 66 | * Pretend that we are an OpenBSD executable. See elf_abi.h for details. 67 | */ 68 | DECLARE_OPENBSD_NOTE 69 | -------------------------------------------------------------------------------- /bindings/virtio/bindings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * bindings.h: Solo5 bindings, virtio implementation additions. 23 | * 24 | * This header file includes (supersedes) the common bindings.h for the virtio 25 | * implementation. 26 | */ 27 | 28 | #ifndef __VIRTIO_BINDINGS_H__ 29 | #define __VIRTIO_BINDINGS_H__ 30 | 31 | #include "../bindings.h" 32 | #include "multiboot.h" 33 | #include "elf_abi.h" 34 | 35 | /* serial.c: console output for debugging */ 36 | void serial_init(void); 37 | void serial_putc(char a); 38 | 39 | void time_init(void); 40 | 41 | /* pvclock.c: KVM paravirtualized clock */ 42 | int pvclock_init(void); 43 | uint64_t pvclock_monotonic(void); 44 | uint64_t pvclock_epochoffset(void); 45 | 46 | /* tscclock.c: TSC/PIT-based clock and sleep */ 47 | int tscclock_init(void); 48 | uint64_t tscclock_monotonic(void); 49 | uint64_t rtc_gettimeofday(void); 50 | void cpu_block(uint64_t until); 51 | 52 | /* pci.c: only enumerate for now */ 53 | struct pci_config_info { 54 | uint8_t bus; 55 | uint8_t dev; 56 | uint16_t vendor_id; 57 | uint16_t subsys_id; 58 | uint16_t base; 59 | uint8_t irq; 60 | }; 61 | 62 | int pci_enumerate(void); 63 | 64 | int virtio_config_network(struct pci_config_info *, solo5_handle_t); 65 | int virtio_config_block(struct pci_config_info *, solo5_handle_t); 66 | 67 | #endif /* __VIRTIO_BINDINGS_H__ */ 68 | -------------------------------------------------------------------------------- /bindings/virtio/serial.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | #define COM1 0x3f8 24 | 25 | #define COM1_DATA (COM1 + 0) 26 | #define COM1_INTR (COM1 + 1) 27 | #define COM1_CTRL (COM1 + 3) 28 | #define COM1_STATUS (COM1 + 5) 29 | 30 | /* only when DLAB is set */ 31 | #define COM1_DIV_LO (COM1 + 0) 32 | #define COM1_DIV_HI (COM1 + 1) 33 | 34 | #define DLAB 0x80 35 | #define PROT 0x03 /* 8N1 (8 bits, no parity, one stop bit) */ 36 | 37 | void serial_init(void) 38 | { 39 | outb(COM1_INTR, 0x00); /* Disable all interrupts */ 40 | outb(COM1_CTRL, DLAB); /* Enable DLAB (set baud rate divisor) */ 41 | outb(COM1_DIV_LO, 0x01); /* Set divisor to 1 (lo byte) 115200 baud */ 42 | outb(COM1_DIV_HI, 0x00); /* (hi byte) */ 43 | outb(COM1_CTRL, PROT); /* Set 8N1, clear DLAB */ 44 | } 45 | 46 | 47 | static int serial_tx_empty(void) 48 | { 49 | return inb(COM1_STATUS) & 0x20; 50 | } 51 | 52 | static void serial_write(char a) 53 | { 54 | while (!serial_tx_empty()) 55 | ; 56 | 57 | outb(COM1_DATA, a); 58 | } 59 | 60 | void serial_putc(char a) 61 | { 62 | if (a == '\n') 63 | serial_write('\r'); 64 | serial_write(a); 65 | } 66 | -------------------------------------------------------------------------------- /bindings/virtio/time.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | /* 24 | * The virtio target uses the KVM paravirtualized clock for timekeeping if 25 | * available, otherwise the TSC is used. CPU blocking-when-idle is performed 26 | * using the PIT via cpu_block() in tscclock.c. 27 | */ 28 | static int use_pvclock; 29 | 30 | /* return ns since time_init() */ 31 | solo5_time_t solo5_clock_monotonic(void) 32 | { 33 | if (use_pvclock) 34 | return pvclock_monotonic(); 35 | else 36 | return tscclock_monotonic(); 37 | } 38 | 39 | /* return wall time in nsecs */ 40 | solo5_time_t solo5_clock_wall(void) 41 | { 42 | if (use_pvclock) 43 | return pvclock_monotonic() + pvclock_epochoffset(); 44 | else 45 | return (rtc_gettimeofday()); 46 | } 47 | 48 | static int timer_handler(void *arg __attribute__((unused))) 49 | { 50 | /* Yes, we handled the irq. */ 51 | return 1; 52 | } 53 | 54 | /* must be called before interrupts are enabled */ 55 | void time_init(void) 56 | { 57 | intr_register_irq(0, timer_handler, NULL); 58 | use_pvclock = !pvclock_init(); 59 | 60 | if (!use_pvclock) 61 | assert(tscclock_init() == 0); 62 | } 63 | -------------------------------------------------------------------------------- /bindings/virtio/virtio_pci.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #ifndef VIRTIO_PCI_H 22 | #define VIRTIO_PCI_H 23 | 24 | /* virtio config space layout */ 25 | #define VIRTIO_PCI_HOST_FEATURES 0 /* 32-bit r/o */ 26 | #define VIRTIO_PCI_GUEST_FEATURES 4 /* 32-bit r/w */ 27 | #define VIRTIO_PCI_QUEUE_PFN 8 /* 32-bit r/w */ 28 | #define VIRTIO_PCI_QUEUE_SIZE 12 /* 16-bit r/o */ 29 | #define VIRTIO_PCI_QUEUE_SEL 14 /* 16-bit r/w */ 30 | #define VIRTIO_PCI_QUEUE_NOTIFY 16 /* 16-bit r/w */ 31 | 32 | /* How many bits to shift physical queue address written to QUEUE_PFN. 33 | * 12 is historical, and due to x86 page size. 34 | */ 35 | #define VIRTIO_PCI_QUEUE_ADDR_SHIFT 12 36 | 37 | 38 | /* The status register lets us tell the device where we are in 39 | * initialization 40 | */ 41 | #define VIRTIO_PCI_STATUS 18 /* 8-bit r/w */ 42 | #define VIRTIO_PCI_STATUS_ACK 0x1 /* we recognize device as virtio */ 43 | #define VIRTIO_PCI_STATUS_DRIVER 0x2 /* we want to drive it */ 44 | #define VIRTIO_PCI_STATUS_DRIVER_OK 0x4 /* initialization is complete */ 45 | #define VIRTIO_PCI_STATUS_FAIL 0x80 /* tell device something's wrong */ 46 | 47 | /* Reading the value will return the current contents of the interrupt 48 | * status register and will also clear it. This is effectively a 49 | * read-and-acknowledge. 50 | */ 51 | #define VIRTIO_PCI_ISR 19 /* 8-bit r/o */ 52 | #define VIRTIO_PCI_ISR_HAS_INTR 0x1 /* interrupt is for this device */ 53 | #define VIRTIO_PCI_ISR_CONFIG 0x2 /* config change bit */ 54 | 55 | /* xxx assuming msi is not configured */ 56 | #define VIRTIO_PCI_CONFIG_OFF 20 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /bindings/xen/bindings.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2020 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * bindings.h: Solo5 bindings, Xen implementation additions. 23 | * 24 | * This header file includes (supersedes) the common bindings.h for the Xen 25 | * implementation. 26 | */ 27 | 28 | #ifndef __XEN_BINDINGS_H__ 29 | #define __XEN_BINDINGS_H__ 30 | 31 | #include "../bindings.h" 32 | #include "elf_abi.h" 33 | 34 | #include "xen/xen.h" 35 | #include "xen/event_channel.h" 36 | 37 | /* console.c: Xen console */ 38 | void console_init(void); 39 | void console_write(const char *, size_t); 40 | 41 | /* pvclock.c: Xen paravirtualized clock */ 42 | int pvclock_init(void); 43 | uint64_t pvclock_monotonic(void); 44 | uint64_t pvclock_epochoffset(void); 45 | 46 | /* time.c: Timekeeping */ 47 | void time_init(void); 48 | 49 | /* evtchn.c: Xen event channel interface */ 50 | typedef void(*evtchn_handler_fn_t)(evtchn_port_t, void *); 51 | 52 | void evtchn_init(void); 53 | void evtchn_register_handler(evtchn_port_t, evtchn_handler_fn_t, void *); 54 | evtchn_port_t evtchn_bind_virq(uint32_t); 55 | void evtchn_mask(evtchn_port_t); 56 | void evtchn_unmask(evtchn_port_t); 57 | 58 | /* Accessors for Xen shared_info and VCPU 0 info structures shared with 59 | * hypervisor. 60 | */ 61 | extern uint8_t HYPERVISOR_SHARED_INFO[]; 62 | 63 | inline struct shared_info *SHARED_INFO(void) 64 | { 65 | return (struct shared_info *)&HYPERVISOR_SHARED_INFO; 66 | } 67 | 68 | inline struct vcpu_info *VCPU0_INFO(void) 69 | { 70 | return &(SHARED_INFO()->vcpu_info[0]); 71 | } 72 | 73 | #endif /* __XEN_BINDINGS_H__ */ 74 | -------------------------------------------------------------------------------- /bindings/xen/stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2020 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "bindings.h" 22 | 23 | /* 24 | * The following are stubs for public API functions that are not implemented 25 | * for the Xen target. 26 | */ 27 | #pragma GCC diagnostic ignored "-Wunused-parameter" 28 | 29 | solo5_result_t solo5_net_acquire(const char *name, solo5_handle_t *handle, 30 | struct solo5_net_info *info) 31 | { 32 | return SOLO5_R_EUNSPEC; 33 | } 34 | 35 | solo5_result_t solo5_net_write(solo5_handle_t handle, const uint8_t *buf, 36 | size_t size) 37 | { 38 | return SOLO5_R_EUNSPEC; 39 | } 40 | 41 | solo5_result_t solo5_net_read(solo5_handle_t handle, uint8_t *buf, size_t size, 42 | size_t *read_size) 43 | { 44 | return SOLO5_R_EUNSPEC; 45 | } 46 | 47 | solo5_result_t solo5_block_acquire(const char *name, solo5_handle_t *handle, 48 | struct solo5_block_info *info) 49 | { 50 | return SOLO5_R_EUNSPEC; 51 | } 52 | 53 | solo5_result_t solo5_block_write(solo5_handle_t handle, solo5_off_t offset, 54 | const uint8_t *buf, size_t size) 55 | { 56 | return SOLO5_R_EUNSPEC; 57 | } 58 | 59 | solo5_result_t solo5_block_read(solo5_handle_t handle,solo5_off_t offset, 60 | uint8_t *buf, size_t size) 61 | { 62 | return SOLO5_R_EUNSPEC; 63 | } 64 | -------------------------------------------------------------------------------- /elftool/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | ifndef TOPDIR 20 | $(error TOPDIR must be set, run $(MAKE) from the top of the source tree or set it manually) 21 | endif 22 | include $(TOPDIR)/Makefile.common 23 | 24 | .PHONY: all 25 | all: 26 | all_TARGETS := 27 | 28 | .SUFFIXES: 29 | $(V).SILENT: 30 | 31 | %.o: %.c %.d 32 | $(HOSTCOMPILE.c) 33 | 34 | %.o: %.S %.d 35 | $(HOSTCOMPILE.S) 36 | 37 | %.d: ; 38 | .PRECIOUS: %.d 39 | 40 | elftool_SRCS := elftool.c 41 | elftool_OBJS := $(patsubst %.c,%.o,$(elftool_SRCS)) 42 | 43 | all_TARGETS += solo5-elftool 44 | 45 | solo5-elftool: $(elftool_OBJS) 46 | $(HOSTLINK) 47 | 48 | all: $(all_TARGETS) 49 | 50 | all_OBJS := $(elftool_OBJS) 51 | all_DEPS := $(patsubst %.o,%.d,$(all_OBJS)) 52 | 53 | .PHONY: clean 54 | 55 | clean: 56 | @echo "CLEAN elftool" 57 | $(RM) $(all_TARGETS) $(all_OBJS) $(all_DEPS) 58 | 59 | include $(wildcard $(all_DEPS)) 60 | -------------------------------------------------------------------------------- /include/xen/COPYING: -------------------------------------------------------------------------------- 1 | XEN NOTICE 2 | ========== 3 | 4 | This copyright applies to all files within this subdirectory and its 5 | subdirectories: 6 | include/public/*.h 7 | include/public/hvm/*.h 8 | include/public/io/*.h 9 | 10 | The intention is that these files can be freely copied into the source 11 | tree of an operating system when porting that OS to run on Xen. Doing 12 | so does *not* cause the OS to become subject to the terms of the GPL. 13 | 14 | All other files in the Xen source distribution are covered by version 15 | 2 of the GNU General Public License except where explicitly stated 16 | otherwise within individual source files. 17 | 18 | -- Keir Fraser (on behalf of the Xen team) 19 | 20 | ===================================================================== 21 | 22 | Permission is hereby granted, free of charge, to any person obtaining a copy 23 | of this software and associated documentation files (the "Software"), to 24 | deal in the Software without restriction, including without limitation the 25 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 26 | sell copies of the Software, and to permit persons to whom the Software is 27 | furnished to do so, subject to the following conditions: 28 | 29 | The above copyright notice and this permission notice shall be included in 30 | all copies or substantial portions of the Software. 31 | 32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 37 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 38 | DEALINGS IN THE SOFTWARE. 39 | -------------------------------------------------------------------------------- /include/xen/arch-arm/hvm/save.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Structure definitions for HVM state that is held by Xen and must 3 | * be saved along with the domain's memory and device-model state. 4 | * 5 | * Copyright (c) 2012 Citrix Systems Ltd. 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to 9 | * deal in the Software without restriction, including without limitation the 10 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 11 | * sell copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | * DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #ifndef __XEN_PUBLIC_HVM_SAVE_ARM_H__ 27 | #define __XEN_PUBLIC_HVM_SAVE_ARM_H__ 28 | 29 | #endif 30 | 31 | /* 32 | * Local variables: 33 | * mode: C 34 | * c-file-style: "BSD" 35 | * c-basic-offset: 4 36 | * tab-width: 4 37 | * indent-tabs-mode: nil 38 | * End: 39 | */ 40 | -------------------------------------------------------------------------------- /include/xen/arch-arm/smccc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * smccc.h 3 | * 4 | * SMC/HVC interface in accordance with SMC Calling Convention. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | * 24 | * Copyright 2017 (C) EPAM Systems 25 | */ 26 | 27 | #ifndef __XEN_PUBLIC_ARCH_ARM_SMCCC_H__ 28 | #define __XEN_PUBLIC_ARCH_ARM_SMCCC_H__ 29 | 30 | #include "public/xen.h" 31 | 32 | /* 33 | * Hypervisor Service version. 34 | * 35 | * We can't use XEN version here, because of SMCCC requirements: 36 | * Major revision should change every time SMC/HVC function is removed. 37 | * Minor revision should change every time SMC/HVC function is added. 38 | * So, it is SMCCC protocol revision code, not XEN version. 39 | * 40 | * Those values are subjected to change, when interface will be extended. 41 | */ 42 | #define XEN_SMCCC_MAJOR_REVISION 0 43 | #define XEN_SMCCC_MINOR_REVISION 1 44 | 45 | /* Hypervisor Service UID. Randomly generated with uuidgen. */ 46 | #define XEN_SMCCC_UID XEN_DEFINE_UUID(0xa71812dc, 0xc698, 0x4369, 0x9acf, \ 47 | 0x79, 0xd1, 0x8d, 0xde, 0xe6, 0x67) 48 | 49 | /* Standard Service Service Call version. */ 50 | #define SSSC_SMCCC_MAJOR_REVISION 0 51 | #define SSSC_SMCCC_MINOR_REVISION 1 52 | 53 | /* Standard Service Call UID. Randomly generated with uuidgen. */ 54 | #define SSSC_SMCCC_UID XEN_DEFINE_UUID(0xf863386f, 0x4b39, 0x4cbd, 0x9220,\ 55 | 0xce, 0x16, 0x41, 0xe5, 0x9f, 0x6f) 56 | 57 | #endif /* __XEN_PUBLIC_ARCH_ARM_SMCCC_H__ */ 58 | 59 | /* 60 | * Local variables: 61 | * mode: C 62 | * c-file-style: "BSD" 63 | * c-basic-offset: 4 64 | * indent-tabs-mode: nil 65 | * End:b 66 | */ 67 | -------------------------------------------------------------------------------- /include/xen/arch-x86_32.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * arch-x86_32.h 3 | * 4 | * Guest OS interface to x86 32-bit Xen. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | * 24 | * Copyright (c) 2004-2006, K A Fraser 25 | */ 26 | 27 | #include "arch-x86/xen.h" 28 | -------------------------------------------------------------------------------- /include/xen/arch-x86_64.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * arch-x86_64.h 3 | * 4 | * Guest OS interface to x86 64-bit Xen. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | * 24 | * Copyright (c) 2004-2006, K A Fraser 25 | */ 26 | 27 | #include "arch-x86/xen.h" 28 | 29 | /* 30 | * ` enum neg_errnoval 31 | * ` HYPERVISOR_set_callbacks(unsigned long event_selector, 32 | * ` unsigned long event_address, 33 | * ` unsigned long failsafe_selector, 34 | * ` unsigned long failsafe_address); 35 | * ` 36 | * Register for callbacks on events. When an event (from an event 37 | * channel) occurs, event_address is used as the value of eip. 38 | * 39 | * A similar callback occurs if the segment selectors are invalid. 40 | * failsafe_address is used as the value of eip. 41 | * 42 | * On x86_64, event_selector and failsafe_selector are ignored (???). 43 | */ 44 | -------------------------------------------------------------------------------- /include/xen/device_tree_defs.h: -------------------------------------------------------------------------------- 1 | #ifndef __XEN_DEVICE_TREE_DEFS_H__ 2 | #define __XEN_DEVICE_TREE_DEFS_H__ 3 | 4 | #if defined(__XEN__) || defined(__XEN_TOOLS__) 5 | /* 6 | * The device tree compiler (DTC) is allocating the phandle from 1 to 7 | * onwards. Reserve a high value for the GIC phandle. 8 | */ 9 | #define GUEST_PHANDLE_GIC (65000) 10 | 11 | #define GUEST_ROOT_ADDRESS_CELLS 2 12 | #define GUEST_ROOT_SIZE_CELLS 2 13 | 14 | /** 15 | * IRQ line type. 16 | * 17 | * DT_IRQ_TYPE_NONE - default, unspecified type 18 | * DT_IRQ_TYPE_EDGE_RISING - rising edge triggered 19 | * DT_IRQ_TYPE_EDGE_FALLING - falling edge triggered 20 | * DT_IRQ_TYPE_EDGE_BOTH - rising and falling edge triggered 21 | * DT_IRQ_TYPE_LEVEL_HIGH - high level triggered 22 | * DT_IRQ_TYPE_LEVEL_LOW - low level triggered 23 | * DT_IRQ_TYPE_LEVEL_MASK - Mask to filter out the level bits 24 | * DT_IRQ_TYPE_SENSE_MASK - Mask for all the above bits 25 | * DT_IRQ_TYPE_INVALID - Use to initialize the type 26 | */ 27 | #define DT_IRQ_TYPE_NONE 0x00000000 28 | #define DT_IRQ_TYPE_EDGE_RISING 0x00000001 29 | #define DT_IRQ_TYPE_EDGE_FALLING 0x00000002 30 | #define DT_IRQ_TYPE_EDGE_BOTH \ 31 | (DT_IRQ_TYPE_EDGE_FALLING | DT_IRQ_TYPE_EDGE_RISING) 32 | #define DT_IRQ_TYPE_LEVEL_HIGH 0x00000004 33 | #define DT_IRQ_TYPE_LEVEL_LOW 0x00000008 34 | #define DT_IRQ_TYPE_LEVEL_MASK \ 35 | (DT_IRQ_TYPE_LEVEL_LOW | DT_IRQ_TYPE_LEVEL_HIGH) 36 | #define DT_IRQ_TYPE_SENSE_MASK 0x0000000f 37 | 38 | #define DT_IRQ_TYPE_INVALID 0x00000010 39 | 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/xen/hvm/e820.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Permission is hereby granted, free of charge, to any person obtaining a copy 3 | * of this software and associated documentation files (the "Software"), to 4 | * deal in the Software without restriction, including without limitation the 5 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 6 | * sell copies of the Software, and to permit persons to whom the Software is 7 | * furnished to do so, subject to the following conditions: 8 | * 9 | * The above copyright notice and this permission notice shall be included in 10 | * all copies or substantial portions of the Software. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | * Copyright (c) 2006, Keir Fraser 21 | */ 22 | 23 | #ifndef __XEN_PUBLIC_HVM_E820_H__ 24 | #define __XEN_PUBLIC_HVM_E820_H__ 25 | 26 | #include "../xen.h" 27 | 28 | /* E820 location in HVM virtual address space. */ 29 | #define HVM_E820_PAGE 0x00090000 30 | #define HVM_E820_NR_OFFSET 0x000001E8 31 | #define HVM_E820_OFFSET 0x000002D0 32 | 33 | #define HVM_BELOW_4G_RAM_END 0xF0000000 34 | #define HVM_BELOW_4G_MMIO_START HVM_BELOW_4G_RAM_END 35 | #define HVM_BELOW_4G_MMIO_LENGTH ((xen_mk_ullong(1) << 32) - \ 36 | HVM_BELOW_4G_MMIO_START) 37 | 38 | #endif /* __XEN_PUBLIC_HVM_E820_H__ */ 39 | -------------------------------------------------------------------------------- /include/xen/hvm/pvdrivers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * pvdrivers.h: Register of PV drivers product numbers. 3 | * Copyright (c) 2012, Citrix Systems Inc. 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to 7 | * deal in the Software without restriction, including without limitation the 8 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9 | * sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | */ 23 | 24 | #ifndef _XEN_PUBLIC_PVDRIVERS_H_ 25 | #define _XEN_PUBLIC_PVDRIVERS_H_ 26 | 27 | /* 28 | * This is the master registry of product numbers for 29 | * PV drivers. 30 | * If you need a new product number allocating, please 31 | * post to xen-devel@lists.xenproject.org. You should NOT use 32 | * a product number without allocating one. 33 | * If you maintain a separate versioning and distribution path 34 | * for PV drivers you should have a separate product number so 35 | * that your drivers can be separated from others. 36 | * 37 | * During development, you may use the product ID to 38 | * indicate a driver which is yet to be released. 39 | */ 40 | 41 | #define PVDRIVERS_PRODUCT_LIST(EACH) \ 42 | EACH("xensource-windows", 0x0001) /* Citrix */ \ 43 | EACH("gplpv-windows", 0x0002) /* James Harper */ \ 44 | EACH("linux", 0x0003) \ 45 | EACH("xenserver-windows-v7.0+", 0x0004) /* Citrix */ \ 46 | EACH("xenserver-windows-v7.2+", 0x0005) /* Citrix */ \ 47 | EACH("experimental", 0xffff) 48 | 49 | #endif /* _XEN_PUBLIC_PVDRIVERS_H_ */ 50 | -------------------------------------------------------------------------------- /include/xen/io/9pfs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 9pfs.h -- Xen 9PFS transport 3 | * 4 | * Refer to docs/misc/9pfs.markdown for the specification 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | * 24 | * Copyright (C) 2017 Stefano Stabellini 25 | */ 26 | 27 | #ifndef __XEN_PUBLIC_IO_9PFS_H__ 28 | #define __XEN_PUBLIC_IO_9PFS_H__ 29 | 30 | #include "../grant_table.h" 31 | #include "ring.h" 32 | 33 | /* 34 | * See docs/misc/9pfs.markdown in xen.git for the full specification: 35 | * https://xenbits.xen.org/docs/unstable/misc/9pfs.html 36 | */ 37 | DEFINE_XEN_FLEX_RING_AND_INTF(xen_9pfs); 38 | 39 | #endif 40 | 41 | /* 42 | * Local variables: 43 | * mode: C 44 | * c-file-style: "BSD" 45 | * c-basic-offset: 4 46 | * tab-width: 4 47 | * indent-tabs-mode: nil 48 | * End: 49 | */ 50 | -------------------------------------------------------------------------------- /include/xen/io/console.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * console.h 3 | * 4 | * Console I/O interface for Xen guest OSes. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | * 24 | * Copyright (c) 2005, Keir Fraser 25 | */ 26 | 27 | #ifndef __XEN_PUBLIC_IO_CONSOLE_H__ 28 | #define __XEN_PUBLIC_IO_CONSOLE_H__ 29 | 30 | typedef uint32_t XENCONS_RING_IDX; 31 | 32 | #define MASK_XENCONS_IDX(idx, ring) ((idx) & (sizeof(ring)-1)) 33 | 34 | struct xencons_interface { 35 | char in[1024]; 36 | char out[2048]; 37 | XENCONS_RING_IDX in_cons, in_prod; 38 | XENCONS_RING_IDX out_cons, out_prod; 39 | }; 40 | 41 | #ifdef XEN_WANT_FLEX_CONSOLE_RING 42 | #include "ring.h" 43 | DEFINE_XEN_FLEX_RING(xencons); 44 | #endif 45 | 46 | #endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */ 47 | 48 | /* 49 | * Local variables: 50 | * mode: C 51 | * c-file-style: "BSD" 52 | * c-basic-offset: 4 53 | * tab-width: 4 54 | * indent-tabs-mode: nil 55 | * End: 56 | */ 57 | -------------------------------------------------------------------------------- /include/xen/io/protocols.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * protocols.h 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | * 22 | * Copyright (c) 2008, Keir Fraser 23 | */ 24 | 25 | #ifndef __XEN_PROTOCOLS_H__ 26 | #define __XEN_PROTOCOLS_H__ 27 | 28 | #define XEN_IO_PROTO_ABI_X86_32 "x86_32-abi" 29 | #define XEN_IO_PROTO_ABI_X86_64 "x86_64-abi" 30 | #define XEN_IO_PROTO_ABI_ARM "arm-abi" 31 | 32 | #if defined(__i386__) 33 | # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32 34 | #elif defined(__x86_64__) 35 | # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64 36 | #elif defined(__arm__) || defined(__aarch64__) 37 | # define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_ARM 38 | #else 39 | # error arch fixup needed here 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/xen/io/xenbus.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * xenbus.h 3 | * 4 | * Xenbus protocol details. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | * 24 | * Copyright (C) 2005 XenSource Ltd. 25 | */ 26 | 27 | #ifndef _XEN_PUBLIC_IO_XENBUS_H 28 | #define _XEN_PUBLIC_IO_XENBUS_H 29 | 30 | /* 31 | * The state of either end of the Xenbus, i.e. the current communication 32 | * status of initialisation across the bus. States here imply nothing about 33 | * the state of the connection between the driver and the kernel's device 34 | * layers. 35 | */ 36 | enum xenbus_state { 37 | XenbusStateUnknown = 0, 38 | 39 | XenbusStateInitialising = 1, 40 | 41 | /* 42 | * InitWait: Finished early initialisation but waiting for information 43 | * from the peer or hotplug scripts. 44 | */ 45 | XenbusStateInitWait = 2, 46 | 47 | /* 48 | * Initialised: Waiting for a connection from the peer. 49 | */ 50 | XenbusStateInitialised = 3, 51 | 52 | XenbusStateConnected = 4, 53 | 54 | /* 55 | * Closing: The device is being closed due to an error or an unplug event. 56 | */ 57 | XenbusStateClosing = 5, 58 | 59 | XenbusStateClosed = 6, 60 | 61 | /* 62 | * Reconfiguring: The device is being reconfigured. 63 | */ 64 | XenbusStateReconfiguring = 7, 65 | 66 | XenbusStateReconfigured = 8 67 | }; 68 | typedef enum xenbus_state XenbusState; 69 | 70 | #endif /* _XEN_PUBLIC_IO_XENBUS_H */ 71 | 72 | /* 73 | * Local variables: 74 | * mode: C 75 | * c-file-style: "BSD" 76 | * c-basic-offset: 4 77 | * tab-width: 4 78 | * indent-tabs-mode: nil 79 | * End: 80 | */ 81 | -------------------------------------------------------------------------------- /include/xen/xen-compat.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * xen-compat.h 3 | * 4 | * Guest OS interface to Xen. Compatibility layer. 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | * 24 | * Copyright (c) 2006, Christian Limpach 25 | */ 26 | 27 | #ifndef __XEN_PUBLIC_XEN_COMPAT_H__ 28 | #define __XEN_PUBLIC_XEN_COMPAT_H__ 29 | 30 | #define __XEN_LATEST_INTERFACE_VERSION__ 0x00040d00 31 | 32 | #if defined(__XEN__) || defined(__XEN_TOOLS__) 33 | /* Xen is built with matching headers and implements the latest interface. */ 34 | #define __XEN_INTERFACE_VERSION__ __XEN_LATEST_INTERFACE_VERSION__ 35 | #elif !defined(__XEN_INTERFACE_VERSION__) 36 | /* Guests which do not specify a version get the legacy interface. */ 37 | #define __XEN_INTERFACE_VERSION__ 0x00000000 38 | #endif 39 | 40 | #if __XEN_INTERFACE_VERSION__ > __XEN_LATEST_INTERFACE_VERSION__ 41 | #error "These header files do not support the requested interface version." 42 | #endif 43 | 44 | #define COMPAT_FLEX_ARRAY_DIM XEN_FLEX_ARRAY_DIM 45 | 46 | #endif /* __XEN_PUBLIC_XEN_COMPAT_H__ */ 47 | -------------------------------------------------------------------------------- /include/xen/xencomm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Permission is hereby granted, free of charge, to any person obtaining a copy 3 | * of this software and associated documentation files (the "Software"), to 4 | * deal in the Software without restriction, including without limitation the 5 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 6 | * sell copies of the Software, and to permit persons to whom the Software is 7 | * furnished to do so, subject to the following conditions: 8 | * 9 | * The above copyright notice and this permission notice shall be included in 10 | * all copies or substantial portions of the Software. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | * Copyright (C) IBM Corp. 2006 21 | */ 22 | 23 | #ifndef _XEN_XENCOMM_H_ 24 | #define _XEN_XENCOMM_H_ 25 | 26 | /* A xencomm descriptor is a scatter/gather list containing physical 27 | * addresses corresponding to a virtually contiguous memory area. The 28 | * hypervisor translates these physical addresses to machine addresses to copy 29 | * to and from the virtually contiguous area. 30 | */ 31 | 32 | #define XENCOMM_MAGIC 0x58434F4D /* 'XCOM' */ 33 | #define XENCOMM_INVALID (~0UL) 34 | 35 | struct xencomm_desc { 36 | uint32_t magic; 37 | uint32_t nr_addrs; /* the number of entries in address[] */ 38 | uint64_t address[0]; 39 | }; 40 | 41 | #endif /* _XEN_XENCOMM_H_ */ 42 | -------------------------------------------------------------------------------- /opam/solo5-cross-aarch64.opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "martin@lucina.net" 3 | authors: [ 4 | "Dan Williams " 5 | "Martin Lucina " 6 | "Ricardo Koller " 7 | ] 8 | homepage: "https://github.com/solo5/solo5" 9 | bug-reports: "https://github.com/solo5/solo5/issues" 10 | license: "ISC" 11 | dev-repo: "git+https://github.com/solo5/solo5.git" 12 | build: [ 13 | ["env" "TARGET_CC=aarch64-linux-gnu-gcc" "TARGET_LD=aarch64-linux-gnu-ld" "TARGET_OBJCOPY=aarch64-linux-gnu-objcopy" "./configure.sh" "--prefix=%{prefix}%"] 14 | [make "V=1"] 15 | ] 16 | install: [make "V=1" "install-toolchain"] 17 | depends: [ 18 | "conf-pkg-config" {build & os = "linux"} 19 | "conf-libseccomp" {build & os = "linux"} 20 | "solo5" {= version} 21 | ] 22 | depexts: [ 23 | ["linux-headers"] {os-distribution = "alpine"} 24 | ["kernel-headers"] {os-distribution = "fedora"} 25 | ["kernel-headers"] {os-distribution = "rhel"} 26 | ["linux-libc-dev"] {os-family = "debian"} 27 | ["gcc-aarch64-linux-gnu"] {os-family = "debian"} 28 | ] 29 | available: [ 30 | (arch != "arm64") & 31 | (os = "linux" & os-family = "debian") 32 | ] 33 | synopsis: "Solo5 sandboxed execution environment" 34 | description: """ 35 | Solo5 is a sandboxed execution environment primarily intended 36 | for, but not limited to, running applications built using various 37 | unikernels (a.k.a. library operating systems). 38 | 39 | This package provides the Solo5 components needed to cross-build 40 | MirageOS unikernels for the aarch64 architecture. 41 | """ 42 | x-maintenance-intent: [ "(latest)" ] 43 | -------------------------------------------------------------------------------- /opam/solo5.opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | maintainer: "martin@lucina.net" 3 | authors: [ 4 | "Dan Williams " 5 | "Martin Lucina " 6 | "Ricardo Koller " 7 | ] 8 | homepage: "https://github.com/solo5/solo5" 9 | bug-reports: "https://github.com/solo5/solo5/issues" 10 | license: "ISC" 11 | dev-repo: "git+https://github.com/solo5/solo5.git" 12 | build: [ 13 | ["./configure.sh" "--prefix=%{prefix}%"] 14 | [make "V=1"] 15 | ] 16 | install: [make "V=1" "install"] 17 | depends: [ 18 | "conf-pkg-config" {build & os = "linux"} 19 | "conf-libseccomp" {build & os = "linux"} 20 | ] 21 | depexts: [ 22 | ["linux-headers"] {os-distribution = "alpine"} 23 | ["kernel-headers"] {os-distribution = "fedora"} 24 | ["kernel-headers"] {os-distribution = "rhel"} 25 | ["linux-libc-dev"] {os-family = "debian"} 26 | ] 27 | conflicts: [ 28 | "ocaml-freestanding" {< "0.7.0"} 29 | "solo5-bindings-hvt" 30 | "solo5-bindings-spt" 31 | "solo5-bindings-virtio" 32 | "solo5-bindings-muen" 33 | "solo5-bindings-genode" 34 | "solo5-bindings-xen" 35 | ] 36 | available: [ 37 | (arch = "x86_64" | arch = "arm64" | arch = "ppc64") & 38 | (os = "linux" | os = "freebsd" | os = "openbsd") 39 | ] 40 | x-ci-accept-failures: [ "centos-7" ] 41 | synopsis: "Solo5 sandboxed execution environment" 42 | description: """ 43 | Solo5 is a sandboxed execution environment primarily intended 44 | for, but not limited to, running applications built using various 45 | unikernels (a.k.a. library operating systems). 46 | 47 | This package provides the Solo5 components needed to build and 48 | run MirageOS unikernels on the host system. 49 | """ 50 | x-maintenance-intent: [ "(latest)" ] 51 | -------------------------------------------------------------------------------- /scripts/gen_version_h.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | die () 4 | { 5 | [ $# -ne 0 ] && echo $0: error: "$@" 1>&2 6 | exit 1 7 | } 8 | 9 | 10 | [ $# -ne 1 ] && exit 1 11 | VERSION_H="$1" 12 | 13 | # If we are being run from a release tarball, then a version.h.distrib must 14 | # be present, and we always use that as our source of truth. Allow ./.git 15 | # to be a file to support git worktrees. 16 | if [ ! -d "./.git" -a ! -f "./.git" ]; then 17 | if [ ! -f "${VERSION_H}.distrib" ]; then 18 | die "${VERSION_H}.distrib: Not found, and we are not in a Git tree" 19 | fi 20 | cp "${VERSION_H}.distrib" "${VERSION_H}" || die 21 | exit 0 22 | fi 23 | 24 | # Otherwise, use "git describe" to get the exact version of this tree, and 25 | # generate a version.h from it. 26 | GIT_VERSION="$(git -C . describe --dirty --tags --always)" || 27 | die "Could not determine Git version" 28 | 29 | cat <${VERSION_H}.tmp || die 30 | /* Automatically generated, do not edit */ 31 | 32 | #ifndef __VERSION_H__ 33 | #define __VERSION_H__ 34 | 35 | #define SOLO5_VERSION "${GIT_VERSION}" 36 | 37 | #endif 38 | EOM 39 | 40 | # Only touch the target file if it does not exist yet or Git version differs. 41 | if [ -f ${VERSION_H} ] && diff -q ${VERSION_H} ${VERSION_H}.tmp >/dev/null; then 42 | rm ${VERSION_H}.tmp || die 43 | else 44 | mv ${VERSION_H}.tmp ${VERSION_H} || die 45 | fi 46 | -------------------------------------------------------------------------------- /scripts/opam-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to generate OPAM metadata for publishing a Solo5 release 4 | # to ocaml/opam-repository. It should be run from the root of a clean, tagged 5 | # Solo5 git repository. 6 | # From Makefile.commmon, the '-Werror' should be removed for the tag of the 7 | # release, to avoid failures with future C compilers (which may add new 8 | # warnings). 9 | 10 | if [ ! -d "./opam" ]; then 11 | echo "ERROR: missing ./opam. Run this from the root of a Solo5 repository." 12 | exit 1 13 | fi 14 | 15 | echo $GIT_VERSION 16 | GIT_VERSION=${GIT_VERSION:-$(git -C . describe --tags --always)} 17 | 18 | DEV= 19 | if ! echo "$GIT_VERSION" | grep -q -E '^v[0-9]+.[0-9]+.[0-9]+$'; then 20 | echo "WARNING: Not a clean Git release: $GIT_VERSION" 21 | echo "WARNING: This is almost certainly not what you want." 22 | DEV=~dev 23 | fi 24 | 25 | WERROR=$(git grep -c ' -Werror' Makefile.common | cut -d ':' -f 2) 26 | if [ -n "$WERROR" ]; then 27 | echo "ERROR: There are occurences of '-Werror' in 'Makefile.common'." 28 | echo "ERROR: This is almost certainly not what you want." 29 | exit 1 30 | fi 31 | 32 | TARBALL="solo5-${GIT_VERSION}.tar.gz" 33 | if [ ! -f ${TARBALL} ]; then 34 | echo "ERROR: Release tarball ${TARBALL} not found." 35 | echo "ERROR: Did you run 'make distrib'?" 36 | exit 1 37 | fi 38 | echo "Using tarball: ${TARBALL}" 39 | CHECKSUM="$(sha512sum ${TARBALL} | cut -d' ' -f1)" 40 | 41 | OPAM_VERSION=$(echo -n "${GIT_VERSION}" | cut -d- -f1 | tr -d v) 42 | [ -n "${DEV}" ] && OPAM_VERSION="${OPAM_VERSION}${DEV}" 43 | echo "OPAM version: ${OPAM_VERSION}" 44 | 45 | OUTPUT_DIR=./opam/release 46 | if [ -d ${OUTPUT_DIR} ]; then 47 | echo "Deleting existing output directory: ${OUTPUT_DIR}" 48 | rm -rf ${OUTPUT_DIR} 49 | fi 50 | mkdir -p ${OUTPUT_DIR}/tmp 51 | cat <${OUTPUT_DIR}/tmp/url 52 | url { 53 | src: "https://github.com/Solo5/solo5/releases/download/${GIT_VERSION}/${TARBALL}" 54 | checksum: "sha512=${CHECKSUM}" 55 | } 56 | EOM 57 | for VARIANT in '' '-cross-aarch64'; do 58 | PKG_DIR=${OUTPUT_DIR}/packages/solo5${VARIANT}/solo5${VARIANT}.${OPAM_VERSION} 59 | mkdir -p ${PKG_DIR} || exit 1 60 | cat opam/solo5${VARIANT}.opam ${OUTPUT_DIR}/tmp/url \ 61 | > ${PKG_DIR}/opam || exit 1 62 | opam lint ${PKG_DIR}/opam || exit 1 63 | done 64 | 65 | echo "Done. Submit ${OUTPUT_DIR}/packages as a PR to opam-repository." 66 | echo "Example: cp -r opam/release/packages path/to/opam-repository" 67 | echo " cd path/to/opam/repository" 68 | echo " git checkout -b solo5.${OPAM_VERSION}" 69 | echo " git add ." 70 | -------------------------------------------------------------------------------- /scripts/virtio-mkimage/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.8 2 | MAINTAINER Martin Lucina 3 | RUN apk add --update --no-cache \ 4 | coreutils \ 5 | dosfstools \ 6 | mtools \ 7 | sfdisk \ 8 | syslinux \ 9 | tar 10 | COPY ./solo5-virtio-mkimage.sh /sbin 11 | ENTRYPOINT [ "/sbin/solo5-virtio-mkimage.sh" ] 12 | -------------------------------------------------------------------------------- /tenders/common/block_attach.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * block_attach.c: Common functions for attaching to block devices. 23 | */ 24 | 25 | #define _GNU_SOURCE 26 | #define _FILE_OFFSET_BITS 64 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | /* 36 | * Attach to the block device specified by (path), returning its capacity in 37 | * bytes in (*capacity). 38 | */ 39 | int block_attach(const char *path, off_t *capacity_) 40 | { 41 | int fd = open(path, O_RDWR); 42 | if (fd == -1) 43 | err(1, "Could not open block device: %s", path); 44 | off_t capacity = lseek(fd, 0, SEEK_END); 45 | if (capacity == -1) 46 | err(1, "%s: Could not determine capacity", path); 47 | 48 | *capacity_ = capacity; 49 | return fd; 50 | } 51 | -------------------------------------------------------------------------------- /tenders/common/block_attach.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * block_attach.h: Common functions for attaching to block devices. 23 | */ 24 | 25 | #ifndef COMMON_BLOCK_ATTACH_H 26 | #define COMMON_BLOCK_ATTACH_H 27 | 28 | #define _GNU_SOURCE 29 | #define _FILE_OFFSET_BITS 64 30 | #include 31 | #include 32 | 33 | /* 34 | * Attach to the block device specified by (path). Returns the file descriptor 35 | * and device capacity in * bytes in (*capacity). 36 | */ 37 | int block_attach(const char *path, off_t *capacity_); 38 | 39 | #endif /* COMMON_BLOCK_ATTACH_H */ 40 | -------------------------------------------------------------------------------- /tenders/common/tap_attach.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * tap_attach.h: Common functions for attaching to TAP interfaces. 23 | */ 24 | 25 | #ifndef COMMON_TAP_ATTACH_H 26 | #define COMMON_TAP_ATTACH_H 27 | 28 | /* 29 | * Attach to an existing TAP interface named (ifname). If ifname is "@", 30 | * assume that a pre-existing TAP interface is open as file descriptor . 31 | * 32 | * Returns -1 and an appropriate errno on failure (ENOENT if the interface does 33 | * not exist), and the tap device file descriptor on success. 34 | */ 35 | int tap_attach(const char *ifname); 36 | 37 | /* 38 | * Generate a random, locally-administered and unicast MAC address, and store it 39 | * in (*mac), which must be an uint8_t[6]. 40 | */ 41 | void tap_attach_genmac(uint8_t *mac); 42 | 43 | #endif /* COMMON_TAP_ATTACH_H */ 44 | -------------------------------------------------------------------------------- /tenders/hvt/hvt_dumpcore_kvm_aarch64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * hvt_dumpcore_kvm_aarch64.c: Glue between the dumpcore module and KVM 23 | * (aarch64). 24 | */ 25 | 26 | int hvt_dumpcore_supported() 27 | { 28 | return -1; 29 | } 30 | 31 | size_t hvt_dumpcore_prstatus_size(void) 32 | { 33 | /* Not supported yet */ 34 | return 0; 35 | } 36 | 37 | int hvt_dumpcore_write_prstatus(int fd, struct hvt *hvt, void *cookie) 38 | { 39 | /* Not supported yet */ 40 | return -1; 41 | } 42 | -------------------------------------------------------------------------------- /tenders/hvt/hvt_dumpcore_openbsd_x86_64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * hvt_dumpcore_openbsd_x86_64.c: Glue between the dumpcore module and OpenBSD 23 | * (x86_64). 24 | */ 25 | 26 | int hvt_dumpcore_supported() 27 | { 28 | return -1; 29 | } 30 | 31 | size_t hvt_dumpcore_prstatus_size(void) 32 | { 33 | /* Not supported yet */ 34 | return 0; 35 | } 36 | 37 | int hvt_dumpcore_write_prstatus(int fd, struct hvt *hvt, void *cookie) 38 | { 39 | /* Not supported yet */ 40 | return -1; 41 | } 42 | -------------------------------------------------------------------------------- /tenders/hvt/hvt_freebsd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * hvt_freebsd.h: FreeBSD vmm(4) backend definitions. 23 | */ 24 | 25 | #ifndef HVT_HV_FREEBSD_H 26 | #define HVT_HV_FREEBSD_H 27 | 28 | #define VMM_USER "nobody" 29 | #define VMM_CHROOT "/var/empty" 30 | 31 | struct hvt_b { 32 | char *vmname; 33 | int vmfd; 34 | struct vm_run vmrun; 35 | }; 36 | 37 | #endif /* HVT_HV_FREEBSD_H */ 38 | -------------------------------------------------------------------------------- /tenders/hvt/hvt_gdb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #ifndef HVT_GDB_H 22 | #define HVT_GDB_H 23 | 24 | /* GDB breakpoint/watchpoint types */ 25 | typedef enum _gdb_breakpoint_type { 26 | /* Do not change these. The values have to match on the GDB client 27 | * side. */ 28 | GDB_BREAKPOINT_SW = 0, 29 | GDB_BREAKPOINT_HW, 30 | GDB_WATCHPOINT_WRITE, 31 | GDB_WATCHPOINT_READ, 32 | GDB_WATCHPOINT_ACCESS, 33 | GDB_BREAKPOINT_MAX 34 | } gdb_breakpoint_type; 35 | 36 | #define GDB_SIGNAL_FIRST 0 37 | #define GDB_SIGNAL_QUIT 3 38 | #define GDB_SIGNAL_KILL 9 39 | #define GDB_SIGNAL_TRAP 5 40 | #define GDB_SIGNAL_SEGV 11 41 | #define GDB_SIGNAL_TERM 15 42 | #define GDB_SIGNAL_IO 23 43 | #define GDB_SIGNAL_DEFAULT 144 44 | 45 | #endif /* #ifndef HVT_GDB_H */ 46 | -------------------------------------------------------------------------------- /tenders/hvt/hvt_gdb_aarch64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * hvt_gdb_aarch64.h: GDB constants common to aarch64 backend implementations. 23 | */ 24 | 25 | #ifndef HVT_GDB_AARCH64_H 26 | #define HVT_GDB_AARCH64_H 27 | 28 | struct hvt_gdb_regs { 29 | uint64_t regs[31]; 30 | uint64_t lr; 31 | uint64_t pc; 32 | uint64_t pstate; 33 | uint64_t sp; 34 | }; 35 | 36 | #endif /* HVT_GDB_AARCH64_H */ 37 | -------------------------------------------------------------------------------- /tenders/hvt/hvt_gdb_freebsd_x86_64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * hvt_gdb_freebsd_x86_64.c: glue between the GDB server (at hvt_modules_gdb.c) 23 | * and FreeBSD's vmm. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include "hvt.h" 36 | #include "hvt_freebsd.h" 37 | #include "hvt_gdb_x86_64.h" 38 | #include "hvt_gdb.h" 39 | 40 | int hvt_gdb_supported(void) 41 | { 42 | return -1; 43 | } 44 | 45 | int hvt_gdb_read_registers(struct hvt *hvt, 46 | uint8_t *registers, 47 | size_t *len) 48 | { 49 | return -1; 50 | } 51 | 52 | int hvt_gdb_write_registers(struct hvt *hvt, 53 | uint8_t *registers, 54 | size_t len) 55 | { 56 | return -1; 57 | } 58 | 59 | int hvt_gdb_enable_ss(struct hvt *hvt) 60 | { 61 | return -1; 62 | } 63 | 64 | int hvt_gdb_disable_ss(struct hvt *hvt) 65 | { 66 | return -1; 67 | } 68 | 69 | int hvt_gdb_read_last_signal(struct hvt *hvt, int *signal) 70 | { 71 | return -1; 72 | } 73 | 74 | int hvt_gdb_add_breakpoint(struct hvt *hvt, uint32_t type, 75 | hvt_gpa_t addr, size_t len) 76 | { 77 | return -1; 78 | } 79 | 80 | int hvt_gdb_remove_breakpoint(struct hvt *hvt, uint32_t type, 81 | hvt_gpa_t addr, size_t len) 82 | { 83 | return -1; 84 | } 85 | -------------------------------------------------------------------------------- /tenders/hvt/hvt_gdb_kvm_aarch64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * hvt_gdb_update_guest_debug is based on update_guest_debug from the QEMU 23 | * source code, target/i386/kvm.c, which is: 24 | * 25 | * Copyright (C) 2006-2008 Qumranet Technologies 26 | * Copyright IBM, Corp. 2008 27 | */ 28 | 29 | /* 30 | * hvt_gdb_kvm_aarch64.c: glue between the GDB server (at hvt_modules_gdb.c) 31 | * and KVM. 32 | */ 33 | 34 | #define _GNU_SOURCE 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include 46 | 47 | #include "hvt.h" 48 | #include "hvt_kvm.h" 49 | #include "hvt_gdb_aarch64.h" 50 | #include "hvt_gdb.h" 51 | 52 | int hvt_gdb_supported(void) 53 | { 54 | return -1; 55 | } 56 | 57 | int hvt_gdb_read_registers(struct hvt *hvt, 58 | uint8_t *registers, 59 | size_t *len) 60 | { 61 | return -1; 62 | } 63 | 64 | int hvt_gdb_write_registers(struct hvt *hvt, 65 | uint8_t *registers, 66 | size_t len) 67 | { 68 | return -1; 69 | } 70 | 71 | int hvt_gdb_enable_ss(struct hvt *hvt) 72 | { 73 | return -1; 74 | } 75 | 76 | int hvt_gdb_disable_ss(struct hvt *hvt) 77 | { 78 | return -1; 79 | } 80 | 81 | int hvt_gdb_read_last_signal(struct hvt *hvt, int *signal) 82 | { 83 | return -1; 84 | } 85 | 86 | int hvt_gdb_add_breakpoint(struct hvt *hvt, uint32_t type, 87 | hvt_gpa_t addr, size_t len) 88 | { 89 | return -1; 90 | } 91 | 92 | int hvt_gdb_remove_breakpoint(struct hvt *hvt, uint32_t type, 93 | hvt_gpa_t addr, size_t len) 94 | { 95 | return -1; 96 | } 97 | -------------------------------------------------------------------------------- /tenders/hvt/hvt_gdb_openbsd_x86_64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * hvt_gdb_openbsd_x86_64.c: glue between the GDB server (at hvt_modules_gdb.c) 23 | * and OpenBSD's vmm. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | #include "hvt.h" 34 | #include "hvt_gdb_x86_64.h" 35 | #include "hvt_gdb.h" 36 | 37 | int hvt_gdb_supported(void) 38 | { 39 | return -1; 40 | } 41 | 42 | int hvt_gdb_read_registers(struct hvt *hvt, 43 | uint8_t *registers, 44 | size_t *len) 45 | { 46 | return -1; 47 | } 48 | 49 | int hvt_gdb_write_registers(struct hvt *hvt, 50 | uint8_t *registers, 51 | size_t len) 52 | { 53 | return -1; 54 | } 55 | 56 | int hvt_gdb_enable_ss(struct hvt *hvt) 57 | { 58 | return -1; 59 | } 60 | 61 | int hvt_gdb_disable_ss(struct hvt *hvt) 62 | { 63 | return -1; 64 | } 65 | 66 | int hvt_gdb_read_last_signal(struct hvt *hvt, int *signal) 67 | { 68 | return -1; 69 | } 70 | 71 | int hvt_gdb_add_breakpoint(struct hvt *hvt, uint32_t type, 72 | hvt_gpa_t addr, size_t len) 73 | { 74 | return -1; 75 | } 76 | 77 | int hvt_gdb_remove_breakpoint(struct hvt *hvt, uint32_t type, 78 | hvt_gpa_t addr, size_t len) 79 | { 80 | return -1; 81 | } 82 | -------------------------------------------------------------------------------- /tenders/hvt/hvt_gdb_x86_64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * hvt_gdb_x86_64.h: GDB constants common to x86_64 backend implementations. 23 | */ 24 | 25 | #ifndef HVT_GDB_X86_64_H 26 | #define HVT_GDB_X86_64_H 27 | 28 | /* 29 | * XXX: While there is no header file in GDB to include here, 30 | * the register structure is described in XML here: 31 | * https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/features/i386/64bit-core.xml;h=5cbae2c0ef489699fa6c6e8ed07f5fe6d3b8a6b6;hb=HEAD 32 | */ 33 | 34 | struct hvt_gdb_regs { 35 | uint64_t rax; 36 | uint64_t rbx; 37 | uint64_t rcx; 38 | uint64_t rdx; 39 | uint64_t rsi; 40 | uint64_t rdi; 41 | uint64_t rbp; 42 | uint64_t rsp; 43 | uint64_t r8; 44 | uint64_t r9; 45 | uint64_t r10; 46 | uint64_t r11; 47 | uint64_t r12; 48 | uint64_t r13; 49 | uint64_t r14; 50 | uint64_t r15; 51 | uint64_t rip; 52 | // In GDB wire protocol, EFLAGS is 32 bits. 53 | uint32_t eflags; 54 | 55 | uint32_t cs; 56 | uint32_t ss; 57 | uint32_t ds; 58 | uint32_t es; 59 | uint32_t fs; 60 | uint32_t gs; 61 | }; 62 | 63 | #endif /* HVT_GDB_X86_64_H */ 64 | -------------------------------------------------------------------------------- /tenders/hvt/hvt_kvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * hvt_kvm.h: KVM backend definitions. 23 | */ 24 | 25 | #ifndef HVT_HV_KVM_H 26 | #define HVT_HV_KVM_H 27 | 28 | struct hvt_b { 29 | int kvmfd; 30 | int vmfd; 31 | int vcpufd; 32 | struct kvm_run *vcpurun; 33 | }; 34 | 35 | #endif /* HVT_HV_KVM_H */ 36 | -------------------------------------------------------------------------------- /tenders/hvt/hvt_openbsd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | /* 22 | * hvt_openbsd.h: OpenBSD vmm(4) backend definitions. 23 | */ 24 | 25 | #ifndef HVT_HV_OPENBSD_H 26 | #define HVT_HV_OPENBSD_H 27 | 28 | #define VMM_NODE "/dev/vmm" 29 | #define VMD_USER "_vmd" 30 | 31 | struct hvt_b { 32 | int vmd_fd; 33 | uint32_t vcp_id; 34 | uint32_t vcpu_id; 35 | }; 36 | 37 | #endif /* HVT_HV_OPENBSD_H */ 38 | -------------------------------------------------------------------------------- /tenders/spt/spt_launch_aarch64.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #define ENTRY(x) .text; .globl x; .type x,%function; x: 22 | #define END(x) .size x, . - x 23 | 24 | /* TODO/XXX: This calling convention is probably not 100% correct */ 25 | 26 | ENTRY(spt_launch) 27 | mov sp, x0 28 | mov x0, x2 29 | mov x30, xzr 30 | 31 | blr x1 32 | 33 | ret 34 | END(spt_launch) 35 | -------------------------------------------------------------------------------- /tenders/spt/spt_launch_ppc64le.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #define ENTRY(x) .text; .globl x; .type x,%function; x: 22 | #define END(x) .size x, . - x 23 | 24 | /* 25 | * r3: stack pointer to use 26 | * r4: function to call 27 | * r5: argument to pass to function 28 | */ 29 | ENTRY(spt_launch) 30 | mr %r1, %r3 // load stack pointer 31 | mr %r3, %r5 // parameter to pass to function goes into r3 32 | mtlr %r4 // move address of function to call into link register 33 | blr // call function via link register 34 | END(spt_launch) 35 | -------------------------------------------------------------------------------- /tenders/spt/spt_launch_x86_64.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #define ENTRY(x) .text; .globl x; .type x,%function; x: 22 | #define END(x) .size x, . - x 23 | 24 | .code64 25 | 26 | ENTRY(spt_launch) 27 | movq %rdi, %rsp 28 | movq %rdx, %rdi 29 | 30 | jmp *%rsi 31 | END(spt_launch) 32 | -------------------------------------------------------------------------------- /tests/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | ifndef TOPDIR 20 | $(error TOPDIR must be set, run $(MAKE) from the top of the source tree or set it manually) 21 | endif 22 | include $(TOPDIR)/Makeconf 23 | 24 | #ifndef CONFIG_CROSS_COMPILE 25 | 26 | TESTDIRS := $(wildcard test_*) 27 | 28 | #endif # !CONFIG_CROSS_COMPILE 29 | 30 | TOPTARGETS := all clean 31 | 32 | .PHONY: $(TOPTARGETS) $(TESTDIRS) 33 | 34 | $(TOPTARGETS): $(TESTDIRS) 35 | 36 | $(TESTDIRS): 37 | @echo "MAKE $@" 38 | $(MAKE) -C $@ $(MAKECMDGOALS) $(SUBOVERRIDE) 39 | 40 | .SUFFIXES: 41 | $(V).SILENT: 42 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | # Automated tests 2 | 3 | This is an automated test suite for Solo5. These tests are run by our automated 4 | CI system, which is somewhat documented at https://github.com/Solo5/solo5-ci. 5 | 6 | When developing Solo5, you should run at least the basic test suite to verify 7 | that your changes are good. 8 | 9 | ## Basic test suite 10 | 11 | To run the test suite, first ensure your host environment is set up by running 12 | (as root): 13 | 14 | ./setup-tests.sh 15 | 16 | Then, run the test suite with: 17 | 18 | ./run-tests.sh 19 | 20 | Some tests / hypervisors require root privileges. For best results, run the 21 | test suite as root. 22 | 23 | To see full output from all tests (not just the failures), run the test suite 24 | with the `-v` option. 25 | 26 | When adding tests, please use the following conventions: 27 | 28 | 1. Each test goes in its own subdirectory. 29 | 2. On success the test should print `SUCCESS` on the console and return from 30 | `solo5_app_main()`. This will halt the unikernel. 31 | 3. Add your tests to `run-tests.sh` for automatic invocation. 32 | 33 | ## End to end tests 34 | 35 | Work in progress. Here be dragons. **Ask @mato before modifying this or 36 | anything in build.sh that refers to it**. 37 | 38 | The `e2e-mirage-solo5` folder contains an "end to end" test for Mirage/Solo5. 39 | Note that this folder is deliberately not included in release tarballs of Solo5. 40 | 41 | The folder is a git subtree snapshot of https://github.com/mato/e2e-mirage-solo5, 42 | added to this repository with: 43 | 44 | ``` 45 | git remote add -f e2e-mirage-solo5 git@github.com:mato/e2e-mirage-solo5 46 | git subtree add --prefix tests/e2e-mirage-solo5 e2e-mirage-solo5 master --squash 47 | 48 | ``` 49 | 50 | This test (well, its driver script) is currently Linux-specific and only tests 51 | the `hvt` target. 52 | 53 | To run the E2E tests **against a checked out copy of Solo5**, apart from the 54 | instructions in `e2e-mirage-solo5/README.md`, you need to perform the following 55 | additional step from the root of the checked out Solo5 tree: 56 | 57 | ``` 58 | rm -f tests/e2e-mirage-solo5/universe/solo5-bindings-hvt/* 59 | ln -sf $(readlink -f .) tests/e2e-mirage-solo5/universe/solo5-bindings-hvt/local 60 | ``` 61 | -------------------------------------------------------------------------------- /tests/bats-core/bats-exec-suite: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | count_only_flag="" 5 | if [ "$1" = "-c" ]; then 6 | count_only_flag=1 7 | shift 8 | fi 9 | 10 | extended_syntax_flag="" 11 | if [ "$1" = "-x" ]; then 12 | extended_syntax_flag="-x" 13 | shift 14 | fi 15 | 16 | trap "kill 0; exit 1" int 17 | 18 | count=0 19 | for filename in "$@"; do 20 | while IFS= read -r line; do 21 | if [[ "$line" =~ $BATS_TEST_PATTERN ]]; then 22 | let count+=1 23 | fi 24 | done <"$filename" 25 | done 26 | 27 | if [ -n "$count_only_flag" ]; then 28 | echo "$count" 29 | exit 30 | fi 31 | 32 | echo "1..$count" 33 | status=0 34 | offset=0 35 | for filename in "$@"; do 36 | index=0 37 | { 38 | IFS= read -r # 1..n 39 | while IFS= read -r line; do 40 | case "$line" in 41 | "begin "* ) 42 | let index+=1 43 | echo "${line/ $index / $(($offset + $index)) }" 44 | ;; 45 | "ok "* | "not ok "* ) 46 | [ -n "$extended_syntax_flag" ] || let index+=1 47 | echo "${line/ $index / $(($offset + $index)) }" 48 | [ "${line:0:6}" != "not ok" ] || status=1 49 | ;; 50 | * ) 51 | echo "$line" 52 | ;; 53 | esac 54 | done 55 | } < <( bats-exec-test $extended_syntax_flag "$filename" ) 56 | offset=$(($offset + $index)) 57 | done 58 | 59 | exit "$status" 60 | -------------------------------------------------------------------------------- /tests/bats-core/bats-preprocess: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | encode_name() { 5 | local name="$1" 6 | local result="test_" 7 | local hex_code 8 | 9 | if [[ ! "$name" =~ [^[:alnum:]\ _-] ]]; then 10 | name="${name//_/-5f}" 11 | name="${name//-/-2d}" 12 | name="${name// /_}" 13 | result+="$name" 14 | else 15 | local length="${#name}" 16 | local char i 17 | 18 | for ((i=0; i&2 31 | exit 1 32 | fi 33 | 34 | case `uname -s` in 35 | Linux) 36 | set -xe 37 | ip tuntap add tap100 mode tap 38 | ip addr add 10.0.0.1/24 dev tap100 39 | ip link set dev tap100 up 40 | ip tuntap add tap101 mode tap 41 | ip addr add 10.1.0.1/24 dev tap101 42 | ip link set dev tap101 up 43 | ;; 44 | FreeBSD) 45 | kldload vmm 46 | kldload if_tap 47 | kldload nmdm 48 | sysctl -w net.link.tap.up_on_open=1 49 | ifconfig tap100 create 10.0.0.1/24 link0 up 50 | ifconfig tap101 create 10.1.0.1/24 link0 up 51 | ;; 52 | OpenBSD) 53 | ( 54 | cd /dev 55 | ./MAKEDEV tap100 56 | ./MAKEDEV tap101 57 | ) 58 | ifconfig tap100 inet 10.0.0.1 netmask 255.255.255.0 59 | ifconfig tap101 inet 10.1.0.1 netmask 255.255.255.0 60 | ;; 61 | *) 62 | exit 1 63 | ;; 64 | esac 65 | -------------------------------------------------------------------------------- /tests/test_blk/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_blk 22 | 23 | CONFIG_MUEN := 24 | 25 | include ../Makefile.tests 26 | -------------------------------------------------------------------------------- /tests/test_blk/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ { "name": "storage", "type": "BLOCK_BASIC" } ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_dumpcore/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_dumpcore 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_dumpcore/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_dumpcore/test_dumpcore.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | #include "../../bindings/lib.c" 23 | 24 | static void puts(const char *s) 25 | { 26 | solo5_console_write(s, strlen(s)); 27 | } 28 | 29 | int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) 30 | { 31 | puts("\n**** Solo5 standalone test_dumpcore ****\n\n"); 32 | solo5_abort(); 33 | return SOLO5_EXIT_SUCCESS; 34 | } 35 | -------------------------------------------------------------------------------- /tests/test_exception/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_exception 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_exception/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_exception/test_exception.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | #include "../../bindings/lib.c" 23 | 24 | static void puts(const char *s) 25 | { 26 | solo5_console_write(s, strlen(s)); 27 | } 28 | 29 | int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) 30 | { 31 | puts("\n**** Solo5 standalone test_exception ****\n\n"); 32 | 33 | uint64_t *addr_invalid = (uint64_t *)(2ULL << 33); 34 | *addr_invalid = 1; 35 | 36 | return SOLO5_EXIT_FAILURE; 37 | } 38 | -------------------------------------------------------------------------------- /tests/test_fpu/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_fpu 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_fpu/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_globals/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_globals 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_globals/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_globals/test_globals.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | #include "../../bindings/lib.c" 23 | 24 | static void puts(const char *s) 25 | { 26 | solo5_console_write(s, strlen(s)); 27 | } 28 | 29 | /* 30 | * Verify that global variables are initialised and writable. (See #73) 31 | */ 32 | 33 | char s[] = "RUCCESS\n"; 34 | 35 | void do_test(void) 36 | { 37 | s[0]++; 38 | puts(s); 39 | } 40 | 41 | int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) 42 | { 43 | puts("\n**** Solo5 standalone test_globals ****\n\n"); 44 | 45 | do_test(); 46 | 47 | return SOLO5_EXIT_SUCCESS; 48 | } 49 | -------------------------------------------------------------------------------- /tests/test_hello/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_hello 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_hello/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_hello/test_hello.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | #include "../../bindings/lib.c" 23 | 24 | static void puts(const char *s) 25 | { 26 | solo5_console_write(s, strlen(s)); 27 | } 28 | 29 | int solo5_app_main(const struct solo5_start_info *si) 30 | { 31 | puts("\n**** Solo5 standalone test_hello ****\n\n"); 32 | puts("Hello, World\nCommand line is: '"); 33 | 34 | size_t len = 0; 35 | const char *p = si->cmdline; 36 | 37 | while (*p++) 38 | len++; 39 | solo5_console_write(si->cmdline, len); 40 | 41 | puts("'\n"); 42 | 43 | /* "Hello_Solo5" will be passed in via the command line */ 44 | if (strcmp(si->cmdline, "Hello_Solo5") == 0) 45 | puts("SUCCESS\n"); 46 | 47 | return SOLO5_EXIT_SUCCESS; 48 | } 49 | -------------------------------------------------------------------------------- /tests/test_mft_maxdevices/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_mft_maxdevices 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_mft_maxdevices/test_mft_maxdevices.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | #include "../../bindings/lib.c" 23 | 24 | static void puts(const char *s) 25 | { 26 | solo5_console_write(s, strlen(s)); 27 | } 28 | 29 | int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) 30 | { 31 | puts("\n**** Solo5 standalone test_mft_maxdevices ****\n\n"); 32 | 33 | solo5_handle_t storage0, storage62; 34 | struct solo5_block_info bi; 35 | 36 | if (solo5_block_acquire("storage0", &storage0, &bi) != SOLO5_R_OK) { 37 | puts("FAILURE\n"); 38 | return SOLO5_EXIT_FAILURE; 39 | } 40 | 41 | /* 42 | * We could test storage1 ... storage61 here, but the point of this test is 43 | * mainly to exercise the manifest generation and validation code, so we 44 | * won't bother. 45 | */ 46 | 47 | if (solo5_block_acquire("storage62", &storage62, &bi) != SOLO5_R_OK) { 48 | puts("FAILURE\n"); 49 | return SOLO5_EXIT_FAILURE; 50 | } 51 | 52 | puts("SUCCESS\n"); 53 | return SOLO5_EXIT_SUCCESS; 54 | } 55 | -------------------------------------------------------------------------------- /tests/test_net/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_net 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_net/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ { "name": "service0", "type": "NET_BASIC" } ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_net_2if/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_net_2if 22 | 23 | include ../Makefile.tests 24 | 25 | test_net_2if.o: ../test_net/test_net.c 26 | -------------------------------------------------------------------------------- /tests/test_net_2if/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ 5 | { "name": "service0", "type": "NET_BASIC" }, 6 | { "name": "service1", "type": "NET_BASIC" } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /tests/test_net_2if/test_net_2if.c: -------------------------------------------------------------------------------- 1 | #define TWO_INTERFACES 2 | #include "../test_net/test_net.c" 3 | -------------------------------------------------------------------------------- /tests/test_notls/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_notls 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_notls/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_notls/test_notls.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | #include "../../bindings/lib.c" 23 | 24 | static void puts(const char *s) 25 | { 26 | solo5_console_write(s, strlen(s)); 27 | } 28 | 29 | int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) 30 | { 31 | puts("\n**** Solo5 standalone test_notls ****\n\n"); 32 | 33 | #if defined(__x86_64__) 34 | __asm__ __volatile("movq %%fs:0x28, %%rax" : : : "rax"); 35 | #elif defined(__aarch64__) 36 | __asm__ __volatile("mrs x0, tpidr_el0; " 37 | "add x0, x0, #0x10; " 38 | "ldr w1, [x0]" 39 | : : : "x0", "w1"); 40 | #elif defined(__powerpc64__) 41 | __asm__ __volatile("ld 3,-28672(13)" : : : "r3", "r13"); 42 | #else 43 | #error Unsupported architecture 44 | #endif 45 | 46 | return SOLO5_EXIT_FAILURE; 47 | } 48 | -------------------------------------------------------------------------------- /tests/test_output/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_output 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_output/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_quiet/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_quiet 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_quiet/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_quiet/test_quiet.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | 23 | static size_t strlen(const char *s) 24 | { 25 | size_t len = 0; 26 | 27 | while (*s++) 28 | len += 1; 29 | return len; 30 | } 31 | 32 | static void puts(const char *s) 33 | { 34 | solo5_console_write(s, strlen(s)); 35 | } 36 | 37 | int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) 38 | { 39 | puts("\n**** Solo5 standalone test_verbose ****\n\n"); 40 | puts("SUCCESS\n"); 41 | /* The run-tests.sh script will run this with --quiet and checks that 42 | * there is no "Solo5:". */ 43 | return SOLO5_EXIT_SUCCESS; 44 | } 45 | -------------------------------------------------------------------------------- /tests/test_rnow/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_rnow 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_rnow/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_rnow/test_rnow.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | #include "../../bindings/lib.c" 23 | 24 | static void puts(const char *s) 25 | { 26 | solo5_console_write(s, strlen(s)); 27 | } 28 | 29 | __attribute__((section (".rodata"), noinline)) void nothing(void) 30 | { 31 | __asm__(""); 32 | } 33 | 34 | int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) 35 | { 36 | puts("\n**** Solo5 standalone test_rnow ****\n\n"); 37 | 38 | /* Verify that read only data (in section .rodata) is not writable. */ 39 | uint64_t *addr_invalid = (uint64_t *)nothing; 40 | *addr_invalid = 1; 41 | 42 | puts("FAILURE\n"); 43 | 44 | return SOLO5_EXIT_FAILURE; 45 | } 46 | -------------------------------------------------------------------------------- /tests/test_rnox/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_rnox 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_rnox/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_rnox/test_rnox.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | #include "../../bindings/lib.c" 23 | 24 | static void puts(const char *s) 25 | { 26 | solo5_console_write(s, strlen(s)); 27 | } 28 | 29 | __attribute__((section (".rodata"), noinline)) void nothing(void) 30 | { 31 | __asm__(""); 32 | } 33 | 34 | int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) 35 | { 36 | puts("\n**** Solo5 standalone test_rnox ****\n\n"); 37 | 38 | /* Verify that read only data (in section .rodata) is not executeable. */ 39 | nothing(); 40 | 41 | puts("FAILURE\n"); 42 | 43 | return SOLO5_EXIT_FAILURE; 44 | } 45 | -------------------------------------------------------------------------------- /tests/test_seccomp/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_seccomp 22 | 23 | CONFIG_HVT := 24 | CONFIG_VIRTIO := 25 | CONFIG_MUEN := 26 | CONFIG_XEN := 27 | 28 | include ../Makefile.tests 29 | -------------------------------------------------------------------------------- /tests/test_seccomp/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_seccomp/test_seccomp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | #include "../../bindings/lib.c" 23 | 24 | static void puts(const char *s) 25 | { 26 | solo5_console_write(s, strlen(s)); 27 | } 28 | 29 | int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) 30 | { 31 | puts("\n**** Solo5 standalone test_seccomp ****\n\n"); 32 | 33 | /* 34 | * Try to call SYS_dup(1), which is not in any seccomp policy we use. 35 | */ 36 | #if defined(__x86_64__) 37 | int ret; 38 | 39 | __asm__ __volatile__ ( 40 | "syscall" 41 | : "=a" (ret) : "a" (32), "D" (1) : "rcx", "r11", "memory" 42 | ); 43 | #elif defined(__aarch64__) 44 | register long x8 __asm__("x8") = 23; 45 | register long x0 __asm__("x0"); 46 | register long x1 __asm__("x1") = 1; 47 | 48 | __asm__ __volatile__ ( 49 | "svc 0" 50 | : "=r" (x0) : "r" (x8), "r" (x1) : "cc", "memory" 51 | ); 52 | #elif defined(__powerpc__) 53 | register long r0 __asm__("r0") = 41; 54 | register long r3 __asm__("r3") = 0; 55 | 56 | __asm__ __volatile__ ( 57 | "sc" 58 | : "=r" (r3) 59 | : "r" (r0), "r" (r3) 60 | : "cc", "memory" 61 | ); 62 | #else 63 | #error Unsupported architecture 64 | #endif 65 | 66 | puts("FAILURE\n"); 67 | return SOLO5_EXIT_FAILURE; 68 | } 69 | -------------------------------------------------------------------------------- /tests/test_ssp/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_ssp 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_ssp/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_ssp/show_canary.gdb: -------------------------------------------------------------------------------- 1 | target remote:1234 2 | p /x __stack_chk_guard 3 | b solo5_app_main 4 | c 5 | p /x __stack_chk_guard 6 | c 7 | q 8 | 9 | -------------------------------------------------------------------------------- /tests/test_ssp/test_ssp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | #include "../../bindings/lib.c" 23 | 24 | static void puts(const char *s) 25 | { 26 | solo5_console_write(s, strlen(s)); 27 | } 28 | 29 | int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) 30 | { 31 | puts("\n**** Solo5 standalone test_ssp ****\n\n"); 32 | 33 | /* 34 | * Now overwrite this functions canary, this will cause 35 | * an ABORT via __stack_chk_fail(). 36 | */ 37 | char buffer[16]; 38 | strcpy (buffer, "1234567890123456789012345678901234567890\n"); 39 | puts(buffer); 40 | 41 | return SOLO5_EXIT_FAILURE; 42 | } 43 | -------------------------------------------------------------------------------- /tests/test_time/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_time 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_time/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_tls/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_tls 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_tls/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_wnox/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_wnox 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_wnox/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_wnox/test_wnox.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | #include "../../bindings/lib.c" 23 | 24 | static void puts(const char *s) 25 | { 26 | solo5_console_write(s, strlen(s)); 27 | } 28 | 29 | __attribute__((section (".data"), noinline)) void nothing(void) 30 | { 31 | __asm__(""); 32 | } 33 | 34 | int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) 35 | { 36 | puts("\n**** Solo5 standalone test_wnox ****\n\n"); 37 | 38 | /* Verify that writable data (in section .data) is not executable. */ 39 | nothing(); 40 | 41 | puts("FAILURE\n"); 42 | 43 | return SOLO5_EXIT_FAILURE; 44 | } 45 | -------------------------------------------------------------------------------- /tests/test_xnor/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_xnor 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_xnor/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_xnor/test_xnor.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | #include "../../bindings/lib.c" 23 | 24 | static void puts(const char *s) 25 | { 26 | solo5_console_write(s, strlen(s)); 27 | } 28 | 29 | __attribute__((noinline)) void nothing(void) 30 | { 31 | __asm__(""); 32 | } 33 | 34 | int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) 35 | { 36 | puts("\n**** Solo5 standalone test_xnor ****\n\n"); 37 | 38 | /* Verify that executable code (in section .text) is not readable. */ 39 | uint64_t *addr_invalid = (uint64_t *)nothing; 40 | if((void *)*addr_invalid != NULL) 41 | puts("executable address read\n"); 42 | 43 | puts("FAILURE\n"); 44 | 45 | return SOLO5_EXIT_FAILURE; 46 | } 47 | -------------------------------------------------------------------------------- /tests/test_xnow/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_xnow 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_xnow/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_xnow/test_xnow.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | #include "../../bindings/lib.c" 23 | 24 | static void puts(const char *s) 25 | { 26 | solo5_console_write(s, strlen(s)); 27 | } 28 | 29 | __attribute__((noinline)) void nothing(void) 30 | { 31 | __asm__(""); 32 | } 33 | 34 | int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) 35 | { 36 | puts("\n**** Solo5 standalone test_xnow ****\n\n"); 37 | 38 | /* Verify that executable code (in section .text) is not writable. */ 39 | uint64_t *addr_invalid = (uint64_t *)nothing; 40 | *addr_invalid = 1; 41 | 42 | puts("FAILURE\n"); 43 | 44 | return SOLO5_EXIT_FAILURE; 45 | } 46 | -------------------------------------------------------------------------------- /tests/test_zeropage/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | include $(TOPDIR)/Makefile.common 20 | 21 | test_NAME := test_zeropage 22 | 23 | include ../Makefile.tests 24 | -------------------------------------------------------------------------------- /tests/test_zeropage/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "solo5.manifest", 3 | "version": 1, 4 | "devices": [ ] 5 | } 6 | -------------------------------------------------------------------------------- /tests/test_zeropage/test_zeropage.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2019 Contributors as noted in the AUTHORS file 3 | * 4 | * This file is part of Solo5, a sandboxed execution environment. 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software 7 | * for any purpose with or without fee is hereby granted, provided 8 | * that the above copyright notice and this permission notice appear 9 | * in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | */ 20 | 21 | #include "solo5.h" 22 | #include "../../bindings/lib.c" 23 | 24 | /* 25 | * Silence GCC's array bounds warning when accessing memory at address "8". 26 | * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578 27 | */ 28 | #pragma GCC diagnostic ignored "-Warray-bounds" 29 | 30 | static void puts(const char *s) 31 | { 32 | solo5_console_write(s, strlen(s)); 33 | } 34 | 35 | int solo5_app_main(const struct solo5_start_info *si __attribute__((unused))) 36 | { 37 | puts("\n**** Solo5 standalone test_zeropage ****\n\n"); 38 | 39 | /* 40 | * On aarch64, writing to an addr_invalid of "0" here appears to cause the 41 | * compiler to generate code for a debug exception (brk instruction)?! 42 | * Write to the next quadword, i.e. uint64_t at "8" instead. 43 | */ 44 | uint64_t *addr_invalid = (uint64_t *)8; 45 | *addr_invalid = 1; 46 | 47 | return SOLO5_EXIT_FAILURE; 48 | } 49 | -------------------------------------------------------------------------------- /toolchain/GNUmakefile: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015-2021 Contributors as noted in the AUTHORS file 2 | # 3 | # This file is part of Solo5, a sandboxed execution environment. 4 | # 5 | # Permission to use, copy, modify, and/or distribute this software 6 | # for any purpose with or without fee is hereby granted, provided 7 | # that the above copyright notice and this permission notice appear 8 | # in all copies. 9 | # 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 14 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 15 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 16 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 17 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 | 19 | ifndef TOPDIR 20 | $(error TOPDIR must be set, run $(MAKE) from the top of the source tree or set it manually) 21 | endif 22 | include $(TOPDIR)/Makefile.common 23 | 24 | .PHONY: all 25 | all: 26 | all_TARGETS := bin/$(CONFIG_TARGET_TRIPLE)-cc \ 27 | bin/$(CONFIG_TARGET_TRIPLE)-ld \ 28 | bin/$(CONFIG_TARGET_TRIPLE)-objcopy \ 29 | include/solo5 \ 30 | include/$(CONFIG_TARGET_TRIPLE) \ 31 | lib/$(CONFIG_TARGET_TRIPLE) 32 | 33 | .SUFFIXES: 34 | $(V).SILENT: 35 | 36 | bin: 37 | mkdir -p $@ 38 | 39 | bin/$(CONFIG_TARGET_TRIPLE)-%: %.in | bin 40 | @echo "SUBST $@" 41 | sed -e 's!@@CONFIG_TARGET_ARCH@@!$(CONFIG_TARGET_ARCH)!g' \ 42 | -e 's!@@CONFIG_TARGET_TRIPLE@@!$(CONFIG_TARGET_TRIPLE)!g' \ 43 | -e 's!@@CONFIG_TARGET_CC@@!$(CONFIG_TARGET_CC)!g' \ 44 | -e 's!@@CONFIG_TARGET_CC_CFLAGS@@!$(CONFIG_TARGET_CC_CFLAGS)!g' \ 45 | -e 's!@@CONFIG_TARGET_CC_LDFLAGS@@!$(CONFIG_TARGET_CC_LDFLAGS)!g' \ 46 | -e 's!@@CONFIG_TARGET_LD@@!$(CONFIG_TARGET_LD)!g' \ 47 | -e 's!@@CONFIG_TARGET_LD_LDFLAGS@@!$(CONFIG_TARGET_LD_LDFLAGS)!g' \ 48 | -e 's!@@CONFIG_TARGET_LD_MAX_PAGE_SIZE@@!$(CONFIG_TARGET_LD_MAX_PAGE_SIZE)!g' \ 49 | -e 's!@@CONFIG_TARGET_OBJCOPY@@!$(CONFIG_TARGET_OBJCOPY)!g' \ 50 | $< >$@ 51 | chmod +x $@ 52 | 53 | include: 54 | mkdir -p $@ 55 | 56 | include/solo5: | include 57 | ln -s $(TOPDIR)/include $@ 58 | 59 | include/$(CONFIG_TARGET_TRIPLE): | include 60 | @echo "GEN $@" 61 | ./gen-headers.sh $@ 62 | 63 | lib: 64 | mkdir -p $@ 65 | 66 | lib/$(CONFIG_TARGET_TRIPLE): | lib 67 | ln -s $(TOPDIR)/bindings $@ 68 | 69 | all: $(all_TARGETS) 70 | 71 | .PHONY: clean 72 | clean: 73 | @echo "CLEAN toolchain" 74 | $(RM) -r bin/ include/ lib/ 75 | -------------------------------------------------------------------------------- /toolchain/ld.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2015-2021 Contributors as noted in the AUTHORS file 3 | # 4 | # This file is part of Solo5, a sandboxed execution environment. 5 | # 6 | # Permission to use, copy, modify, and/or distribute this software 7 | # for any purpose with or without fee is hereby granted, provided 8 | # that the above copyright notice and this permission notice appear 9 | # in all copies. 10 | # 11 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | 20 | # @@CONFIG_TARGET_TRIPLE@@-ld: Solo5 wrapper for 'ld'. 21 | # Generated by configure.sh at build time. 22 | # 23 | # Passes through to @@CONFIG_TARGET_LD@ for actual work. Defines all flags 24 | # required for correct operation when linking code intended for inclusion in a 25 | # Solo5 unikernel. 26 | # 27 | # Provides a '-z solo5-abi=ABI' option to select the Solo5 bindings to use if 28 | # linking a unikernel. No default for ABI is provided, as it is expected that a 29 | # caller directly using 'ld' knows what they are doing. 30 | 31 | L="$(realpath $0 | xargs dirname)/../lib/@@CONFIG_TARGET_TRIPLE@@" 32 | [ ! -d "${L}" ] && echo "$0: Could not determine library path" 1>&2 && exit 1 33 | # ld accepts -z solo5-abi=ABI, but does not provide a default ABI 34 | # this is intentional 35 | B= 36 | Z= 37 | for arg do 38 | shift 39 | if [ -n "${Z}" ]; then 40 | # handle -z linker-arg 41 | Z= 42 | case "$arg" in 43 | solo5-abi=*) 44 | B="${arg##*=}" 45 | continue 46 | ;; 47 | *) 48 | set -- "$@" "-z" "$arg" 49 | continue 50 | ;; 51 | esac 52 | fi 53 | 54 | case "$arg" in 55 | -z) 56 | if [ -z "${Z}" ]; then 57 | Z=1 58 | continue 59 | fi 60 | ;; 61 | esac 62 | set -- "$@" "$arg" 63 | done 64 | [ -n "${B}" ] && B="-T solo5_${B}.lds -l :solo5_${B}.o" 65 | [ -n "${__V}" ] && set -x 66 | exec @@CONFIG_TARGET_LD@@ \ 67 | @@CONFIG_TARGET_LD_LDFLAGS@@ \ 68 | -nostdlib \ 69 | -L ${L} \ 70 | -z max-page-size=@@CONFIG_TARGET_LD_MAX_PAGE_SIZE@@ \ 71 | -static \ 72 | ${B} \ 73 | "$@" 74 | -------------------------------------------------------------------------------- /toolchain/objcopy.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2015-2021 Contributors as noted in the AUTHORS file 3 | # 4 | # This file is part of Solo5, a sandboxed execution environment. 5 | # 6 | # Permission to use, copy, modify, and/or distribute this software 7 | # for any purpose with or without fee is hereby granted, provided 8 | # that the above copyright notice and this permission notice appear 9 | # in all copies. 10 | # 11 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 12 | # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 13 | # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 14 | # AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR 15 | # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 16 | # OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 17 | # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 18 | # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | 20 | # @@CONFIG_TARGET_TRIPLE@@-objcopy: Solo5 wrapper for 'objcopy'. 21 | # Generated by configure.sh at build time. 22 | # 23 | # Passes through to @@CONFIG_TARGET_OBJCOPY@ for actual work. 24 | # 25 | [ -n "${__V}" ] && set -x 26 | exec @@CONFIG_TARGET_OBJCOPY@@ \ 27 | "$@" 28 | --------------------------------------------------------------------------------