Skip to content

Commit

Permalink
Add smoke_test_hw_config (for HW_REV_ID) and update regression test l…
Browse files Browse the repository at this point in the history
…ist (rm kv_sha512_flow)
  • Loading branch information
calebofearth committed Jul 22, 2024
1 parent f280b02 commit e8afaa8
Show file tree
Hide file tree
Showing 7 changed files with 380 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/integration/stimulus/L0_regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ contents:
- ../test_suites/smoke_test_trng/smoke_test_trng.yml
- ../test_suites/smoke_test_qspi/smoke_test_qspi.yml
- ../test_suites/smoke_test_uart/smoke_test_uart.yml
- ../test_suites/smoke_test_hw_config/smoke_test_hw_config.yml
- ../test_suites/smoke_test_kv_uds_reset/smoke_test_kv_uds_reset.yml
- ../test_suites/smoke_test_kv_securitystate/smoke_test_kv_securitystate.yml
- ../test_suites/smoke_test_kv_ecc_flow/smoke_test_kv_ecc_flow.yml
Expand Down
1 change: 1 addition & 0 deletions src/integration/stimulus/L0_trng_regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ contents:
- ../test_suites/c_intr_handler/c_intr_handler.yml
- ../test_suites/smoke_test_sram_ecc/smoke_test_sram_ecc.yml
- ../test_suites/smoke_test_trng/smoke_test_trng.yml
- ../test_suites/smoke_test_hw_config/smoke_test_hw_config.yml
- ../test_suites/smoke_test_kv_uds_reset/smoke_test_kv_uds_reset.yml
- ../test_suites/smoke_test_wdt/smoke_test_wdt.yml
- ../test_suites/smoke_test_cg_wdt/smoke_test_cg_wdt.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ contents:
- ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_trng/smoke_test_trng.yml
- ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_qspi/smoke_test_qspi.yml
- ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_uart/smoke_test_uart.yml
- ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_hw_config/smoke_test_hw_config.yml
- ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_kv_uds_reset/smoke_test_kv_uds_reset.yml
- ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_kv_securitystate/smoke_test_kv_securitystate.yml
- ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_kv_ecc_flow/smoke_test_kv_ecc_flow.yml
- ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_kv_hmac_flow/smoke_test_kv_hmac_flow.yml
- ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_kv_hmac_multiblock_flow/smoke_test_kv_hmac_multiblock_flow.yml
- ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_kv_sha512_flow/smoke_test_kv_sha512_flow.yml
# SHA512 KV functionality is removed
# - ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_kv_sha512_flow/smoke_test_kv_sha512_flow.yml
- ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_kv_crypto_flow/smoke_test_kv_crypto_flow.yml
- ${CALIPTRA_ROOT}/src/integration/test_suites/pv_hash_and_sign/pv_hash_and_sign.yml
- ${CALIPTRA_ROOT}/src/integration/test_suites/smoke_test_pcr_signing/smoke_test_pcr_signing.yml
Expand Down
193 changes: 193 additions & 0 deletions src/integration/test_suites/smoke_test_hw_config/caliptra_isr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ---------------------------------------------------------------------
// File: caliptra_isr.h
// Description:
// Provides function declarations for use by external test files, so
// that the ISR functionality may behave like a library.
// TODO:
// This header file includes inline function definitions for event and
// test specific interrupt service behavior, so it should be copied and
// modified for each test.
// ---------------------------------------------------------------------

#ifndef CALIPTRA_ISR_H
#define CALIPTRA_ISR_H

#include "caliptra_reg.h"
#include <stdint.h>
#include "printf.h"
#include "riscv_hw_if.h"

