diff options
author | Vikram Kanigiri <vikram.kanigiri@arm.com> | 2015-01-08 17:07:25 +0000 |
---|---|---|
committer | Vikram Kanigiri <vikram.kanigiri@arm.com> | 2015-01-15 15:33:49 +0000 |
commit | 4a78dc6c2a1d60498ca37691e6424768989f5fb7 (patch) | |
tree | e8155de9a089fb378502932487004093356464a6 /tests/runtime_services | |
parent | 29bf4a147f95f9f4273b9fef9a96f1471b995bde (diff) |
Rework and enable TSP interrupt tests.
This patch reworks and enables tests to verify TSP interrupt handling
mechanisms with various scenarios.
Change-Id: Ieeb892d557cd866ff432f12db449481377c21ac4
Diffstat (limited to 'tests/runtime_services')
-rw-r--r-- | tests/runtime_services/trusted_os/tsp/test_normal_int_switch.c | 372 |
1 files changed, 244 insertions, 128 deletions
diff --git a/tests/runtime_services/trusted_os/tsp/test_normal_int_switch.c b/tests/runtime_services/trusted_os/tsp/test_normal_int_switch.c index eae8a4e..849ccad 100644 --- a/tests/runtime_services/trusted_os/tsp/test_normal_int_switch.c +++ b/tests/runtime_services/trusted_os/tsp/test_normal_int_switch.c @@ -30,6 +30,8 @@ #include <arch_helpers.h> #include <assert.h> +#include <gic_v2.h> +#include <irq.h> #include <mmio.h> #include <platform.h> #include <platform_def.h> @@ -38,138 +40,171 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <tests_api.h> +#include <systimer.h> +#include <trusted_os.h> +#include <tftf.h> #include <tsp.h> +#include <uuid_utils.h> #define STRESS_COUNT 100 #define MAX_IRQ_FIRED 10 #define TIMER_INT_CAP 10 /* we cap the timer duration to 10 ms */ -extern int tftf_systimer_handler(void *data); - /* * The shared data between the handler and the * preempt_tsp_via_IRQ routine. - * TODO check if barriers are needed if the handler - * and the preempt_tsp_via_IRQ are running on - * different CPUs. */ typedef struct { smc64_ret_values tsp_result; - int sys_irq_num; + int fired_irq_count; int loop_abort; int wait_for_fiq; } irq_handler_shared_data; static irq_handler_shared_data shared_data; +/* Programs ARM Generic Per CPU NS Physical timer interrupt */ +static void tftf_ppi_timer_fire_in(uint64_t time_ms) +{ + uint64_t cval; + uint32_t ctl = 0; + + cval = read_cntpct_el0() + ((read_cntfrq_el0() * time_ms) / 1000); + write_cntp_cval_el0(cval); + + /* + * Reads of CNTPCT can occur speculatively and out of order relative + * to other instructions executed on the same PE. Add an instruction + * synchronisation barrier to ensure that the counter value is + * programmed before the counter is enabled. + */ + isb(); + + /* Enable the non-secure physical timer */ + set_cntp_ctl_enable(ctl); + write_cntp_ctl_el0(ctl); + isb(); +} + /* - * The custom handler for the systimer interrupt. The - * tsp_result is checked to confirm that the TSP has been - * preempted and to decide whether to fire the systimer - * again or not. + * Handler for the ARM Generic Per CPU NS Physical timer interrupt. + * Verifies if the TSP has been pre-empted and if not it reprograms + * the PPI NS Physical timer. + * The handler aborts if the TSP is not pre-empted in MAX_IRQ_FIRED + * times. */ -static int tftf_int_test_systimer_handler(void *data) +static int arm_generic_ppi_timer_handler(void *data) { - uint32_t val; - -#ifndef NDEBUG /* Ensure this is the irq we expect */ - unsigned int irq_id = *(unsigned int *)data; - assert(irq_id == IRQ_CNTPSIRQ1); -#endif - shared_data.sys_irq_num++; - /* Deassert the timer interrupt */ - val = mmio_read_32(SYS_CNT_BASE1 + CNTP_CTL); - set_cntp_ctl_imask(val); - mmio_write_32(SYS_CNT_BASE1 + CNTP_CTL, val); + assert(*(unsigned int *)data == IRQ_PCPU_NS_TIMER); + + shared_data.fired_irq_count++; + + assert(get_cntp_ctl_istatus(read_cntp_ctl_el0())); /* Disable the timer */ - val = 0; - set_cntp_ctl_imask(val); - mmio_write_32(SYS_CNT_BASE1 + CNTP_CTL, val); + write_cntp_ctl_el0(0); + isb(); if (shared_data.tsp_result.ret0 != TSP_SMC_PREEMPTED) { - if (shared_data.sys_irq_num >= MAX_IRQ_FIRED) { + if (shared_data.fired_irq_count >= MAX_IRQ_FIRED) { shared_data.loop_abort = 1; } else { if (shared_data.wait_for_fiq) wfi(); /* We will get woken by the FIQ firing */ + /* Fire the timer at random time */ - tftf_systimer_fire_in( + tftf_ppi_timer_fire_in( (uint64_t)(rand() % TIMER_INT_CAP)); } } + return 0; } - /* - * This routine configures the systimer to issue and interrupt and - * ensures that the secure world has preempted during STD SMC handling. - * The systimer interrupt handler is redefined here for more control and - * and specifying a terminating conditionn for the loop. + * This routine configures the ARM Generic PPI NS Physical timer to issue + * an interrupt which ensures that the secure world has preempted during + * Standard SMC handling. */ -TEST_RESULT preempt_tsp_via_IRQ(const smc64_args *tsp_svc_params, +static TEST_RESULT preempt_tsp_via_IRQ(const smc64_args *tsp_svc_params, int hold_irq_handler_for_fiq) { - int rc = 0; - char msg[100]; + int rc; memset(&shared_data, 0, sizeof(shared_data)); if (hold_irq_handler_for_fiq) shared_data.wait_for_fiq = 1; - /* We register a custom systimer handler for the test */ - rc = tftf_irq_register(IRQ_CNTPSIRQ1, tftf_int_test_systimer_handler); - if (rc != 0) - return TEST_RESULT_FAIL; + /* Register Handler for the interrupt */ + rc = tftf_irq_register_handler(IRQ_PCPU_NS_TIMER, + arm_generic_ppi_timer_handler); + if (rc != 0) { + tftf_testcase_printf("Failed to register IRQ handler\n"); + return TEST_RESULT_SKIPPED; + } + + /* Enable ARM Generic PPI Timer interrupt */ + tftf_irq_enable(IRQ_PCPU_NS_TIMER, GIC_HIGHEST_NS_PRIORITY); /* Fire the timer in rand() time capped at TIMER_INT_CAP ms*/ - tftf_systimer_fire_in((uint64_t)(rand() % TIMER_INT_CAP)); + tftf_ppi_timer_fire_in((uint64_t)(rand() % TIMER_INT_CAP)); do { shared_data.tsp_result = tftf_smc64(tsp_svc_params); /* Check if we have been preempted */ - } while ((shared_data.tsp_result.ret0 != TSP_SMC_PREEMPTED) && + } while ((shared_data.tsp_result.ret0 != TSP_SMC_PREEMPTED) && !shared_data.loop_abort); /* Wait for pending interrupt to fire */ wfi(); + pr_debug("IRQ fired for %d times\n", shared_data.fired_irq_count); - snprintf(msg, sizeof(msg), "IRQ fired for %d times\n", - shared_data.sys_irq_num); - tftf_testcase_output(msg); + /* Disable ARM Generic PPI timer interrupt */ + tftf_irq_disable(IRQ_PCPU_NS_TIMER); - /* Revert to the default systimer handler */ - rc = tftf_irq_register(IRQ_CNTPSIRQ1, tftf_systimer_handler); + /* Unregister handler */ + rc = tftf_irq_unregister_handler(IRQ_PCPU_NS_TIMER); if (rc != 0) - return TEST_RESULT_FAIL; + tftf_testcase_printf("Failed to unregister IRQ handler\n"); - if ((shared_data.tsp_result.ret0 != TSP_SMC_PREEMPTED) || - shared_data.loop_abort) + if (shared_data.loop_abort) { + tftf_testcase_printf("Failed to Interrupt TSP\n"); return TEST_RESULT_FAIL; - else { - tftf_testcase_output("Successfully preempted secure world\n"); + } else { return TEST_RESULT_SUCCESS; } } /* * @TestAim@ Test the secure world preemption by non secure interrupt. - * Steps: 1. Issue and STD SMC and try preempting it via IRQ - * 2. Resume the preempted SMC + * + * Steps: 1. Issue Standard SMC and try preempting it via IRQ + * 2. Resume the preempted SMC + * Returns SUCCESS if above 2 steps are performed correctly else failure. */ TEST_RESULT tsp_int_and_resume(void) { smc64_args tsp_svc_params; smc64_ret_values tsp_result = {0}; TEST_RESULT res; - tftf_testcase_output("Interrupt test - TSP is interrupted" - "and resumed\n"); + uuid_t tos_uuid; + char tos_uuid_str[UUID_STR_SIZE]; + + if (!is_trusted_os_present(&tos_uuid)) { + tftf_testcase_printf("No Trusted OS detected\n"); + return TEST_RESULT_SKIPPED; + } - /* STD SMC */ + if (!uuid_equal(&tos_uuid, &tsp_uuid)) { + tftf_testcase_printf("Trusted OS is not the TSP, its UUID" + " is: %s\n", uuid_to_str(&tos_uuid, + tos_uuid_str)); + return TEST_RESULT_SKIPPED; + } + + /* Standard SMC */ tsp_svc_params.arg0 = TSP_STD_FID(TSP_ADD); tsp_svc_params.arg1 = 4; tsp_svc_params.arg2 = 6; @@ -184,11 +219,16 @@ TEST_RESULT tsp_int_and_resume(void) /* Check the result of the addition */ if (tsp_result.ret0 != 0 || tsp_result.ret1 != 8 || tsp_result.ret2 != 12) { - tftf_testcase_output("SMC resume returned wrong result\n"); + tftf_testcase_printf("SMC resume returned wrong result:" + "got %d %d %d expected: 0 8 12\n", + (unsigned int)tsp_result.ret0, + (unsigned int)tsp_result.ret1, + (unsigned int)tsp_result.ret2); + tftf_testcase_printf("SMC resume returned wrong result\n"); return TEST_RESULT_FAIL; } - /* STD SMC */ + /* Standard SMC */ tsp_svc_params.arg0 = TSP_STD_FID(TSP_SUB); tsp_svc_params.arg1 = 4; tsp_svc_params.arg2 = 6; @@ -203,11 +243,15 @@ TEST_RESULT tsp_int_and_resume(void) /* Check the result of the substraction */ if (tsp_result.ret0 != 0 || tsp_result.ret1 != 0 || tsp_result.ret2 != 0) { - tftf_testcase_output("SMC resume returned wrong result\n"); + tftf_testcase_printf("SMC resume returned wrong result:" + "got %d %d %d expected: 0 0 0\n", + (unsigned int)tsp_result.ret0, + (unsigned int)tsp_result.ret1, + (unsigned int)tsp_result.ret2); return TEST_RESULT_FAIL; } - /* STD SMC */ + /* Standard SMC */ tsp_svc_params.arg0 = TSP_STD_FID(TSP_MUL); tsp_svc_params.arg1 = 4; tsp_svc_params.arg2 = 6; @@ -222,11 +266,15 @@ TEST_RESULT tsp_int_and_resume(void) /* Check the result of the multiplication */ if (tsp_result.ret0 != 0 || tsp_result.ret1 != 16 || tsp_result.ret2 != 36) { - tftf_testcase_output("SMC resume returned wrong result\n"); + tftf_testcase_printf("SMC resume returned wrong result:" + "got %d %d %d expected: 0 16 36\n", + (unsigned int)tsp_result.ret0, + (unsigned int)tsp_result.ret1, + (unsigned int)tsp_result.ret2); return TEST_RESULT_FAIL; } - /* STD SMC */ + /* Standard SMC */ tsp_svc_params.arg0 = TSP_STD_FID(TSP_DIV); tsp_svc_params.arg1 = 4; tsp_svc_params.arg2 = 6; @@ -241,30 +289,46 @@ TEST_RESULT tsp_int_and_resume(void) /* Check the result of the division */ if (tsp_result.ret0 != 0 || tsp_result.ret1 != 1 || tsp_result.ret2 != 1) { - tftf_testcase_output("SMC resume returned wrong result\n"); + tftf_testcase_printf("SMC resume returned wrong result:" + "got %d %d %d expected: 0 1 1\n", + (unsigned int)tsp_result.ret0, + (unsigned int)tsp_result.ret1, + (unsigned int)tsp_result.ret2); return TEST_RESULT_FAIL; } return TEST_RESULT_SUCCESS; } - /* - * @TestAim@ Test the Fast SMC when tsp is pre-empted by interrupt. - * The Fast SMC should return error. - * Steps: 1. Issue and STD SMC and try preempting it via IRQ - * 2. Issue Fast SMC. this is not expected and TSP should return error. - * 3. Resume the preempted SMC + * @TestAim@ Verify Fast SMC request on an interrupted tsp returns error. + * + * Steps: 1. Issue Standard SMC and preempt it via IRQ + * 2. Issue Fast SMC, this is not expected and TSP should return error. + * 3. Resume the preempted SMC and verify the result. + * Returns SUCCESS if above 3 steps are performed correctly else failure. */ TEST_RESULT test_fast_smc_when_tsp_preempted(void) { smc64_args tsp_svc_params; smc64_ret_values tsp_result = {0}; TEST_RESULT res = TEST_RESULT_SUCCESS; - tftf_testcase_output("Interrupt test - TSP is interrupted" - "and Fast SMC is issued\n"); + uuid_t tos_uuid; + char tos_uuid_str[UUID_STR_SIZE]; + + if (!is_trusted_os_present(&tos_uuid)) { + tftf_testcase_printf("No Trusted OS detected\n"); + return TEST_RESULT_SKIPPED; + } + + if (!uuid_equal(&tos_uuid, &tsp_uuid)) { + tftf_testcase_printf("Trusted OS is not the TSP, its UUID" + " is: %s\n", uuid_to_str(&tos_uuid, + tos_uuid_str)); + return TEST_RESULT_SKIPPED; + } - /* STD SMC */ + /* Standard SMC */ tsp_svc_params.arg0 = TSP_STD_FID(TSP_ADD); tsp_svc_params.arg1 = 4; tsp_svc_params.arg2 = 6; @@ -280,7 +344,7 @@ TEST_RESULT test_fast_smc_when_tsp_preempted(void) tsp_result = tftf_smc64(&tsp_svc_params); if (tsp_result.ret0 != SMC_UNKNOWN) { - tftf_testcase_output("Fast SMC should not execute" + tftf_testcase_printf("Fast SMC should not execute" "while SMC is preempted\n"); res = TEST_RESULT_FAIL; } @@ -292,7 +356,12 @@ TEST_RESULT test_fast_smc_when_tsp_preempted(void) /* Check the result of the addition */ if (tsp_result.ret0 != 0 || tsp_result.ret1 != 8 || tsp_result.ret2 != 12) { - tftf_testcase_output("SMC did not resume OK\n"); + tftf_testcase_printf("SMC resume returned wrong result:" + "got %d %d %d expected: 0 8 12\n", + (unsigned int)tsp_result.ret0, + (unsigned int)tsp_result.ret1, + (unsigned int)tsp_result.ret2); + res = TEST_RESULT_FAIL; } @@ -300,21 +369,35 @@ TEST_RESULT test_fast_smc_when_tsp_preempted(void) } /* - * @TestAim@ Test the STD SMC when tsp is pre-empted by interrupt. - * The STD SMC should return error. - * Steps: 1. Issue and STD SMC and try preempting it via IRQ - * 2. Issue another STD SMC. this is not expected and TSP should return error. + * @TestAim@ Test the Standard SMC when tsp is pre-empted by interrupt. + * + * The Standard SMC should return error. + * Steps: 1. Issue and Standard SMC and try preempting it via IRQ + * 2. Issue another Standard SMC. this is not expected and TSP should return error. * 3. Resume the preempted SMC + * Returns SUCCESS if above 3 steps are performed correctly else failure. */ TEST_RESULT test_std_smc_when_tsp_preempted(void) { smc64_args tsp_svc_params; smc64_ret_values tsp_result = {0}; TEST_RESULT res = TEST_RESULT_SUCCESS; - tftf_testcase_output("Interrupt test - TSP is interrupted and" - "STD SMC is issued\n"); + uuid_t tos_uuid; + char tos_uuid_str[UUID_STR_SIZE]; + + if (!is_trusted_os_present(&tos_uuid)) { + tftf_testcase_printf("No Trusted OS detected\n"); + return TEST_RESULT_SKIPPED; + } - /* STD SMC */ + if (!uuid_equal(&tos_uuid, &tsp_uuid)) { + tftf_testcase_printf("Trusted OS is not the TSP, its UUID" + " is: %s\n", uuid_to_str(&tos_uuid, + tos_uuid_str)); + return TEST_RESULT_SKIPPED; + } + + /* Standard SMC */ tsp_svc_params.arg0 = TSP_STD_FID(TSP_ADD); tsp_svc_params.arg1 = 4; tsp_svc_params.arg2 = 6; @@ -322,7 +405,7 @@ TEST_RESULT test_std_smc_when_tsp_preempted(void) if (res == TEST_RESULT_FAIL) return res; - /* Now that we have ensured preemption, issue STD SMC */ + /* Now that we have ensured preemption, issue Standard SMC */ tsp_svc_params.arg0 = TSP_STD_FID(TSP_ADD); tsp_svc_params.arg1 = 4; tsp_svc_params.arg2 = 6; @@ -330,8 +413,8 @@ TEST_RESULT test_std_smc_when_tsp_preempted(void) tsp_result = tftf_smc64(&tsp_svc_params); if (tsp_result.ret0 != SMC_UNKNOWN) { - tftf_testcase_output("STD SMC should not execute" - "while SMC is preempted\n"); + tftf_testcase_printf("Standard SMC should not execute" + "while SMC is preempted\n"); res = TEST_RESULT_FAIL; } @@ -342,7 +425,11 @@ TEST_RESULT test_std_smc_when_tsp_preempted(void) /* Check the result of the addition */ if (tsp_result.ret0 != 0 || tsp_result.ret1 != 8 || tsp_result.ret2 != 12) { - tftf_testcase_output("SMC did not resume OK\n"); + tftf_testcase_printf("SMC resume returned wrong result:" + "got %d %d %d expected: 0 8 12\n", + (unsigned int)tsp_result.ret0, + (unsigned int)tsp_result.ret1, + (unsigned int)tsp_result.ret2); res = TEST_RESULT_FAIL; } @@ -350,71 +437,76 @@ TEST_RESULT test_std_smc_when_tsp_preempted(void) } /* - * @TestAim@ Test RESUME SMC call when TSP is not preempted. - * RESUME should fail. - * Steps: 1. Issue resume SMC. This is not expected by TSP and returns error. - * 2. Issue STD SMC and try preempting it via IRQ - * 3. Resume the preempted SMC + * @TestAim@ Test RESUME SMC call when TSP is not preempted. RESUME should fail. + * + * Issues resume SMC. This is not expected by TSP and returns error. + * This is a negative test, Return SUCCESS is RESUME returns SMC_UNKNOWN */ TEST_RESULT test_resume_smc_without_preemption(void) { smc64_args tsp_svc_params; smc64_ret_values tsp_result = {0}; - TEST_RESULT res = TEST_RESULT_SUCCESS; - tftf_testcase_output("Interrupt test - Resume SMC is issued" - "without TSP pre-emption\n"); - - /* Issue RESUME */ - tsp_svc_params.arg0 = TSP_FID_RESUME; - tsp_result = tftf_smc64(&tsp_svc_params); + uuid_t tos_uuid; + char tos_uuid_str[UUID_STR_SIZE]; - if (tsp_result.ret0 != SMC_UNKNOWN) { - tftf_testcase_output("SMC Resume should be Invalid\n"); - res = TEST_RESULT_FAIL; - return res; + if (!is_trusted_os_present(&tos_uuid)) { + tftf_testcase_printf("No Trusted OS detected\n"); + return TEST_RESULT_SKIPPED; } - /* STD SMC */ - tsp_svc_params.arg0 = TSP_STD_FID(TSP_ADD); - tsp_svc_params.arg1 = 4; - tsp_svc_params.arg2 = 6; - /* Try to preempt TSP via IRQ */ - res = preempt_tsp_via_IRQ(&tsp_svc_params, 0); - if (res == TEST_RESULT_FAIL) - return res; + if (!uuid_equal(&tos_uuid, &tsp_uuid)) { + tftf_testcase_printf("Trusted OS is not the TSP, its UUID" + " is: %s\n", uuid_to_str(&tos_uuid, + tos_uuid_str)); + return TEST_RESULT_SKIPPED; + } /* Issue RESUME */ tsp_svc_params.arg0 = TSP_FID_RESUME; tsp_result = tftf_smc64(&tsp_svc_params); - /* Check the result of the addition */ - if (tsp_result.ret0 != 0 || tsp_result.ret1 != 8 || - tsp_result.ret2 != 12) { - tftf_testcase_output("SMC did not resume OK\n"); - res = TEST_RESULT_FAIL; + if (tsp_result.ret0 != SMC_UNKNOWN) { + tftf_testcase_printf("SMC Resume should return UNKNOWN, got:%d\n", \ + (unsigned int)tsp_result.ret0); + return TEST_RESULT_FAIL; } - return res; + return TEST_RESULT_SUCCESS; } /* * @TestAim@ Stress Test the secure world preemption by non secure interrupt - * Steps: 1. Issue and STD SMC and try preempting it via IRQ + * + * Steps: 1. Issue a Standard SMC and try preempting it via IRQ * 2. Resume the preempted SMC and repeat from Step 1 for STRESS_COUNT times. + * Returns SUCCESS if above 2 steps are performed correctly else failure. */ TEST_RESULT tsp_int_and_resume_stress(void) { smc64_args tsp_svc_params; smc64_ret_values tsp_result = {0}; TEST_RESULT res = TEST_RESULT_SUCCESS; - tftf_testcase_output("Interrupt Stress test - test preemption" - "and resume\n"); + uuid_t tos_uuid; + char tos_uuid_str[UUID_STR_SIZE]; + + if (!is_trusted_os_present(&tos_uuid)) { + tftf_testcase_printf("No Trusted OS detected\n"); + return TEST_RESULT_SKIPPED; + } + + if (!uuid_equal(&tos_uuid, &tsp_uuid)) { + tftf_testcase_printf("Trusted OS is not the TSP, its UUID" + " is: %s\n", uuid_to_str(&tos_uuid, + tos_uuid_str)); + return TEST_RESULT_SKIPPED; + } + int count = 0; mp_printf("This stress test will repeat %d times\n", STRESS_COUNT); while ((count < STRESS_COUNT) && (res == TEST_RESULT_SUCCESS)) { - /* STD SMC */ + /* Standard SMC */ tsp_svc_params.arg0 = TSP_STD_FID(TSP_ADD); tsp_svc_params.arg1 = 4; tsp_svc_params.arg2 = 6; @@ -430,7 +522,11 @@ TEST_RESULT tsp_int_and_resume_stress(void) /* Check the result of the addition */ if (tsp_result.ret0 != 0 || tsp_result.ret1 != 8 || tsp_result.ret2 != 12) { - tftf_testcase_output("SMC did not resume OK\n"); + tftf_testcase_printf("SMC resume returned wrong result:" + "got %d %d %d expected: 0 8 12\n", + (unsigned int)tsp_result.ret0, + (unsigned int)tsp_result.ret1, + (unsigned int)tsp_result.ret2); res = TEST_RESULT_FAIL; } @@ -441,23 +537,39 @@ TEST_RESULT tsp_int_and_resume_stress(void) /* * @TestAim@ Test Secure FIQ when pre-empted by non secure interrupt. + * * We really cannot verify whether FIQ fired and preempted the IRQ handler - * or not. The TSP prints the address at which the exectuion was interrupted + * or not. The TSP prints the address at which the execution was interrupted * for the FIQ. By looking at the address printed from the TSP logs, we can - * verify that the IRQ handler was interrupted by FIQ. - * Steps: 1. Issue and STD SMC and try preempting it via IRQ + * verify that the IRQ handler was interrupted by FIQ. For now, We are assuming + * CPU is woken by Secure Timer Interrupt. + * + * Steps: 1. Issue a Standard SMC and try preempting it via IRQ * 2. Wait in the IRQ handler for FIQ which is firing every 500 ms. * 3. Resume the preempted SMC + * Returns SUCCESS if above 3 steps are performed correctly else failure. */ TEST_RESULT tsp_fiq_while_int(void) { smc64_args tsp_svc_params; smc64_ret_values tsp_result = {0}; TEST_RESULT res; - tftf_testcase_output("Interrupt test - Test FIQ when" - "TSP is interrupted\n"); + uuid_t tos_uuid; + char tos_uuid_str[UUID_STR_SIZE]; + + if (!is_trusted_os_present(&tos_uuid)) { + tftf_testcase_printf("No Trusted OS detected\n"); + return TEST_RESULT_SKIPPED; + } + + if (!uuid_equal(&tos_uuid, &tsp_uuid)) { + tftf_testcase_printf("Trusted OS is not the TSP, its UUID" + " is: %s\n", uuid_to_str(&tos_uuid, + tos_uuid_str)); + return TEST_RESULT_SKIPPED; + } - /* STD SMC */ + /* Standard SMC */ tsp_svc_params.arg0 = TSP_STD_FID(TSP_ADD); tsp_svc_params.arg1 = 4; tsp_svc_params.arg2 = 6; @@ -472,7 +584,11 @@ TEST_RESULT tsp_fiq_while_int(void) /* Check the result of the addition */ if (tsp_result.ret0 != 0 || tsp_result.ret1 != 8 || tsp_result.ret2 != 12) { - tftf_testcase_output("SMC resume returned wrong result\n"); + tftf_testcase_printf("SMC resume returned wrong result:" + "got %d %d %d expected: 0 8 12\n", + (unsigned int)tsp_result.ret0, + (unsigned int)tsp_result.ret1, + (unsigned int)tsp_result.ret2); return TEST_RESULT_FAIL; } return TEST_RESULT_SUCCESS; |