Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
coolkingcole committed Dec 15, 2023
2 parents d12d406 + 91506e7 commit ccc16d5
Show file tree
Hide file tree
Showing 35 changed files with 1,178 additions and 285 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Dockerfile
.*sw*
.dockerignore
.github
.git/FETCH_HEAD
92 changes: 90 additions & 2 deletions .github/workflows/parallel_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,27 @@ jobs:
image: ubuntu:20.04
steps:
- name: Update
<<<<<<< HEAD
run: apt-get update -y
- name: Install ssl
run: apt-get install -y libssl-dev
=======
run: apt-get -qq update -y
- name: Install ssl
run: apt-get -qq install -y libssl-dev
>>>>>>> dev
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install Python dev headers
<<<<<<< HEAD
run: apt-get install -y libpython3.9-dev
- uses: actions/checkout@v2 # Clones to $GITHUB_WORKSPACE. NOTE: this requires git > 2.18 (not on ubuntu 18.04 by default) to get .git directory
=======
run: apt-get -qq install -y libpython3.9-dev
- uses: actions/checkout@v4 # Clones to $GITHUB_WORKSPACE. NOTE: this requires git > 2.18 (not on ubuntu 18.04 by default) to get .git directory
>>>>>>> dev
- name: Lint PyPANDA with flake8
run: |
pip install --upgrade pip
Expand All @@ -46,8 +57,13 @@ jobs:
runs-on: panda-arc
steps:
- name: Install git
<<<<<<< HEAD
run: sudo apt-get update -y && sudo apt-get install git -y
- uses: actions/checkout@v2 # Clones to $GITHUB_WORKSPACE. NOTE: this requires git > 2.18 (not on ubuntu 18.04 by default) to get .git directory
=======
run: sudo apt-get -qq update -y && sudo apt-get -qq install git -y
- uses: actions/checkout@v4 # Clones to $GITHUB_WORKSPACE. NOTE: this requires git > 2.18 (not on ubuntu 18.04 by default) to get .git directory
>>>>>>> dev
with:
fetch-depth: 0

Expand All @@ -57,6 +73,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: ${{ github.workspace }}
<<<<<<< HEAD
tags: panda_local:${{ github.sha }}
target: developer
- name: Minimal test of built container # Just test to see if one of our binaries is built
Expand All @@ -70,14 +87,38 @@ jobs:
path: panda_local.tar.gz
retention-days: 2
taint_tests:
=======
tags: ghcr.io/${{ github.repository_owner }}/panda_local:${{ github.sha }}
target: developer
- name: Minimal test of built container # Just test to see if one of our binaries is built
run: docker run --rm "ghcr.io/${{ github.repository_owner }}/panda_local:${{ github.sha }}" /bin/bash -c 'exit $(/panda/build/arm-softmmu/panda-system-arm -help | grep -q "usage. panda-system-arm")'
- name: 'Login to Github Container Registry'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push to ghcr.io
run: docker push ghcr.io/${{ github.repository_owner }}/panda_local:${{ github.sha }}

tests:
>>>>>>> dev
if: github.repository == 'panda-re/panda'
runs-on: panda-arc
needs: [build_container]

strategy:
matrix:
target: [i386, x86_64]

include:
- test_type: "taint"
target: "i386"
- test_type: "taint"
target: "x86_64"
- test_type: "pypanda"
test_script: "all"
- test_type: "make_check"
test_script: "all"