/* --------------- symbols/typedefs --------------- */
typedef struct {
uint32_t doe_error;
uint32_t doe_notif;
uint32_t ecc_error;
uint32_t ecc_notif;
uint32_t hmac_error;
uint32_t hmac_notif;
uint32_t kv_error;
uint32_t kv_notif;
uint32_t sha512_error;
uint32_t sha512_notif;
uint32_t sha256_error;
uint32_t sha256_notif;
uint32_t qspi_error;
uint32_t qspi_notif;
uint32_t uart_error;
uint32_t uart_notif;
uint32_t i3c_error;
uint32_t i3c_notif;
uint32_t soc_ifc_error;
uint32_t soc_ifc_notif;
uint32_t sha512_acc_error;
uint32_t sha512_acc_notif;
} caliptra_intr_received_s;
extern volatile caliptra_intr_received_s cptra_intr_rcv;

/* --------------- Function Declarations --------------- */

// Performs all the CSR setup to configure and enable vectored external interrupts
void init_interrupts(void);

// These inline functions are used to insert event-specific functionality into the
// otherwise generic ISR that gets laid down by the parameterized macro "nonstd_veer_isr"
inline void service_doe_error_intr() {return;}
inline void service_doe_notif_intr() {return;}

inline void service_ecc_error_intr() {return;}
inline void service_ecc_notif_intr() {return;}

inline void service_hmac_error_intr() {return;}
inline void service_hmac_notif_intr() {return;}

inline void service_kv_error_intr() {return;}
inline void service_kv_notif_intr() {return;}
inline void service_sha512_error_intr() {return;}
inline void service_sha512_notif_intr() {return;}

inline void service_sha256_error_intr() {return;}
inline void service_sha256_notif_intr() {return;}

inline void service_qspi_error_intr() {return;}
inline void service_qspi_notif_intr() {return;}
inline void service_uart_error_intr() {return;}
inline void service_uart_notif_intr() {return;}
inline void service_i3c_error_intr() {return;}
inline void service_i3c_notif_intr() {return;}

inline void service_soc_ifc_error_intr() {
uint32_t * reg = (uint32_t *) (CLP_SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R);
uint32_t sts = *reg;
/* Write 1 to Clear the pending interrupt */
if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INTERNAL_STS_MASK) {
*reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INTERNAL_STS_MASK;
cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INTERNAL_STS_MASK;
}
if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INV_DEV_STS_MASK) {
*reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INV_DEV_STS_MASK;
cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_INV_DEV_STS_MASK;
}
if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_CMD_FAIL_STS_MASK) {
*reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_CMD_FAIL_STS_MASK;
cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_CMD_FAIL_STS_MASK;
}
if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_BAD_FUSE_STS_MASK) {
*reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_BAD_FUSE_STS_MASK;
cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_BAD_FUSE_STS_MASK;
}
if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_ICCM_BLOCKED_STS_MASK) {
*reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_ICCM_BLOCKED_STS_MASK;
cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_ICCM_BLOCKED_STS_MASK;
}
if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_MBOX_ECC_UNC_STS_MASK) {
*reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_MBOX_ECC_UNC_STS_MASK;
cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_MBOX_ECC_UNC_STS_MASK;
}
if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_WDT_TIMER1_TIMEOUT_STS_MASK) {
*reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_WDT_TIMER1_TIMEOUT_STS_MASK;
cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_WDT_TIMER1_TIMEOUT_STS_MASK;
}
if (sts & SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_WDT_TIMER2_TIMEOUT_STS_MASK) {
*reg = SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_WDT_TIMER2_TIMEOUT_STS_MASK;
cptra_intr_rcv.soc_ifc_error |= SOC_IFC_REG_INTR_BLOCK_RF_ERROR_INTERNAL_INTR_R_ERROR_WDT_TIMER2_TIMEOUT_STS_MASK;
}
if (sts == 0) {
VPRINTF(ERROR,"bad soc_ifc_error_intr sts:%x\n", sts);
SEND_STDOUT_CTRL(0x1);
while(1);
}
}

