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 to LLVM 17 #60

Merged
Merged
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
62 changes: 34 additions & 28 deletions .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
#------------------------------------------------------------------------------
# QEMU OpenTitan CI
#
# Copyright (c) 2023 Rivos, Inc.
# Copyright (c) 2023-2024 Rivos, Inc.
# SPDX-License-Identifier: Apache License 2.0
#------------------------------------------------------------------------------

Expand All @@ -12,12 +13,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install deps
run: wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key |
sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc &&
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" &&
sudo apt-get update &&
sudo apt-get install -y git make pkg-config clang-16 cmake ninja-build python3 rust-all
libpixman-1-dev
run: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key |
sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc &&
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main" &&
sudo apt-get update &&
sudo apt-get install -y git make pkg-config clang-17 cmake ninja-build python3 rust-all \
libpixman-1-dev
- name: Check out QEMU
uses: actions/checkout@v4
- name: Configure
Expand All @@ -26,7 +28,7 @@ jobs:
git clean -dffx subprojects
mkdir build-clang
(cd build-clang &&
../configure --cc=clang-16 --disable-werror --target-list=riscv32-softmmu,riscv64-softmmu)
../configure --cc=clang-17 --disable-werror --target-list=riscv32-softmmu,riscv64-softmmu)
- name: Build
run: |
ninja -C build-clang &&
Expand Down Expand Up @@ -64,11 +66,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install tools
run: wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key |
sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc &&
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" &&
sudo apt-get update &&
sudo apt-get install -y clang-format-16
run: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key |
sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc &&
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main" &&
sudo apt-get update &&
sudo apt-get install -y clang-format-17
- name: Check out QEMU
uses: actions/checkout@v4
- name: Check execution
Expand All @@ -80,17 +83,18 @@ jobs:
needs: build-clang
steps:
- name: Install tools
run: wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key |
sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc &&
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" &&
sudo apt-get update &&
sudo apt-get install -y clang-tidy-16
run: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key |
sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc &&
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main" &&
sudo apt-get update &&
sudo apt-get install -y clang-tidy-17
- name: Check out QEMU
uses: actions/checkout@v4
- name: Download QEMU source artifacts
uses: actions/download-artifact@v3
with:
name: qemu-src
name: qemu-src
- name: Unpack source artifacts
run: |
tar xzf qemu-src-artifact.tar.gz
Expand All @@ -104,12 +108,13 @@ jobs:
needs: build-clang
steps:
- name: Install tools
run: sudo apt-get update &&
sudo apt-get install -y libpixman-1-0
run: |
sudo apt-get update &&
sudo apt-get install -y libpixman-1-0
- name: Download QEMU binary artifacts
uses: actions/download-artifact@v3
with:
name: qemu-bin
name: qemu-bin
- name: Check machine availability
run: |
chmod +x ./qemu-system-riscv32 &&
Expand All @@ -129,12 +134,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install tools
run: wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key |
sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc &&
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" &&
sudo apt-get update &&
sudo apt-get install -y git make pkg-config gcc cmake ninja-build
python3 rust-all libpixman-1-dev
run: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key |
sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc &&
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main" &&
sudo apt-get update &&
sudo apt-get install -y git make pkg-config gcc cmake ninja-build python3 rust-all \
libpixman-1-dev
- name: Check out QEMU
uses: actions/checkout@v4
- name: Configure
Expand Down
12 changes: 6 additions & 6 deletions .gitlab-ci.d/opentitan/build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#------------------------------------------------------------------------------
# QEMU OpenTitan CI
#
# apk add llvm rust python3 clang16 clang16-extra-tools cmake ninja-build
# samurai git make pkgconfig glib-dev pixman-dev zstd py3-pip
# pip3 install pyelftools hjson
#------------------------------------------------------------------------------