steps:
- name: Download a panda artifact
uses: actions/download-artifact@v3
Expand All @@ -87,26 +128,43 @@ jobs:
run: docker load -i panda_local.tar.gz
# Given a container with PANDA installed at /panda, run the taint tests
- name: Update
<<<<<<< HEAD
run: sudo apt-get update -y
- name: Install ssl
run: sudo apt-get install -y wget
- name: Run taint tests inside current container
run: >-
wget -q https://panda-re.mit.edu/qcows/linux/debian/7.3/x86/debian_7.3_x86.qcow -o wheezy_panda2.qcow2;
=======
run: sudo apt-get -qq update -y
- name: Install ssl
run: sudo apt-get -qq install -y wget
- name: Run Taint Tests
if: matrix.test_type == 'taint'
run: >-
wget -q -O wheezy_panda2.qcow2 https://panda-re.mit.edu/qcows/linux/debian/7.3/x86/debian_7.3_x86.qcow;
>>>>>>> dev
wget -q https://panda-re.mit.edu/qcows/linux/ubuntu/1804/x86_64/bionic-server-cloudimg-amd64-noaslr-nokaslr.qcow2;
docker run --name panda_test_${{ matrix.target }}_${GITHUB_RUN_ID}
--mount type=bind,source=$(pwd)/wheezy_panda2.qcow2,target=/home/panda/regdir/qcows/wheezy_panda2.qcow2
--mount type=bind,source=$(pwd)/bionic-server-cloudimg-amd64-noaslr-nokaslr.qcow2,target=/home/panda/regdir/qcows/bionic-server-cloudimg-amd64-noaslr-nokaslr.qcow2
<<<<<<< HEAD
--rm -t "panda_local:${{ github.sha }}" bash -c
=======
--rm -t "ghcr.io/${{ github.repository_owner }}/panda_local:${{ github.sha }}" bash -c
>>>>>>> dev
"cd /tmp; git clone https://github.com/panda-re/panda_test;
cd ./panda_test/tests/taint2;
echo 'Running Record:';
python3 taint2_multi_arch_record_or_replay.py --arch ${{ matrix.target }} --mode record;
echo 'Running Replay:';
python3 taint2_multi_arch_record_or_replay.py --arch ${{ matrix.target }} --mode replay;
sed -i '/^\s*$/d' taint2_log;
if cat taint2_log; then echo 'Taint unit test log found!'; else echo 'Taint unit test log NOT found!' && exit 1; fi;
echo -e '\nFailures:';
if grep 'fail' taint2_log; then echo 'TEST FAILED!' && exit 1; else echo -e 'None.\nTEST PASSED!' && exit 0; fi"

<<<<<<< HEAD
sym_trace_tests:
if: github.repository == 'panda-re/panda'
runs-on: panda-arc
Expand All @@ -119,8 +177,20 @@ jobs:
steps:
# Given a container with PANDA installed at /panda, run the taint tests
- name: Run symbolic tracing tests inside current container
=======
- name: Run PyPanda Tests
if: matrix.test_type == 'pypanda'
>>>>>>> dev
run: >-
wget -q https://panda-re.mit.edu/qcows/linux/ubuntu/1604/x86/ubuntu_1604_x86.qcow;
docker run --name panda_test_${{ matrix.test_script }}_${GITHUB_RUN_ID}
--mount type=bind,source=$(pwd)/ubuntu_1604_x86.qcow,target=/root/.panda/ubuntu_1604_x86.qcow
-e PANDA_TEST=yes --cap-add SYS_NICE
--rm -t "ghcr.io/${{ github.repository_owner }}/panda_local:${{ github.sha }}" bash -c
"cd /panda/panda/python/tests/ && make && pip3 install -r requirements.txt && chmod +x ./run_all_tests.sh && ./run_all_tests.sh";
docker run --name panda_sym_test_${{ matrix.target }}_${GITHUB_RUN_ID}
<<<<<<< HEAD
--rm -t "panda_local:${{ github.sha }}" bash -c
"pip3 install capstone keystone-engine z3-solver; python3 /panda/panda/python/examples/unicorn/taint_sym_x86_64.py;
if [ $? -eq 0 ]; then echo -e 'TEST PASSED!' && exit 0; else echo 'TEST FAILED!' && exit 1; fi"
Expand Down Expand Up @@ -158,9 +228,18 @@ jobs:
steps:
- name: Run individual pypanda tests
# TODO: pip requirements install here should be moved to Docker image build to save test time
=======
--rm -t "ghcr.io/${{ github.repository_owner }}/panda_local:${{ github.sha }}" bash -c
"pip3 install capstone keystone-engine z3-solver; python3 /panda/panda/python/examples/unicorn/taint_sym_x86_64.py;
if [ $? -eq 0 ]; then echo -e 'TEST PASSED!' && exit 0; else echo 'TEST FAILED!' && exit 1; fi"

- name: Run make Tests
if: matrix.test_type == 'make_check'
>>>>>>> dev
run: >-
wget https://panda-re.mit.edu/qcows/linux/ubuntu/1604/x86/ubuntu_1604_x86.qcow;
docker run --name panda_test_${{ matrix.test_script }}_${GITHUB_RUN_ID}
<<<<<<< HEAD
--mount type=bind,source=$(pwd)/ubuntu_1604_x86.qcow,target=/root/.panda/ubuntu_1604_x86.qcow
-e PANDA_TEST=yes --cap-add SYS_NICE
--rm -t "panda_local:${{ github.sha }}" bash -c
Expand All @@ -169,6 +248,15 @@ jobs:
cleanup:
# Cleanup after prior jobs finish - even if they fail
needs: [taint_tests, sym_trace_tests, make_check, pypanda_tests]
=======
-e PANDA_TEST=yes --cap-add SYS_NICE
--rm -t "ghcr.io/${{ github.repository_owner }}/panda_local:${{ github.sha }}" bash -c
"cd /panda/build && make check"

