Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/publish_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,10 @@ jobs:
git config --global user.email "[email protected]"
git config --global user.name "PANDA Bot"
git add .
git commit -m "Documentation update for PANDA commit ${{ github.sha }} branch ${{ github.ref_name }}"
git push || true
if [ -n "$(git status --porcelain)" ]; then
echo "Changes found. Updating docs.panda.re."
git commit -m "Documentation update for PANDA commit ${{ github.sha }} branch ${{ github.ref_name }}"
git push || true
else
echo "No changes detected. Skipping push."
fi
45 changes: 23 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
ARG TARGET_LIST="x86_64-softmmu,i386-softmmu,arm-softmmu,aarch64-softmmu,ppc-softmmu,mips-softmmu,mipsel-softmmu,mips64-softmmu,mips64el-softmmu"
ARG CAPSTONE_VERSION="5.0.5"
ARG PACKAGE_VERSION="3.1.0"
ARG INSTALL_PREFIX="/usr/local"

### BASE IMAGE
FROM ${REGISTRY}/$BASE_IMAGE AS base
Expand Down Expand Up @@ -73,12 +74,12 @@

# Note we diable NUMA for docker builds because it causes make check to fail in docker
RUN git -C /panda submodule update --init dtc && \
git -C /panda rev-parse HEAD > /usr/local/panda_commit_hash && \
git -C /panda rev-parse HEAD > ${INSTALL_PREFIX}/panda_commit_hash && \
mkdir /panda/build && cd /panda/build && \
python3 -m setuptools_scm -r .. --strip-dev 2>/dev/null >/tmp/savedversion && \
/panda/configure \
--target-list="${TARGET_LIST}" \
--prefix=/usr/local \
--prefix=${INSTALL_PREFIX} \
--disable-numa \
--extra-cflags=-Wno-error \
--extra-cxxflags=-Wno-error \
Expand All @@ -103,11 +104,11 @@
#### Install PANDA + pypanda from builder - Stage 4
FROM builder AS installer
RUN make -C /panda/build install && \
rm -rf /usr/local/lib/panda/*/cosi \
/usr/local/lib/panda/*/cosi_strace \
/usr/local/lib/panda/*/gdb \
/usr/local/lib/panda/*/snake_hook \
/usr/local/lib/panda/*/rust_skeleton
rm -rf ${INSTALL_PREFIX}/lib/panda/*/cosi \
${INSTALL_PREFIX}/lib/panda/*/cosi_strace \
${INSTALL_PREFIX}/lib/panda/*/gdb \
${INSTALL_PREFIX}/lib/panda/*/snake_hook \
${INSTALL_PREFIX}/lib/panda/*/rust_skeleton

# Build wheel and install pypanda
RUN cd /panda/panda/python/core && \
Expand All @@ -127,17 +128,17 @@
# 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 find ${INSTALL_PREFIX}/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; \
rm -rf $PKG/pc-bios && ln -s ${INSTALL_PREFIX}/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; \
ln -s ${INSTALL_PREFIX}/share/panda/llvm-helpers-$SARCH.bc $ARCHP/llvm-helpers-$SARCH.bc1; \
ln -s ${INSTALL_PREFIX}/bin/libpanda-$SARCH.so $ARCHP/libpanda-$SARCH.so; \
rm -rf $ARCHP/panda/plugins; \
ln -s /usr/local/lib/panda/$SARCH/ $ARCHP/panda/plugins; \
ln -s ${INSTALL_PREFIX}/lib/panda/$SARCH/ $ARCHP/panda/plugins; \
done

### Copy files for panda+pypanda from installer - Stage 5
Expand All @@ -148,21 +149,21 @@
COPY --from=base /tmp/build_dep.txt /tmp

# Copy panda + libcapstone.so* + libosi libraries
COPY --from=cleanup /usr/local /usr/local
COPY --from=cleanup ${INSTALL_PREFIX} ${INSTALL_PREFIX}

Check warning on line 152 in Dockerfile

View workflow job for this annotation

GitHub Actions / build_container

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$INSTALL_PREFIX' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
COPY --from=cleanup /usr/lib/x86_64-linux-gnu/libcapstone.so* /usr/lib/x86_64-linux-gnu/
COPY --from=cleanup /usr/lib/x86_64-linux-gnu/libosi.so /usr/lib/x86_64-linux-gnu/libiohal.so /usr/lib/x86_64-linux-gnu/liboffset.so /usr/lib/x86_64-linux-gnu/