build-clang:
Expand All @@ -23,11 +19,13 @@ build-clang:
- git clean -dffx subprojects
- mkdir build
- cd build
- ../configure --cc=clang-16 --disable-werror $QEMU_BUILD_OPTS
- ../configure --cc=clang-17 --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 earlgrey -o exit_eg.bin
- ../scripts/opentitan/swexit.py -t darjeeling -o exit_dj.bin
artifacts:
Expand All @@ -39,7 +37,7 @@ build-clang:
- build/*.h
- build/qapi/*.h
- build/trace/*.h
- build/compile_commands.json
- build/compile_commands.json.tpl
- build/qemu-system-riscv32
- build/qemu-img
- build/exit_*.bin
Expand Down Expand Up @@ -72,4 +70,6 @@ tidy:
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
2 changes: 1 addition & 1 deletion hw/opentitan/ot_gpio_dj.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ static void ot_gpio_dj_in_change(void *opaque, int no, int level)
{
OtGpioDjState *s = opaque;

trace_ot_gpio_in_change(s->ot_id, no, level<0, level> 0);
trace_ot_gpio_in_change(s->ot_id, no, level < 0, level > 0);

g_assert(no < PARAM_NUM_IO);

Expand Down
2 changes: 1 addition & 1 deletion hw/opentitan/ot_gpio_eg.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static void ot_gpio_eg_in_change(void *opaque, int no, int level)
{
OtGpioEgState *s = opaque;

trace_ot_gpio_in_change(s->ot_id, no, level<0, level> 0);
trace_ot_gpio_in_change(s->ot_id, no, level < 0, level > 0);

g_assert(no < PARAM_NUM_IO);

Expand Down
2 changes: 1 addition & 1 deletion hw/opentitan/ot_pinmux_dj.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ REG32(WKUP_CAUSE,
#define REGS_SIZE (REGS_COUNT * sizeof(uint32_t))
#define CASE_SCALAR(_reg_) R_##_reg_
#define CASE_RANGE(_reg_, _rpt_) R_##_reg_...(R_##_reg_ + (_rpt_) - (1u))
#define PAD_ATTR_TO_IRQ(_pad_) ((int)((_pad_)&INT32_MAX))
#define PAD_ATTR_TO_IRQ(_pad_) ((int)((_pad_) & INT32_MAX))
#define PAD_ATTR_ENABLE(_en_) (((unsigned)!(_en_)) << 31u)

static_assert((OT_PINMUX_PAD_ATTR_MASK | OT_PINMUX_PAD_ATTR_FORCE_MODE_MASK) <
Expand Down
2 changes: 1 addition & 1 deletion hw/opentitan/ot_pinmux_eg.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ REG32(WKUP_CAUSE,
#define REGS_SIZE (REGS_COUNT * sizeof(uint32_t))
#define CASE_SCALAR(_reg_) R_##_reg_
#define CASE_RANGE(_reg_, _rpt_) R_##_reg_...(R_##_reg_ + (_rpt_) - (1u))
#define PAD_ATTR_TO_IRQ(_pad_) ((int)((_pad_)&INT32_MAX))
#define PAD_ATTR_TO_IRQ(_pad_) ((int)((_pad_) & INT32_MAX))
#define PAD_ATTR_ENABLE(_en_) (((unsigned)!(_en_)) << 31u)

static_assert((OT_PINMUX_PAD_ATTR_MASK | OT_PINMUX_PAD_ATTR_FORCE_MODE_MASK) <
Expand Down
4 changes: 2 additions & 2 deletions hw/opentitan/ot_spi_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ static_assert(SPI_SRAM_END_OFFSET == 0xe80u, "Invalid SRAM definition");
static_assert((1u << FIFO_PHASE_BIT) >= GENERIC_BUFFER_SIZE,
"Invalid phase bit");
#define FIFO_PTR_MASK ((1u << FIFO_PHASE_BIT) - 1u)
#define FIFO_PTR(_ptr_) ((_ptr_)&FIFO_PTR_MASK)
#define FIFO_PTR(_ptr_) ((_ptr_) & FIFO_PTR_MASK)
#define FIFO_PHASE(_ptr_) ((bool)((_ptr_) >> (FIFO_PHASE_BIT)))
#define FIFO_MAKE_PTR(_phase_, _ptr_) \
((((unsigned)(bool)(_phase_)) << FIFO_PHASE_BIT) | FIFO_PTR(_ptr_))
Expand Down Expand Up @@ -649,7 +649,7 @@ static const char *TPM_REG_NAMES[TPM_REGS_COUNT] = {
#define JEDEC_ID_MASK (R_JEDEC_ID_ID_MASK | R_JEDEC_ID_MF_MASK)

#define COMMAND_OPCODE(_cmd_info_) \
((uint8_t)((_cmd_info_)&CMD_INFO_OPCODE_MASK))
((uint8_t)((_cmd_info_) & CMD_INFO_OPCODE_MASK))
#define FLASH_SLOT(_name_) ((R_CMD_INFO_##_name_) - R_CMD_INFO_0)

#define STATE_NAME_ENTRY(_st_) [_st_] = stringify(_st_)
Expand Down
4 changes: 4 additions & 0 deletions hw/opentitan/ot_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ static uint64_t ot_uart_read(void *opaque, hwaddr addr, unsigned size)
case OT_UART_RX_FIFO_SIZE:
val32 |= R_STATUS_RXFULL_MASK;
break;
default:
break;
}
/* report TXEMPTY+TXIDLE or TXFULL */
switch (fifo8_num_used(&s->tx_fifo)) {
Expand All @@ -403,6 +405,8 @@ static uint64_t ot_uart_read(void *opaque, hwaddr addr, unsigned size)
case OT_UART_TX_FIFO_SIZE:
val32 |= R_STATUS_TXFULL_MASK;
break;
default:
break;
}
if (!ot_uart_is_tx_enabled(s)) {
val32 |= R_STATUS_TXIDLE_MASK;
Expand Down
6 changes: 3 additions & 3 deletions include/exec/jtagstub.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ struct _TAPDataHandler {
* @_ver_ Version
*/
#define JTAG_IDCODE(_mfid_, _pnum_, _ver_) \
((((_ver_)&0xfu) << 28u) | (((_pnum_)&0xffffu) << 12u) | \
(((_mfid_)&0x7ffu) << 1u) | 0b1)
((((_ver_) & 0xfu) << 28u) | (((_pnum_) & 0xffffu) << 12u) | \
(((_mfid_) & 0x7ffu) << 1u) | 0b1)

/*
* Create JEDEC Manufacturer ID
Expand All @@ -61,7 +61,7 @@ struct _TAPDataHandler {
* @_id_ Entry in JEDEC table
*/
#define JEDEC_MANUFACTURER_ID(_tbl_, _id_) \
(((((_tbl_)-1u) & 0xfu) << 7u) | ((_id_)&0x7fu))
(((((_tbl_)-1u) & 0xfu) << 7u) | ((_id_) & 0x7fu))

/*
* Start the JTAG server
Expand Down
12 changes: 6 additions & 6 deletions include/hw/riscv/ibex_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum {
/* ------------------------------------------------------------------------ */

#define IBEX_JTAG_PART_NUM(_part_, _tap_) \
((((_part_)&0xfffu) << 4u) | ((_tap_)&0xfu))
((((_part_) & 0xfffu) << 4u) | ((_tap_) & 0xfu))

#define LOWRISC_JEDEC_MANUFACTURER_ID 0x6fu /* MSB is parity bit, ignored */
#define LOWRISC_JEDEC_TABLE 13u
Expand Down Expand Up @@ -199,31 +199,31 @@ typedef struct {
((_addr_) | (((uint32_t)_flag_) & IBEX_MEMMAP_REGIDX_MASK))
#define IBEX_MEMMAP_MAKE_REG_MASK(_flag_) (1u << (_flag_))
#define IBEX_MEMMAP_DEFAULT_REG_MASK (1u << 0u)
#define IBEX_MEMMAP_GET_REGIDX(_addr_) ((_addr_)&IBEX_MEMMAP_REGIDX_MASK)
#define IBEX_MEMMAP_GET_REGIDX(_addr_) ((_addr_) & IBEX_MEMMAP_REGIDX_MASK)
#define IBEX_MEMMAP_GET_ADDRESS(_addr_) ((_addr_) & ~IBEX_MEMMAP_REGIDX_MASK)

#define IBEX_GPIO_GRP_BITS 5u
#define IBEX_GPIO_GRP_COUNT (1u << (IBEX_GPIO_GRP_BITS))
#define IBEX_GPIO_GRP_SHIFT (32u - IBEX_GPIO_GRP_BITS)
#define IBEX_GPIO_GRP_MASK ((IBEX_GPIO_GRP_COUNT)-1u) << (IBEX_GPIO_GRP_SHIFT)
#define IBEX_GPIO_IDX_MASK (~(IBEX_GPIO_GRP_MASK))
#define IBEX_GPIO_GET_IDX(_idx_) ((_idx_)&IBEX_GPIO_IDX_MASK)
#define IBEX_GPIO_GET_IDX(_idx_) ((_idx_) & IBEX_GPIO_IDX_MASK)
#define IBEX_GPIO_GET_GRP(_idx_) \
(((_idx_) & (IBEX_GPIO_GRP_MASK)) >> IBEX_GPIO_GRP_SHIFT)
#define IBEX_GPIO_MAKE_GRPIDX(_grp_, _ix_) \
(((_grp_) << IBEX_GPIO_GRP_SHIFT) | ((_ix_)&IBEX_GPIO_IDX_MASK))
(((_grp_) << IBEX_GPIO_GRP_SHIFT) | ((_ix_) & IBEX_GPIO_IDX_MASK))

#define IBEX_DEVLINK_RMT_BITS 8u
#define IBEX_DEVLINK_RMT_COUNT (1u << (IBEX_DEVLINK_RMT_BITS))
#define IBEX_DEVLINK_RMT_SHIFT (32u - IBEX_DEVLINK_RMT_BITS)
#define IBEX_DEVLINK_RMT_MASK \
((IBEX_DEVLINK_RMT_COUNT)-1u) << (IBEX_DEVLINK_RMT_SHIFT)
#define IBEX_DEVLINK_IDX_MASK (~(IBEX_DEVLINK_RMT_MASK))
#define IBEX_DEVLINK_DEVICE(_idx_) ((_idx_)&IBEX_DEVLINK_IDX_MASK)
#define IBEX_DEVLINK_DEVICE(_idx_) ((_idx_) & IBEX_DEVLINK_IDX_MASK)
#define IBEX_DEVLINK_REMOTE(_idx_) \
(((_idx_) & (IBEX_DEVLINK_RMT_MASK)) >> IBEX_DEVLINK_RMT_SHIFT)
#define IBEX_DEVLINK_MAKE_RMTDEV(_par_, _ix_) \
(((_par_) << IBEX_DEVLINK_RMT_SHIFT) | ((_ix_)&IBEX_DEVLINK_IDX_MASK))
(((_par_) << IBEX_DEVLINK_RMT_SHIFT) | ((_ix_) & IBEX_DEVLINK_IDX_MASK))

/* MemMapEntry that should be ignored (i.e. skipped, not mapped) */
#define MEMMAPSKIP \
Expand Down
1 change: 1 addition & 0 deletions scripts/opentitan/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Checks: '*,
-hicpp-signed-bitwise,
-llvmlibc-*,
-llvm-include-order,
-misc-include-cleaner,
-modernize-macro-to-enum,
-performance-no-int-to-ptr,
-readability-function-cognitive-complexity,
Expand Down
4 changes: 2 additions & 2 deletions scripts/opentitan/ot-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Copyright (c) 2024 Rivos, Inc.
# SPDX-License-Identifier: Apache2

EXPECTED_VERSION="16"
EXPECTED_VERSION="17"

# find clang-format executable: either 'clang-format-16' or 'clang-format'
# find clang-format executable: either 'clang-format-17' or 'clang-format'
for ver_suffix in "-${EXPECTED_VERSION}" ""; do
clangformat="$(which clang-format${ver_suffix} 2>/dev/null)"
if [ -n "${clangformat}" ]; then
Expand Down
4 changes: 2 additions & 2 deletions scripts/opentitan/ot-tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Copyright (c) 2024 Rivos, Inc.
# SPDX-License-Identifier: Apache2

EXPECTED_VERSION="16"
EXPECTED_VERSION="17"

# find clang-tidy executable: either 'clang-tidy-16' or 'clang-tidy'
# find clang-tidy executable: either 'clang-tidy-17' or 'clang-tidy'
for ver_suffix in "-${EXPECTED_VERSION}" ""; do
clangtidy="$(which clang-tidy${ver_suffix} 2>/dev/null)"
if [ -n "${clangtidy}" ]; then
Expand Down
4 changes: 3 additions & 1 deletion target/riscv/pmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
#ifndef RISCV_PMP_H
#define RISCV_PMP_H

#include "cpu.h"
#ifndef RISCV_CPU_H
#error must include cpu.h header
#endif

typedef enum {
PMP_READ = 1 << 0,
Expand Down
Loading