Skip to content

Commit

Permalink
Make vbox compileable with VIDEZZO_FORK enabled (not finished) #12
Browse files Browse the repository at this point in the history
however, pVM->iom.s.StatIoPortIn is not initialized
  • Loading branch information
cyruscyliu committed Feb 6, 2024
1 parent 1f8cfac commit adc2a22
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ RUN git config --global --add safe.directory '*'
Run apt-get install -y glslang-tools llvm
RUN apt-get install -y bison flex
RUN apt-get install -y libspice-protocol-dev libspice-server-dev
RUN apt-get install -y kmod

# fix missing slirp
RUN apt-get install -y libslirp-dev
Expand Down
9 changes: 9 additions & 0 deletions videzzo_fork.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@
#ifndef VIDEZZO_FORK_H
#define VIDEZZO_FORK_H

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>

//
// VIDEZZO_FORK
//
extern uint8_t __FUZZ_COUNTERS_START;
extern uint8_t __FUZZ_COUNTERS_END;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
void counter_shm_init(void);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus

#endif /* VIDEZZO_FORK_H */
2 changes: 2 additions & 0 deletions videzzo_vbox/0002-copy-to-vbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
target=vbox/src/VBox
cp ../clangcovdump.h $target/Devices/build
cp ../videzzo.h $target/Frontends/VBoxManage
cp ../videzzo_fork.h $target/Frontends/VBoxManage
cp ../videzzo_fork.ld $target/Frontends/VBoxManage
cp ../libvidezzo.a.vbox $target/Frontends/VBoxManage/libvidezzo.a
cp VBoxViDeZZo.cpp $target/Frontends/VBoxManage
cp VBoxMalloc.h $target/Frontends/VBoxManage
Expand Down
3 changes: 2 additions & 1 deletion videzzo_vbox/0003-compile-vbox-san.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ pushd out-san && source ./env.sh && popd
ANNOTATION="-videzzo-instrumentation=$PWD/videzzo_vbox_types.yaml -flegacy-pass-manager"
EXPORT_SYMBOL_LIST="$PWD/export_symbol_list.txt"
EXPORT_SYMBOL="-Wl,--export-dynamic -Wl,--export-dynamic-symbol-list=$EXPORT_SYMBOL_LIST"
LINKER_SCRIPT="-Wl,-T,$PWD/src/VBox/Frontends/VBoxManage/videzzo_fork.ld"
kmk VBOX_FUZZ=1 KBUILD_TYPE=debug VBOX_GCC_TOOL=CLANG \
PATH_OUT_BASE=$PWD/out-san \
TOOL_CLANG_CFLAGS="-fsanitize=fuzzer-no-link -fPIE -DRT_NO_STRICT ${ANNOTATION}" \
TOOL_CLANG_CXXFLAGS="-fsanitize=fuzzer-no-link -fPIE -DRT_NO_STRICT ${ANNOTATION}" \
TOOL_CLANG_LDFLAGS="-fsanitize=fuzzer-no-link ${EXPORT_SYMBOL}" \
TOOL_CLANG_LDFLAGS="-fsanitize=fuzzer-no-link ${EXPORT_SYMBOL} ${LINKER_SCRIPT}" \
VBOXDD_SANITIZER=1 \
VBOX_FUZZ_LDFLAGS="-fsanitize=fuzzer,address,undefined"