# 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"
ENV LD_LIBRARY_PATH=/usr/local/lib/python3.8/dist-packages/pandare/data/x86_64-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/i386-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/arm-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/ppc-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/mips-softmmu/panda/plugins/:/usr/local/lib/python3.8/dist-packages/pandare/data/mipsel-softmmu/panda/plugins/
ENV LD_LIBRARY_PATH=${INSTALL_PREFIX}/lib/python3.8/dist-packages/pandare/data/x86_64-softmmu/panda/plugins/:${INSTALL_PREFIX}/lib/python3.8/dist-packages/pandare/data/i386-softmmu/panda/plugins/:${INSTALL_PREFIX}/lib/python3.8/dist-packages/pandare/data/arm-softmmu/panda/plugins/:${INSTALL_PREFIX}/lib/python3.8/dist-packages/pandare/data/ppc-softmmu/panda/plugins/:${INSTALL_PREFIX}/lib/python3.8/dist-packages/pandare/data/mips-softmmu/panda/plugins/:${INSTALL_PREFIX}/lib/python3.8/dist-packages/pandare/data/mipsel-softmmu/panda/plugins/

Check warning on line 158 in Dockerfile

View workflow job for this annotation

GitHub Actions / build_container

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$INSTALL_PREFIX' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/
#PANDA_PATH is used by rust plugins
ENV PANDA_PATH=/usr/local/lib/python3.8/dist-packages/pandare/data
ENV PANDA_PATH=${INSTALL_PREFIX}/lib/python3.8/dist-packages/pandare/data

Check warning on line 160 in Dockerfile

View workflow job for this annotation

GitHub Actions / build_container

Variables should be defined before their use

UndefinedVar: Usage of undefined variable '$INSTALL_PREFIX' More info: https://docs.docker.com/go/dockerfile/rule/undefined-var/

