-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Robbie VanVossen <[email protected]>
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include <autoconf.h> | ||
#include <assert.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <sel4/sel4.h> | ||
#include <sel4utils/arch/util.h> | ||
|
||
#include <vka/object.h> | ||
#include <vka/capops.h> | ||
|
||
#include "../test.h" | ||
#include "../helpers.h" | ||
|
||
#ifdef CONFIG_ALLOW_SMC_CALLS | ||
|
||
#define ARM_STD_SVC_VERSION 0x8400ff03 | ||
#define UNASSIGNED_SMC 0x82000000 | ||
|
||
static int test_smc_calls(env_t env) | ||
{ | ||
seL4_ARM_SMCContext smc_args; | ||
seL4_ARM_SMCContext smc_results; | ||
int error; | ||
|
||
seL4_CPtr smc_cap = env->smc; | ||
seL4_CPtr badged_smc_cap = get_free_slot(env); | ||
|
||
error = cnode_mint(env, smc_cap, badged_smc_cap, seL4_AllRights, ARM_STD_SVC_VERSION); | ||
test_error_eq(error, seL4_NoError); | ||
|
||
/* Set function and arguments */ | ||
smc_args.x0 = ARM_STD_SVC_VERSION; | ||
smc_args.x1 = 0; | ||
smc_args.x2 = 0; | ||
smc_args.x3 = 0; | ||
smc_args.x4 = 0; | ||
smc_args.x5 = 0; | ||
smc_args.x6 = 0; | ||
smc_args.x7 = 0; | ||
|
||
/* This should succeed */ | ||
error = seL4_ARM_SMC_Call(badged_smc_cap, &smc_args, &smc_results); | ||
test_error_eq(error, seL4_NoError); | ||
|
||
test_eq(smc_results.x0, 0UL); | ||
test_eq(smc_results.x1, 1UL); | ||
test_eq(smc_results.x2, 0UL); | ||
test_eq(smc_results.x3, 0UL); | ||
|
||
/* This should fail - SMC call with a different function id from badge */ | ||
smc_args.x0 = UNASSIGNED_SMC; | ||
error = seL4_ARM_SMC_Call(badged_smc_cap, &smc_args, &smc_results); | ||
test_error_eq(error, seL4_IllegalOperation); | ||
|
||
/* This should fail - can't mint from cap with non-zero badge */ | ||
seL4_CPtr bad_badged_cap = get_free_slot(env); | ||
error = cnode_mint(env, badged_smc_cap, bad_badged_cap, seL4_AllRights, UNASSIGNED_SMC); | ||
test_error_eq(error, seL4_IllegalOperation); | ||
|
||
return sel4test_get_result(); | ||
} | ||
DEFINE_TEST(SMC0001, "Test SMC calls", test_smc_calls, true) | ||
|
||
#endif |