PHMon: A Programmable Hardware Monitor and Its Security Use Cases

2 minute read

Published:

This post is the reading notes and building process of PHMon: A Programmable Hardware Monitor and Its Security Use Cases

Building

  • Platform: Ubuntu 20.04
  • Status: processing

Check and Modify the Compiling Script

PHMon has provide a installation script to compile everything automatically.

Basically, it does:

  • Configure the whole RISC-V toolchain
  • Configure Rocket-Chip toolchain
  • Configure environment attributes
    • env var
    • symbolic link
  • Inject customized patch into a 4.15 linux
    • include/linux/varanus.h
    • fs/komodo.c
    • Modified Compilation Configuration of Linux
  • Inject customized path into rocket-chip
    • Modification on CSRs, cache and other components.

I made some change towards install.sh to avoid some deprecated instructions and weird bug:

diff --git a/code/install.sh b/code/install.sh
index 62a6013..29ef257 100755
--- a/code/install.sh
+++ b/code/install.sh
@@ -5,10 +5,8 @@ export PHMon=`pwd`
-git clone https://github.com/ucb-bar/fpga-zynq/
+git clone --recursive https://github.com/ucb-bar/fpga-zynq/
 cd fpga-zynq
-git submodule update --init --recursive
 
 git clone https://github.com/riscv/riscv-linux
 cd riscv-linux
@@ -34,9 +32,8 @@ rm -rf riscv-tools
-git clone https://github.com/riscv/riscv-gnu-toolchain.git
+git clone --recursive https://github.com/riscv/riscv-gnu-toolchain.git
 cd riscv-gnu-toolchain
-git submodule update --init --recursive
 # Use --enable-multilab if you want to have support for both 32-bit and 64-bit
 #./configure --prefix=$RISCV --enable-multilib
 ./configure --prefix=$RISCV

Then:

$ cd PHMon/code
$ ./install.sh

It was like almost 4 hours long til the compilation is finished. Actually most of time is wasted on git clone.

compilation finished

What are they?

  • riscv-fesvr
  • varanus
  • komodo
  • Why do we need rocket-rocc-example
  • What does rocket.patch do

Run PHMon on ZedBoard

Some facts about zedboard

The top abstraction of zedboard can be seperated by Processor Subsystem(PS) and Program Logic(PL). One of the best practices is to manage PL by PS (using POSIX commands).

zedboard-block-diagram

Just as what is shown in the above diagram, zedboard

Connect to ZedBoard

Connect zedboard with ubuntu host pc with an ethernet wire and UART serial wire. We are going to scp everything necessary into zedboard.

Switch-on the power supply of zedboard, LD13 and LD12 should illuminate

Then configure the ethernet settings of ubuntu:

SettingsNetwork → ⚙️ → IPv4

Configure as shown in the following image:

And the default ip address of zedboard is 192.168.1.10.

After that, check the connection: enter 192.168.1.10 into the address box of a browser:

And try ssh to zedboard:

$ ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 root@192.168.1.10

Default password is root.

scp all needed files

$ cd evaluation/PHMon
$ scp -oKexAlgorithms=+diffie-hellman-group1-sha1 rocketchip_wrapper.bit.bin root@192.168.1.10:/tmp
$ scp