# Ensure runtime dependencies are installed for our libpanda objects and panda plugins
RUN ldconfig && \
update-alternatives --install /usr/bin/python python /usr/bin/python3 10 && \
if (ldd /usr/local/lib/python*/dist-packages/pandare/data/*-softmmu/libpanda-*.so | grep 'not found'); then exit 1; fi && \
if (ldd /usr/local/lib/python*/dist-packages/pandare/data/*-softmmu/panda/plugins/*.so | grep 'not found'); then exit 1; fi
if (ldd ${INSTALL_PREFIX}/lib/python*/dist-packages/pandare/data/*-softmmu/libpanda-*.so | grep 'not found'); then exit 1; fi && \
if (ldd ${INSTALL_PREFIX}/lib/python*/dist-packages/pandare/data/*-softmmu/panda/plugins/*.so | grep 'not found'); then exit 1; fi


FROM base AS packager
Expand All @@ -178,11 +179,11 @@
COPY --from=base /tmp/build_dep.txt /tmp

# Set up /package-root with files from panda we'll package
COPY --from=p /usr/local/bin/panda* /usr/local/bin/libpanda* /usr/local/bin/qemu-img /package-root/usr/local/bin/
COPY --from=p /usr/local/include/ /package-root/usr/include/
COPY --from=p /usr/local/etc/panda /package-root/usr/local/etc/panda
COPY --from=p /usr/local/lib/panda /package-root/usr/local/lib/panda
COPY --from=p /usr/local/share/panda /package-root/usr/local/share/panda
COPY --from=p ${INSTALL_PREFIX}/bin/panda* ${INSTALL_PREFIX}/bin/libpanda* ${INSTALL_PREFIX}/bin/qemu-img /package-root/usr/bin/
COPY --from=p ${INSTALL_PREFIX}/include/ /package-root/usr/include/
COPY --from=p ${INSTALL_PREFIX}/etc/panda /package-root/etc/panda
COPY --from=p ${INSTALL_PREFIX}/lib/panda /package-root/usr/lib/panda
COPY --from=p ${INSTALL_PREFIX}/share/panda /package-root/usr/share/panda

# Create DEBIAN directory and control file
COPY ./panda/debian/control /package-root/DEBIAN/control
Expand Down
7 changes: 7 additions & 0 deletions panda/plugins/osi_linux/osi_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,13 @@ bool init_plugin(void *self) {
if (kconf_file != NULL) g_free(kconf_file);
const char* panda_dir = g_getenv("PANDA_DIR");
kconf_file = g_strdup_printf("%s%s", panda_dir, KERNEL_CONF);
LOG_INFO("Looking for kconf_file attempt %u: %s", 3, kconf_file);
kconffile_canon = realpath(kconf_file, NULL);
}
if (kconffile_canon == NULL) { // from /etc/panda/osi_linux (Debian package)
if (kconf_file != NULL) g_free(kconf_file);
kconf_file = g_build_filename("/etc", "panda", "osi_linux", "kernelinfo.conf", NULL);
LOG_INFO("Looking for kconf_file attempt %u: %s", 4, kconf_file);
kconffile_canon = realpath(kconf_file, NULL);
}

Expand Down
3 changes: 3 additions & 0 deletions panda/python/core/pandare/panda.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ def get_plugin_path(self):
if build_dir == "/usr/local/bin/":
# Installed - use /usr/local/lib/panda/plugins
self.plugin_path = f"/usr/local/lib/panda/{self.arch_name}"
elif build_dir == "/usr/bin/":
# Installed - use /usr/lib/panda/plugins
self.plugin_path = f"/usr/lib/panda/{self.arch_name}"
elif isdir(rel_dir):
self.plugin_path = rel_dir
else:
Expand Down
10 changes: 7 additions & 3 deletions panda/python/core/pandare/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def _find_build_dir(arch_name, find_executable=False):
Internal function to return the build directory for the specified architecture
'''

debian_build = "/usr/bin/"
system_build = "/usr/local/bin/"
python_package = pjoin(*[dirname(__file__), "data"])
local_build = realpath(pjoin(dirname(__file__), "../../../../build"))
Expand All @@ -190,9 +191,12 @@ def _find_build_dir(arch_name, find_executable=False):
f"libpanda-{arch_name}.so"

# system path could have panda-system-X or libpanda-X.so. Others would have an arch_name - softmmu directory
pot_paths = [system_build,
pjoin(python_package, arch_dir),
pjoin(local_build, arch_dir)]
pot_paths = [
system_build,
debian_build,
pjoin(python_package, arch_dir),
pjoin(local_build, arch_dir)
]

if find_executable and 'PATH' in environ:
# If we're looking for the panda executable, also search the user's path
Expand Down
34 changes: 31 additions & 3 deletions panda/src/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,25 @@ PANDAENDCOMMENT */
#define LIBRARY_NAME "/libpanda-" TARGET_NAME ".so"
#define PLUGIN_DIR "/" TARGET_NAME "-softmmu/panda/plugins/"

#define INSTALL_PLUGIN_DIR "/usr/local/lib/panda/"
#define INSTALL_BIN_DIR "/usr/local/bin/" // libpanda-arch.so and panda-system-arch in here
const char* INSTALL_PLUGIN_DIR;
const char* INSTALL_BIN_DIR; // libpanda-arch.so and panda-system-arch in here

const gchar *panda_bool_true_strings[] = {"y", "yes", "true", "1", NULL};
const gchar *panda_bool_false_strings[] = {"n", "no", "false", "0", NULL};

const char * panda_system_paths[] = {
"/usr/bin/panda-system-aarch64",
"/usr/bin/panda-system-arm",
"/usr/bin/panda-system-i386",
"/usr/bin/panda-system-mips",
"/usr/bin/panda-system-mips64",
"/usr/bin/panda-system-mips64el",
"/usr/bin/panda-system-mipsel",
"/usr/bin/panda-system-ppc",
"/usr/bin/panda-system-x86_64",
NULL
};

#if 0
###########################################################
WARNING: This is all gloriously thread-unsafe!!!
Expand Down Expand Up @@ -153,6 +166,14 @@ static bool load_libpanda(void) {
g_free((char *)panda_lib);
}

INSTALL_BIN_DIR = "/usr/local/bin/";
for (int i = 0; panda_system_paths[i] != NULL; i++) {
if (access(panda_system_paths[i], F_OK) != -1) {
INSTALL_BIN_DIR = "/usr/bin";
break;
}
}

// Try standard install location
panda_lib = g_strdup_printf("%s%s", INSTALL_BIN_DIR, LIBRARY_NAME);
if (g_file_test(panda_lib, G_FILE_TEST_EXISTS)) {
Expand Down Expand Up @@ -347,7 +368,14 @@ char* resolve_file_from_plugin_directory(const char* file_name_fmt, const char*
return plugin_path;
}
g_free(plugin_path);


INSTALL_PLUGIN_DIR = "/usr/local/lib/panda/";
for (int i = 0; panda_system_paths[i] != NULL; i++) {
if (access(panda_system_paths[i], F_OK) != -1) {
INSTALL_PLUGIN_DIR = "/usr/lib/panda";
break;
}
}

// Third, check relative to the standard install location.
plugin_path = attempt_normalize_path(
Expand Down