├── .appveyor.yml ├── .codecov.yml ├── .doxygen.txt ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CMakeLists.txt ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── NOTES.txt ├── README.md ├── Vagrantfile ├── bfack └── src │ ├── CMakeLists.txt │ └── ack.cpp ├── bfdriver ├── include │ └── common.h ├── src │ ├── common.c │ └── platform │ │ ├── efi │ │ ├── CMakeLists.txt │ │ ├── MpService.h │ │ ├── entry.c │ │ ├── platform.asm │ │ └── platform.c │ │ ├── linux │ │ ├── Makefile │ │ ├── entry.c │ │ └── platform.c │ │ ├── test │ │ └── platform.c │ │ └── windows │ │ ├── bareflank.inf │ │ ├── bareflank.sln │ │ ├── bareflank.vcxproj │ │ ├── bareflank.vcxproj.filters │ │ ├── device.c │ │ ├── device.h │ │ ├── driver.c │ │ ├── driver.h │ │ ├── platform.c │ │ ├── queue.c │ │ └── queue.h └── tests │ ├── CMakeLists.txt │ ├── test_common_add_module.cpp │ ├── test_common_dump.cpp │ ├── test_common_fini.cpp │ ├── test_common_init.cpp │ ├── test_common_load.cpp │ ├── test_common_start.cpp │ ├── test_common_stop.cpp │ ├── test_common_unload.cpp │ ├── test_support.cpp │ └── test_support.h ├── bfdummy ├── include │ └── dummy_libs.h └── src │ ├── CMakeLists.txt │ ├── libs │ ├── CMakeLists.txt │ ├── dummy_lib1.cpp │ └── dummy_lib2.cpp │ └── main │ ├── CMakeLists.txt │ └── dummy_main.cpp ├── bfelf_loader ├── include │ ├── bfelf_loader.h │ ├── bfelf_loader_reloc_aarch64.h │ └── bfelf_loader_reloc_x64.h └── tests │ ├── CMakeLists.txt │ ├── test_binary.cpp │ ├── test_fake_elf.cpp │ ├── test_fake_elf.h │ ├── test_file_get_entry.cpp │ ├── test_file_get_load_instr.cpp │ ├── test_file_get_needed.cpp │ ├── test_file_get_num_load_instrs.cpp │ ├── test_file_get_num_needed.cpp │ ├── test_file_get_pic_pie.cpp │ ├── test_file_get_section_info.cpp │ ├── test_file_get_total_size.cpp │ ├── test_file_init.cpp │ ├── test_helpers.cpp │ ├── test_load.cpp │ ├── test_loader_add.cpp │ ├── test_loader_relocate.cpp │ ├── test_loader_resolve_symbol.cpp │ ├── test_read_binary_and_get_needed_list.cpp │ ├── test_real.cpp │ ├── test_real_elf.cpp │ ├── test_real_elf.h │ ├── test_set_args.cpp │ └── test_set_integer_args.cpp ├── bfintrinsics ├── include │ ├── arch │ │ ├── intel_x64 │ │ │ ├── apic │ │ │ │ ├── ioapic.h │ │ │ │ ├── lapic.h │ │ │ │ └── x2apic.h │ │ │ ├── barrier.h │ │ │ ├── bit.h │ │ │ ├── cpuid.h │ │ │ ├── crs.h │ │ │ ├── drs.h │ │ │ ├── ept.h │ │ │ ├── msrs.h │ │ │ ├── pause.h │ │ │ ├── vmcs │ │ │ │ ├── 16bit_control_fields.h │ │ │ │ ├── 16bit_guest_state_fields.h │ │ │ │ ├── 16bit_host_state_fields.h │ │ │ │ ├── 32bit_control_fields.h │ │ │ │ ├── 32bit_guest_state_fields.h │ │ │ │ ├── 32bit_host_state_fields.h │ │ │ │ ├── 32bit_read_only_data_fields.h │ │ │ │ ├── 64bit_control_fields.h │ │ │ │ ├── 64bit_guest_state_fields.h │ │ │ │ ├── 64bit_host_state_fields.h │ │ │ │ ├── 64bit_read_only_data_fields.h │ │ │ │ ├── debug.h │ │ │ │ ├── helpers.h │ │ │ │ ├── natural_width_control_fields.h │ │ │ │ ├── natural_width_guest_state_fields.h │ │ │ │ ├── natural_width_host_state_fields.h │ │ │ │ └── natural_width_read_only_data_fields.h │ │ │ └── vmx.h │ │ └── x64 │ │ │ ├── cache.h │ │ │ ├── cpuid.h │ │ │ ├── gdt.h │ │ │ ├── idt.h │ │ │ ├── misc.h │ │ │ ├── msrs.h │ │ │ ├── paging.h │ │ │ ├── pm.h │ │ │ ├── portio.h │ │ │ ├── rdtsc.h │ │ │ ├── rflags.h │ │ │ ├── srs.h │ │ │ └── tlb.h │ └── intrinsics.h └── src │ ├── CMakeLists.txt │ ├── arch │ ├── intel_x64 │ │ ├── barrier.asm │ │ ├── bit.asm │ │ ├── crs.asm │ │ ├── drs.asm │ │ ├── pause.asm │ │ └── vmx.asm │ └── x64 │ │ ├── cache.asm │ │ ├── cpuid.asm │ │ ├── gdt.asm │ │ ├── idt.asm │ │ ├── msrs.asm │ │ ├── pm.asm │ │ ├── portio.asm │ │ ├── rdtsc.asm │ │ ├── rflags.asm │ │ ├── srs.asm │ │ └── tlb.asm │ └── null.cpp ├── bfm ├── include │ ├── command_line_parser.h │ ├── ioctl.h │ └── ioctl_driver.h ├── src │ ├── CMakeLists.txt │ ├── command_line_parser.cpp │ ├── ioctl_driver.cpp │ ├── main.cpp │ └── platform │ │ ├── linux │ │ ├── ioctl.cpp │ │ ├── ioctl_private.cpp │ │ └── ioctl_private.h │ │ └── windows │ │ ├── ioctl.cpp │ │ ├── ioctl_private.cpp │ │ └── ioctl_private.h └── tests │ ├── CMakeLists.txt │ ├── test_command_line_parser.cpp │ ├── test_ioctl_driver.cpp │ ├── test_main.cpp │ └── test_support.h ├── bfruntime ├── src │ ├── crt │ │ ├── CMakeLists.txt │ │ ├── crt.cpp │ │ ├── start_aarch64.S │ │ └── start_x64.asm │ ├── dso │ │ ├── CMakeLists.txt │ │ └── dso.cpp │ ├── pthread │ │ ├── CMakeLists.txt │ │ ├── pthread.cpp │ │ └── threadcontext.asm │ └── syscall │ │ ├── CMakeLists.txt │ │ └── syscall.cpp └── tests │ ├── CMakeLists.txt │ └── crt │ └── test_crt.cpp ├── bfsdk ├── include │ ├── bfack.h │ ├── bfaffinity.h │ ├── bfarch.h │ ├── bfbenchmark.h │ ├── bfbitmanip.h │ ├── bfbuffer.h │ ├── bfcallonce.h │ ├── bfconstants.h │ ├── bfdebug.h │ ├── bfdebugringinterface.h │ ├── bfdelegate.h │ ├── bfdriverinterface.h │ ├── bfdwarf.h │ ├── bfehframelist.h │ ├── bferrorcodes.h │ ├── bfexception.h │ ├── bfexports.h │ ├── bffile.h │ ├── bfgsl.h │ ├── bfjson.h │ ├── bfmanager.h │ ├── bfmemory.h │ ├── bfobject.h │ ├── bfplatform.h │ ├── bfshuffle.h │ ├── bfstd.h │ ├── bfstring.h │ ├── bfsupport.h │ ├── bfthreadcontext.h │ ├── bftypes.h │ ├── bfupperlower.h │ ├── bfvcpuid.h │ └── bfvector.h └── tests │ ├── CMakeLists.txt │ ├── test_affinity.cpp │ ├── test_benchmark.cpp │ ├── test_bitmanip.cpp │ ├── test_buffer.cpp │ ├── test_callonce.cpp │ ├── test_catch.cpp │ ├── test_debug.cpp │ ├── test_debugringinterface.cpp │ ├── test_delegate.cpp │ ├── test_errorcodes.cpp │ ├── test_exceptions.cpp │ ├── test_file.cpp │ ├── test_gsl.cpp │ ├── test_gsl_lite.cpp │ ├── test_json.cpp │ ├── test_manager.cpp │ ├── test_shuffle.cpp │ ├── test_string.cpp │ ├── test_types.cpp │ ├── test_upperlower.cpp │ ├── test_vcpuid.cpp │ └── test_vector.cpp ├── bfunwind ├── include │ ├── abort.h │ ├── dwarf4.h │ ├── eh_frame.h │ ├── ia64_cxx_abi.h │ ├── log.h │ ├── misc.h │ ├── registers.h │ └── registers_intel_x64.h └── src │ ├── CMakeLists.txt │ ├── dwarf4.cpp │ ├── eh_frame.cpp │ ├── ia64_cxx_abi.cpp │ └── registers_intel_x64.asm ├── bfvmm ├── include │ ├── debug │ │ ├── debug_ring │ │ │ └── debug_ring.h │ │ └── serial │ │ │ ├── serial_ns16550a.h │ │ │ └── serial_pl011.h │ ├── hve │ │ └── arch │ │ │ ├── intel_x64 │ │ │ ├── check.h │ │ │ ├── check_vmcs_control_fields.h │ │ │ ├── check_vmcs_guest_fields.h │ │ │ ├── check_vmcs_host_fields.h │ │ │ ├── ept.h │ │ │ ├── ept │ │ │ │ ├── helpers.h │ │ │ │ └── mmap.h │ │ │ ├── exception.h │ │ │ ├── exit_handler.h │ │ │ ├── hashtable.h │ │ │ ├── interrupt_queue.h │ │ │ ├── microcode.h │ │ │ ├── mtrrs.h │ │ │ ├── vcpu.h │ │ │ ├── vcpu_global_state.h │ │ │ ├── vcpu_state.h │ │ │ ├── vmcs.h │ │ │ ├── vmexit │ │ │ │ ├── control_register.h │ │ │ │ ├── cpuid.h │ │ │ │ ├── descriptor.h │ │ │ │ ├── ept_misconfiguration.h │ │ │ │ ├── ept_violation.h │ │ │ │ ├── external_interrupt.h │ │ │ │ ├── init_signal.h │ │ │ │ ├── interrupt_window.h │ │ │ │ ├── io_instruction.h │ │ │ │ ├── monitor_trap.h │ │ │ │ ├── nmi.h │ │ │ │ ├── nmi_window.h │ │ │ │ ├── preemption_timer.h │ │ │ │ ├── rdmsr.h │ │ │ │ ├── sipi_signal.h │ │ │ │ ├── wrmsr.h │ │ │ │ ├── xsave.h │ │ │ │ └── xsetbv.h │ │ │ ├── vmx.h │ │ │ └── vpid.h │ │ │ └── x64 │ │ │ ├── gdt.h │ │ │ ├── idt.h │ │ │ ├── tss.h │ │ │ └── unmapper.h │ ├── memory_manager │ │ ├── arch │ │ │ └── x64 │ │ │ │ ├── cr3.h │ │ │ │ └── cr3 │ │ │ │ ├── helpers.h │ │ │ │ └── mmap.h │ │ ├── buddy_allocator.h │ │ ├── memory_manager.h │ │ └── object_allocator.h │ ├── test │ │ ├── hve.h │ │ ├── intrinsics.h │ │ ├── memory_manager.h │ │ ├── misc.h │ │ └── support.h │ ├── vcpu │ │ ├── vcpu.h │ │ ├── vcpu_factory.h │ │ └── vcpu_manager.h │ └── vmm.h ├── integration │ ├── CMakeLists.txt │ └── arch │ │ └── intel_x64 │ │ ├── CMakeLists.txt │ │ ├── efi │ │ ├── CMakeLists.txt │ │ ├── test_efi.cpp │ │ └── test_efi_with_interrupts.cpp │ │ ├── ept │ │ ├── CMakeLists.txt │ │ ├── enable_ept.cpp │ │ └── remap_page.cpp │ │ ├── test_all.cpp │ │ ├── test_all_inheritance.cpp │ │ ├── vmexit │ │ ├── control_register │ │ │ ├── CMakeLists.txt │ │ │ ├── trap_cr0.cpp │ │ │ ├── trap_cr3.cpp │ │ │ └── trap_cr4.cpp │ │ ├── cpuid │ │ │ ├── CMakeLists.txt │ │ │ └── trap_cpuid.cpp │ │ ├── ept_misconfiguration │ │ │ ├── CMakeLists.txt │ │ │ └── trap_ept_misconfiguration.cpp │ │ ├── ept_violation │ │ │ ├── CMakeLists.txt │ │ │ ├── trap_ept_execute_violation.cpp │ │ │ ├── trap_ept_read_violation.cpp │ │ │ └── trap_ept_write_violation.cpp │ │ ├── external_interrupt │ │ │ ├── CMakeLists.txt │ │ │ └── trap_all_interrupts.cpp │ │ ├── io_instruction │ │ │ ├── CMakeLists.txt │ │ │ └── trap_in_out.cpp │ │ ├── monitor_trap │ │ │ ├── CMakeLists.txt │ │ │ └── single_step_cpuid.cpp │ │ ├── rdmsr │ │ │ ├── CMakeLists.txt │ │ │ └── trap_rdmsr.cpp │ │ └── wrmsr │ │ │ ├── CMakeLists.txt │ │ │ └── trap_wrmsr.cpp │ │ └── vpid │ │ ├── CMakeLists.txt │ │ └── enable_vpid.cpp ├── main │ ├── CMakeLists.txt │ └── main.cpp ├── src │ ├── CMakeLists.txt │ ├── debug │ │ ├── CMakeLists.txt │ │ ├── arch │ │ │ ├── aarch64 │ │ │ │ └── serial_ns16550a.cpp │ │ │ └── x64 │ │ │ │ └── serial_ns16550a.cpp │ │ ├── debug_ring │ │ │ └── debug_ring.cpp │ │ ├── serial │ │ │ ├── serial_ns16550a.cpp │ │ │ └── serial_pl011.cpp │ │ └── unistd.cpp │ ├── entry │ │ ├── CMakeLists.txt │ │ └── entry.cpp │ ├── hve │ │ ├── CMakeLists.txt │ │ └── arch │ │ │ ├── intel_x64 │ │ │ ├── check_vmcs_control_fields.cpp │ │ │ ├── check_vmcs_guest_fields.cpp │ │ │ ├── check_vmcs_host_fields.cpp │ │ │ ├── ept.cpp │ │ │ ├── exception.asm │ │ │ ├── exception.cpp │ │ │ ├── exit_handler.cpp │ │ │ ├── exit_handler_entry.asm │ │ │ ├── hashtable.cpp │ │ │ ├── interrupt_queue.cpp │ │ │ ├── microcode.cpp │ │ │ ├── mtrrs.cpp │ │ │ ├── vcpu.cpp │ │ │ ├── vcpu_factory.cpp │ │ │ ├── vmcs.cpp │ │ │ ├── vmcs_launch.asm │ │ │ ├── vmcs_promote.asm │ │ │ ├── vmcs_resume.asm │ │ │ ├── vmexit │ │ │ │ ├── control_register.cpp │ │ │ │ ├── cpuid.cpp │ │ │ │ ├── descriptor.cpp │ │ │ │ ├── ept_misconfiguration.cpp │ │ │ │ ├── ept_violation.cpp │ │ │ │ ├── external_interrupt.cpp │ │ │ │ ├── init_signal.cpp │ │ │ │ ├── interrupt_window.cpp │ │ │ │ ├── io_instruction.cpp │ │ │ │ ├── monitor_trap.cpp │ │ │ │ ├── nmi.cpp │ │ │ │ ├── nmi_window.cpp │ │ │ │ ├── preemption_timer.cpp │ │ │ │ ├── rdmsr.cpp │ │ │ │ ├── sipi_signal.cpp │ │ │ │ ├── wrmsr.cpp │ │ │ │ ├── xsave.cpp │ │ │ │ └── xsetbv.cpp │ │ │ ├── vmx.cpp │ │ │ └── vpid.cpp │ │ │ └── x64 │ │ │ └── unmapper.cpp │ ├── memory_manager │ │ ├── CMakeLists.txt │ │ ├── arch │ │ │ └── x64 │ │ │ │ └── cr3 │ │ │ │ └── helpers.cpp │ │ └── memory_manager.cpp │ └── vcpu │ │ ├── CMakeLists.txt │ │ └── vcpu.cpp └── tests │ ├── CMakeLists.txt │ ├── debug │ ├── CMakeLists.txt │ ├── debug_ring │ │ ├── CMakeLists.txt │ │ └── test_debug_ring.cpp │ └── serial │ │ ├── test_serial_ns16550a.cpp │ │ └── test_serial_pl011.cpp │ ├── hve │ ├── CMakeLists.txt │ └── arch │ │ ├── intel_x64 │ │ ├── test_check.cpp │ │ ├── test_check_vmcs_controls_fields.cpp │ │ ├── test_check_vmcs_guest_fields.cpp │ │ ├── test_check_vmcs_host_fields.cpp │ │ ├── test_exception.cpp │ │ ├── test_exit_handler.cpp │ │ ├── test_nmi.cpp │ │ ├── test_support.h │ │ ├── test_vcpu.cpp │ │ ├── test_vmcs.cpp │ │ ├── test_vmx.cpp │ │ └── vmexit │ │ │ ├── test_control_register.cpp │ │ │ ├── test_cpuid.cpp │ │ │ ├── test_rdmsr.cpp │ │ │ └── test_wrmsr.cpp │ │ └── x64 │ │ ├── test_gdt.cpp │ │ └── test_idt.cpp │ ├── memory_manager │ ├── CMakeLists.txt │ ├── arch │ │ └── x64 │ │ │ └── cr3 │ │ │ ├── test_helpers.cpp │ │ │ └── test_mmap.cpp │ ├── test_buddy_allocator.cpp │ ├── test_memory_manager.cpp │ └── test_object_allocator.cpp │ └── vcpu │ ├── CMakeLists.txt │ ├── test_vcpu.cpp │ └── test_vcpu_factory.cpp ├── config.cmake └── scripts ├── cmake ├── config │ ├── default.cmake │ ├── example_config.cmake │ ├── example_extension.cmake │ ├── travis_asan.cmake │ ├── travis_codecov.cmake │ ├── travis_format.cmake │ ├── travis_shared.cmake │ ├── travis_static.cmake │ ├── travis_tidy.cmake │ └── travis_usan.cmake ├── depends │ ├── astyle.cmake │ ├── binutils.cmake │ ├── catch.cmake │ ├── clang_tidy.cmake │ ├── cxxopts.cmake │ ├── gnuefi.cmake │ ├── gsl.cmake │ ├── hippomocks.cmake │ ├── json.cmake │ ├── libcxx.cmake │ ├── libcxxabi.cmake │ ├── llvm.cmake │ ├── newlib.cmake │ └── python.cmake ├── flags │ ├── asan_flags.cmake │ ├── codecov_flags.cmake │ ├── efi_flags.cmake │ ├── test_flags.cmake │ ├── usan_flags.cmake │ ├── userspace_flags.cmake │ ├── vmm_flags.cmake │ └── warning_flags.cmake ├── macros.cmake ├── project.cmake ├── targets.cmake ├── toolchain │ ├── clang_aarch64_vmm.cmake │ ├── clang_x86_64_efi.cmake │ └── clang_x86_64_vmm.cmake └── validate.cmake ├── util ├── bareflank_astyle_format.sh ├── bareflank_clang_tidy.sh ├── driver_build.sh ├── driver_clean.sh ├── driver_load.sh └── driver_unload.sh └── vagrant └── provision_ubuntu17_10.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (C) 2019 Assured Information Security, 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 deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | 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 all 13 | 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 FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | Vagrant.configure(2) do |config| 23 | config.vm.provider "virtualbox" do |vb| 24 | vb.memory = "2048" 25 | vb.cpus = 2 26 | end 27 | 28 | config.vm.define "ubuntu17_10", primary: true do |ubuntu17_10| 29 | ubuntu17_10.vm.box = "ubuntu/artful64" 30 | ubuntu17_10.vm.provision "shell", 31 | path: "scripts/vagrant/provision_ubuntu17_10.sh" 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /bfack/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(bfack C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project() 27 | 28 | add_executable(bfack ack.cpp) 29 | target_link_static_libraries(bfack bfintrinsics) 30 | 31 | install(TARGETS bfack DESTINATION bin) 32 | -------------------------------------------------------------------------------- /bfack/src/ack.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | int main() 26 | { 27 | if (bfack() != 0) { 28 | std::clog << "ack: success" << '\n'; 29 | } 30 | else { 31 | std::clog << "ack: failure" << '\n'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bfdriver/src/platform/efi/platform.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | ; in the Software without restriction, including without limitation the rights 7 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | ; 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 all 12 | ; 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 FROM, 19 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | ; SOFTWARE. 21 | 22 | bits 64 23 | default rel 24 | 25 | section .text 26 | 27 | global _set_ne 28 | _set_ne: 29 | mov rax, cr0 30 | or rax, 0x20 31 | mov cr0, rax 32 | 33 | ret 34 | -------------------------------------------------------------------------------- /bfdriver/src/platform/linux/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | TARGET_MODULE:=bareflank 23 | 24 | ifneq ($(KERNELRELEASE),) 25 | obj-m := $(TARGET_MODULE).o 26 | 27 | $(TARGET_MODULE)-objs += entry.o 28 | $(TARGET_MODULE)-objs += platform.o 29 | $(TARGET_MODULE)-objs += ../../common.o 30 | 31 | EXTRA_CFLAGS += -DKERNEL 32 | EXTRA_CFLAGS += -DLINUX_KERNEL 33 | EXTRA_CFLAGS += -I$(src)/../../../include/ 34 | EXTRA_CFLAGS += -I$(src)/../../../../bfsdk/include/ 35 | EXTRA_CFLAGS += -I$(src)/../../../../bfelf_loader/include/ 36 | 37 | else 38 | BUILDSYSTEM_DIR:=/lib/modules/$(shell uname -r)/build 39 | PWD:=$(shell pwd) 40 | 41 | all: 42 | $(MAKE) -C $(BUILDSYSTEM_DIR) M=$(PWD) modules 43 | 44 | clean: 45 | $(MAKE) -C $(BUILDSYSTEM_DIR) M=$(PWD) clean 46 | rm -f ../../common.o 47 | rm -f ../../.common.o.cmd 48 | 49 | load: 50 | insmod ./$(TARGET_MODULE).ko 51 | 52 | unload: 53 | -rmmod ./$(TARGET_MODULE).ko 54 | 55 | endif 56 | -------------------------------------------------------------------------------- /bfdriver/src/platform/windows/bareflank.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | {01371a61-2ed2-4da4-9ef8-a45467279dda} 35 | *.c 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /bfdriver/src/platform/windows/device.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * 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 all 12 | * 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 FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | NTSTATUS 26 | bareflankCreateDevice( 27 | _Inout_ PWDFDEVICE_INIT DeviceInit 28 | ) 29 | { 30 | NTSTATUS status; 31 | WDFDEVICE device; 32 | WDF_OBJECT_ATTRIBUTES deviceAttributes; 33 | 34 | WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&deviceAttributes, DEVICE_CONTEXT); 35 | 36 | status = WdfDeviceCreate(&DeviceInit, &deviceAttributes, &device); 37 | if (!NT_SUCCESS(status)) { 38 | return status; 39 | } 40 | 41 | status = WdfDeviceCreateDeviceInterface(device, &GUID_DEVINTERFACE_bareflank, NULL); 42 | if (!NT_SUCCESS(status)) { 43 | return status; 44 | } 45 | 46 | status = bareflankQueueInitialize(device); 47 | if (!NT_SUCCESS(status)) { 48 | return status; 49 | } 50 | 51 | BFDEBUG("bareflankCreateDevice: success\n"); 52 | return status; 53 | } 54 | -------------------------------------------------------------------------------- /bfdriver/src/platform/windows/device.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * 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 all 12 | * 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 FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | EXTERN_C_START 24 | 25 | typedef struct _DEVICE_CONTEXT { 26 | ULONG reserved; 27 | 28 | } DEVICE_CONTEXT, *PDEVICE_CONTEXT; 29 | 30 | WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(DEVICE_CONTEXT, DeviceGetContext) 31 | 32 | NTSTATUS 33 | bareflankCreateDevice( 34 | _Inout_ PWDFDEVICE_INIT DeviceInit 35 | ); 36 | 37 | EXTERN_C_END 38 | -------------------------------------------------------------------------------- /bfdriver/src/platform/windows/driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * 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 all 12 | * 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 FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | #define INITGUID 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | EXTERN_C_START 38 | 39 | DRIVER_INITIALIZE DriverEntry; 40 | EVT_WDF_DRIVER_DEVICE_ADD bareflankEvtDeviceAdd; 41 | EVT_WDF_OBJECT_CONTEXT_CLEANUP bareflankEvtDriverContextCleanup; 42 | EVT_WDF_DEVICE_D0_ENTRY bareflankEvtDeviceD0Entry; 43 | EVT_WDF_DEVICE_D0_EXIT bareflankEvtDeviceD0Exit; 44 | 45 | EXTERN_C_END 46 | -------------------------------------------------------------------------------- /bfdriver/src/platform/windows/queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * 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 all 12 | * 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 FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | EXTERN_C_START 24 | 25 | typedef struct _QUEUE_CONTEXT { 26 | ULONG reserved; 27 | 28 | } QUEUE_CONTEXT, *PQUEUE_CONTEXT; 29 | 30 | WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(QUEUE_CONTEXT, QueueGetContext) 31 | 32 | NTSTATUS 33 | bareflankQueueInitialize( 34 | _In_ WDFDEVICE hDevice 35 | ); 36 | 37 | EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL bareflankEvtIoDeviceControl; 38 | EVT_WDF_IO_QUEUE_IO_STOP bareflankEvtIoStop; 39 | 40 | EXTERN_C_END 41 | -------------------------------------------------------------------------------- /bfdriver/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(bfdriver_test C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project( 27 | INCLUDES ../include 28 | CXX_FLAGS -DVMM_PREFIX_PATH='"${VMM_PREFIX_PATH}"' 29 | ) 30 | 31 | list(APPEND SOURCES 32 | test_support.cpp 33 | ${SOURCE_BFDRIVER_DIR}/src/common.c 34 | ${SOURCE_BFDRIVER_DIR}/src/platform/test/platform.c 35 | ) 36 | 37 | add_static_library( 38 | test_support 39 | SOURCES ${SOURCES} 40 | ALWAYS 41 | ) 42 | 43 | do_test(test_common_add_module DEPENDS test_support) 44 | do_test(test_common_dump DEPENDS test_support) 45 | do_test(test_common_fini DEPENDS test_support) 46 | do_test(test_common_init DEPENDS test_support) 47 | do_test(test_common_load DEPENDS test_support) 48 | do_test(test_common_start DEPENDS test_support) 49 | do_test(test_common_stop DEPENDS test_support) 50 | do_test(test_common_unload DEPENDS test_support) 51 | -------------------------------------------------------------------------------- /bfdriver/tests/test_common_init.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | #ifdef _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT 31 | 32 | TEST_CASE("run init") 33 | { 34 | CHECK(common_init() == BF_SUCCESS); 35 | } 36 | 37 | TEST_CASE("failure") 38 | { 39 | MockRepository mocks; 40 | mocks.OnCallFunc(platform_init).Return(BF_ERROR_UNKNOWN); 41 | 42 | CHECK(common_init() == BF_ERROR_UNKNOWN); 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /bfdriver/tests/test_support.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef TEST_SUPPORT_H 23 | #define TEST_SUPPORT_H 24 | 25 | extern file g_file; 26 | extern std::vector g_filenames_success; 27 | extern std::vector g_filenames_init_fails; 28 | extern std::vector g_filenames_fini_fails; 29 | extern std::vector g_filenames_add_mdl_fails; 30 | extern std::vector g_filenames_get_drr_fails; 31 | extern std::vector g_filenames_set_rsdp_fails; 32 | extern std::vector g_filenames_vmm_init_fails; 33 | extern std::vector g_filenames_vmm_fini_fails; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /bfdummy/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(bfdummy C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project( 27 | INCLUDES ${CMAKE_CURRENT_LIST_DIR}/../include 28 | ) 29 | 30 | add_subdirectory(libs) 31 | -------------------------------------------------------------------------------- /bfdummy/src/libs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | add_shared_library( 23 | dummy_lib1 24 | SOURCES dummy_lib1.cpp 25 | DEFINES SHARED_DUMMY 26 | ALWAYS 27 | ) 28 | 29 | add_shared_library( 30 | dummy_lib2 31 | SOURCES dummy_lib2.cpp 32 | DEFINES SHARED_DUMMY 33 | ALWAYS 34 | ) 35 | -------------------------------------------------------------------------------- /bfdummy/src/libs/dummy_lib1.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | EXPORT_SYM extern "C" int 26 | lib1_foo() 27 | { return 1; } 28 | 29 | derived1::derived1() noexcept 30 | { 31 | global_var++; 32 | } 33 | 34 | derived1::~derived1() 35 | { 36 | global_var--; 37 | m_member = 0; 38 | } 39 | 40 | int 41 | derived1::foo(int arg) noexcept 42 | { 43 | return arg + m_member; 44 | } 45 | -------------------------------------------------------------------------------- /bfdummy/src/libs/dummy_lib2.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | 24 | extern "C" int lib1_foo(); 25 | 26 | derived2::derived2() noexcept 27 | { 28 | global_var += lib1_foo(); 29 | } 30 | 31 | derived2::~derived2() 32 | { 33 | global_var -= lib1_foo(); 34 | m_member = 0; 35 | } 36 | 37 | int 38 | derived2::foo(int arg) noexcept 39 | { 40 | return arg + m_member; 41 | } 42 | -------------------------------------------------------------------------------- /bfelf_loader/tests/test_file_get_num_load_instrs.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | TEST_CASE("bfelf_file_get_num_load_instrs: invalid elf file") 26 | { 27 | auto ret = bfelf_file_get_num_load_instrs(nullptr); 28 | CHECK(ret == BFELF_ERROR_INVALID_ARG); 29 | } 30 | 31 | TEST_CASE("bfelf_file_get_num_load_instrs: uninitialized") 32 | { 33 | bfelf_file_t ef = {}; 34 | 35 | auto ret = bfelf_file_get_num_load_instrs(&ef); 36 | CHECK(ret == 0); 37 | } 38 | 39 | TEST_CASE("bfelf_file_get_num_load_instrs: success") 40 | { 41 | int64_t ret = 0; 42 | bfelf_file_t ef = {}; 43 | 44 | auto data = get_fake_elf(); 45 | auto &buf = std::get<0>(data); 46 | auto size = std::get<1>(data); 47 | 48 | ret = bfelf_file_init(buf.get(), size, &ef); 49 | CHECK(ret == BFELF_SUCCESS); 50 | 51 | ret = bfelf_file_get_num_load_instrs(&ef); 52 | CHECK(ret > 0); 53 | } 54 | -------------------------------------------------------------------------------- /bfelf_loader/tests/test_file_get_num_needed.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | TEST_CASE("bfelf_file_get_num_needed: invalid elf file") 26 | { 27 | auto ret = bfelf_file_get_num_needed(nullptr); 28 | CHECK(ret == BFELF_ERROR_INVALID_ARG); 29 | } 30 | 31 | TEST_CASE("bfelf_file_get_num_needed: success") 32 | { 33 | bfelf_file_t ef = {}; 34 | 35 | auto ret = bfelf_file_get_num_needed(&ef); 36 | CHECK(ret == 0); 37 | } 38 | -------------------------------------------------------------------------------- /bfelf_loader/tests/test_file_get_pic_pie.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | TEST_CASE("bfelf_file_get_pic_pie: invalid elf file") 26 | { 27 | auto ret = bfelf_file_get_pic_pie(nullptr); 28 | CHECK(ret == BFELF_ERROR_INVALID_ARG); 29 | } 30 | 31 | TEST_CASE("bfelf_file_get_pic_pie: success") 32 | { 33 | bfelf_file_t ef = {}; 34 | 35 | auto ret = bfelf_file_get_pic_pie(&ef); 36 | CHECK(ret == 1); 37 | } 38 | -------------------------------------------------------------------------------- /bfelf_loader/tests/test_file_get_total_size.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | TEST_CASE("bfelf_file_get_total_size: invalid elf file") 26 | { 27 | auto ret = bfelf_file_get_total_size(nullptr); 28 | CHECK(ret == 0); 29 | } 30 | 31 | TEST_CASE("bfelf_file_get_total_size: success") 32 | { 33 | bfelf_file_t ef = {}; 34 | 35 | auto ret = bfelf_file_get_total_size(&ef); 36 | CHECK(ret == 0); 37 | } 38 | -------------------------------------------------------------------------------- /bfelf_loader/tests/test_real_elf.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef TEST_REAL_ELF_H 23 | #define TEST_REAL_ELF_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | extern file g_file; 30 | extern bool out_of_memory; 31 | extern std::vector g_filenames; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /bfelf_loader/tests/test_set_args.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | TEST_CASE("bfelf_set_args: invalid info") 29 | { 30 | int argc = 0; 31 | const char *argv = nullptr; 32 | 33 | auto ret = bfelf_set_args(nullptr, argc, &argv); 34 | CHECK(ret == BFELF_ERROR_INVALID_ARG); 35 | } 36 | 37 | TEST_CASE("bfelf_set_args: success") 38 | { 39 | int argc = 0; 40 | crt_info_t info = {}; 41 | const char *argv = nullptr; 42 | 43 | auto ret = bfelf_set_args(&info, argc, &argv); 44 | CHECK(ret == BF_SUCCESS); 45 | } 46 | -------------------------------------------------------------------------------- /bfelf_loader/tests/test_set_integer_args.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | TEST_CASE("bfelf_set_integer_args: invalid info") 29 | { 30 | auto ret = bfelf_set_integer_args(nullptr, 0, 0, 0, 0); 31 | CHECK(ret == BFELF_ERROR_INVALID_ARG); 32 | } 33 | 34 | TEST_CASE("bfelf_set_integer_args: success") 35 | { 36 | crt_info_t info = {}; 37 | 38 | auto ret = bfelf_set_integer_args(&info, 0, 0, 0, 0); 39 | CHECK(ret == BF_SUCCESS); 40 | } 41 | -------------------------------------------------------------------------------- /bfintrinsics/src/arch/intel_x64/barrier.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | ; in the Software without restriction, including without limitation the rights 7 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | ; 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 all 12 | ; 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 FROM, 19 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | ; SOFTWARE. 21 | 22 | bits 64 23 | default rel 24 | 25 | section .text 26 | 27 | global _rmb 28 | _rmb: 29 | lfence 30 | ret 31 | 32 | global _wmb 33 | _wmb: 34 | sfence 35 | ret 36 | 37 | global _mb 38 | _mb: 39 | mfence 40 | ret 41 | -------------------------------------------------------------------------------- /bfintrinsics/src/arch/intel_x64/bit.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | ; in the Software without restriction, including without limitation the rights 7 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | ; 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 all 12 | ; 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 FROM, 19 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | ; SOFTWARE. 21 | 22 | bits 64 23 | default rel 24 | 25 | section .text 26 | 27 | global _popcnt 28 | _popcnt: 29 | popcnt rax, rdi 30 | ret 31 | 32 | global _bsf 33 | _bsf: 34 | bsf rax, rdi 35 | ret 36 | 37 | global _bsr 38 | _bsr: 39 | bsr rax, rdi 40 | ret 41 | -------------------------------------------------------------------------------- /bfintrinsics/src/arch/intel_x64/drs.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | ; in the Software without restriction, including without limitation the rights 7 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | ; 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 all 12 | ; 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 FROM, 19 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | ; SOFTWARE. 21 | 22 | bits 64 23 | default rel 24 | 25 | section .text 26 | 27 | global _read_dr7 28 | _read_dr7: 29 | mov rax, dr7 30 | ret 31 | 32 | global _write_dr7 33 | _write_dr7: 34 | mov dr7, rdi 35 | ret 36 | -------------------------------------------------------------------------------- /bfintrinsics/src/arch/intel_x64/pause.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | ; in the Software without restriction, including without limitation the rights 7 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | ; 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 all 12 | ; 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 FROM, 19 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | ; SOFTWARE. 21 | 22 | bits 64 23 | default rel 24 | 25 | section .text 26 | 27 | global _pause 28 | _pause: 29 | pause 30 | ret 31 | -------------------------------------------------------------------------------- /bfintrinsics/src/arch/x64/cache.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | ; in the Software without restriction, including without limitation the rights 7 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | ; 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 all 12 | ; 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 FROM, 19 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | ; SOFTWARE. 21 | 22 | bits 64 23 | default rel 24 | 25 | section .text 26 | 27 | global _invd 28 | _invd: 29 | invd 30 | ret 31 | 32 | global _wbinvd 33 | _wbinvd: 34 | wbinvd 35 | ret 36 | 37 | global _clflush 38 | _clflush: 39 | clflush [rdi] 40 | ret 41 | -------------------------------------------------------------------------------- /bfintrinsics/src/arch/x64/gdt.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | ; in the Software without restriction, including without limitation the rights 7 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | ; 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 all 12 | ; 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 FROM, 19 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | ; SOFTWARE. 21 | 22 | bits 64 23 | default rel 24 | 25 | section .text 26 | 27 | global _read_gdt 28 | _read_gdt: 29 | sgdt [rdi] 30 | ret 31 | 32 | global _write_gdt 33 | _write_gdt: 34 | lgdt [rdi] 35 | ret 36 | -------------------------------------------------------------------------------- /bfintrinsics/src/arch/x64/idt.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | ; in the Software without restriction, including without limitation the rights 7 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | ; 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 all 12 | ; 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 FROM, 19 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | ; SOFTWARE. 21 | 22 | bits 64 23 | default rel 24 | 25 | section .text 26 | 27 | global _read_idt 28 | _read_idt: 29 | sidt [rdi] 30 | ret 31 | 32 | global _write_idt 33 | _write_idt: 34 | lidt [rdi] 35 | ret 36 | -------------------------------------------------------------------------------- /bfintrinsics/src/arch/x64/msrs.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | ; in the Software without restriction, including without limitation the rights 7 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | ; 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 all 12 | ; 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 FROM, 19 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | ; SOFTWARE. 21 | 22 | bits 64 23 | default rel 24 | 25 | section .text 26 | 27 | global _read_msr 28 | _read_msr: 29 | mov rcx, rdi 30 | rdmsr 31 | shl rdx, 32 32 | or rax, rdx 33 | 34 | ret 35 | 36 | global _write_msr 37 | _write_msr: 38 | mov rax, rsi 39 | mov rdx, rsi 40 | shr rdx, 32 41 | mov rcx, rdi 42 | wrmsr 43 | 44 | ret 45 | -------------------------------------------------------------------------------- /bfintrinsics/src/arch/x64/pm.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | ; in the Software without restriction, including without limitation the rights 7 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | ; 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 all 12 | ; 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 FROM, 19 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | ; SOFTWARE. 21 | 22 | bits 64 23 | default rel 24 | 25 | section .text 26 | 27 | global _halt 28 | _halt: 29 | hlt 30 | 31 | global _stop 32 | _stop: 33 | cli 34 | hlt 35 | -------------------------------------------------------------------------------- /bfintrinsics/src/arch/x64/rflags.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | ; in the Software without restriction, including without limitation the rights 7 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | ; 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 all 12 | ; 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 FROM, 19 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | ; SOFTWARE. 21 | 22 | bits 64 23 | default rel 24 | 25 | section .text 26 | 27 | global _read_rflags 28 | _read_rflags: 29 | pushfq 30 | pop rax 31 | ret 32 | 33 | global _write_rflags 34 | _write_rflags: 35 | push rdi 36 | popf 37 | ret 38 | -------------------------------------------------------------------------------- /bfintrinsics/src/arch/x64/tlb.asm: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | ; in the Software without restriction, including without limitation the rights 7 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | ; 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 all 12 | ; 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 FROM, 19 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | ; SOFTWARE. 21 | 22 | bits 64 23 | default rel 24 | 25 | section .text 26 | 27 | global _invlpg 28 | _invlpg: 29 | invlpg [rdi] 30 | ret 31 | -------------------------------------------------------------------------------- /bfintrinsics/src/null.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | void 23 | do_nothing_function() 24 | { 25 | // This function is here to ensure that a CPP file is compiled as part 26 | // of the build for the intrinsics. Without this, some compilers get mad 27 | // like Visual Studio as they attempt to link in libraries that assume 28 | // a C or CPP file was compiled 29 | } 30 | -------------------------------------------------------------------------------- /bfm/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(bfm_test C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project( 27 | INCLUDES ../include 28 | ) 29 | 30 | add_static_library( 31 | test_support 32 | SOURCES ../src/main.cpp 33 | SOURCES ../src/command_line_parser.cpp 34 | SOURCES ../src/ioctl_driver.cpp 35 | ALWAYS 36 | ) 37 | 38 | do_test(test_command_line_parser 39 | DEPENDS test_support 40 | ) 41 | 42 | do_test(test_ioctl_driver 43 | DEPENDS test_support 44 | ) 45 | 46 | do_test(test_main 47 | DEPENDS test_support 48 | ) 49 | -------------------------------------------------------------------------------- /bfruntime/src/crt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(bfcrt C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project( 27 | TIDY_EXCLUSIONS -cert-err34-c,-misc-misplaced-widening-cast 28 | CXX_FLAGS -Wno-main 29 | ) 30 | 31 | list(APPEND SOURCES 32 | crt.cpp 33 | ) 34 | 35 | if(NOT CMAKE_INSTALL_PREFIX STREQUAL "${TEST_PREFIX_PATH}") 36 | if(${BUILD_TARGET_ARCH} STREQUAL "x86_64" AND NOT WIN32) 37 | list(APPEND SOURCES 38 | start_x64.asm 39 | ) 40 | endif() 41 | if(${BUILD_TARGET_ARCH} STREQUAL "aarch64") 42 | list(APPEND SOURCES 43 | start_aarch64.S 44 | ) 45 | endif() 46 | endif() 47 | 48 | add_static_library( 49 | bfcrt 50 | SOURCES ${SOURCES} 51 | ALWAYS 52 | ) 53 | -------------------------------------------------------------------------------- /bfruntime/src/crt/start_aarch64.S: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | ; in the Software without restriction, including without limitation the rights 7 | ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | ; 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 all 12 | ; 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 FROM, 19 | ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | ; SOFTWARE. 21 | 22 | .global _start 23 | .section .text 24 | .balign 4 25 | 26 | _start: 27 | stp x29, x30, [sp, #-16]! 28 | mov x29, sp 29 | 30 | mov sp, x0 31 | mov x0, x1 32 | 33 | adr x1, canary 34 | ldr x1, [x1] 35 | stp x1, x1, [sp, #-16]! 36 | 37 | bl _start_c 38 | 39 | adr x1, canary 40 | ldr x1, [x1] 41 | ldr x2, [sp], #16 42 | 43 | mov sp, x29 44 | 45 | cmp x1, x2 46 | b.ne stack_overflow 47 | 48 | ldp x29, x30, [sp], #16 49 | ret 50 | 51 | stack_overflow: 52 | mov x0, #0x0010 53 | movk x0, #0x8000, lsl #48 // x0 = 0x8000000000000010 54 | ldp x29, x30, [sp], #16 55 | ret 56 | 57 | canary: 58 | .word 0xABCDEF12, 0x34567890 59 | -------------------------------------------------------------------------------- /bfruntime/src/dso/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(bfdso C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project() 27 | 28 | add_static_library( 29 | bfdso 30 | SOURCES dso.cpp 31 | ALWAYS 32 | ) 33 | -------------------------------------------------------------------------------- /bfruntime/src/dso/dso.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | static int __addr = 42; 23 | void *__dso_handle = &__addr; 24 | -------------------------------------------------------------------------------- /bfruntime/src/pthread/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(bfpthread C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project() 27 | 28 | add_shared_library( 29 | bfpthread 30 | SOURCES pthread.cpp threadcontext.asm 31 | DEFINES SHARED_PTHREAD 32 | ) 33 | 34 | add_static_library( 35 | bfpthread 36 | SOURCES pthread.cpp threadcontext.asm 37 | DEFINES STATIC_PTHREAD 38 | ) 39 | -------------------------------------------------------------------------------- /bfruntime/src/syscall/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(bfsyscall C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project() 27 | 28 | add_shared_library( 29 | bfsyscall 30 | SOURCES syscall.cpp 31 | DEFINES SHARED_SYSCALL 32 | ) 33 | 34 | add_static_library( 35 | bfsyscall 36 | SOURCES syscall.cpp 37 | DEFINES STATIC_SYSCALL 38 | ) 39 | -------------------------------------------------------------------------------- /bfruntime/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(bfruntime_test C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project() 27 | 28 | add_subdirectory(../src/crt ${CMAKE_CURRENT_BINARY_DIR}/crt) 29 | 30 | do_test(test_crt 31 | SOURCES crt/test_crt.cpp 32 | DEPENDS bfcrt 33 | ) 34 | -------------------------------------------------------------------------------- /bfsdk/include/bfack.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef BFACK_H 23 | #define BFACK_H 24 | 25 | #include 26 | 27 | #ifdef __cplusplus 28 | #define NOEXCEPT noexcept 29 | #else 30 | #define NOEXCEPT 31 | #endif 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | uint32_t _cpuid_eax(uint32_t val) NOEXCEPT; 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | /// Ack 44 | /// 45 | /// Note: 46 | /// 47 | /// Use this function instead of calling CPUID manually as the CPUID leaves 48 | /// are always subject to change, as nested virtualization might require 49 | /// mods to this approach. 50 | /// 51 | /// @return returns 1 if Bareflank is running, 0 otherwise. 52 | /// 53 | static inline int 54 | bfack(void) NOEXCEPT 55 | { return _cpuid_eax(0x4BF00000) == 0x4BF00001 ? 1 : 0; } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /bfsdk/include/bfaffinity.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * 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 all 12 | * 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 FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | #ifndef WIN64 24 | #define _GNU_SOURCE 25 | #include 26 | #endif 27 | 28 | #include 29 | 30 | #ifdef WIN64 31 | 32 | #include 33 | 34 | static inline int 35 | set_affinity(uint64_t core) 36 | { 37 | if (SetProcessAffinityMask(GetCurrentProcess(), 1ULL << core) == 0) { 38 | return -1; 39 | } 40 | 41 | return 0; 42 | } 43 | 44 | #else 45 | 46 | static inline int 47 | set_affinity(uint64_t core) 48 | { 49 | cpu_set_t mask; 50 | 51 | CPU_ZERO(&mask); 52 | CPU_SET(core, &mask); 53 | 54 | if (sched_setaffinity(0, sizeof(mask), &mask) != 0) { 55 | return -1; 56 | } 57 | 58 | return 0; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /bfsdk/include/bfarch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * 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 all 12 | * 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 FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | #ifndef BFARCH_H 24 | #define BFARCH_H 25 | 26 | #ifndef BF_ARCH 27 | 28 | #if defined(_MSC_VER) 29 | # if defined(_M_X64) 30 | # define BF_ARCH "intel_x64" 31 | # define BF_X64 32 | # define BF_INTEL_X64 33 | # else 34 | # error "bfarch.h: unsupported architecture" 35 | # endif 36 | #elif defined(__GNUC__) || defined(__clang__) 37 | # if defined(__x86_64__) 38 | # define BF_ARCH "intel_x64" 39 | # define BF_X64 40 | # define BF_INTEL_X64 41 | # elif defined(__aarch64__) 42 | # define BF_ARCH "aarch64" 43 | # define BF_AARCH64 44 | # else 45 | # error "bfarch.h: unsupported architecture" 46 | # endif 47 | #else 48 | # error "bfarch.h: unsupported compiler" 49 | #endif 50 | 51 | #endif 52 | #endif 53 | -------------------------------------------------------------------------------- /bfsdk/include/bfcallonce.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef BFCALLONCE 23 | #define BFCALLONCE 24 | 25 | /// @cond 26 | 27 | #include 28 | 29 | // TODO 30 | // 31 | // This code is only needed because there seems to be a bug with GCC that 32 | // causes a system error when --coverage is enabled. The following was written 33 | // to have the same names and implementation as std::call_once so that at 34 | // some point this code can easily be removed. 35 | // 36 | namespace bfn 37 | { 38 | 39 | struct once_flag { 40 | bool m_value{false}; 41 | mutable std::mutex m_mutex{}; 42 | }; 43 | 44 | template 45 | void call_once(once_flag &flag, FUNC func) 46 | { 47 | std::lock_guard lock(flag.m_mutex); 48 | 49 | if (!flag.m_value) { 50 | func(); 51 | flag.m_value = true; 52 | } 53 | } 54 | 55 | } 56 | 57 | /// @endcond 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /bfsdk/include/bfexports.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * 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 all 12 | * 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 FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | * SOFTWARE. 21 | */ 22 | 23 | #ifndef BFEXPORTS_H 24 | #define BFEXPORTS_H 25 | 26 | #if defined(_WIN32) || defined(__CYGWIN__) 27 | #define IMPORT_SYM __declspec(dllimport) 28 | #define EXPORT_SYM __declspec(dllexport) 29 | #else 30 | #define IMPORT_SYM 31 | #define EXPORT_SYM __attribute__ ((visibility ("default"))) 32 | #endif 33 | 34 | #if defined(_WIN32) || defined(__CYGWIN__) 35 | #define WEAK_SYM 36 | #else 37 | #define WEAK_SYM __attribute__((weak)) 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /bfsdk/include/bfobject.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | /// 23 | /// @file bfobject.h 24 | /// 25 | 26 | #ifndef BFOBJECT_H 27 | #define BFOBJECT_H 28 | 29 | /// User Data 30 | /// 31 | /// This defines the base class used for passing around subclasses. 32 | /// This is mainly used so that dynamic_cast can be used if desired 33 | /// for casting and deletion. 34 | /// 35 | class bfobject 36 | { 37 | public: 38 | 39 | /// Default Constructor 40 | /// 41 | bfobject() = default; 42 | 43 | /// Default Destructor 44 | /// 45 | virtual ~bfobject() = default; 46 | 47 | public: 48 | 49 | /// @cond 50 | 51 | bfobject(bfobject &&) noexcept = delete; 52 | bfobject &operator=(bfobject &&) noexcept = delete; 53 | 54 | bfobject(const bfobject &) = delete; 55 | bfobject &operator=(const bfobject &) = delete; 56 | 57 | /// @endcond 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /bfsdk/include/bfshuffle.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | /// 23 | /// @file bfshuffle.h 24 | /// 25 | 26 | #ifndef BFSHUFFLE_H 27 | #define BFSHUFFLE_H 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | namespace bfn 34 | { 35 | 36 | /// Shuffle Vector 37 | /// 38 | /// @expects none 39 | /// @ensures none 40 | /// 41 | /// @param list the vector to shuffle 42 | /// 43 | template void 44 | shuffle(std::vector &list) 45 | { 46 | std::random_device rd; 47 | std::shuffle(list.begin(), list.end(), std::mt19937{rd()}); 48 | } 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /bfsdk/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(bfsdk_test C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project() 27 | 28 | add_library(test_catch STATIC test_catch.cpp) 29 | install(TARGETS test_catch DESTINATION lib) 30 | 31 | do_test(test_affinity) 32 | do_test(test_benchmark) 33 | do_test(test_bitmanip) 34 | do_test(test_buffer) 35 | do_test(test_callonce) 36 | do_test(test_debug) 37 | do_test(test_debugringinterface) 38 | do_test(test_delegate) 39 | do_test(test_errorcodes) 40 | do_test(test_exceptions) 41 | do_test(test_file) 42 | do_test(test_gsl_lite) 43 | do_test(test_gsl) 44 | do_test(test_json) 45 | do_test(test_manager) 46 | do_test(test_shuffle) 47 | do_test(test_string) 48 | do_test(test_types) 49 | do_test(test_upperlower) 50 | do_test(test_vcpuid) 51 | do_test(test_vector) 52 | -------------------------------------------------------------------------------- /bfsdk/tests/test_affinity.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | TEST_CASE("set_affinity") 26 | { 27 | CHECK(set_affinity(0) == 0); 28 | CHECK(set_affinity(31) == -1); 29 | } 30 | -------------------------------------------------------------------------------- /bfsdk/tests/test_callonce.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | TEST_CASE("set bit") 26 | { 27 | int count = 0; 28 | bfn::once_flag flag; 29 | 30 | auto func = [&] { 31 | count++; 32 | }; 33 | 34 | bfn::call_once(flag, func); 35 | bfn::call_once(flag, func); 36 | bfn::call_once(flag, func); 37 | 38 | CHECK(count == 1); 39 | } 40 | -------------------------------------------------------------------------------- /bfsdk/tests/test_catch.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #define CATCH_CONFIG_MAIN 23 | #include 24 | -------------------------------------------------------------------------------- /bfsdk/tests/test_gsl.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | TEST_CASE("memset") 28 | { 29 | char buf[42] = {}; 30 | auto view = gsl::span(buf); 31 | 32 | gsl::memset(view, 0); 33 | } 34 | -------------------------------------------------------------------------------- /bfsdk/tests/test_shuffle.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | TEST_CASE("shuffle test") 26 | { 27 | int tries = 0; 28 | 29 | std::vectorlist1{0, 1, 2, 3, 4}; 30 | std::vectorlist2{0, 1, 2, 3, 4}; 31 | 32 | while (list1 == list2 && tries++ < 10) { 33 | bfn::shuffle(list1); 34 | } 35 | 36 | CHECK(list1 != list2); 37 | } 38 | -------------------------------------------------------------------------------- /bfsdk/tests/test_types.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | // TIDY_EXCLUSION=-cppcoreguidelines-pro-type-reinterpret-cast 23 | // 24 | // Reason: 25 | // Although in general this is a good rule, for hypervisor level code that 26 | // interfaces with the kernel, and raw hardware, this rule is 27 | // impractical. 28 | // 29 | 30 | #include 31 | #include 32 | 33 | TEST_CASE("bfscast") 34 | { 35 | CHECK(bfscast(unsigned, 42) == 42U); 36 | } 37 | 38 | TEST_CASE("bfrcast") 39 | { 40 | CHECK(bfrcast(void *, 0) == nullptr); 41 | } 42 | 43 | TEST_CASE("bfadd") 44 | { 45 | std::vector buf(10); 46 | CHECK(bfadd(int *, buf.data(), sizeof(int)) == &buf.at(1)); 47 | } 48 | 49 | TEST_CASE("bfcadd") 50 | { 51 | std::vector buf(10); 52 | CHECK(bfcadd(const int *, buf.data(), sizeof(int)) == &buf.at(1)); 53 | } 54 | 55 | TEST_CASE("bfignored") 56 | { 57 | auto i = 42; 58 | bfignored(i); 59 | } 60 | -------------------------------------------------------------------------------- /bfsdk/tests/test_upperlower.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | TEST_CASE("upper") 26 | { 27 | CHECK(bfn::upper(0xABCDEF0123456789UL) == 0xABCDEF0123456000UL); 28 | CHECK(bfn::upper(0xABCDEF0123456789UL, 12) == 0xABCDEF0123456000UL); 29 | } 30 | 31 | TEST_CASE("lower") 32 | { 33 | CHECK(bfn::lower(0xABCDEF0123456789UL) == 0x0000000000000789UL); 34 | CHECK(bfn::lower(0xABCDEF0123456789UL, 12) == 0x0000000000000789UL); 35 | } 36 | -------------------------------------------------------------------------------- /bfsdk/tests/test_vcpuid.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | TEST_CASE("functions") 26 | { 27 | CHECK(vcpuid::is_bootstrap_vcpu(0)); 28 | CHECK(vcpuid::is_host_vm_vcpu(0)); 29 | CHECK(vcpuid::is_guest_vm_vcpu(0x10000)); 30 | } 31 | -------------------------------------------------------------------------------- /bfunwind/include/abort.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef ABORT_H 23 | #define ABORT_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | extern "C" uint64_t 30 | unsafe_write_cstr(const char *cstr, size_t len); 31 | 32 | inline void 33 | private_abort(const char *msg, const char *func) 34 | { 35 | const char *str_txt1 = "\033[1;31mFATAL ERROR\033[0m [\033[1;33m"; 36 | const char *str_txt2 = "\033[0m]: "; 37 | const char *str_endl = "\n"; \ 38 | 39 | unsafe_write_cstr(str_txt1, strlen(str_txt1)); \ 40 | unsafe_write_cstr(func, strlen(func)); \ 41 | unsafe_write_cstr(str_txt2, strlen(str_txt2)); \ 42 | unsafe_write_cstr(msg, strlen(msg)); \ 43 | unsafe_write_cstr(str_endl, strlen(str_endl)); \ 44 | 45 | abort(); 46 | } 47 | 48 | #define ABORT(a) private_abort(a,__func__); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /bfunwind/include/log.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef LOG_H 23 | #define LOG_H 24 | 25 | #ifndef DISABLE_LOGGING 26 | #include 27 | #define log(...) printf(__VA_ARGS__); 28 | #else 29 | #define log(...) 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /bfunwind/include/misc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef MISC_H 23 | #define MISC_H 24 | 25 | #include 26 | #include 27 | 28 | inline uint64_t bfabs(int64_t value) 29 | { return value >= 0 ? static_cast(value) : static_cast(-value); } 30 | 31 | inline uint64_t 32 | add_offset(uint64_t value, int64_t offset) 33 | { 34 | auto abs_offset = bfabs(offset); 35 | 36 | if (offset >= 0) { 37 | return value + abs_offset; 38 | } 39 | 40 | if (value >= abs_offset) { 41 | return value - abs_offset; 42 | } 43 | 44 | ABORT("attempted add an offset that would result in overflow"); 45 | return 0; 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /bfunwind/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(bfunwind C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project( 27 | INCLUDES ${CMAKE_CURRENT_LIST_DIR}/../include 28 | TIDY_EXCLUSIONS -cppcoreguidelines-pro* 29 | ) 30 | 31 | list(APPEND SOURCES 32 | dwarf4.cpp 33 | eh_frame.cpp 34 | ia64_cxx_abi.cpp 35 | registers_intel_x64.asm 36 | ) 37 | 38 | add_shared_library( 39 | bfunwind 40 | SOURCES ${SOURCES} 41 | DEFINES SHARED_SYSCALL 42 | ) 43 | 44 | add_static_library( 45 | bfunwind 46 | SOURCES ${SOURCES} 47 | DEFINES STATIC_SYSCALL 48 | ) 49 | 50 | install(FILES ../include/ia64_cxx_abi.h DESTINATION include RENAME unwind.h) 51 | -------------------------------------------------------------------------------- /bfvmm/include/hve/arch/intel_x64/hashtable.h: -------------------------------------------------------------------------------- 1 | #ifndef HASHTABLE_INTEL_X64_H 2 | #define HASHTABLE_INTEL_X64_H 3 | 4 | // ----------------------------------------------------------------------------- 5 | // Exports 6 | // ----------------------------------------------------------------------------- 7 | 8 | #include 9 | 10 | #ifndef STATIC_HVE 11 | #ifdef SHARED_HVE 12 | #define EXPORT_HVE EXPORT_SYM 13 | #else 14 | #define EXPORT_HVE IMPORT_SYM 15 | #endif 16 | #else 17 | #define EXPORT_HVE 18 | #endif 19 | 20 | // ----------------------------------------------------------------------------- 21 | // Definitions 22 | // ----------------------------------------------------------------------------- 23 | 24 | namespace bfvmm::intel_x64 25 | { 26 | 27 | class vcpu; 28 | 29 | struct kv { 30 | uint32_t k; 31 | uint32_t v; 32 | 33 | void init() { 34 | k = v = 0; 35 | } 36 | }; 37 | 38 | /// Hashtable provider 39 | /// 40 | /// Provides hashtable (like) functionality 41 | /// 42 | class EXPORT_HVE hashtable 43 | { 44 | public: 45 | 46 | /// Constructor 47 | /// 48 | /// @expects 49 | /// @ensures 50 | /// 51 | /// @param vcpu the vcpu object for this rdmsr handler 52 | /// 53 | hashtable( 54 | gsl::not_null vcpu); 55 | 56 | /// Destructor 57 | /// 58 | /// @expects 59 | /// @ensures 60 | /// 61 | ~hashtable() = default; 62 | 63 | bool insert(uint32_t key); 64 | int find(uint32_t key); 65 | uint32_t get_free_idx(void); 66 | void dump(void); 67 | 68 | private: 69 | kv m_hashmap[512]; 70 | bool m_isfull; 71 | vcpu *m_vcpu; 72 | 73 | public: 74 | hashtable(hashtable &&) = default; 75 | hashtable &operator=(hashtable &&) = default; 76 | 77 | hashtable(const hashtable &) = delete; 78 | hashtable &operator=(const hashtable &) = delete; 79 | 80 | }; 81 | 82 | } 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /bfvmm/include/hve/arch/intel_x64/vcpu_global_state.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef VCPU_GLOBAL_STATE_INTEL_X64_H 23 | #define VCPU_GLOBAL_STATE_INTEL_X64_H 24 | 25 | #include 26 | 27 | /// @cond 28 | #pragma pack(push, 1) 29 | 30 | namespace bfvmm::intel_x64 31 | { 32 | 33 | struct vcpu_global_state_t { 34 | 35 | uint64_t ia32_vmx_cr0_fixed0 { 36 | ::intel_x64::msrs::ia32_vmx_cr0_fixed0::get() 37 | }; 38 | 39 | uint64_t ia32_vmx_cr4_fixed0 { 40 | ::intel_x64::msrs::ia32_vmx_cr4_fixed0::get() 41 | }; 42 | }; 43 | 44 | inline vcpu_global_state_t g_vcpu_global_state; 45 | 46 | } 47 | 48 | #pragma pack(pop) 49 | /// @endcond 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /bfvmm/include/memory_manager/arch/x64/cr3.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef CR3_H 23 | #define CR3_H 24 | 25 | #include "cr3/mmap.h" 26 | #include "cr3/helpers.h" 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /bfvmm/include/test/misc.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | /// @cond 23 | 24 | #include 25 | 26 | extern "C" void 27 | unlock_write(void) 28 | { } 29 | 30 | extern "C" uint64_t 31 | unsafe_write_cstr(const char *cstr, size_t len) 32 | { bfignored(cstr); bfignored(len); return 0; } 33 | 34 | extern "C" uint64_t 35 | thread_context_cpuid(void) 36 | { return 0; } 37 | 38 | extern "C" uint64_t * 39 | thread_context_tlsptr(void) 40 | { return 0; } 41 | 42 | /// @endcond 43 | -------------------------------------------------------------------------------- /bfvmm/include/test/support.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | /// @cond 23 | 24 | #ifndef TEST_SUPPORT_H 25 | #define TEST_SUPPORT_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | #include "intrinsics.h" 34 | 35 | #include "hve.h" 36 | #include "memory_manager.h" 37 | #include "misc.h" 38 | 39 | struct quiet { 40 | quiet() 41 | { unsafe_write_cstr(nullptr, 0); } 42 | }; 43 | 44 | quiet g_quite{}; 45 | 46 | void setup_test_support() 47 | { 48 | #ifdef BF_X64 49 | setup_registers_x64(); 50 | setup_gdt_x64(); 51 | setup_idt_x64(); 52 | #endif 53 | 54 | #ifdef BF_INTEL_X64 55 | setup_registers_intel_x64(); 56 | setup_msrs_intel_x64(); 57 | setup_cpuid_intel_x64(); 58 | #endif 59 | } 60 | 61 | #endif 62 | 63 | /// @endcond 64 | -------------------------------------------------------------------------------- /bfvmm/include/vcpu/vcpu_manager.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #ifndef VCPU_MANAGER_H 23 | #define VCPU_MANAGER_H 24 | 25 | #include 26 | 27 | #include "vcpu.h" 28 | #include "vcpu_factory.h" 29 | 30 | /// vCPU Manager Macro 31 | /// 32 | /// The following macro can be used to quickly call the vcpu manager as 33 | /// this class will likely be called by a lot of code. This call is guaranteed 34 | /// to not be NULL 35 | /// 36 | /// @expects none 37 | /// @ensures ret != nullptr 38 | /// 39 | #define g_vcm bfmanager::instance() 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /bfvmm/integration/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(integration C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project() 27 | 28 | if(${BUILD_TARGET_ARCH} STREQUAL "x86_64") 29 | add_subdirectory(arch/intel_x64) 30 | elseif(${BUILD_TARGET_ARCH} STREQUAL "aarch64") 31 | message(WARNING "Unimplemented") 32 | else() 33 | message(FATAL_ERROR "Unsupported architecture") 34 | endif() 35 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | add_vmm_executable( 23 | integration_intel_x64_test_all 24 | SOURCES test_all.cpp 25 | ) 26 | 27 | add_vmm_executable( 28 | integration_intel_x64_test_all_inheritance 29 | SOURCES test_all_inheritance.cpp 30 | ) 31 | 32 | add_subdirectory(efi) 33 | add_subdirectory(ept) 34 | add_subdirectory(vmexit/control_register) 35 | add_subdirectory(vmexit/cpuid) 36 | add_subdirectory(vmexit/ept_misconfiguration) 37 | add_subdirectory(vmexit/ept_violation) 38 | add_subdirectory(vmexit/external_interrupt) 39 | add_subdirectory(vmexit/io_instruction) 40 | add_subdirectory(vmexit/monitor_trap) 41 | add_subdirectory(vmexit/rdmsr) 42 | add_subdirectory(vmexit/wrmsr) 43 | add_subdirectory(vpid) 44 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/efi/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | add_vmm_executable( 23 | integration_intel_x64_efi_test_efi_with_interrupts 24 | SOURCES test_efi_with_interrupts.cpp 25 | ) 26 | 27 | add_vmm_executable( 28 | integration_intel_x64_efi_test_efi 29 | SOURCES test_efi.cpp 30 | ) 31 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/ept/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | add_vmm_executable( 23 | integration_intel_x64_misc_ept_enable_ept 24 | SOURCES enable_ept.cpp 25 | ) 26 | 27 | add_vmm_executable( 28 | integration_intel_x64_misc_ept_remap_page 29 | SOURCES remap_page.cpp 30 | ) 31 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/test_all.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | // TIDY_EXCLUSION=-cert-err58-cpp 23 | // 24 | // Reason: 25 | // This test triggers on the use of a std::mutex being globally defined 26 | // from the EPT map. 27 | // 28 | 29 | #include 30 | 31 | ept::mmap g_guest_map; 32 | 33 | void 34 | init() 35 | { 36 | ept::identity_map(g_guest_map, MAX_PHYS_ADDR); 37 | } 38 | 39 | bool 40 | test_handler( 41 | vcpu_t *vcpu, external_interrupt_handler::info_t &info) 42 | { 43 | vcpu->queue_external_interrupt(info.vector); 44 | return true; 45 | } 46 | 47 | void 48 | init_vcpu(vcpu_t *vcpu) 49 | { 50 | vcpu->add_external_interrupt_handler( 51 | external_interrupt_handler_delegate_t::create() 52 | ); 53 | 54 | vcpu->set_eptp(g_guest_map); 55 | } 56 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/vmexit/control_register/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | add_vmm_executable( 23 | integration_intel_x64_vmexit_control_register_trap_cr0 24 | SOURCES trap_cr0.cpp 25 | ) 26 | 27 | add_vmm_executable( 28 | integration_intel_x64_vmexit_control_register_trap_cr3 29 | SOURCES trap_cr3.cpp 30 | ) 31 | 32 | add_vmm_executable( 33 | integration_intel_x64_vmexit_control_register_trap_cr4 34 | SOURCES trap_cr4.cpp 35 | ) 36 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/vmexit/control_register/trap_cr0.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | 24 | uint64_t g_cr0; 25 | 26 | void 27 | global_init() 28 | { 29 | bfdebug_info(0, "running trap_cr0 integration test"); 30 | bfdebug_lnbr(0); 31 | } 32 | 33 | bool 34 | test_handler(vcpu_t *vcpu) 35 | { 36 | vcpu->set_cr0(g_cr0); 37 | return false; 38 | } 39 | 40 | void 41 | test_hlt_delegate(bfobject *obj) 42 | { 43 | bfignored(obj); 44 | 45 | g_cr0 = ::intel_x64::cr0::get(); 46 | ::intel_x64::cr0::set(0); 47 | 48 | if (::intel_x64::cr0::get() == g_cr0) { 49 | bfdebug_pass(0, "test"); 50 | } 51 | } 52 | 53 | void 54 | vcpu_init_nonroot(vcpu_t *vcpu) 55 | { 56 | vcpu->add_hlt_delegate( 57 | hlt_delegate_t::create() 58 | ); 59 | 60 | vcpu->add_wrcr0_handler( 61 | 0xFFFFFFFFFFFFFFFF, handler_delegate_t::create() 62 | ); 63 | } 64 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/vmexit/control_register/trap_cr4.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | 24 | uint64_t g_cr4; 25 | 26 | void 27 | global_init() 28 | { 29 | bfdebug_info(0, "running trap_cr4 integration test"); 30 | bfdebug_lnbr(0); 31 | } 32 | 33 | bool 34 | test_handler(vcpu_t *vcpu) 35 | { 36 | vcpu->set_cr4(g_cr4); 37 | return false; 38 | } 39 | 40 | void 41 | test_hlt_delegate(bfobject *obj) 42 | { 43 | bfignored(obj); 44 | 45 | g_cr4 = ::intel_x64::cr4::get(); 46 | ::intel_x64::cr4::set(0); 47 | 48 | if (::intel_x64::cr4::get() == g_cr4) { 49 | bfdebug_pass(0, "test"); 50 | } 51 | } 52 | 53 | void 54 | vcpu_init_nonroot(vcpu_t *vcpu) 55 | { 56 | vcpu->add_hlt_delegate( 57 | hlt_delegate_t::create() 58 | ); 59 | 60 | vcpu->add_wrcr4_handler( 61 | 0xFFFFFFFFFFFFFFFF, handler_delegate_t::create() 62 | ); 63 | } 64 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/vmexit/cpuid/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | add_vmm_executable( 23 | integration_intel_x64_vmexit_cpuid_trap 24 | SOURCES trap_cpuid.cpp 25 | ) 26 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/vmexit/ept_misconfiguration/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | add_vmm_executable( 23 | integration_intel_x64_vmexit_trap_ept_misconfiguration 24 | SOURCES trap_ept_misconfiguration.cpp 25 | ) 26 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/vmexit/ept_violation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | add_vmm_executable( 23 | integration_intel_x64_vmexit_ept_violation_trap_ept_read_violation 24 | SOURCES trap_ept_read_violation.cpp 25 | ) 26 | 27 | add_vmm_executable( 28 | integration_intel_x64_vmexit_ept_violation_trap_ept_write_violation 29 | SOURCES trap_ept_write_violation.cpp 30 | ) 31 | 32 | add_vmm_executable( 33 | integration_intel_x64_vmexit_ept_violation_trap_ept_execute_violation 34 | SOURCES trap_ept_execute_violation.cpp 35 | ) 36 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/vmexit/external_interrupt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | add_vmm_executable( 23 | integration_intel_x64_vmexit_trap_all_interrupts 24 | SOURCES trap_all_interrupts.cpp 25 | ) 26 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/vmexit/io_instruction/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | add_vmm_executable( 23 | integration_intel_x64_io_instruction_trap_in_out 24 | SOURCES trap_in_out.cpp 25 | ) 26 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/vmexit/monitor_trap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | add_vmm_executable( 23 | integration_intel_x64_monitor_trap_single_step_cpuid 24 | SOURCES single_step_cpuid.cpp 25 | ) 26 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/vmexit/rdmsr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | add_vmm_executable( 23 | integration_intel_x64_rdmsr_trap 24 | SOURCES trap_rdmsr.cpp 25 | ) 26 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/vmexit/wrmsr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | add_vmm_executable( 23 | integration_intel_x64_wrmsr_trap 24 | SOURCES trap_wrmsr.cpp 25 | ) 26 | -------------------------------------------------------------------------------- /bfvmm/integration/arch/intel_x64/vpid/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | add_vmm_executable( 23 | integration_intel_x64_misc_vpid_enable_vpid 24 | SOURCES enable_vpid.cpp 25 | ) 26 | -------------------------------------------------------------------------------- /bfvmm/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(bfvmm_main C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project() 27 | 28 | list(APPEND SOURCES 29 | main.cpp 30 | ) 31 | 32 | add_vmm_executable( 33 | bfvmm 34 | SOURCES ${SOURCES} 35 | ) 36 | -------------------------------------------------------------------------------- /bfvmm/main/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | -------------------------------------------------------------------------------- /bfvmm/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(bfvmm C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project( 27 | INCLUDES ${CMAKE_CURRENT_LIST_DIR}/../include 28 | ) 29 | 30 | add_subdirectory(debug) 31 | add_subdirectory(memory_manager) 32 | add_subdirectory(hve) 33 | add_subdirectory(vcpu) 34 | add_subdirectory(entry) 35 | 36 | install(FILES ../include/vmm.h DESTINATION include) 37 | -------------------------------------------------------------------------------- /bfvmm/src/debug/arch/aarch64/serial_ns16550a.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | 24 | namespace bfvmm 25 | { 26 | 27 | uint8_t 28 | serial_ns16550a::inb(uint16_t addr) const noexcept 29 | { 30 | auto location = static_cast(addr) + m_addr; 31 | auto ptr = reinterpret_cast(location); 32 | return *ptr; 33 | } 34 | 35 | void 36 | serial_ns16550a::outb(uint16_t addr, uint8_t data) const noexcept 37 | { 38 | auto location = static_cast(addr) + m_addr; 39 | auto ptr = reinterpret_cast(location); 40 | *ptr = data; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /bfvmm/src/debug/arch/x64/serial_ns16550a.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | 24 | namespace bfvmm 25 | { 26 | 27 | uint8_t 28 | serial_ns16550a::inb(uint16_t addr) const noexcept 29 | { 30 | return x64::portio::inb(static_cast(addr + m_addr)); 31 | } 32 | 33 | void 34 | serial_ns16550a::outb(uint16_t addr, uint8_t data) const noexcept 35 | { 36 | x64::portio::outb(static_cast(addr + m_addr), data); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /bfvmm/src/entry/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | list(APPEND SOURCES 23 | entry.cpp 24 | ) 25 | 26 | add_static_library( 27 | bfvmm_entry 28 | SOURCES ${SOURCES} 29 | ALWAYS 30 | ) 31 | -------------------------------------------------------------------------------- /bfvmm/src/hve/arch/intel_x64/hashtable.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | namespace bfvmm::intel_x64 5 | { 6 | 7 | 8 | hashtable::hashtable( 9 | gsl::not_null vcpu 10 | ) 11 | //m_vcpu{vcpu}, 12 | //m_hashmap{0}, 13 | { 14 | m_isfull = false; 15 | m_vcpu = vcpu; 16 | for (auto i = 0; i < 512; i++) { 17 | m_hashmap[i].k = m_hashmap[i].v = 0; 18 | } 19 | } 20 | 21 | // returns the index at which the key is found 22 | int hashtable::find( 23 | uint32_t key) 24 | { 25 | for (auto i = 0; i < 512; i++) { 26 | if (m_hashmap[i].k == key) 27 | return i; 28 | } 29 | return -1; 30 | } 31 | 32 | uint32_t hashtable::get_free_idx(void) 33 | { 34 | for (auto i = 0; i < 512; i++) { 35 | if (m_hashmap[i].k == 0) 36 | return i; 37 | } 38 | return -1; 39 | } 40 | 41 | void hashtable::dump(void) { 42 | bfdebug_transaction(0, [&](std::string * msg) { 43 | for (auto i = 0; i < 512; i++) { 44 | if (m_hashmap[i].k != 0) { 45 | bfdebug_subnhex(0, "msr:", m_hashmap[i].k, msg); 46 | bfdebug_subndec(0, "count:", m_hashmap[i].v, msg); 47 | m_hashmap[i].init(); 48 | } 49 | } 50 | }); 51 | } 52 | 53 | bool hashtable::insert( 54 | uint32_t key) 55 | { 56 | auto idx = find(key); 57 | 58 | // not found 59 | if (idx == -1) { 60 | idx = get_free_idx(); 61 | 62 | if (idx == -1) { 63 | return false; 64 | } else { 65 | // got a free spot! insert 66 | m_hashmap[idx].k = key; 67 | m_hashmap[idx].v = 1; 68 | } 69 | } else { 70 | //found key, increment counter 71 | m_hashmap[idx].v++; 72 | } 73 | return true; 74 | } 75 | 76 | 77 | } 78 | -------------------------------------------------------------------------------- /bfvmm/src/hve/arch/intel_x64/interrupt_queue.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | namespace bfvmm::intel_x64 26 | { 27 | 28 | // For now, this is a simple first in, first out queue. In the future, 29 | // we should implement the priority portion of the interrupt queue that 30 | // the APIC is doing in hardware. 31 | // 32 | // It should be noted that the reason this works is that by the time 33 | // the VMM sees the interrupt, the APIC has already released an interrupt 34 | // with priority in mind, which means in theory, a simple queue is 35 | // sufficient. Incomplete, but sufficient. 36 | 37 | void 38 | interrupt_queue::push(vector_t vector) 39 | { m_vectors.push(vector); } 40 | 41 | interrupt_queue::vector_t 42 | interrupt_queue::pop() 43 | { 44 | auto vector = m_vectors.front(); 45 | m_vectors.pop(); 46 | 47 | return vector; 48 | } 49 | 50 | bool 51 | interrupt_queue::empty() const 52 | { return m_vectors.empty(); } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /bfvmm/src/hve/arch/intel_x64/vcpu_factory.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | namespace bfvmm 26 | { 27 | 28 | WEAK_SYM std::unique_ptr 29 | vcpu_factory::make(vcpuid::type vcpuid, bfobject *obj) 30 | { 31 | bfignored(obj); 32 | return std::make_unique(vcpuid); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /bfvmm/src/hve/arch/intel_x64/vpid.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | 24 | namespace bfvmm::intel_x64 25 | { 26 | 27 | vpid_handler::vpid_handler( 28 | gsl::not_null vcpu) 29 | { 30 | bfignored(vcpu); 31 | 32 | static uint16_t s_id = 1; 33 | //m_id = s_id++; 34 | m_id = s_id; 35 | } 36 | 37 | void vpid_handler::enable() 38 | { 39 | vmcs_n::virtual_processor_identifier::set(m_id); 40 | vmcs_n::secondary_processor_based_vm_execution_controls::enable_vpid::enable(); 41 | 42 | bfdebug_transaction(1, [&](std::string * msg) { 43 | bfdebug_subnhex(1, "enabled vpid", m_id, msg); 44 | }); 45 | 46 | } 47 | 48 | void vpid_handler::disable() 49 | { 50 | vmcs_n::virtual_processor_identifier::set(0); 51 | vmcs_n::secondary_processor_based_vm_execution_controls::enable_vpid::disable(); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /bfvmm/src/vcpu/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | list(APPEND SOURCES 23 | vcpu.cpp 24 | ) 25 | 26 | add_shared_library( 27 | bfvmm_vcpu 28 | SOURCES ${SOURCES} 29 | DEFINES SHARED_VCPU 30 | DEFINES SHARED_HVE 31 | DEFINES SHARED_MEMORY_MANAGER 32 | DEFINES SHARED_INTRINSICS 33 | ) 34 | 35 | add_static_library( 36 | bfvmm_vcpu 37 | SOURCES ${SOURCES} 38 | DEFINES STATIC_VCPU 39 | DEFINES STATIC_HVE 40 | DEFINES STATIC_MEMORY_MANAGER 41 | DEFINES STATIC_INTRINSICS 42 | ) 43 | 44 | # ------------------------------------------------------------------------------ 45 | # Install 46 | # ------------------------------------------------------------------------------ 47 | 48 | install(DIRECTORY ../../include/vcpu/ DESTINATION include/bfvmm/vcpu) 49 | -------------------------------------------------------------------------------- /bfvmm/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | cmake_minimum_required(VERSION 3.6) 23 | project(bfvmm_test C CXX) 24 | 25 | include(${SOURCE_CMAKE_DIR}/project.cmake) 26 | init_project( 27 | INCLUDES ${CMAKE_CURRENT_LIST_DIR}/../include 28 | ) 29 | 30 | add_subdirectory(../src/debug ${CMAKE_CURRENT_BINARY_DIR}/src/debug) 31 | add_subdirectory(../src/hve ${CMAKE_CURRENT_BINARY_DIR}/src/hve) 32 | add_subdirectory(../src/memory_manager ${CMAKE_CURRENT_BINARY_DIR}/src/memory_manager) 33 | add_subdirectory(../src/vcpu ${CMAKE_CURRENT_BINARY_DIR}/src/vcpu) 34 | 35 | add_subdirectory(debug) 36 | add_subdirectory(hve) 37 | add_subdirectory(memory_manager) 38 | add_subdirectory(vcpu) 39 | 40 | install(DIRECTORY ../include/test/ DESTINATION include/bfvmm/test) 41 | -------------------------------------------------------------------------------- /bfvmm/tests/debug/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | do_test(test_debug_ring 23 | SOURCES debug_ring/test_debug_ring.cpp 24 | DEPENDS bfvmm_debug 25 | DEFINES STATIC_DEBUG 26 | DEFINES STATIC_INTRINSICS 27 | ) 28 | 29 | do_test(test_serial_ns16550a 30 | SOURCES serial/test_serial_ns16550a.cpp 31 | DEPENDS bfvmm_debug 32 | DEFINES STATIC_DEBUG 33 | DEFINES STATIC_INTRINSICS 34 | ) 35 | 36 | # do_test(test_serial_port_pl011 37 | # SOURCES serial/test_serial_pl011.cpp 38 | # DEPENDS bfvmm_debug 39 | # DEFINES STATIC_DEBUG 40 | # DEFINES STATIC_INTRINSICS 41 | # ) 42 | -------------------------------------------------------------------------------- /bfvmm/tests/debug/debug_ring/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | # macro(do_test str) 23 | # add_executable(test_${str} test_${str}.cpp) 24 | # target_compile_definitions(test_${str} PRIVATE STATIC_DEBUG_RING) 25 | # target_link_libraries(test_${str} bfvmm_debug_ring_static) 26 | # target_link_libraries(test_${str} test_catch) 27 | # add_test(test_${str} test_${str}) 28 | # install(TARGETS test_${str} DESTINATION ${BUILD_SYSROOT_TEST}/bin/bfvmm) 29 | # endmacro(do_test) 30 | 31 | do_test( 32 | NAME test_debug_ring 33 | LIBS bfvmm_debug_ring_static 34 | ) 35 | -------------------------------------------------------------------------------- /bfvmm/tests/hve/arch/intel_x64/test_check.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include "test_support.h" 23 | 24 | #ifdef _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT 25 | 26 | TEST_CASE("check all") 27 | { 28 | std::vector cfg; 29 | setup_check_all_paths(cfg); 30 | 31 | test_vmcs_check(cfg, bfvmm::intel_x64::check::all); 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /bfvmm/tests/hve/arch/intel_x64/test_nmi.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #ifdef _HIPPOMOCKS__ENABLE_CFUNC_MOCKING_SUPPORT 30 | 31 | TEST_CASE("set_nmi_handler") 32 | { 33 | bfvmm::x64::idt idt{256}; 34 | CHECK_NOTHROW(set_nmi_handler(&idt, 8)); 35 | } 36 | 37 | TEST_CASE("inject_nmi") 38 | { 39 | namespace int_info = ::intel_x64::vmcs::vm_entry_interruption_information; 40 | 41 | int_info::set(0); 42 | CHECK_NOTHROW(inject_nmi()); 43 | 44 | CHECK(int_info::vector::get() == 2); 45 | CHECK(int_info::interruption_type::get() == int_info::interruption_type::non_maskable_interrupt); 46 | CHECK(int_info::valid_bit::is_enabled()); 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /bfvmm/tests/vcpu/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | list(APPEND ARGN 23 | DEPENDS bfvmm_vcpu 24 | DEPENDS bfvmm_hve 25 | DEPENDS bfvmm_memory_manager 26 | DEFINES STATIC_VCPU 27 | DEFINES STATIC_HVE 28 | DEFINES STATIC_MEMORY_MANAGER 29 | DEFINES STATIC_INTRINSICS 30 | ) 31 | 32 | do_test(test_vcpu 33 | SOURCES test_vcpu.cpp 34 | ${ARGN} 35 | ) 36 | 37 | do_test(test_vcpu_factory 38 | SOURCES test_vcpu_factory.cpp 39 | ${ARGN} 40 | ) 41 | -------------------------------------------------------------------------------- /bfvmm/tests/vcpu/test_vcpu_factory.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // 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 all 12 | // 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 FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | // SOFTWARE. 21 | 22 | #include 23 | #include 24 | 25 | namespace bfvmm 26 | { 27 | 28 | WEAK_SYM std::unique_ptr 29 | vcpu_factory::make(vcpuid::type vcpuid, bfobject *obj) 30 | { 31 | bfignored(obj); 32 | return std::make_unique(vcpuid); 33 | } 34 | 35 | } 36 | 37 | TEST_CASE("vcpu_factory: make_vcpu") 38 | { 39 | bfvmm::vcpu_factory factory; 40 | CHECK(factory.make(0, nullptr) != nullptr); 41 | } 42 | -------------------------------------------------------------------------------- /scripts/cmake/config/travis_asan.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | set(ENABLE_ASAN ON) 23 | 24 | set(ENABLE_BUILD_VMM OFF) 25 | set(ENABLE_BUILD_USERSPACE OFF) 26 | set(ENABLE_BUILD_TEST ON) 27 | 28 | set(CMAKE_BUILD_TYPE Debug) 29 | set(ENABLE_COMPILER_WARNINGS ON) 30 | 31 | set(C_FLAGS_TEST "-fuse-ld=gold") 32 | set(CXX_FLAGS_TEST "-fuse-ld=gold") 33 | -------------------------------------------------------------------------------- /scripts/cmake/config/travis_codecov.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | set(ENABLE_CODECOV ON) 23 | 24 | set(ENABLE_BUILD_VMM ON) 25 | set(ENABLE_BUILD_USERSPACE ON) 26 | set(ENABLE_BUILD_TEST ON) 27 | 28 | set(CMAKE_BUILD_TYPE Debug) 29 | set(ENABLE_COMPILER_WARNINGS ON) 30 | -------------------------------------------------------------------------------- /scripts/cmake/config/travis_format.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | set(ENABLE_FORMAT ON) 23 | 24 | set(ENABLE_BUILD_VMM ON) 25 | set(ENABLE_BUILD_USERSPACE ON) 26 | set(ENABLE_BUILD_TEST ON) 27 | 28 | set(CMAKE_BUILD_TYPE Debug) 29 | set(ENABLE_COMPILER_WARNINGS ON) 30 | -------------------------------------------------------------------------------- /scripts/cmake/config/travis_shared.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | set(BUILD_SHARED_LIBS ON) 23 | set(BUILD_STATIC_LIBS OFF) 24 | 25 | set(CMAKE_BUILD_TYPE Release) 26 | set(ENABLE_COMPILER_WARNINGS ON) 27 | -------------------------------------------------------------------------------- /scripts/cmake/config/travis_static.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | set(BUILD_SHARED_LIBS OFF) 23 | set(BUILD_STATIC_LIBS ON) 24 | 25 | set(CMAKE_BUILD_TYPE Release) 26 | set(ENABLE_COMPILER_WARNINGS ON) 27 | -------------------------------------------------------------------------------- /scripts/cmake/config/travis_tidy.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | set(ENABLE_TIDY ON) 23 | 24 | set(ENABLE_BUILD_VMM ON) 25 | set(ENABLE_BUILD_USERSPACE ON) 26 | set(ENABLE_BUILD_TEST ON) 27 | 28 | set(CMAKE_BUILD_TYPE Debug) 29 | set(ENABLE_COMPILER_WARNINGS ON) 30 | -------------------------------------------------------------------------------- /scripts/cmake/config/travis_usan.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | set(ENABLE_USAN ON) 23 | 24 | set(ENABLE_BUILD_VMM OFF) 25 | set(ENABLE_BUILD_USERSPACE OFF) 26 | set(ENABLE_BUILD_TEST ON) 27 | 28 | set(CMAKE_BUILD_TYPE Debug) 29 | set(ENABLE_COMPILER_WARNINGS ON) 30 | 31 | set(C_FLAGS_TEST "-fuse-ld=gold") 32 | set(CXX_FLAGS_TEST "-fuse-ld=gold") 33 | -------------------------------------------------------------------------------- /scripts/cmake/depends/astyle.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | if(ENABLE_FORMAT) 23 | message(STATUS "Including dependency: astyle") 24 | 25 | download_dependency( 26 | astyle 27 | URL ${ASTYLE_URL} 28 | URL_MD5 ${ASTYLE_URL_MD5} 29 | ) 30 | 31 | add_dependency( 32 | astyle userspace 33 | ) 34 | endif() 35 | -------------------------------------------------------------------------------- /scripts/cmake/depends/catch.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | if(ENABLE_BUILD_TEST) 23 | message(STATUS "Including dependency: catch") 24 | 25 | download_dependency( 26 | catch 27 | URL ${CATCH_URL} 28 | URL_MD5 ${CATCH_URL_MD5} 29 | ) 30 | 31 | list(APPEND CATCH_CONFIGURE_FLAGS 32 | -DBUILD_TESTING=OFF 33 | ) 34 | 35 | add_dependency( 36 | catch test 37 | CMAKE_ARGS ${CATCH_CONFIGURE_FLAGS} 38 | ) 39 | endif() 40 | -------------------------------------------------------------------------------- /scripts/cmake/depends/clang_tidy.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | if(ENABLE_TIDY) 23 | if(NOT CLANG_TIDY_BIN) 24 | find_program(CLANG_TIDY_BIN clang-tidy-6.0) 25 | 26 | if(NOT CLANG_TIDY_BIN) 27 | message(STATUS "Including dependency: clang-tidy") 28 | message(STATUS "*** FATAL ERROR: Clang Tidy 6.0 was not found. To Fix:") 29 | message(STATUS " - install clang-tidy-6.0 or") 30 | message(STATUS " - ln -s /usr/bin/clang-tidy /usr/bin/clang-tidy-6.0") 31 | message(FATAL_ERROR "Unable to find: clang-tidy") 32 | endif() 33 | endif() 34 | endif() 35 | -------------------------------------------------------------------------------- /scripts/cmake/depends/cxxopts.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | if(ENABLE_BUILD_USERSPACE) 23 | message(STATUS "Including dependency: cxxopts") 24 | 25 | download_dependency( 26 | cxxopts 27 | URL ${CXXOPTS_URL} 28 | URL_MD5 ${CXXOPTS_URL_MD5} 29 | ) 30 | endif() 31 | 32 | if(ENABLE_BUILD_USERSPACE) 33 | add_dependency( 34 | cxxopts userspace 35 | ) 36 | endif() 37 | -------------------------------------------------------------------------------- /scripts/cmake/depends/gnuefi.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | if(ENABLE_BUILD_EFI AND NOT WIN32) 23 | message(STATUS "Including dependency: gnuefi") 24 | 25 | download_dependency( 26 | gnuefi 27 | URL ${GNUEFI_URL} 28 | URL_MD5 ${GNUEFI_URL_MD5} 29 | ) 30 | 31 | add_dependency( 32 | gnuefi efi 33 | CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy_directory ${CACHE_DIR}/gnuefi/ ${DEPENDS_DIR}/gnuefi/${EFI_PREFIX}/build 34 | BUILD_COMMAND make 35 | COMMAND make -C lib 36 | COMMAND make -C gnuefi 37 | INSTALL_COMMAND make INSTALLROOT=${PREFIXES_DIR}/ PREFIX=${EFI_PREFIX} install 38 | COMMAND make INSTALLROOT=${PREFIXES_DIR}/ PREFIX=${EFI_PREFIX} -C lib install 39 | COMMAND make INSTALLROOT=${PREFIXES_DIR}/ PREFIX=${EFI_PREFIX} -C gnuefi install 40 | ) 41 | endif() 42 | -------------------------------------------------------------------------------- /scripts/cmake/depends/gsl.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | if(ENABLE_BUILD_VMM OR ENABLE_BUILD_USERSPACE OR ENABLE_BUILD_TEST) 23 | message(STATUS "Including dependency: gsl") 24 | 25 | download_dependency( 26 | gsl 27 | URL ${GSL_URL} 28 | URL_MD5 ${GSL_URL_MD5} 29 | ) 30 | endif() 31 | 32 | list(APPEND GSL_CONFIGURE_FLAGS 33 | -DGSL_TEST=OFF 34 | ) 35 | 36 | if(ENABLE_BUILD_VMM OR ENABLE_BUILD_TEST) 37 | add_dependency( 38 | gsl vmm 39 | CMAKE_ARGS ${GSL_CONFIGURE_FLAGS} 40 | ) 41 | endif() 42 | 43 | if(ENABLE_BUILD_USERSPACE) 44 | add_dependency( 45 | gsl userspace 46 | CMAKE_ARGS ${GSL_CONFIGURE_FLAGS} 47 | ) 48 | endif() 49 | 50 | if(ENABLE_BUILD_TEST) 51 | add_dependency( 52 | gsl test 53 | CMAKE_ARGS ${GSL_CONFIGURE_FLAGS} 54 | ) 55 | endif() 56 | -------------------------------------------------------------------------------- /scripts/cmake/depends/hippomocks.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | if(ENABLE_BUILD_TEST) 23 | message(STATUS "Including dependency: hippomocks") 24 | 25 | download_dependency( 26 | hippomocks 27 | URL ${HIPPOMOCKS_URL} 28 | URL_MD5 ${HIPPOMOCKS_URL_MD5} 29 | ) 30 | 31 | add_dependency( 32 | hippomocks test 33 | ) 34 | endif() 35 | -------------------------------------------------------------------------------- /scripts/cmake/depends/json.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | if(ENABLE_BUILD_VMM OR ENABLE_BUILD_USERSPACE OR ENABLE_BUILD_TEST) 23 | message(STATUS "Including dependency: json") 24 | 25 | download_dependency( 26 | json 27 | URL ${JSON_URL} 28 | URL_MD5 ${JSON_URL_MD5} 29 | ) 30 | endif() 31 | 32 | list(APPEND JSON_CONFIGURE_FLAGS 33 | -DJSON_BuildTests=OFF 34 | ) 35 | 36 | if(ENABLE_BUILD_VMM) 37 | add_dependency( 38 | json vmm 39 | CMAKE_ARGS ${JSON_CONFIGURE_FLAGS} 40 | ) 41 | endif() 42 | 43 | if(ENABLE_BUILD_USERSPACE) 44 | add_dependency( 45 | json userspace 46 | CMAKE_ARGS ${JSON_CONFIGURE_FLAGS} 47 | ) 48 | endif() 49 | 50 | if(ENABLE_BUILD_TEST) 51 | add_dependency( 52 | json test 53 | CMAKE_ARGS ${JSON_CONFIGURE_FLAGS} 54 | ) 55 | endif() 56 | -------------------------------------------------------------------------------- /scripts/cmake/depends/llvm.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | if((ENABLE_BUILD_VMM OR ENABLE_BUILD_TEST) AND NOT WIN32) 23 | message(STATUS "Including dependency: llvm") 24 | 25 | download_dependency( 26 | llvm 27 | URL ${LLVM_URL} 28 | URL_MD5 ${LLVM_URL_MD5} 29 | PREFIX vmm 30 | ) 31 | endif() 32 | -------------------------------------------------------------------------------- /scripts/cmake/depends/python.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | if(ENABLE_BUILD_VMM OR ENABLE_BUILD_TEST AND NOT WIN32) 23 | if(NOT PYTHON_BIN) 24 | find_program(PYTHON_BIN python) 25 | 26 | if(NOT PYTHON_BIN) 27 | message(STATUS "Including dependency: python") 28 | message(FATAL_ERROR "Unable to find: python") 29 | endif() 30 | endif() 31 | endif() 32 | -------------------------------------------------------------------------------- /scripts/cmake/flags/asan_flags.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | unset(BFFLAGS_ASAN) 23 | 24 | list(APPEND BFFLAGS_ASAN 25 | -O1 26 | -g 27 | -fno-omit-frame-pointer 28 | -fsanitize=address 29 | -fsanitize=leak 30 | ) 31 | -------------------------------------------------------------------------------- /scripts/cmake/flags/codecov_flags.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | unset(BFFLAGS_CODECOV) 23 | unset(BFFLAGS_CODECOV_LINKER) 24 | 25 | list(APPEND BFFLAGS_CODECOV 26 | -g 27 | -O0 28 | -fprofile-arcs 29 | -ftest-coverage 30 | -DDEBUG_LEVEL=5 31 | ) 32 | 33 | list(APPEND BFFLAGS_CODECOV_LINKER 34 | --coverage 35 | ) 36 | -------------------------------------------------------------------------------- /scripts/cmake/flags/efi_flags.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | unset(BFFLAGS_EFI) 23 | unset(BFFLAGS_EFI_C) 24 | unset(BFFLAGS_EFI_CXX) 25 | unset(BFFLAGS_EFI_X86_64) 26 | unset(BFFLAGS_EFI_AARCH64) 27 | 28 | list(APPEND BFFLAGS_EFI 29 | -isystem ${EFI_PREFIX_PATH}/include/efi/ 30 | -isystem ${EFI_PREFIX_PATH}/include/efi/x86_64/ 31 | ) 32 | 33 | list(APPEND BFFLAGS_EFI 34 | -mno-red-zone 35 | -mno-avx 36 | # -maccumulate-outgoing-args 37 | -fpic 38 | -g 39 | -O2 40 | -Wall 41 | -Wextra 42 | -Wno-error=pragmas 43 | -fshort-wchar 44 | -fno-strict-aliasing 45 | -ffreestanding 46 | -fno-stack-protector 47 | -fno-stack-check 48 | -fno-merge-all-constants 49 | -DCONFIG_x86_64 50 | -DGNU_EFI_USE_MS_ABI 51 | -D__KERNEL__ 52 | -DKERNEL 53 | -DEFI 54 | ) 55 | 56 | list(APPEND BFFLAGS_EFI_C 57 | --std=c11 58 | ) 59 | 60 | list(APPEND BFFLAGS_EFI_CXX 61 | ) 62 | 63 | list(APPEND BFFLAGS_EFI_X86_64 64 | ) 65 | -------------------------------------------------------------------------------- /scripts/cmake/flags/usan_flags.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | unset(BFFLAGS_USAN) 23 | 24 | list(APPEND BFFLAGS_USAN 25 | -fsanitize=undefined 26 | ) 27 | -------------------------------------------------------------------------------- /scripts/cmake/flags/warning_flags.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | unset(BFFLAGS_WARNING_C) 23 | unset(BFFLAGS_WARNING_CXX) 24 | 25 | list(APPEND BFFLAGS_WARNING_C 26 | -Wall 27 | -Wextra 28 | -Wpedantic 29 | -Wshadow 30 | -Wcast-align 31 | -Wconversion 32 | -Wsign-conversion 33 | ) 34 | 35 | list(APPEND BFFLAGS_WARNING_CXX 36 | ${BFFLAGS_WARNING_C} 37 | -Wctor-dtor-privacy 38 | -Wnon-virtual-dtor 39 | -Wold-style-cast 40 | -Woverloaded-virtual 41 | ) 42 | -------------------------------------------------------------------------------- /scripts/cmake/project.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | 22 | string(REPLACE "|" ";" PROJECT_INCLUDE_LIST "${PROJECT_INCLUDE_LIST}") 23 | foreach(file ${PROJECT_INCLUDE_LIST}) 24 | include(${file}) 25 | endforeach(file) 26 | -------------------------------------------------------------------------------- /scripts/cmake/toolchain/clang_aarch64_vmm.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2019 Assured Information Security, Inc. 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 deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # 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 all 12 | # 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 FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | # SOFTWARE. 21 | -------------------------------------------------------------------------------- /scripts/util/driver_clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # Copyright (C) 2019 Assured Information Security, 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 deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # 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 all 13 | # 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 FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | case $(uname -s) in 24 | CYGWIN_NT*) 25 | rm -Rf $1/src/platform/windows/.vs/ 26 | rm -Rf $1/src/platform/windows/bareflank.VC.db 27 | rm -Rf $1/src/platform/windows/x64/ 28 | ;; 29 | Linux) 30 | cd $1/src/platform/linux 31 | make clean 32 | ;; 33 | *) 34 | >&2 echo "OS not supported" 35 | exit 1 36 | esac 37 | -------------------------------------------------------------------------------- /scripts/util/driver_unload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # Copyright (C) 2019 Assured Information Security, 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 deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # 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 all 13 | # 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 FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | case $(uname -s) in 24 | CYGWIN_NT*) 25 | >&2 /cygdrive/c/Program\ Files\ \(x86\)/Windows\ Kits/10/Tools/x64/devcon remove "ROOT\bareflank" 26 | ;; 27 | Linux) 28 | cd $1/src/platform/linux 29 | sudo make unload 1> /dev/null 2> /dev/null 30 | ;; 31 | *) 32 | >&2 echo "OS not supported" 33 | exit 1 34 | esac 35 | -------------------------------------------------------------------------------- /scripts/vagrant/provision_ubuntu17_10.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # Copyright (C) 2019 Assured Information Security, 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 deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # 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 all 13 | # 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 FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | VAGRANT_BUILD_DIR="/vagrant/build_ubuntu17_10" 24 | VAGRANT_HOME_DIR="/home/ubuntu" 25 | 26 | sudo apt-get update 27 | sudo apt-get install -y git build-essential linux-headers-$(uname -r) clang \ 28 | binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu nasm cmake clang-tidy-4.0 \ 29 | cmake-curses-gui astyle 30 | 31 | # Have 'vagrant ssh' bring you straight to a build directory 32 | echo "mkdir -p $VAGRANT_BUILD_DIR && cd $VAGRANT_BUILD_DIR" >> $VAGRANT_HOME_DIR/.profile 33 | --------------------------------------------------------------------------------