Fix SPM warnings

pull/9823/head
Oren Cohen 2019-02-24 12:31:04 +02:00
parent 68d91fb277
commit 483b23c318
13 changed files with 44 additions and 43 deletions

View File

@ -78,7 +78,7 @@ void server_main(void *ptr)
SPM_PANIC("Invalid msg type");
}
} else {
SPM_PANIC("Received invalid signal %d", signals);
SPM_PANIC("Received invalid signal %lu", signals);
}
}
}

View File

@ -84,7 +84,7 @@ void part1_main(void *ptr)
psa_reply(msg.handle, PSA_SUCCESS);
break;
default:
SPM_PANIC("Unexpected message type %d!", (int)(msg.type));
SPM_PANIC("Unexpected message type %lu!", msg.type);
}
}
}

View File

@ -34,6 +34,7 @@ void part2_main(void *ptr)
if (0 == (signals & SERVER_TEST_PART2_WAIT_ANY_SID_MSK)) {
SPM_PANIC("returned from psa_wait without ROT_SRV_REVERSE_MSK or ROT_SRV_DB_TST_MSK bit on\n");
}
if (signals & ROT_SRV_REVERSE_MSK) {
psa_get(ROT_SRV_REVERSE_MSK, &msg);
switch (msg.type) {
@ -59,17 +60,17 @@ void part2_main(void *ptr)
str = NULL;
break;
}
case PSA_IPC_CONNECT:
case PSA_IPC_DISCONNECT:
break;
default:
SPM_PANIC("Unexpected message type %d!", (int)(msg.type));
SPM_PANIC("Unexpected message type %lu!", msg.type);
break;
}
psa_reply(msg.handle, PSA_SUCCESS);
} else { // -- Doorbell test
psa_get(ROT_SRV_DB_TST_MSK, &msg);
switch (msg.type) {
case PSA_IPC_CALL: {
@ -91,7 +92,7 @@ void part2_main(void *ptr)
psa_reply(msg.handle, PSA_SUCCESS);
break;
default:
SPM_PANIC("Unexpected message type %d!", (int)(msg.type));
SPM_PANIC("Unexpected message type %lu!", msg.type);
break;
}
}

View File

@ -494,7 +494,7 @@ PSA_TEST_SERVER(rhandle_factorial)
disconnect_count++;
break;
default:
SPM_PANIC("Unexpected message type %d!", (int)(msg.type));
SPM_PANIC("Unexpected message type %lu!", msg.type);
}
num = NULL;

View File

@ -47,14 +47,14 @@ void part1_main(void *ptr)
signals = psa_wait(ROT_SRV1_MSK, PSA_BLOCK);
if ((signals & ROT_SRV1_MSK) != ROT_SRV1_MSK) {
SPM_PANIC("Received unknown signal (0x%08x)\n", signals);
SPM_PANIC("Received unknown signal (0x%08lx)\n", signals);
}
psa_get(ROT_SRV1_MSK, &msg);
if (msg.handle != PSA_NULL_HANDLE) {
client_id = msg.client_id;
if (client_id != PSA_NSPE_IDENTIFIER) {
SPM_PANIC("Received message from unexpected source (0x%08x)\n", client_id);
SPM_PANIC("Received message from unexpected source (0x%08lx)\n", client_id);
}
}
@ -78,7 +78,7 @@ void part1_main(void *ptr)
for (size_t i = 0; i < PSA_MAX_IOVEC - 1; i++) {
uint32_t bytes_read = psa_read(msg.handle, i, read_ptr, msg.in_size[i]);
if (bytes_read != msg.in_size[i]) {
SPM_PANIC("Expected to read %d, got %d", msg.in_size[i], bytes_read);
SPM_PANIC("Expected to read %zu, got %lu", msg.in_size[i], bytes_read);
}
read_ptr += bytes_read;
@ -110,7 +110,7 @@ void part1_main(void *ptr)
break;
}
default:
SPM_PANIC("Unexpected message type %d!", (int)(msg.type));
SPM_PANIC("Unexpected message type %lu!", msg.type);
break;
}

View File

