Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pyot to support execution from flash and VMEM file format #150

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
7625bc5
[ot] scripts/opentitan: flashgen.py: split into a module and a front-end
rivos-eblot Feb 18, 2025
1c829d3
[ot] python/qemu: ot.eflash.gen: add an option to bypass OT header va…
rivos-eblot Feb 18, 2025
8ff06ad
[ot] scripts/opentitan: pyot.py: fix a second level error
rivos-eblot Feb 18, 2025
14dcaf2
[ot] scripts/opentitan: pyot.py: remove _configure_logger
rivos-eblot Feb 18, 2025
889f7c3
[ot] scripts/opentitan: pyot.py: split into many modules and a front-end
rivos-eblot Feb 18, 2025
1fc43fb
[ot] scripts/opentitan: pyot.py: add no-flash-header option
rivos-eblot Feb 18, 2025
dc0ad69
[ot] python/qemu: ot.pyot: move guess_test_type into a utility module
rivos-eblot Mar 13, 2025
51c12ef
[ot] python/qemu: ot.util.file: add detection of VMEM file type
rivos-eblot Mar 13, 2025
ead7d2f
[ot] python/qemu: ot.pyot.filemgr: add support for ELF application files
rivos-eblot Mar 13, 2025
84abcf8
[ot] python/qemu: ot.pyot.filemgr: do not emit kernel option when emb…
rivos-eblot Feb 18, 2025
cb389db
[ot] python/qemu: ot.util.recfmt: import text record utility module
rivos-eblot Mar 3, 2025
f97417b
[ot] python/qemu: ot.util.recfmt: update Python syntax
rivos-eblot Mar 4, 2025
2f2cd77
[ot] python/qemu: ot.util.recfmt: add VMEM parser and builder
rivos-eblot Mar 4, 2025
f197d52
[ot] python/qemu: ot.util.file: add an ELF to VMEM conversion function
rivos-eblot Mar 5, 2025
47c9bc1
[ot] python/qemu: ot.pyot: fix invalid typing hints
rivos-eblot Mar 5, 2025
afba4b7
[ot] hw/opentitan: ot_csrng: fix format
rivos-eblot Mar 10, 2025
272881c
[ot] hw/opentitan: ot_flash: fix format
rivos-eblot Mar 10, 2025
1f37e96
[ot] .gitlab-ci.d: opentitan: add GitLab CI scripts
rivos-eblot Mar 10, 2025
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
76 changes: 76 additions & 0 deletions .gitlab-ci.d/opentitan/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#------------------------------------------------------------------------------
# QEMU OpenTitan CI
#------------------------------------------------------------------------------