Expand Down
3 changes: 2 additions & 1 deletion videzzo_vbox/0005-compile-vbox-cov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ COVERAGE="-fprofile-instr-generate -fcoverage-mapping"
ANNOTATION="-videzzo-instrumentation=$PWD/videzzo_vbox_types.yaml -flegacy-pass-manager"
EXPORT_SYMBOL_LIST="$PWD/export_symbol_list.txt"
EXPORT_SYMBOL="-Wl,--export-dynamic -Wl,--export-dynamic-symbol-list=$EXPORT_SYMBOL_LIST"
LINKER_SCRIPT="-Wl,-T,$PWD/src/VBox/Frontends/VBoxManage/videzzo_fork.ld"
kmk VBOX_FUZZ=1 KBUILD_TYPE=debug VBOX_GCC_TOOL=CLANG \
PATH_OUT_BASE=$PWD/out-cov \
TOOL_CLANG_CFLAGS="-fsanitize=fuzzer-no-link -DCLANG_COV_DUMP -DRT_NO_STRICT ${COVERAGE} ${ANNOTATION} -fPIE" \
TOOL_CLANG_CXXFLAGS="-fsanitize=fuzzer-no-link -DCLANG_COV_DUMP -DRT_NO_STRICT ${COVERAGE} ${ANNOTATION} -fPIE" \
TOOL_CLANG_LDFLAGS="-fsanitize=fuzzer-no-link ${COVERAGE} ${EXPORT_SYMBOL}" \
TOOL_CLANG_LDFLAGS="-fsanitize=fuzzer-no-link ${COVERAGE} ${EXPORT_SYMBOL} ${LINKER_SCRIPT}" \
VBOX_FUZZ_LDFLAGS="-fsanitize=fuzzer ${COVERAGE}"

# 1. compile kernel drivers
Expand Down
3 changes: 2 additions & 1 deletion videzzo_vbox/0006-compile-vbox-deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ pushd out-deb && source ./env.sh && popd
ANNOTATION="-videzzo-instrumentation=$PWD/videzzo_vbox_types.yaml -flegacy-pass-manager"
EXPORT_SYMBOL_LIST="$PWD/export_symbol_list.txt"
EXPORT_SYMBOL="-Wl,--export-dynamic -Wl,--export-dynamic-symbol-list=$EXPORT_SYMBOL_LIST"
LINKER_SCRIPT="-Wl,-T,$PWD/src/VBox/Frontends/VBoxManage/videzzo_fork.ld"
kmk VBOX_FUZZ=1 KBUILD_TYPE=debug VBOX_GCC_TOOL=CLANG \
PATH_OUT_BASE=$PWD/out-deb \
TOOL_CLANG_CFLAGS="-fsanitize=fuzzer-no-link -fPIE -DRT_NO_STRICT ${ANNOTATION}" \
TOOL_CLANG_CXXFLAGS="-fsanitize=fuzzer-no-link -fPIE -DRT_NO_STRICT ${ANNOTATION}" \
TOOL_CLANG_LDFLAGS="-fsanitize=fuzzer-no-link ${EXPORT_SYMBOL}" \
TOOL_CLANG_LDFLAGS="-fsanitize=fuzzer-no-link ${EXPORT_SYMBOL} ${LINKER_SCRIPT}" \
VBOXDD_SANITIZER=1 \
VBOX_FUZZ_LDFLAGS="-fsanitize=fuzzer,address,undefined"

Expand Down
2 changes: 1 addition & 1 deletion videzzo_vbox/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ vbox-dep:
# svn might fail due to network issues
# please run `svn cleanup && svn update` to finish
if [ ! -d "vbox" ]; then \
svn co https://www.virtualbox.org/svn/vbox/trunk vbox; make patch; fi
svn co -r 95063 https://www.virtualbox.org/svn/vbox/trunk vbox; make patch; fi

vbox: vbox-dep
make compile
Expand Down
5 changes: 5 additions & 0 deletions videzzo_vbox/VBoxViDeZZo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ using namespace com;

#include <wordexp.h>
#include "videzzo.h"
#include "videzzo_fork.h"

/* without this, include/VBox/vmm/pdmtask.h does not import PDMTASKTYPE enum */
#define VBOX_IN_VMM 1
Expand Down Expand Up @@ -820,6 +821,10 @@ static void videzzo_vbox_pre() {

// step 3: get VM to be running
pVM->enmVMState = VMSTATE_RUNNING;

if (getenv("VIDEZZO_FORK")) {
counter_shm_init();
}
}

static ComPtr<IVirtualBoxClient> virtualBoxClient;
Expand Down

0 comments on commit adc2a22

Please sign in to comment.