@ -101,11 +101,11 @@ void psa_hndl_mgr_handle_destroy(psa_handle_manager_t *handle_mgr, psa_handle_t
// Get the handle's index in the handles pool
uint32_t pool_ix = ((handle >> PSA_HANDLE_MGR_HANDLE_INDEX_POS) & PSA_HANDLE_MGR_HANDLE_INDEX_MSK);
if (pool_ix >= handle_mgr->pool_size) {
SPM_PANIC("[ERROR] Handle's index [%d] is bigger than handles pool size [%d]! \n", (int)pool_ix, (int)(handle_mgr->pool_size));
SPM_PANIC("[ERROR] Handle's index [%lu] is bigger than handles pool size [%hu]! \n", pool_ix, handle_mgr->pool_size);
}
if (handle_mgr->handles_pool[pool_ix].handle != handle) {
SPM_PANIC("[ERROR] Handle %d is not found in expected index! \n", (int)handle);
SPM_PANIC("[ERROR] Handle %ld is not found in expected index! \n", handle);
}
// Get active partition id - Needed for requester identification
@ -135,11 +135,11 @@ void *psa_hndl_mgr_handle_get_mem(psa_handle_manager_t *handle_mgr, psa_handle_t
// Get the handle's index in the handles pool
uint32_t pool_ix = ((handle >> PSA_HANDLE_MGR_HANDLE_INDEX_POS) & PSA_HANDLE_MGR_HANDLE_INDEX_MSK);
if (pool_ix >= handle_mgr->pool_size) {
SPM_PANIC("[ERROR] Handle's index [%d] is bigger than handles pool size [%d]! \n", (int)pool_ix, (int)(handle_mgr->pool_size));
SPM_PANIC("[ERROR] Handle's index [%lu] is bigger than handles pool size [%hu]! \n", pool_ix, handle_mgr->pool_size);
}
if (handle_mgr->handles_pool[pool_ix].handle != handle) {
SPM_PANIC("[ERROR] Handle %d is not found in expected index! \n", (int)handle);
SPM_PANIC("[ERROR] Handle %ld is not found in expected index! \n", handle);
}
// Get active partition id - Needed for requester identification

View File

@ -53,12 +53,12 @@ static inline spm_rot_service_t *rot_service_get(uint32_t sid)
static inline void spm_validate_connection_allowed(spm_rot_service_t *target, spm_partition_t *source)
{
if ((NULL == source) && (false == target->allow_nspe)) {
SPM_PANIC("SID 0x%x is not allowed to be called from NSPE\n", target->sid);
SPM_PANIC("SID 0x%lx is not allowed to be called from NSPE\n", target->sid);
}
if (NULL != source) {
if (NULL == source->extern_sids) {
SPM_PANIC("Partition %d did not declare extern functions\n", source->partition_id);
SPM_PANIC("Partition %ld did not declare extern functions\n", source->partition_id);
}
for (uint32_t i = 0; i < source->extern_sids_count; i++) {
@ -67,7 +67,7 @@ static inline void spm_validate_connection_allowed(spm_rot_service_t *target, sp
}
}
SPM_PANIC("SID 0x%x is not in partition %d extern functions list\n", target->sid, source->partition_id);
SPM_PANIC("SID 0x%lx is not in partition %ld extern functions list\n", target->sid, source->partition_id);
}
}
@ -113,12 +113,12 @@ void psa_connect_async(uint32_t sid, spm_pending_connect_msg_t *msg)
spm_rot_service_t *dst_rot_service = rot_service_get(sid);
if (NULL == dst_rot_service) {
SPM_PANIC("SID 0x%x is invalid!\n", sid);
SPM_PANIC("SID 0x%lx is invalid!\n", sid);
}
if (((dst_rot_service->min_version_policy == PSA_MINOR_VERSION_POLICY_RELAXED) && (msg->min_version > dst_rot_service->min_version)) ||
((dst_rot_service->min_version_policy == PSA_MINOR_VERSION_POLICY_STRICT) && (msg->min_version != dst_rot_service->min_version))) {
SPM_PANIC("minor version %d does not comply with sid %d minor version %d and minor policy %d",
SPM_PANIC("minor version %lu does not comply with sid %lu minor version %lu and minor policy %lu",
msg->min_version, dst_rot_service->sid, dst_rot_service->min_version, dst_rot_service->min_version_policy);
}

View File

@ -35,7 +35,7 @@ inline void validate_iovec(
(in_len + out_len <= PSA_MAX_IOVEC)
)
) {
SPM_PANIC("Failed iovec Validation invec=(0X%p) inlen=(%d) outvec=(0X%p) outlen=(%d)\n", in_vec, in_len, out_vec, out_len);
SPM_PANIC("Failed iovec Validation invec=(0X%p) inlen=(%lu) outvec=(0X%p) outlen=(%lu)\n", in_vec, in_len, out_vec, out_len);
}
}
@ -43,7 +43,7 @@ inline void channel_state_switch(uint8_t *current_state, uint8_t expected_state,
{
uint8_t actual_state = expected_state;
if (!core_util_atomic_cas_u8(current_state, &actual_state, new_state)) {
SPM_PANIC("channel in incorrect processing state: %d while %d is expected!\n",
SPM_PANIC("channel in incorrect processing state: %hhu while %hhu is expected!\n",
actual_state, expected_state);
}
}
@ -52,7 +52,7 @@ inline void channel_state_assert(const uint8_t *current_state, uint8_t expected_
{
uint8_t actual_state = core_util_atomic_load_u8(current_state);
if (actual_state != expected_state) {
SPM_PANIC("channel in incorrect processing state: %d while %d is expected!\n",
SPM_PANIC("channel in incorrect processing state: %hhu while %hhu is expected!\n",
actual_state, expected_state);
}
}

View File

@ -121,7 +121,7 @@ static void copy_message_to_spm(spm_ipc_channel_t *channel, psa_msg_t *user_msg)
temp_active_message.iovecs[i].in.base,
temp_active_message.iovecs[i].in.len,
channel->src_partition)) {
SPM_PANIC("in_vec[%d] is inaccessible\n", i);
SPM_PANIC("in_vec[%ld] is inaccessible\n", i);
}
}
}
@ -145,7 +145,7 @@ static void copy_message_to_spm(spm_ipc_channel_t *channel, psa_msg_t *user_msg)
temp_active_message.iovecs[temp_invec_size + i].out.base,
temp_active_message.iovecs[temp_invec_size + i].out.len,
channel->src_partition)) {
SPM_PANIC("out_vec[%d] is inaccessible\n", i);
SPM_PANIC("out_vec[%lu] is inaccessible\n", i);
}
}
}
@ -215,16 +215,16 @@ psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout)
signal_mask = flags_all;
} else {
if ((~flags_all) & signal_mask) {
SPM_PANIC("signal mask 0x%x must have only bits from 0x%x!\n",
SPM_PANIC("signal mask 0x%lx must have only bits from 0x%lx!\n",
signal_mask, flags_all);
}
}
psa_signal_t asserted_signals = osThreadFlagsWait(
signal_mask,
osFlagsWaitAny | osFlagsNoClear,
(PSA_BLOCK & timeout) ? osWaitForever : 0
);
signal_mask,
osFlagsWaitAny | osFlagsNoClear,
(PSA_BLOCK & timeout) ? osWaitForever : 0
);
// Asserted_signals must be a subset of the supported ROT_SRV and interrupt signals.
SPM_ASSERT((asserted_signals == (asserted_signals & flags_all)) ||
@ -248,7 +248,7 @@ void psa_get(psa_signal_t signum, psa_msg_t *msg)
bool is_one_bit = ((signum != 0) && !(signum & (signum - 1)));
if (!is_one_bit || !(signum & curr_partition->flags)) {
SPM_PANIC(
"signum 0x%x must have only 1 bit ON and must be a subset of 0x%x!\n",
"signum 0x%lx must have only 1 bit ON and must be a subset of 0x%lx!\n",
signum,
curr_partition->flags
);
@ -261,7 +261,7 @@ void psa_get(psa_signal_t signum, psa_msg_t *msg)
spm_rot_service_t *curr_rot_service = get_rot_service(curr_partition, signum);
if (curr_rot_service == NULL) {
SPM_PANIC("Received signal (0x%08x) that does not match any root of trust service", signum);
SPM_PANIC("Received signal (0x%08lx) that does not match any root of trust service", signum);
}
spm_ipc_channel_t *curr_channel = spm_rot_service_queue_dequeue(curr_rot_service);
@ -289,7 +289,7 @@ void psa_get(psa_signal_t signum, psa_msg_t *msg)
break;
}
default:
SPM_PANIC("psa_get - unexpected message type=0x%08X", curr_channel->msg_type);
SPM_PANIC("psa_get - unexpected message type=0x%08hhX", curr_channel->msg_type);
break;
}
@ -368,7 +368,7 @@ void psa_write(psa_handle_t msg_handle, uint32_t outvec_idx, const void *buffer,
psa_outvec *active_iovec = &active_msg->iovecs[outvec_idx].out;
if (num_bytes > active_iovec->len) {
SPM_PANIC("Invalid write operation (Requested %d, Avialable %d)\n", num_bytes, active_iovec->len);
SPM_PANIC("Invalid write operation (Requested %zu, Avialable %zu)\n", num_bytes, active_iovec->len);
}
memcpy((uint8_t *)(active_iovec->base), buffer, num_bytes);
@ -402,7 +402,7 @@ void psa_reply(psa_handle_t msg_handle, psa_status_t status)
switch (active_channel->msg_type) {
case PSA_IPC_CONNECT: {
if ((status != PSA_SUCCESS) && (status != PSA_CONNECTION_REFUSED)) {
SPM_PANIC("status (0X%08x) is not allowed for PSA_IPC_CONNECT", status);
SPM_PANIC("status (0X%08lx) is not allowed for PSA_IPC_CONNECT", status);
}
spm_pending_connect_msg_t *connect_msg_data = (spm_pending_connect_msg_t *)(active_channel->msg_ptr);
@ -435,7 +435,7 @@ void psa_reply(psa_handle_t msg_handle, psa_status_t status)
}
case PSA_IPC_CALL: {
if ((status >= PSA_RESERVED_ERROR_MIN) && (status <= PSA_RESERVED_ERROR_MAX)) {
SPM_PANIC("status (0X%08x) is not allowed for PSA_IPC_CALL", status);
SPM_PANIC("status (0X%08lx) is not allowed for PSA_IPC_CALL", status);
}
channel_state_switch(&active_channel->state,
@ -476,7 +476,7 @@ void psa_reply(psa_handle_t msg_handle, psa_status_t status)
// Note: The status code is ignored for PSA_IPC_DISCONNECT message type
}
default:
SPM_PANIC("psa_reply() - Unexpected message type=0x%08X", active_channel->msg_type);
SPM_PANIC("psa_reply() - Unexpected message type=0x%08hhX", active_channel->msg_type);
break;
}
@ -500,7 +500,7 @@ void psa_notify(int32_t partition_id)
{
spm_partition_t *target_partition = get_partition_by_pid(partition_id);
if (NULL == target_partition) {
SPM_PANIC("Could not find partition (partition_id = %d)\n",
SPM_PANIC("Could not find partition (partition_id = %ld)\n",
partition_id
);
}
@ -541,12 +541,12 @@ void psa_eoi(uint32_t irq_signal)
}
if (0 == (curr_partition->flags & irq_signal)) {
SPM_PANIC("Signal %d not in irq range\n", irq_signal);
SPM_PANIC("Signal %lu not in irq range\n", irq_signal);
}
bool is_one_bit = ((irq_signal != 0) && !(irq_signal & (irq_signal - 1)));
if (!is_one_bit) {
SPM_PANIC("signal 0x%x must have only 1 bit ON!\n", irq_signal);
SPM_PANIC("signal 0x%lx must have only 1 bit ON!\n", irq_signal);
}
IRQn_Type irq_line = curr_partition->irq_mapper(irq_signal);

View File

@ -28,7 +28,7 @@ uint32_t psa_security_lifecycle_state(void)
}
uint32_t lc_state = 0;
psa_outvec resp[1] = { &lc_state, sizeof(lc_state) };
psa_outvec resp[1] = { {&lc_state, sizeof(lc_state)} };
psa_status_t status = psa_call(conn, NULL, 0, resp, 1);
if (status == PSA_DROP_CONNECTION) {

View File

@ -78,7 +78,7 @@ static void message_handler(psa_msg_t *msg, SignalHandler handler)
break;
}
default: {
SPM_PANIC("Unexpected message type %d!", (int)(msg->type));
SPM_PANIC("Unexpected message type %lu!", msg->type);
break;
}
}

View File

@ -165,7 +165,7 @@ static void message_handler(psa_msg_t *msg, SignalHandler handler)
break;
}
default: {
SPM_PANIC("Unexpected message type %d!", (int)(msg->type));
SPM_PANIC("Unexpected message type %lu!", msg->type);
break;
}
}

View File

@ -111,7 +111,7 @@ IRQn_Type spm_{{partition.name|lower}}_signal_to_irq_mapper(uint32_t signal)
break;
}
SPM_PANIC("Unknown signal number %d", signal);
SPM_PANIC("Unknown signal number %lu", signal);
return 0;
}
{% endif %}