cleanup:
# Cleanup after prior jobs finish - even if they fail
needs: [tests]
>>>>>>> dev
runs-on: panda-arc
if: always()

Expand Down
27 changes: 21 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
ARG BASE_IMAGE="ubuntu:20.04"
# Note PANDA supports ubuntu:22.04, but docker versions <= 20.10.7 can't run 22.04 containers

ARG TARGET_LIST="x86_64-softmmu,i386-softmmu,arm-softmmu,aarch64-softmmu,ppc-softmmu,mips-softmmu,mipsel-softmmu,mips64-softmmu"

### BASE IMAGE
Expand Down Expand Up @@ -63,7 +61,8 @@ RUN git -C /panda submodule update --init dtc && \
--target-list="${TARGET_LIST}" \
--prefix=/usr/local \
--disable-numa \
--enable-llvm
--enable-llvm && \
rm -rf /panda/.git

RUN make -C /panda/build -j "$(nproc)"

Expand Down Expand Up @@ -97,13 +96,29 @@ RUN python3 -m pip install --ignore-install pycparser && python3 -m pip install
RUN ls -alt $(pip show pandare | grep Location: | awk '{print $2}')/pandare/autogen/
RUN bash -c "ls $(pip show pandare | grep Location: | awk '{print $2}')/pandare/autogen/panda_{aarch64_64,arm_32,mips64_64,mips_32,mipsel_32,ppc_32,ppc_64,x86_64_64,i386_32}.py"

# this layer is used to strip shared objects and change python data to be
# symlinks to the installed panda data directory
FROM installer as cleanup
RUN find /usr/local/lib/panda -name "*.so" -exec strip {} \;
RUN PKG=`pip show pandare | grep Location: | awk '{print $2}'`/pandare/data; \
rm -rf $PKG/pc-bios && ln -s /usr/local/share/panda $PKG/pc-bios; \
for arch in `find $PKG -name "*-softmmu" -type d -exec basename {} \;` ; do \
ARCHP=$PKG/$arch; \
SARCH=`echo $arch | cut -d'-' -f 1`; \
rm $ARCHP/libpanda-$SARCH.so $ARCHP/llvm-helpers-$SARCH.bc; \
ln -s /usr/local/share/panda/llvm-helpers-$SARCH.bc $ARCHP/llvm-helpers-$SARCH.bc1; \
ln -s /usr/local/bin/libpanda-$SARCH.so $ARCHP/libpanda-$SARCH.so; \
rm -rf $ARCHP/panda/plugins; \
ln -s /usr/local/lib/panda/$SARCH/ $ARCHP/panda/plugins; \
done

### Copy files for panda+pypanda from installer - Stage 5
FROM base as panda

# Copy panda + libcapstone.so* + libosi libraries
COPY --from=installer /usr/local /usr/local
COPY --from=installer /usr/lib/libcapstone* /usr/lib/
COPY --from=installer /lib/libosi.so /lib/libiohal.so /lib/liboffset.so /lib/
COPY --from=cleanup /usr/local /usr/local
COPY --from=cleanup /usr/lib/libcapstone* /usr/lib/
COPY --from=cleanup /lib/libosi.so /lib/libiohal.so /lib/liboffset.so /lib/

