From b1414db5b309a7d7fdce6ac84898f638ce547963 Mon Sep 17 00:00:00 2001 From: Unlearned Man <92023558+Fly0307@users.noreply.github.com> Date: Sat, 30 Dec 2023 15:26:52 +0800 Subject: [PATCH 1/5] Create CI.yml --- .github/CI.yml | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/CI.yml diff --git a/.github/CI.yml b/.github/CI.yml new file mode 100644 index 000000000..8593405e5 --- /dev/null +++ b/.github/CI.yml @@ -0,0 +1,48 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# # Controls when the workflow will run +# on: +# # Triggers the workflow on push or pull request events but only for the main branch +# push: +# branches: [ main ] +# pull_request: +# branches: [ main ] + +# # Allows you to run this workflow manually from the Actions tab +# workflow_dispatch: +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches-ignore: + - '*' + pull_request: + branches-ignore: + - '*' + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + # using: 'docker' + runs-on: ubuntu-latest + name: Build and run penglai enclave + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Checkout repository + uses: actions/checkout@v2 + - name: Build and test Penglai monitor (based on OpenSBI). + id: build_run + uses: Fly0307/action-penglai-opensbi-build-and-test@oe-23 + # Runs a single command using the runners shell + + # Runs a set of commands using the runners shell + # - name: Run a multi-line script + # run: | + # echo Add other actions to build, + # echo test, and deploy your project. From c4b1740a087e38d68dc89b9e81663163ed5081f4 Mon Sep 17 00:00:00 2001 From: Unlearned Man <92023558+Fly0307@users.noreply.github.com> Date: Sat, 30 Dec 2023 15:31:56 +0800 Subject: [PATCH 2/5] Update build.yml --- .github/workflows/build.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 375c4922b..a70624981 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,3 +16,12 @@ jobs: - name: build step id: build uses: Ddnirvana/action-penglai-build@v1 + build_run: + runs-on: ubuntu-latest + name: Build and run penglai enclave + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Build and test Penglai monitor (based on OpenSBI). + id: build_run + uses: Fly0307/action-penglai-opensbi-build-and-test@oe-23 From b74fd94ebc8647485ec4f7ad82beb79bca4f348b Mon Sep 17 00:00:00 2001 From: Unlearned Man <92023558+Fly0307@users.noreply.github.com> Date: Sat, 30 Dec 2023 15:34:54 +0800 Subject: [PATCH 3/5] Update build.yml --- .github/workflows/build.yml | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a70624981..0f687b189 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,21 +7,12 @@ on: branches: [openeuler, opensbi] jobs: - build: - runs-on: ubuntu-latest - name: build penglai enclave (based on openSBI) - steps: - - name: Check out code - uses: actions/checkout@v2 - - name: build step - id: build - uses: Ddnirvana/action-penglai-build@v1 build_run: runs-on: ubuntu-latest name: Build and run penglai enclave steps: - - name: Checkout repository - uses: actions/checkout@v2 - - name: Build and test Penglai monitor (based on OpenSBI). - id: build_run - uses: Fly0307/action-penglai-opensbi-build-and-test@oe-23 + - name: Checkout repository + uses: actions/checkout@v2 + - name: Build and test Penglai monitor (based on OpenSBI). + id: build_run + uses: Fly0307/action-penglai-opensbi-build-and-test@oe-23 From b5d53bdf6035bc409d026e62321877646f2b2752 Mon Sep 17 00:00:00 2001 From: ZhaoXi Date: Sat, 3 Feb 2024 16:22:32 +0800 Subject: [PATCH 4/5] update README and scripts --- README.md | 60 +++++++++++++++++++++++----------------- docker_cmd.sh | 8 +++--- scripts/build_opensbi.sh | 2 +- 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 8b0a394c5..ff0aa0c4f 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,10 @@ Penglai uses Docker for building and uses submodules to track different componet **For openEuler version $\lt$ 23:** There is no need to compile uboot. +``` +# Fetch the uboot submodule +git submodule update --init --recursive +``` **For openEuler version $\ge$ 23:** @@ -52,7 +56,7 @@ Follow the instructions in openeuler riscv gitee to compile uboot for OE-23.X. # Fetch the uboot submodule git submodule update --init --recursive cd ./u-boot -make qemu-riscv64_defconfig +make qemu-riscv64_smode_defconfig make ARCH=riscv CROSS_COMPILE=riscv64-unknown-linux-gnu- -j$(nproc) ``` @@ -81,18 +85,16 @@ For oe versions greater than 23, you can access the source code after [Run openE cd /home/penglai/penglai-enclave/opensbi-0.9 mkdir -p build-oe/qemu-virt CROSS_COMPILE=riscv64-unknown-linux-gnu- make O=build-oe/qemu-virt PLATFORM=generic FW_PAYLOAD=y FW_PAYLOAD_PATH=/home/penglai/penglai-enclave/Image - Note: the /home/penglai/penglai-enclave/Image is the image compiled openEuler Kernel Image. **For openEuler version $\ge$ 23:** ``` -cp ../Penglai-Enclave-sPMP/u-boot/u-boot.bin . docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it ddnirvana/penglai-enclave:v0.5 bash cd /home/penglai/penglai-enclave/opensbi-1.2 rm -rf build-oe/qemu-virt mkdir -p build-oe/qemu-virt -CROSS_COMPILE=riscv64-unknown-linux-gnu- make O=build-oe/qemu-virt PLATFORM=generic FW_PAYLOAD=y FW_PAYLOAD_PATH=/home/penglai/penglai-enclave/u-boot.bin -j$(nproc) +CROSS_COMPILE=riscv64-unknown-linux-gnu- make O=build-oe/qemu-virt PLATFORM=generic FW_PAYLOAD=y FW_PAYLOAD_PATH=/home/penglai/penglai-enclave/u-boot/u-boot.bin -j$(nproc) ``` A simpler way: @@ -106,7 +108,7 @@ A simpler way: **Note**: if you use the simpler way, please **copy** your latest kernel *Image* file to the root dir of the repo. -### Build Penglai SDK +### Build Penglai driver module **For openEuler version $\lt$ 23:** @@ -122,7 +124,7 @@ It will generate penglai.ko in the penglai-enclave-driver dir. When openEuler version is >= 23, you need to start openEuler in qemu as the next step [Run openEuler with Penglai Supports](#run-openeuler-with-penglai-supports) finished before compiling penglai-driver. - +### Build Penglai sdk When penglai.ko is completed,following the commnads to build user-level sdk and demos: @@ -166,7 +168,7 @@ Run VM in QEMU: - The test qemu version is 5.2.0 or 8.0.0. - The fw_payload.elf is the opensbi file. -- The openEuler-preview.riscv64.qcow2 is the disk image for openEuler (You can download from https://repo.openeuler.org/openEuler-preview/RISC-V/Image/). +- The openEuler-preview.riscv64.qcow2 is the disk image for openEuler (You can download from https://repo.openeuler.org/openEuler-preview/RISC-V/). - To login, username is "root", passwd is "openEuler12#$" Note: a script, run_openeuler.sh is provided to execute the above command easily @@ -204,21 +206,41 @@ a simple way: ./run_openeuler.sh -k 2303 -o 1.2 ``` +### RUN demo + +**For openEuler version $\lt$ 23:** + +**Copy files to openEuler Qemu** + +You can copy any files to the VM using *scp*. + +For example, to run the following demo, you should: + + #For version 23, there is no need to copy penglai.ko + scp -P 12055 penglai-enclave-driver/penglai.ko root@localhost:~/ + scp -P 12055 sdk/demo/host/host root@localhost:~/ + scp -P 12055 sdk/demo/prime/prime root@localhost:~/ + +The passwd is "openEuler12#$" + +**For openEuler version $\ge$ 23:** + After starting the VM, you need to get the source code in the qemu VM and execute compile kernel moudle with penglai-driver for openEuler version $\ge$ 23. Copy penglai-enclave-driver to the root/ directory of the oe VM: ``` #in host -scp -P 12055 penglai-enclave-driver root@localhost:~/ +scp -P -r 12055 penglai-enclave-driver root@localhost:~/ +scp -P 12055 sdk/demo/host/host root@localhost:~/ +scp -P 12055 sdk/demo/prime/prime root@localhost:~/ ``` - Execute the following commands and the kernel source code will be downloaded locally, the path is `/usr/lib/modules/6.1.19-2.oe2303.riscv64`. ``` #in VM cd ~/ -sudo dnf install -y kernel-devel kernel-source +dnf install -y kernel-devel kernel-source ``` Go into the penglai-enclave-driver directory and modify the original kernel source path openeuler-kernel in the Makefile from `../openeuler-kernel/`to `/usr/lib/modules/6.1.19-2.oe2303.riscv64/build/`. @@ -227,30 +249,18 @@ Compile and install the kernel module: ``` cd ~/penglai-enclave-driver -vim Makefile #modify source path +#modify source path +sed -i 's|make -C ../openeuler-kernel/ ARCH=riscv M=$(PWD) modules|make -C /usr/lib/modules/$(shell uname -r)/build ARCH=riscv M=$(PWD) modules|' Makefile > /dev/null 2>&1 make -j$(nproc) insmod penglai.ko ``` -### RUN demo - -**Copy files to openEuler Qemu** - -You can copy any files to the VM using *scp*. - -For example, to run the following demo, you should: - - scp -P 12055 penglai-enclave-driver/penglai.ko root@localhost:~/ - scp -P 12055 sdk/demo/host/host root@localhost:~/ - scp -P 12055 sdk/demo/prime/prime root@localhost:~/ - -The passwd is "openEuler12#$" - **Insmod the enclave-driver** If you already installed in the previous step, you don't need to repeat it ``` +cd ~/ insmod penglai.ko ``` diff --git a/docker_cmd.sh b/docker_cmd.sh index b567824da..4f7e4bf8a 100755 --- a/docker_cmd.sh +++ b/docker_cmd.sh @@ -18,7 +18,7 @@ function print_usage() { # no arguments if [ $# == 0 ]; then echo "Default: building penglai demo image" - docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it ddnirvana/penglai-enclave:v0.1 bash scripts/build_opensbi.sh + docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it fly0307/penglai-enclave:v0.1 bash scripts/build_opensbi.sh -v 1.2 -k 2203 exit 0 fi @@ -30,7 +30,7 @@ fi # build penglai if [[ $1 == *"build"* ]]; then echo "Build: building penglai demo image" - docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it ddnirvana/penglai-enclave:v0.1 bash scripts/build_opensbi.sh + docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it fly0307/penglai-enclave:v0.1 bash scripts/build_opensbi.sh exit 0 fi @@ -45,14 +45,14 @@ fi if [[ $1 == *"docker"* ]]; then echo "Run: run docker" #sudo docker run --privileged --cap-add=ALL -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it ddnirvana/penglai-enclave:v0.1 - docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --network=host --rm -it ddnirvana/penglai-enclave:v0.5 bash + docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --network=host --rm -it fly0307/penglai-enclave:v0.1 bash exit 0 fi # make clean if [[ $1 == *"clean"* ]]; then echo "Clean: make clean" - docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it ddnirvana/penglai-enclave:v0.1 make clean + docker run -v $(pwd):/home/penglai/penglai-enclave -w /home/penglai/penglai-enclave --rm -it fly0307/penglai-enclave:v0.1 make clean exit 0 fi diff --git a/scripts/build_opensbi.sh b/scripts/build_opensbi.sh index d3ce42ef7..00fd48027 100755 --- a/scripts/build_opensbi.sh +++ b/scripts/build_opensbi.sh @@ -18,7 +18,7 @@ function build_opensbi_2() { cd /home/penglai/penglai-enclave/opensbi-${1} rm -rf build-oe/qemu-virt mkdir -p build-oe/qemu-virt - CROSS_COMPILE=riscv64-unknown-linux-gnu- make O=build-oe/qemu-virt PLATFORM=generic FW_PAYLOAD=y FW_PAYLOAD_PATH=/home/penglai/penglai-enclave/u-boot.bin -j$(nproc) + CROSS_COMPILE=riscv64-unknown-linux-gnu- make O=build-oe/qemu-virt PLATFORM=generic FW_PAYLOAD=y FW_PAYLOAD_PATH=/home/penglai/penglai-enclave/u-boot/u-boot.bin -j$(nproc) } function print_usage() { From 080753bb60e5f4c3f8239852495c9ad2bf88d16f Mon Sep 17 00:00:00 2001 From: ZhaoXi Date: Sat, 3 Feb 2024 16:36:31 +0800 Subject: [PATCH 5/5] update README --- .github/CI.yml | 48 ------------------------------------------------ README.md | 16 ++++++++-------- 2 files changed, 8 insertions(+), 56 deletions(-) delete mode 100644 .github/CI.yml diff --git a/.github/CI.yml b/.github/CI.yml deleted file mode 100644 index 8593405e5..000000000 --- a/.github/CI.yml +++ /dev/null @@ -1,48 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: CI - -# # Controls when the workflow will run -# on: -# # Triggers the workflow on push or pull request events but only for the main branch -# push: -# branches: [ main ] -# pull_request: -# branches: [ main ] - -# # Allows you to run this workflow manually from the Actions tab -# workflow_dispatch: -# Controls when the workflow will run -on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - branches-ignore: - - '*' - pull_request: - branches-ignore: - - '*' - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on - # using: 'docker' - runs-on: ubuntu-latest - name: Build and run penglai enclave - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - name: Checkout repository - uses: actions/checkout@v2 - - name: Build and test Penglai monitor (based on OpenSBI). - id: build_run - uses: Fly0307/action-penglai-opensbi-build-and-test@oe-23 - # Runs a single command using the runners shell - - # Runs a set of commands using the runners shell - # - name: Run a multi-line script - # run: | - # echo Add other actions to build, - # echo test, and deploy your project. diff --git a/README.md b/README.md index ff0aa0c4f..1bb059df8 100644 --- a/README.md +++ b/README.md @@ -197,6 +197,13 @@ qemu-system-riscv64 -nographic -machine virt \ -netdev user,id=usernet,hostfwd=tcp::12055-:22 \ -device qemu-xhci -usb -device usb-kbd -device usb-tablet ``` +Once started, you should execut the following command to obtain the kernel module compilation environment. Execute the following commands and the kernel source code will be downloaded locally, the path is `/usr/lib/modules/6.1.19-2.oe2303.riscv64`(For openEuler 2303). +``` +#in VM +cd ~/ +dnf install -y kernel-devel kernel-source +``` + a simple way: @@ -235,15 +242,8 @@ scp -P -r 12055 penglai-enclave-driver root@localhost:~/ scp -P 12055 sdk/demo/host/host root@localhost:~/ scp -P 12055 sdk/demo/prime/prime root@localhost:~/ ``` -Execute the following commands and the kernel source code will be downloaded locally, the path is `/usr/lib/modules/6.1.19-2.oe2303.riscv64`. - -``` -#in VM -cd ~/ -dnf install -y kernel-devel kernel-source -``` -Go into the penglai-enclave-driver directory and modify the original kernel source path openeuler-kernel in the Makefile from `../openeuler-kernel/`to `/usr/lib/modules/6.1.19-2.oe2303.riscv64/build/`. +Go into the penglai-enclave-driver directory and modify the original kernel source path openeuler-kernel in the Makefile from `../openeuler-kernel/`to `/usr/lib/modules/$(shell uname -r)/build/`. Compile and install the kernel module: