Exemple #1
0
int
main(void)
{
	struct epoll_event *const ev = tail_alloc(sizeof(*ev));
	ev->events = EPOLLIN;

	long rc = invoke_syscall(-1U, EPOLL_CTL_ADD, -2U, ev);
	printf("epoll_ctl(-1, EPOLL_CTL_ADD, -2, {EPOLLIN,"
	       " {u32=%u, u64=%" PRIu64 "}}) = %ld %s (%m)\n",
	       ev->data.u32, ev->data.u64, rc, errno2name());

	rc = invoke_syscall(-3U, EPOLL_CTL_DEL, -4U, ev);
	printf("epoll_ctl(-3, EPOLL_CTL_DEL, -4, %p) = %ld %s (%m)\n",
	       ev, rc, errno2name());

	rc = invoke_syscall(-1UL, EPOLL_CTL_MOD, -16UL, 0);
	printf("epoll_ctl(-1, EPOLL_CTL_MOD, -16, NULL) = %ld %s (%m)\n",
	       rc, errno2name());

	puts("+++ exited with 0 +++");
	return 0;
}
Exemple #2
0
void mbox_send(mbox_t mbox, void *msg, int nbytes)
{
  invoke_syscall(SYSCALL_MBOX_SEND, (int)mbox, (int)msg, nbytes);
}
Exemple #3
0
void mbox_close(mbox_t mbox)
{
  invoke_syscall(SYSCALL_MBOX_CLOSE, (int)mbox, IGNORE, IGNORE);
}
Exemple #4
0
mbox_t mbox_open(const char *name)
{
  return (mbox_t) invoke_syscall(SYSCALL_MBOX_OPEN, (int)name, IGNORE, IGNORE);
}
Exemple #5
0
int wait(pid_t pid)
{
  return invoke_syscall(SYSCALL_WAIT, (int)pid, IGNORE, IGNORE);
}
Exemple #6
0
int kill(pid_t pid)
{
  return invoke_syscall(SYSCALL_KILL, (int)pid, IGNORE, IGNORE);
}
Exemple #7
0
pid_t spawn(const char *filename)
{
  return (pid_t) invoke_syscall(SYSCALL_SPAWN, (int)filename, IGNORE, IGNORE);
}
Exemple #8
0
void yield(void)
{
    invoke_syscall(SYSCALL_YIELD, IGNORE, IGNORE, IGNORE);
}
Exemple #9
0
void write_serial(char c)
{
    invoke_syscall(SYSCALL_WRITE_SERIAL, (int)c, IGNORE, IGNORE);
}
Exemple #10
0
void shutdown(void)
{
    invoke_syscall(SYSCALL_SHUTDOWN, IGNORE, IGNORE, IGNORE);
}
Exemple #11
0
void sleep(int milliseconds)
{
    invoke_syscall(SYSCALL_SLEEP, milliseconds, IGNORE, IGNORE);
}
Exemple #12
0
void setpriority(int p)
{
    invoke_syscall(SYSCALL_SETPRIORITY, p, IGNORE, IGNORE);
}
Exemple #13
0
int getpriority(void)
{
    return invoke_syscall(SYSCALL_GETPRIORITY, IGNORE, IGNORE, IGNORE);
}
Exemple #14
0
int getpid(void)
{
    return invoke_syscall(SYSCALL_GETPID, IGNORE, IGNORE, IGNORE);
}
Exemple #15
0
void exit(void)
{
    invoke_syscall(SYSCALL_EXIT, IGNORE, IGNORE, IGNORE);
}
Exemple #16
0
/*
 * Sample sandboxed code.  Calculate an MD5 checksum of the data arriving via
 * c3, and place the checksum in c4.  a0 will hold input data length.  a1
 * indicates whether we should try a system call (abort()).  c4 must be (at
 * least) 33 bytes.
 */
int
invoke(register_t op, size_t len, struct cheri_object system_object,
    __capability char *data_input, __capability char *data_output,
    struct cheri_object fd_object)
{
	int i = 0;
	volatile int *ip = &i;

	cheri_system_setup(system_object);

	switch (op) {
	case CHERITEST_HELPER_OP_MD5:
		return (invoke_md5(len, data_input, data_output));

	case CHERITEST_HELPER_OP_ABORT:
		abort();

	case CHERITEST_HELPER_OP_SPIN:
		while (1);

	case CHERITEST_HELPER_OP_CP2_BOUND:
	case CHERITEST_HELPER_OP_CP2_PERM:
	case CHERITEST_HELPER_OP_CP2_TAG:
	case CHERITEST_HELPER_OP_CP2_SEAL:
		return (invoke_cap_fault(op));

	case CHERITEST_HELPER_OP_VM_RFAULT:
	case CHERITEST_HELPER_OP_VM_WFAULT:
	case CHERITEST_HELPER_OP_VM_XFAULT:
		return (invoke_vm_fault(op));

	case CHERITEST_HELPER_OP_SYSCALL:
		return (invoke_syscall());

	case CHERITEST_HELPER_OP_DIVZERO:
		return (1/(*ip));

	case CHERITEST_HELPER_OP_SYSCAP:
		return (invoke_syscap(system_object));

	case CHERITEST_HELPER_OP_CS_HELLOWORLD:
		return (cheri_system_helloworld());

	case CHERITEST_HELPER_OP_CS_PUTS:
		return (cheri_system_puts(
		    (__capability char *)"sandbox cs_puts\n"));

	case CHERITEST_HELPER_OP_CS_PUTCHAR:
		return (cheri_system_putchar('C'));	/* Is for cookie. */

	case CHERITEST_HELPER_OP_PRINTF:
		return (printf("%s: printf in sandbox test\n", __func__));

	case CHERITEST_HELPER_OP_MALLOC:
		return (invoke_malloc());

	case CHERITEST_HELPER_OP_FD_FSTAT_C:
		return (invoke_fd_fstat_c(fd_object));

	case CHERITEST_HELPER_OP_FD_LSEEK_C:
		return (invoke_fd_lseek_c(fd_object));

	case CHERITEST_HELPER_OP_FD_READ_C:
		return (invoke_fd_read_c(fd_object));

	case CHERITEST_HELPER_OP_FD_WRITE_C:
		return (invoke_fd_write_c(fd_object));

	}
	return (-1);
}
Exemple #17
0
char get_char(void)
{
  return (char) invoke_syscall(SYSCALL_GET_CHAR, IGNORE, IGNORE, IGNORE);
}
Exemple #18
0
void mbox_recv(mbox_t mbox, void *msg, int nbytes)
{
  invoke_syscall(SYSCALL_MBOX_RECV, (int) mbox, (int)msg, nbytes);
}