inline void service_soc_ifc_notif_intr () {
uint32_t * reg = (uint32_t *) (CLP_SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R);
uint32_t sts = *reg;
/* Write 1 to Clear the pending interrupt */
if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_AVAIL_STS_MASK) {
VPRINTF(HIGH, "cmd_avail\n");
*reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_AVAIL_STS_MASK;
cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_AVAIL_STS_MASK;
}
if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_MBOX_ECC_COR_STS_MASK) {
VPRINTF(HIGH, "mbox_ecc_cor\n");
*reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_MBOX_ECC_COR_STS_MASK;
cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_MBOX_ECC_COR_STS_MASK;
}
if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_DEBUG_LOCKED_STS_MASK) {
VPRINTF(HIGH, "debug_locked\n");
*reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_DEBUG_LOCKED_STS_MASK;
cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_DEBUG_LOCKED_STS_MASK;
}
if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SCAN_MODE_STS_MASK) {
VPRINTF(HIGH, "SCAN_MODE\n");
*reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SCAN_MODE_STS_MASK;
cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SCAN_MODE_STS_MASK;
}
if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SOC_REQ_LOCK_STS_MASK) {
VPRINTF(HIGH, "soc_req_lock\n");
*reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SOC_REQ_LOCK_STS_MASK;
cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_SOC_REQ_LOCK_STS_MASK;
}
if (sts & SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_GEN_IN_TOGGLE_STS_MASK) {
VPRINTF(HIGH, "gen_in_toggle\n");
*reg = SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_GEN_IN_TOGGLE_STS_MASK;
cptra_intr_rcv.soc_ifc_notif |= SOC_IFC_REG_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_GEN_IN_TOGGLE_STS_MASK;
}
if (sts == 0) {
VPRINTF(ERROR,"bad soc_ifc_notif_intr sts:%x\n", sts);
SEND_STDOUT_CTRL(0x1);
while(1);
}
}

inline void service_sha512_acc_error_intr() {return;}
inline void service_sha512_acc_notif_intr() {
uint32_t * reg = (uint32_t *) (CLP_SHA512_ACC_CSR_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R);
uint32_t sts = *reg;
/* Write 1 to Clear the pending interrupt */
if (sts & SHA512_ACC_CSR_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK) {
*reg = SHA512_ACC_CSR_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK;
cptra_intr_rcv.sha512_acc_notif |= SHA512_ACC_CSR_INTR_BLOCK_RF_NOTIF_INTERNAL_INTR_R_NOTIF_CMD_DONE_STS_MASK;
}
if (sts == 0) {
VPRINTF(ERROR,"bad sha512_acc_notif_intr sts:%x\n", sts);
SEND_STDOUT_CTRL(0x1);
while(1);
}
}


#endif //CALIPTRA_ISR_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "caliptra_defines.h"
#include "caliptra_isr.h"
#include "riscv-csr.h"
#include "veer-csr.h"
#include "riscv_hw_if.h"
#include <string.h>
#include <stdint.h>
#include "printf.h"


//int whisperPrintf(const char* format, ...);
//#define ee_printf whisperPrintf


volatile char* stdout = (char *)STDOUT;
volatile uint32_t intr_count;
#ifdef CPT_VERBOSITY
enum printf_verbosity verbosity_g = CPT_VERBOSITY;
#else
enum printf_verbosity verbosity_g = LOW;
#endif

volatile caliptra_intr_received_s cptra_intr_rcv = {
.doe_error = 0,
.doe_notif = 0,
.ecc_error = 0,
.ecc_notif = 0,
.hmac_error = 0,
.hmac_notif = 0,
.kv_error = 0,
.kv_notif = 0,
.sha512_error = 0,
.sha512_notif = 0,
.sha256_error = 0,
.sha256_notif = 0,
.qspi_error = 0,
.qspi_notif = 0,
.uart_error = 0,
.uart_notif = 0,
.i3c_error = 0,
.i3c_notif = 0,
.soc_ifc_error = 0,
.soc_ifc_notif = 0,
.sha512_acc_error = 0,
.sha512_acc_notif = 0,
};