build-clang:
tags:
- qemu_ot
stage: build
# build QEMU for OT platforms, ensure subprojects are cleaned up first
# store generated header files and ninja command file as artifacts, which are
# required to run the clang-tidy stage
# libvhost-user.c generates sign-compare warnings with clang, so disable
# warning-as-error
# the alternative would be to build here with GCC, then rebuild everything
# with clang in clang-tidy stage, as meson generates different, incompatible
# warning list between GCC and clang...
script:
- rm -rf build
- git clean -dffx subprojects
- mkdir build
- cd build
- ../configure --cc=clang-19 --disable-werror $QEMU_BUILD_OPTS
--target-list=riscv32-softmmu,riscv64-softmmu,x86_64-linux-user
- ninja
- ninja qemu-img
- strip qemu-system-riscv32 qemu-img
- QEMU_DIR="$(cd .. && pwd -P)"; cat compile_commands.json |
sed -E 's,'"$QEMU_DIR"',@QEMU_DIR@,g' > compile_commands.json.tpl
- ../scripts/opentitan/swexit.py -t ibexdemo -b 0x0 -o exit_id.bin
- ../scripts/opentitan/swexit.py -t earlgrey -b 0x80 -o exit_eg.bin
artifacts:
public: false
expire_in: 1 hour
name: "qemu-ot"
paths:
- subprojects/libtomcrypt/src/headers/*.h
- build/*.h
- build/qapi/*.h
- build/trace/*.h
- build/compile_commands.json.tpl
- build/qemu-system-riscv32
- build/qemu-img
- build/exit_*.bin

build-gcc:
tags:
- qemu_ot
stage: build
# build QEMU for OT platforms, ensure subprojects are cleaned up first
# build with GCC may need different warnings
script:
- rm -rf build-gcc
- mkdir build-gcc
- cd build-gcc
- ../configure --cc=gcc $QEMU_BUILD_OPTS --target-list=riscv32-softmmu,riscv64-softmmu
- ninja

format:
tags:
- qemu_ot
stage: build
script:
- scripts/opentitan/ot-format.sh --ci -i
- git status -s
- test -z "$(git status -s)" || git diff
- test -z "$(git status -s)"

tidy:
tags:
- qemu_ot
stage: build
needs: ["build-clang"]
script:
- QEMU_DIR="$(pwd -P)"; cat build/compile_commands.json.tpl |
sed -E 's,@QEMU_DIR@,'"$QEMU_DIR"',g' > build/compile_commands.json
- scripts/opentitan/ot-tidy.sh --ci -p build
31 changes: 31 additions & 0 deletions .gitlab-ci.d/opentitan/ot-bmtests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Baremetal Tests for Earlgrey

baremetal-eg-tests:
tags:
- qemu_ot
stage: test
needs:
- "build-clang"
- project: rv/sandbox/rot/baremetal_test
job: build-eg
ref: $BAREMETAL_REF
artifacts: true
variables:
BASEDIR: bmtests/eg
CI_EXEC: 1
script:
- python3 -m virtualenv .venv
- . .venv/bin/activate
- pip3 install -r scripts/opentitan/requirements.txt
- rm -rf ${BASEDIR}
- mkdir -p ${BASEDIR}
- zstd -d --stdout ot-eg-bmtest.tar.zst | tar xf - -C ${BASEDIR}
- find ${BASEDIR}
- scripts/opentitan/pyot.py -vv -c ${BASEDIR}/data/qemu/ot-earlgrey/pyot-eflash.hjson
-w ot-earlgrey.csv -R -T 3
artifacts:
public: false
expire_in: 1 year
name: "bm-ot-earlgrey"
paths:
- ot-earlgrey.csv
12 changes: 12 additions & 0 deletions .gitlab-ci.d/opentitan/ot-smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
smoke-tests-ot:
tags:
- qemu_ot
stage: test
needs: ["build-clang"]
script:
- build/qemu-system-riscv32 -M help | grep ibexdemo
- build/qemu-system-riscv32 -M help | grep ot-earlgrey
- timeout -s KILL 4 build/qemu-system-riscv32 -M ibexdemo -nographic
-device loader,addr=0x100080,file=build/exit_id.bin -d in_asm,int
- timeout -s KILL 4 build/qemu-system-riscv32 -M ot-earlgrey,no_epmp_cfg=true -nographic
-object ot-rom_img,id=rom,file=build/exit_eg.bin -d in_asm,int
12 changes: 12 additions & 0 deletions .gitlab-ci.d/opentitan/pylint-ot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pylint-ot:
tags:
- qemu_ot
stage: build
script:
# disable duplicate code as all front end are tested at once (false positive)
# disable fixme ("# TODO" comments)
- python3 -m virtualenv .venv
- . .venv/bin/activate
- pip3 install -r scripts/opentitan/requirements.txt
- pylint --rcfile scripts/opentitan/.pylintrc -d 'duplicate-code' -d 'fixme'
scripts/opentitan/*.py python/qemu/jtagtools python/qemu/ot
9 changes: 9 additions & 0 deletions .gitlab-ci.d/opentitan/qemu-ot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variables:
BAREMETAL_REF: "b0-250310-1"
QEMU_BUILD_OPTS: "--disable-install-blobs"

include:
- local: '/.gitlab-ci.d/opentitan/build.yml'
- local: '/.gitlab-ci.d/opentitan/pylint-ot.yml'
- local: '/.gitlab-ci.d/opentitan/ot-smoke.yml'
- local: '/.gitlab-ci.d/opentitan/ot-bmtests.yml'
3 changes: 2 additions & 1 deletion hw/opentitan/ot_csrng.c
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,8 @@ static int ot_csrng_handle_command(OtCSRNGState *s, unsigned slot)
default:
qemu_log_mask(LOG_GUEST_ERROR, "Unknown command: %u\n", acmd);
// JW: check this shouldn't be CMD_STAGE_INVALID_CMD_SEQ_ALERT.
s->regs[R_RECOV_ALERT_STS] |= R_RECOV_ALERT_STS_CMD_STAGE_INVALID_ACMD_ALERT_MASK;
s->regs[R_RECOV_ALERT_STS] |=
R_RECOV_ALERT_STS_CMD_STAGE_INVALID_ACMD_ALERT_MASK;
CHANGE_STATE(s, CSRNG_ERROR);
ot_csrng_update_alerts(s);
return -1;
Expand Down
11 changes: 6 additions & 5 deletions hw/opentitan/ot_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1402,10 +1402,10 @@ static void ot_flash_op_erase_bank(OtFlashState *s, unsigned address)
}

/*
* For bank erase only, if the data partition is selected, just the
* data partition is erased. If the info partition is selected, BOTH
* the data and info partitions are erased.
*/
* For bank erase only, if the data partition is selected, just the
* data partition is erased. If the info partition is selected, BOTH
* the data and info partitions are erased.
*/
unsigned bank_address = address - (address % bank_size);
bank_address /= sizeof(uint32_t); /* convert to word address */
unsigned data_address, info_address = 0u;
Expand Down Expand Up @@ -1819,7 +1819,8 @@ static void ot_flash_regs_write(void *opaque, hwaddr addr, uint64_t val64,
s->op.info_part = part_sel;
s->op.info_sel = info_sel;
s->op.erase_sel = (bool)erase_sel;
/* Erase operations neither go through FIFOs nor use/require a word count */
/* Erase operations neither go through FIFOs nor use/require a
* word count */
s->op.count = 0u;
xtrace_ot_flash_info("Erase at", s->op.address);
break;
Expand Down
4 changes: 4 additions & 0 deletions python/qemu/ot/eflash/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) 2025 Rivos, Inc.
# SPDX-License-Identifier: Apache2

"""Embedded Flash tools."""
Loading