# Workaround issue #901 - ensure LD_LIBRARY_PATH contains the panda plugins directories
#ARG TARGET_LIST="x86_64-softmmu,i386-softmmu,arm-softmmu,ppc-softmmu,mips-softmmu,mipsel-softmmu"
Expand Down
35 changes: 35 additions & 0 deletions panda/include/panda/callbacks/cb-defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ typedef enum panda_cb_type {
PANDA_CB_HD_WRITE, // Each HDD write
PANDA_CB_GUEST_HYPERCALL, // Hypercall from the guest (e.g. CPUID)
PANDA_CB_MONITOR, // Monitor callback
PANDA_CB_QMP, // QMP callback
PANDA_CB_CPU_RESTORE_STATE, // In cpu_restore_state() (fault/exception)
PANDA_CB_BEFORE_LOADVM, // at start of replay, before loadvm
PANDA_CB_ASID_CHANGED, // When CPU asid (address space identifier) changes
Expand Down Expand Up @@ -592,6 +593,23 @@ typedef union panda_cb {
*/
int (*monitor)(Monitor *mon, const char *cmd);

/* Callback ID: PANDA_CB_QMP
qmp:
Called when someone sends an unhandled QMP command
Arguments:
char *command: the command string as json
char *args: the arguments string as json
char **result: pointer to a json result or NULL
Helper call location: TBA
Return value:
bool: true IFF the command was handled by the plugin
*/
bool (*qmp)(char *command, char* args, char **result);


/* Callback ID: PANDA_CB_CPU_RESTORE_STATE
Expand Down Expand Up @@ -1544,6 +1562,23 @@ typedef union panda_cb_with_context {
*/
int (*monitor)(void* context, Monitor *mon, const char *cmd);

/* Callback ID: PANDA_CB_QMP
qmp:
Called when someone sends an unhandled QMP command
Arguments:
char *command: the command string as json
char *args: the arguments string as json
char **result: pointer to a json result or NULL
Helper call location: TBA
Return value:
bool: true IFF the command was handled by the plugin
*/
bool (*qmp)(void* context, char *command, char* args, char **result);


/* Callback ID: PANDA_CB_CPU_RESTORE_STATE
Expand Down
1 change: 1 addition & 0 deletions panda/include/panda/callbacks/cb-support.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ bool panda_callbacks_after_find_fast(CPUState *cpu, TranslationBlock *tb, bool b
int panda_callbacks_insn_exec(CPUState *env, target_ptr_t pc);
int panda_callbacks_after_insn_exec(CPUState *env, target_ptr_t pc);
int panda_callbacks_monitor(Monitor *mon, const char *cmd);
bool panda_callbacks_qmp(char *command, char *args, char **result);
int panda_callbacks_before_loadvm(void);
void panda_callbacks_replay_hd_transfer(CPUState *env, uint32_t type, target_ptr_t src_addr, target_ptr_t dest_addr, size_t num_bytes);
void panda_callbacks_after_machine_init(CPUState *env);
Expand Down
1 change: 1 addition & 0 deletions panda/include/panda/callbacks/cb-trampolines.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void panda_cb_trampoline_phys_mem_after_write(void* context, CPUState *env, targ
int panda_cb_trampoline_insn_exec(void* context, CPUState *env, target_ptr_t pc);
int panda_cb_trampoline_after_insn_exec(void* context, CPUState *env, target_ptr_t pc);
int panda_cb_trampoline_monitor(void* context, Monitor *mon, const char *cmd);
bool panda_cb_trampoline_qmp(void* context, char *command, char *args, char **result);
//int panda_cb_trampoline_before_loadvm(void* context);
void panda_cb_trampoline_replay_hd_transfer(void* context, CPUState *env, uint32_t type, target_ptr_t src_addr, target_ptr_t dest_addr, size_t num_bytes);
void panda_cb_trampoline_after_machine_init(void* context, CPUState *env);
Expand Down
16 changes: 4 additions & 12 deletions panda/include/panda/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ void panda_disable_plugin(void *plugin);

// Structure to store metadata about a plugin
typedef struct panda_plugin {
char name[256]; // Currently basename(filename)
void *plugin; // Handle to the plugin (for use with dlsym())
char *name; // Plugin name: basename(filename)
void *plugin; // Handle to the plugin (for use with dlsym())
bool unload; // When true, unload plugin when safe
bool exported_symbols; // True if plugin dlopened with RTLD_GLOBAL
} panda_plugin;


Expand Down Expand Up @@ -181,10 +183,6 @@ void panda_unregister_callbacks(void *plugin);
*/
bool panda_load_plugin(const char *filename, const char *plugin_name);


bool _panda_load_plugin(const char *filename, const char *plugin_name, bool library_mode);


/**
* panda_add_arg() - Add an argument to those for a plugin.
* @plugin_name: The name of the plugin.
Expand All @@ -194,10 +192,6 @@ bool _panda_load_plugin(const char *filename, const char *plugin_name, bool libr
*/
bool panda_add_arg(const char *plugin_name, const char *plugin_arg);


// I think this is not used anywhere?
bool panda_load_external_plugin(const char *filename, const char *plugin_name, void *plugin_uuid, void *init_fn_ptr);

/**
* panda_get_plugin_by_name() - Returns pointer to the plugin of this name.
* @name: The name of the desired plugin.
Expand Down Expand Up @@ -232,8 +226,6 @@ void panda_unload_plugins(void);
extern bool panda_update_pc;
extern bool panda_use_memcb;
extern panda_cb_list *panda_cbs[PANDA_CB_LAST];
extern bool panda_plugins_to_unload[MAX_PANDA_PLUGINS];
extern bool panda_plugin_to_unload;
extern bool panda_tb_chaining;

// this stuff is used by the new qemu cmd-line arg '-os os_name'
Expand Down
3 changes: 3 additions & 0 deletions panda/plugins/callwitharg/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CFLAGS+= -std=c++17
$(PLUGIN_TARGET_DIR)/panda_$(PLUGIN_NAME).so: \
$(PLUGIN_OBJ_DIR)/$(PLUGIN_NAME).o
Loading

0 comments on commit ccc16d5

Please sign in to comment.