void main(void) {
int argc=0;
char *argv[1];
uint32_t data;
uint32_t data_exp;
uint8_t fail = 0;

VPRINTF(LOW, "----------------------------------\nHardware Config Test from VeeR EL2 !!\n----------------------------------\n");

// Setup the interrupt CSR configuration
init_interrupts();

// Test HW REV ID
data = (lsu_read_32(CLP_SOC_IFC_REG_CPTRA_HW_REV_ID) & SOC_IFC_REG_CPTRA_HW_REV_ID_CPTRA_GENERATION_MASK) >> SOC_IFC_REG_CPTRA_HW_REV_ID_CPTRA_GENERATION_LOW;
#ifdef CALIPTRA_HW_REV_ID
if (data != CALIPTRA_HW_REV_ID) {
VPRINTF(FATAL, "HW REV ID register reports a version of major [%u], minor [%u], patch [%u] which does not match the expected value %u.%u.%u\n",
(data & 0xf),
(data & 0xf0) >> 4,
(data & 0xff00) >> 16,
(CALIPTRA_HW_REV_ID & 0xf),
(CALIPTRA_HW_REV_ID & 0xf0) >> 4,
(CALIPTRA_HW_REV_ID & 0xff00) >> 16);
fail = 1;
}
#else
VPRINTF(FATAL, "CALIPTRA_HW_REV_ID is not defined!\n");
fail = 1;
#endif

// Test HW CONFIG
data = lsu_read_32(CLP_SOC_IFC_REG_CPTRA_HW_CONFIG);
#ifdef CALIPTRA_HWCONFIG_TRNG_EN
data_exp = SOC_IFC_REG_CPTRA_HW_CONFIG_ITRNG_EN_MASK;
#else
data_exp = 0;
#endif
if ((data & SOC_IFC_REG_CPTRA_HW_CONFIG_ITRNG_EN_MASK) != data_exp) {
VPRINTF(FATAL, "HW Config register reports [%d] for ITRNG EN, expected [%d]!\n", (data & SOC_IFC_REG_CPTRA_HW_CONFIG_ITRNG_EN_MASK), data_exp);
fail = 1;
}
#ifdef CALIPTRA_HWCONFIG_QSPI_EN
data_exp = SOC_IFC_REG_CPTRA_HW_CONFIG_QSPI_EN_MASK;
#else
data_exp = 0;
#endif
if ((data & SOC_IFC_REG_CPTRA_HW_CONFIG_QSPI_EN_MASK) != data_exp) {
VPRINTF(FATAL, "HW Config register reports [%d] for QSPI EN, expected [%d]!\n", (data & SOC_IFC_REG_CPTRA_HW_CONFIG_QSPI_EN_MASK), data_exp);
fail = 1;
}
#ifdef CALIPTRA_HWCONFIG_I3C_EN
data_exp = SOC_IFC_REG_CPTRA_HW_CONFIG_I3C_EN_MASK;
#else
data_exp = 0;
#endif
if ((data & SOC_IFC_REG_CPTRA_HW_CONFIG_I3C_EN_MASK) != data_exp) {
VPRINTF(FATAL, "HW Config register reports [%d] for I3C EN, expected [%d]!\n", (data & SOC_IFC_REG_CPTRA_HW_CONFIG_I3C_EN_MASK), data_exp);
fail = 1;
}
#ifdef CALIPTRA_HWCONFIG_UART_EN
data_exp = SOC_IFC_REG_CPTRA_HW_CONFIG_UART_EN_MASK;
#else
data_exp = 0;
#endif
if ((data & SOC_IFC_REG_CPTRA_HW_CONFIG_UART_EN_MASK) != data_exp) {
VPRINTF(FATAL, "HW Config register reports [%d] for UART EN, expected [%d]!\n", (data & SOC_IFC_REG_CPTRA_HW_CONFIG_UART_EN_MASK), data_exp);
fail = 1;
}

// Ending status
if (fail) {
SEND_STDOUT_CTRL(0x1);
while(1);
}

return;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
seed: 1
testname: smoke_test_hw_config
Loading

0 comments on commit e8afaa8

Please sign in to comment.