Trivial: Style fix
make the style checker happy
diff --git a/libsel4debug/CMakeLists.txt b/libsel4debug/CMakeLists.txt
index eee8665..fad98da 100644
--- a/libsel4debug/CMakeLists.txt
+++ b/libsel4debug/CMakeLists.txt
@@ -70,9 +70,6 @@
add_library(sel4debug STATIC EXCLUDE_FROM_ALL ${deps})
target_include_directories(
sel4debug
- PUBLIC
- include
- "arch_include/${KernelArch}"
- sel4_arch_include/${KernelSel4Arch}
+ PUBLIC include "arch_include/${KernelArch}" sel4_arch_include/${KernelSel4Arch}
)
target_link_libraries(sel4debug PUBLIC muslc sel4 utils PRIVATE sel4debug_Config kernel_autoconf)
diff --git a/libsel4debug/src/alloc.c b/libsel4debug/src/alloc.c
index 45561a8..2bd5e05 100644
--- a/libsel4debug/src/alloc.c
+++ b/libsel4debug/src/alloc.c
@@ -113,7 +113,7 @@
return ptr;
}
- metadata_t *pre = (metadata_t*)ptr;
+ metadata_t *pre = (metadata_t *)ptr;
ptr += sizeof(*pre);
unaligned_uintptr_t *post = ptr + size;
@@ -145,7 +145,7 @@
return ptr;
}
- metadata_t *pre = (metadata_t*)(ptr - sizeof(*pre));
+ metadata_t *pre = (metadata_t *)(ptr - sizeof(*pre));
unaligned_uintptr_t *post = ptr + pre->size;
/* Check the leading canary (underflow). */
@@ -165,7 +165,7 @@
"to %p)\n", ptr, ret_addr);
}
- return (void*)pre;
+ return (void *)pre;
}
/* Buffer for tracking currently live heap pointers. This is used to detect
@@ -251,9 +251,9 @@
* use-after-free bugs. If we fault while doing this, it probably means the
* user underran their buffer and overwrote the 'size' metadata.
*/
- metadata_t *pre = (metadata_t*)(ptr - sizeof(*pre));
+ metadata_t *pre = (metadata_t *)(ptr - sizeof(*pre));
for (unsigned int i = 0; i < pre->size; i++) {
- ((char*)ptr)[i] ^= (char)~i;
+ ((char *)ptr)[i] ^= (char)~i;
}
ptr = unbox(ptr, ret);
diff --git a/libsel4debug/src/backtrace.c b/libsel4debug/src/backtrace.c
index 4d695ae..1674f11 100644
--- a/libsel4debug/src/backtrace.c
+++ b/libsel4debug/src/backtrace.c
@@ -35,9 +35,10 @@
*/
#define BACKTRACE_BASE (((void*)seL4_GetIPCBuffer()) + sizeof(seL4_IPCBuffer))
-int backtrace(void **buffer, int size) {
- int *bt_stack_sz = (int*)BACKTRACE_BASE;
- void **bt_stack = (void**)(BACKTRACE_BASE + sizeof(int));
+int backtrace(void **buffer, int size)
+{
+ int *bt_stack_sz = (int *)BACKTRACE_BASE;
+ void **bt_stack = (void **)(BACKTRACE_BASE + sizeof(int));
/* Write as many entries as we can, starting from the top of the stack,
* into the caller's buffer.
@@ -52,26 +53,28 @@
#ifdef CONFIG_LIBSEL4DEBUG_FUNCTION_INSTRUMENTATION_BACKTRACE
-void __cyg_profile_func_enter(void *func, void *caller) {
+void __cyg_profile_func_enter(void *func, void *caller)
+{
if (seL4_GetIPCBuffer() == NULL) {
/* The caller doesn't have a valid IPC buffer. Assume it has not been
* setup yet and just skip logging the current function.
*/
return;
}
- int *bt_stack_sz = (int*)BACKTRACE_BASE;
- void **bt_stack = (void**)(BACKTRACE_BASE + sizeof(int));
+ int *bt_stack_sz = (int *)BACKTRACE_BASE;
+ void **bt_stack = (void **)(BACKTRACE_BASE + sizeof(int));
/* Push the current function */
bt_stack[*bt_stack_sz] = func;
*bt_stack_sz += 1;
}
-void __cyg_profile_func_exit(void *func, void *caller) {
+void __cyg_profile_func_exit(void *func, void *caller)
+{
if (seL4_GetIPCBuffer() == NULL) {
return;
}
- int *bt_stack_sz = (int*)BACKTRACE_BASE;
+ int *bt_stack_sz = (int *)BACKTRACE_BASE;
/* Pop the current function */
*bt_stack_sz -= 1;
diff --git a/libsel4debug/src/bootinfo.c b/libsel4debug/src/bootinfo.c
index 7503ea0..44e01f3 100644
--- a/libsel4debug/src/bootinfo.c
+++ b/libsel4debug/src/bootinfo.c
@@ -18,8 +18,7 @@
#include <sel4/sel4.h>
#include <utils/util.h>
-void
-debug_print_bootinfo(seL4_BootInfo *info)
+void debug_print_bootinfo(seL4_BootInfo *info)
{
printf("Node %lu of %lu\n", (long)info->nodeID, (long)info->numNodes);
@@ -41,7 +40,8 @@
int index = info->untypedList[i].sizeBits;
assert(index < ARRAY_SIZE(sizes));
sizes[index]++;
- printf("%p | %zu | %d\n", (void*)info->untypedList[i].paddr, (size_t)info->untypedList[i].sizeBits, (int)info->untypedList[i].isDevice);
+ printf("%p | %zu | %d\n", (void *)info->untypedList[i].paddr, (size_t)info->untypedList[i].sizeBits,
+ (int)info->untypedList[i].isDevice);
}
printf("Untyped summary\n");
diff --git a/libsel4debug/src/caps.c b/libsel4debug/src/caps.c
index 1a1eef7..49baa05 100644
--- a/libsel4debug/src/caps.c
+++ b/libsel4debug/src/caps.c
@@ -16,8 +16,7 @@
#include <sel4/sel4.h>
#include <stdio.h>
-void
-debug_cap_identify(seL4_CPtr cap)
+void debug_cap_identify(seL4_CPtr cap)
{
#ifdef CONFIG_DEBUG_BUILD
int type = seL4_DebugCapIdentify(cap);
diff --git a/libsel4muslcsys/include/arch_stdio.h b/libsel4muslcsys/include/arch_stdio.h
index 54a37bf..199c02a 100644
--- a/libsel4muslcsys/include/arch_stdio.h
+++ b/libsel4muslcsys/include/arch_stdio.h
@@ -34,7 +34,7 @@
/*
* Register a function to be called when sys_writev is called on either
* stdout or stderr. This will return the existing function that is registered.
- * Calling this function with NULL is valid and will result in no function being
+ * Calling this function with NULL is valid and will result in no function being
* called, but writev still returning the number of characters written. This is
* similar to piping to /dev/null.
*/
diff --git a/libsel4muslcsys/include/muslcsys/io.h b/libsel4muslcsys/include/muslcsys/io.h
index acbf542..2c9a73f 100644
--- a/libsel4muslcsys/include/muslcsys/io.h
+++ b/libsel4muslcsys/include/muslcsys/io.h
@@ -56,6 +56,6 @@
/* install a cpio interface to use with open */
typedef void *(*muslcsys_cpio_get_file_fn_t)(void *cpio_symbol, unsigned long len,
- const char *name, unsigned long *size);
+ const char *name, unsigned long *size);
void muslcsys_install_cpio_interface(void *cpio_symbol, unsigned long cpio_len,
- muslcsys_cpio_get_file_fn_t fn);
+ muslcsys_cpio_get_file_fn_t fn);
diff --git a/libsel4muslcsys/src/sys_exit.c b/libsel4muslcsys/src/sys_exit.c
index 101d4cb..258e22a 100644
--- a/libsel4muslcsys/src/sys_exit.c
+++ b/libsel4muslcsys/src/sys_exit.c
@@ -18,8 +18,7 @@
#include <stdarg.h>
#include <utils/util.h>
-static void
-sel4_abort(void)
+static void sel4_abort(void)
{
#if defined(CONFIG_DEBUG_BUILD) && defined(CONFIG_LIB_SEL4_MUSLC_SYS_DEBUG_HALT)
printf("seL4 root server abort()ed\n");
@@ -28,52 +27,45 @@
while (1); /* We don't return after this */
}
-long
-sys_exit(va_list ap)
+long sys_exit(va_list ap)
{
abort();
return 0;
}
-long
-sys_rt_sigprocmask(va_list ap)
+long sys_rt_sigprocmask(va_list ap)
{
ZF_LOGV("Ignoring call to %s", __FUNCTION__);
return 0;
}
-long
-sys_gettid(va_list ap)
+long sys_gettid(va_list ap)
{
ZF_LOGV("Ignoring call to %s", __FUNCTION__);
return 0;
}
-long
-sys_getpid(va_list ap)
+long sys_getpid(va_list ap)
{
ZF_LOGV("Ignoring call to %s", __FUNCTION__);
return 0;
}
-long
-sys_tgkill(va_list ap)
+long sys_tgkill(va_list ap)
{
ZF_LOGV("%s assuming self kill", __FUNCTION__);
sel4_abort();
return 0;
}
-long
-sys_tkill(va_list ap)
+long sys_tkill(va_list ap)
{
ZF_LOGV("%s assuming self kill", __FUNCTION__);
sel4_abort();
return 0;
}
-long
-sys_exit_group(va_list ap)
+long sys_exit_group(va_list ap)
{
ZF_LOGV("Ignoring call to %s", __FUNCTION__);
return 0;
diff --git a/libsel4muslcsys/src/sys_io.c b/libsel4muslcsys/src/sys_io.c
index ff1b138..bd94f4e 100644
--- a/libsel4muslcsys/src/sys_io.c
+++ b/libsel4muslcsys/src/sys_io.c
@@ -59,8 +59,7 @@
/* total number of fds */
static int num_fds = 256;
-void
-add_free_fd(int fd)
+void add_free_fd(int fd)
{
get_fd_struct(fd)->filetype = FILE_TYPE_FREE;
free_fd_table_index++;
@@ -68,8 +67,7 @@
free_fd_table[free_fd_table_index] = fd;
}
-int
-get_free_fd(void)
+int get_free_fd(void)
{
if (free_fd_table_index == -1) {
return -EMFILE;
@@ -79,14 +77,12 @@
return free_fd_table[free_fd_table_index + 1];
}
-int
-valid_fd(int fd)
+int valid_fd(int fd)
{
return fd < num_fds && fd >= FIRST_USER_FD;
}
-static int
-allocate_file_table(void)
+static int allocate_file_table(void)
{
fd_table = malloc(FD_TABLE_SIZE(num_fds));
if (fd_table == NULL) {
@@ -109,8 +105,7 @@
return 0;
}
-int
-grow_fds(int how_much)
+int grow_fds(int how_much)
{
int new_num_fds = num_fds + how_much;
@@ -157,8 +152,7 @@
return 0;
}
-int
-allocate_fd()
+int allocate_fd()
{
if (fd_table == NULL) {
if (allocate_file_table() == -ENOMEM) {
@@ -169,22 +163,19 @@
return get_free_fd();
}
-muslcsys_fd_t *
-get_fd_struct(int fd)
+muslcsys_fd_t *get_fd_struct(int fd)
{
assert(fd < num_fds && fd >= FIRST_USER_FD);
return &fd_table[fd - FIRST_USER_FD];
}
-static size_t
-sys_platform_write(void *data, size_t count)
+static size_t sys_platform_write(void *data, size_t count)
{
char *realdata = data;
return __arch_write(realdata, count);
}
-static long
-sys_open_impl(const char *pathname, int flags, mode_t mode)
+static long sys_open_impl(const char *pathname, int flags, mode_t mode)
{
/* mask out flags we can support */
flags &= ~O_LARGEFILE;
@@ -221,15 +212,14 @@
add_free_fd(fd);
return -ENOMEM;
}
- cpio_file_data_t *fd_data = (cpio_file_data_t*)fds->data;
+ cpio_file_data_t *fd_data = (cpio_file_data_t *)fds->data;
fd_data->start = file;
fd_data->size = size;
fd_data->current = 0;
return fd;
}
-long
-sys_open(va_list ap)
+long sys_open(va_list ap)
{
const char *pathname = va_arg(ap, const char *);
int flags = va_arg(ap, int);
@@ -238,8 +228,7 @@
return sys_open_impl(pathname, flags, mode);
}
-long
-sys_openat(va_list ap)
+long sys_openat(va_list ap)
{
int dirfd = va_arg(ap, int);
const char *pathname = va_arg(ap, const char *);
@@ -254,8 +243,7 @@
return sys_open_impl(pathname, flags, mode);
}
-long
-sys_close(va_list ap)
+long sys_close(va_list ap)
{
int fd = va_arg(ap, int);
if (fd < FIRST_USER_FD) {
@@ -281,7 +269,8 @@
static write_buf_fn stdio_write = sys_platform_write;
-write_buf_fn sel4muslcsys_register_stdio_write_fn(write_buf_fn write_fn) {
+write_buf_fn sel4muslcsys_register_stdio_write_fn(write_buf_fn write_fn)
+{
write_buf_fn old = stdio_write;
stdio_write = write_fn;
return old;
@@ -289,8 +278,7 @@
/* Writev syscall implementation for muslc. Only implemented for stdin and stdout. */
-long
-sys_writev(va_list ap)
+long sys_writev(va_list ap)
{
int fildes = va_arg(ap, int);
struct iovec *iov = va_arg(ap, struct iovec *);
@@ -341,7 +329,7 @@
long sys_readv(va_list ap)
{
int fd = va_arg(ap, int);
- struct iovec *iov = va_arg(ap, struct iovec*);
+ struct iovec *iov = va_arg(ap, struct iovec *);
int iovcnt = va_arg(ap, int);
int i;
long read;
@@ -377,15 +365,14 @@
long sys_read(va_list ap)
{
int fd = va_arg(ap, int);
- void *buf = va_arg(ap, void*);
+ void *buf = va_arg(ap, void *);
size_t count = va_arg(ap, size_t);
/* construct an iovec and call readv */
struct iovec iov = {.iov_base = buf, .iov_len = count };
return readv(fd, &iov, 1);
}
-long
-sys_ioctl(va_list ap)
+long sys_ioctl(va_list ap)
{
int fd = va_arg(ap, int);
int request = va_arg(ap, int);
@@ -399,8 +386,7 @@
return 0;
}
-long
-sys_prlimit64(va_list ap)
+long sys_prlimit64(va_list ap)
{
pid_t pid = va_arg(ap, pid_t);
int resource = va_arg(ap, int);
@@ -433,14 +419,13 @@
return result;
}
-static int
-safe_addition(int a, int b) {
+static int safe_addition(int a, int b)
+{
return !(a >= 0 && b > INT_MAX - a) &&
!(a < 0 && b < INT_MAX - a);
}
-long
-sys_lseek(va_list ap)
+long sys_lseek(va_list ap)
{
int fd = va_arg(ap, int);
off_t offset = va_arg(ap, off_t);
@@ -466,29 +451,29 @@
int new_offset = 0;
switch (whence) {
- case SEEK_SET:
- new_offset = offset;
- break;
- case SEEK_CUR:
- if (!safe_addition(cpio_fd->current, offset)) {
- return -EOVERFLOW;
- }
- new_offset = cpio_fd->current + offset;
- break;
- case SEEK_END:
- if (offset > 0) {
- /* can't seek beyond the end of the cpio file */
- return -EINVAL;
- }
- new_offset = cpio_fd->size + offset;
- break;
- default:
+ case SEEK_SET:
+ new_offset = offset;
+ break;
+ case SEEK_CUR:
+ if (!safe_addition(cpio_fd->current, offset)) {
+ return -EOVERFLOW;
+ }
+ new_offset = cpio_fd->current + offset;
+ break;
+ case SEEK_END:
+ if (offset > 0) {
+ /* can't seek beyond the end of the cpio file */
return -EINVAL;
+ }
+ new_offset = cpio_fd->size + offset;
+ break;
+ default:
+ return -EINVAL;
}
if (new_offset < 0) {
return -EINVAL;
- /* can't seek past the end of the cpio file */
+ /* can't seek past the end of the cpio file */
} else if (new_offset > cpio_fd->size) {
return -EINVAL;
}
@@ -505,7 +490,7 @@
int fd = va_arg(ap, int);
uint32_t offset_high = va_arg(ap, uint32_t);
uint32_t offset_low = va_arg(ap, uint32_t);
- off_t *result = va_arg(ap, off_t*);
+ off_t *result = va_arg(ap, off_t *);
int whence = va_arg(ap, int);
/* need to directly call syscall to prevent circular call to this function. the llseek function
* is used when off_t is a 64bit type (see the lseek definition in muslc), Underneath the
@@ -525,13 +510,14 @@
return 0;
}
-long sys_access(va_list ap) {
+long sys_access(va_list ap)
+{
const char *pathname = va_arg(ap, const char *);
int mode = va_arg(ap, int);
/* just try and open. currently we only support reading with the CPIO file system */
if (mode == F_OK || mode == R_OK) {
int fd = open(pathname, O_RDONLY, 0);
- if(fd < 0) {
+ if (fd < 0) {
return -EACCES;
}
close(fd);
@@ -542,7 +528,8 @@
}
void muslcsys_install_cpio_interface(void *cpio_symbol, unsigned long cpio_len,
- muslcsys_cpio_get_file_fn_t fn) {
+ muslcsys_cpio_get_file_fn_t fn)
+{
cpio_archive_symbol = cpio_symbol;
cpio_archive_len = cpio_len;
cpio_get_file_impl = fn;
diff --git a/libsel4muslcsys/src/sys_morecore.c b/libsel4muslcsys/src/sys_morecore.c
index 0437bc7..fdd267b 100644
--- a/libsel4muslcsys/src/sys_morecore.c
+++ b/libsel4muslcsys/src/sys_morecore.c
@@ -47,8 +47,7 @@
returns 0 if failure, returns newbrk if success.
*/
-long
-sys_brk(va_list ap)
+long sys_brk(va_list ap)
{
uintptr_t ret;
@@ -68,8 +67,7 @@
/* Large mallocs will result in muslc calling mmap, so we do a minimal implementation
here to support that. We make a bunch of assumptions in the process */
-long
-sys_mmap_impl(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
+long sys_mmap_impl(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
if (flags & MAP_ANONYMOUS) {
/* Check that we don't try and allocate more than exists */
@@ -84,8 +82,7 @@
return -ENOMEM;
}
-long
-sys_mremap(va_list ap)
+long sys_mremap(va_list ap)
{
assert(!"not implemented");
return -ENOMEM;
@@ -116,8 +113,7 @@
static uintptr_t brk_start;
-static void
-init_morecore_region(void)
+static void init_morecore_region(void)
{
if (morecore_base == 0) {
if (morecore_size == 0) {
@@ -128,8 +124,7 @@
}
}
-static long
-sys_brk_static(va_list ap)
+static long sys_brk_static(va_list ap)
{
uintptr_t ret;
uintptr_t newbrk = va_arg(ap, uintptr_t);
@@ -148,8 +143,7 @@
return ret;
}
-static long
-sys_brk_dynamic(va_list ap)
+static long sys_brk_dynamic(va_list ap)
{
uintptr_t ret;
@@ -167,8 +161,8 @@
} else {
/* try and map pages until this point */
while (brk_start < newbrk) {
- int error = vspace_new_pages_at_vaddr(muslc_this_vspace, (void*) brk_start, 1,
- seL4_PageBits, muslc_brk_reservation);
+ int error = vspace_new_pages_at_vaddr(muslc_this_vspace, (void *) brk_start, 1,
+ seL4_PageBits, muslc_brk_reservation);
if (error) {
ZF_LOGE("Mapping new pages to extend brk region failed\n");
return 0;
@@ -180,8 +174,7 @@
return ret;
}
-long
-sys_brk(va_list ap)
+long sys_brk(va_list ap)
{
if (morecore_area != NULL) {
return sys_brk_static(ap);
@@ -197,8 +190,7 @@
/* Large mallocs will result in muslc calling mmap, so we do a minimal implementation
here to support that. We make a bunch of assumptions in the process */
-static long
-sys_mmap_impl_static(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
+static long sys_mmap_impl_static(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
if (flags & MAP_ANONYMOUS) {
/* ensure the morecore region is initialized */
@@ -215,8 +207,7 @@
return -ENOMEM;
}
-static long
-sys_mmap_impl_dynamic(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
+static long sys_mmap_impl_dynamic(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
if (!muslc_this_vspace) {
ZF_LOGE("Need to assign vspace for mmap to work!\n");
@@ -233,8 +224,7 @@
return -ENOMEM;
}
-long
-sys_mmap_impl(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
+long sys_mmap_impl(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
if (morecore_area != NULL) {
return sys_mmap_impl_static(addr, length, prot, flags, fd, offset);
@@ -247,11 +237,10 @@
}
}
-static long
-sys_mremap_dynamic(va_list ap)
+static long sys_mremap_dynamic(va_list ap)
{
- void *old_address = va_arg(ap, void*);
+ void *old_address = va_arg(ap, void *);
size_t old_size = va_arg(ap, size_t);
size_t new_size = va_arg(ap, size_t);
int flags = va_arg(ap, int);
@@ -265,7 +254,7 @@
assert(new_size >= old_size);
if (flags & MREMAP_FIXED) {
- new_address_arg = va_arg(ap, void*);
+ new_address_arg = va_arg(ap, void *);
}
/* first find all the old caps */
@@ -284,7 +273,8 @@
int error;
void *new_address;
int new_pages = new_size >> seL4_PageBits;
- reservation_t reservation = vspace_reserve_range(muslc_this_vspace, new_pages * PAGE_SIZE_4K, seL4_AllRights, 1, &new_address);
+ reservation_t reservation = vspace_reserve_range(muslc_this_vspace, new_pages * PAGE_SIZE_4K, seL4_AllRights, 1,
+ &new_address);
if (!reservation.res) {
ZF_LOGE("Failed to make reservation for remap\n");
goto restore;
@@ -297,7 +287,8 @@
goto restore;
}
/* create any new pages */
- error = vspace_new_pages_at_vaddr(muslc_this_vspace, new_address + num_pages * PAGE_SIZE_4K, new_pages - num_pages, seL4_PageBits, reservation);
+ error = vspace_new_pages_at_vaddr(muslc_this_vspace, new_address + num_pages * PAGE_SIZE_4K, new_pages - num_pages,
+ seL4_PageBits, reservation);
if (error) {
ZF_LOGE("Creating new pages for remap region failed\n");
vspace_unmap_pages(muslc_this_vspace, new_address, num_pages, seL4_PageBits, VSPACE_PRESERVE);
@@ -312,20 +303,18 @@
reservation = vspace_reserve_range_at(muslc_this_vspace, old_address, num_pages * PAGE_SIZE_4K, seL4_AllRights, 1);
assert(reservation.res);
error = vspace_map_pages_at_vaddr(muslc_this_vspace, caps, cookies, old_address,
- num_pages, seL4_PageBits, reservation);
+ num_pages, seL4_PageBits, reservation);
assert(!error);
return -ENOMEM;
}
-static long
-sys_mremap_static(va_list ap)
+static long sys_mremap_static(va_list ap)
{
assert(!"not implemented");
return -ENOMEM;
}
-long
-sys_mremap(va_list ap)
+long sys_mremap(va_list ap)
{
if (morecore_area != NULL) {
return sys_mremap_static(ap);
@@ -341,17 +330,15 @@
#endif
/* This is a "dummy" implementation of sys_madvise() to satisfy free() in muslc. */
-long
-sys_madvise(va_list ap)
+long sys_madvise(va_list ap)
{
ZF_LOGV("calling dummy version of sys_madvise()\n");
return 0;
}
-long
-sys_mmap(va_list ap)
+long sys_mmap(va_list ap)
{
- void *addr = va_arg(ap, void*);
+ void *addr = va_arg(ap, void *);
size_t length = va_arg(ap, size_t);
int prot = va_arg(ap, int);
int flags = va_arg(ap, int);
@@ -360,10 +347,9 @@
return sys_mmap_impl(addr, length, prot, flags, fd, offset);
}
-long
-sys_mmap2(va_list ap)
+long sys_mmap2(va_list ap)
{
- void *addr = va_arg(ap, void*);
+ void *addr = va_arg(ap, void *);
size_t length = va_arg(ap, size_t);
int prot = va_arg(ap, int);
int flags = va_arg(ap, int);
diff --git a/libsel4muslcsys/src/vsyscall.c b/libsel4muslcsys/src/vsyscall.c
index f2a261c..666e5ad 100644
--- a/libsel4muslcsys/src/vsyscall.c
+++ b/libsel4muslcsys/src/vsyscall.c
@@ -37,8 +37,9 @@
static bool boot_set_thread_area_happened;
static void *boot_set_thread_area_arg;
-static long boot_set_thread_area(va_list ap) {
- void *tp = va_arg(ap, void*);
+static long boot_set_thread_area(va_list ap)
+{
+ void *tp = va_arg(ap, void *);
if (boot_set_thread_area_happened) {
ZF_LOGE("Boot version of set_thread_area somehow got called twice");
return -ESRCH;
@@ -56,7 +57,7 @@
char *tcb_string = getenv("boot_tcb_cptr");
if (tcb_string) {
seL4_CPtr tcb;
- if (sscanf(tcb_string, "%p", (void**)&tcb) == 1) {
+ if (sscanf(tcb_string, "%p", (void **)&tcb) == 1) {
seL4_TCB_SetTLSBase(tcb, (seL4_Word)tp);
}
}
@@ -66,14 +67,16 @@
return 0;
}
-bool muslcsys_get_boot_set_thread_area(void **arg) {
+bool muslcsys_get_boot_set_thread_area(void **arg)
+{
*arg = boot_set_thread_area_arg;
return boot_set_thread_area_happened;
}
#endif
-static long boot_set_tid_address(va_list ap) {
- int *tid = va_arg(ap, int*);
+static long boot_set_tid_address(va_list ap)
+{
+ int *tid = va_arg(ap, int *);
if (boot_set_tid_address_happened) {
ZF_LOGE("Boot version of set_tid_address somehow got called twice");
return 1;
@@ -83,21 +86,23 @@
return 1;
}
-bool muslcsys_get_boot_set_tid_address(int **arg) {
+bool muslcsys_get_boot_set_tid_address(int **arg)
+{
*arg = boot_set_tid_address_arg;
return boot_set_tid_address_happened;
}
/* Basic sys_writev for use during booting that will only use seL4_DebugPutChar */
-long boot_sys_writev(va_list ap) {
+long boot_sys_writev(va_list ap)
+{
int UNUSED fildes = va_arg(ap, int);
struct iovec *iov = va_arg(ap, struct iovec *);
int iovcnt = va_arg(ap, int);
ssize_t ret = 0;
- for(int i = 0; i < iovcnt; i++) {
- char * UNUSED base = (char*)iov[i].iov_base;
+ for (int i = 0; i < iovcnt; i++) {
+ char *UNUSED base = (char *)iov[i].iov_base;
for (int j = 0; j < iov[i].iov_len; j++) {
#ifdef CONFIG_PRINTING
seL4_DebugPutChar(base[j]);
@@ -178,7 +183,8 @@
#endif
};
-static int find_sparse_syscall(int syscall) {
+static int find_sparse_syscall(int syscall)
+{
for (int i = 0; i < ARRAY_SIZE(sparse_syscall_table); i++) {
if (sparse_syscall_table[i].sysnum == syscall) {
return i;
@@ -187,12 +193,14 @@
return -1;
}
-muslcsys_syscall_t muslcsys_install_syscall(int syscall, muslcsys_syscall_t new_syscall) {
+muslcsys_syscall_t muslcsys_install_syscall(int syscall, muslcsys_syscall_t new_syscall)
+{
muslcsys_syscall_t ret;
if (syscall >= ARRAY_SIZE(syscall_table)) {
int index = find_sparse_syscall(syscall);
if (index < 0) {
- ZF_LOGF("Syscall %d exceeds syscall table size of %zu and not found in sparse table", syscall, ARRAY_SIZE(syscall_table));
+ ZF_LOGF("Syscall %d exceeds syscall table size of %zu and not found in sparse table", syscall,
+ ARRAY_SIZE(syscall_table));
}
ret = sparse_syscall_table[index].syscall;
sparse_syscall_table[index].syscall = ret;
@@ -208,7 +216,8 @@
* it can be overriden. We are able to have this constructor
* in this file since we know it will get looked at by the linker due
* to __vsyscall_ptr being here */
-static void CONSTRUCTOR(CONSTRUCTOR_MIN_PRIORITY) init_syscall_table(void) {
+static void CONSTRUCTOR(CONSTRUCTOR_MIN_PRIORITY) init_syscall_table(void)
+{
muslcsys_syscall_t ret UNUSED;
ret = muslcsys_install_syscall(__NR_set_tid_address, sys_set_tid_address);
assert(ret == boot_set_tid_address);
@@ -228,14 +237,16 @@
#ifdef CONFIG_LIB_SEL4_MUSLC_SYS_CPIO_FS
extern char _cpio_archive[];
extern char _cpio_archive_end[];
-static void CONSTRUCTOR(CONSTRUCTOR_MIN_PRIORITY) install_default_cpio(void) {
+static void CONSTRUCTOR(CONSTRUCTOR_MIN_PRIORITY) install_default_cpio(void)
+{
unsigned long cpio_len = _cpio_archive_end - _cpio_archive;
muslcsys_install_cpio_interface(_cpio_archive, cpio_len, cpio_get_file);
}
#endif
#ifdef CONFIG_PRINTING
-static void debug_error(int sysnum) {
+static void debug_error(int sysnum)
+{
char buf[100];
int i;
sprintf(buf, "libsel4muslcsys: Error attempting syscall %d\n", sysnum);
@@ -244,11 +255,13 @@
}
}
#else
-static void debug_error(int sysnum) {
+static void debug_error(int sysnum)
+{
}
#endif
-long sel4_vsyscall(long sysnum, ...) {
+long sel4_vsyscall(long sysnum, ...)
+{
va_list al;
va_start(al, sysnum);
muslcsys_syscall_t syscall;
diff --git a/libsel4platsupport/include/sel4platsupport/timer.h b/libsel4platsupport/include/sel4platsupport/timer.h
index 3c98a5f..2f8fc76 100644
--- a/libsel4platsupport/include/sel4platsupport/timer.h
+++ b/libsel4platsupport/include/sel4platsupport/timer.h
@@ -66,7 +66,8 @@
* @param timer_objects struct for returning cap meta data.
* @return 0 on success, otherwise failure.
*/
-int sel4platsupport_init_default_timer_caps(vka_t *vka, vspace_t *vspace, simple_t *simple, timer_objects_t *timer_objects);
+int sel4platsupport_init_default_timer_caps(vka_t *vka, vspace_t *vspace, simple_t *simple,
+ timer_objects_t *timer_objects);
/*
* Initialise the default timer for this platform and do all of the seL4 related work.
@@ -87,14 +88,14 @@
* @return 0 on success.
*/
int sel4platsupport_init_default_timer_ops(vka_t *vka, vspace_t *vspace, simple_t *simple, ps_io_ops_t ops,
- seL4_CPtr notification, seL4_timer_t *timer);
+ seL4_CPtr notification, seL4_timer_t *timer);
/*
* Wrapper around sel4platsupport_init_default_timer_ops that generates as much of an
* io_ops interface as it can from the given vka and vspace
*/
int sel4platsupport_init_default_timer(vka_t *vka, vspace_t *vspace, simple_t *simple,
- seL4_CPtr notification, seL4_timer_t *timer);
+ seL4_CPtr notification, seL4_timer_t *timer);
/*
* Initialise an seL4_timer with irqs from provided timer objects. As per sel4platsupport_init_timer,
* timer_objects are provided and the user is expected to initialise the ltimer after calling this function
@@ -112,7 +113,7 @@
* @return 0 on success.
*/
int sel4platsupport_init_timer_irqs(vka_t *vka, simple_t *simple, seL4_CPtr ntfn,
- seL4_timer_t *timer, timer_objects_t *objects);
+ seL4_timer_t *timer, timer_objects_t *objects);
/*
* Handle a timer irq for this timer.
diff --git a/libsel4platsupport/src/device.c b/libsel4platsupport/src/device.c
index e99bb22..084597f 100644
--- a/libsel4platsupport/src/device.c
+++ b/libsel4platsupport/src/device.c
@@ -18,8 +18,7 @@
#include <vka/capops.h>
#include <utils/util.h>
-seL4_Error
-sel4platsupport_copy_irq_cap(vka_t *vka, simple_t *simple, ps_irq_t *irq, cspacepath_t *dest)
+seL4_Error sel4platsupport_copy_irq_cap(vka_t *vka, simple_t *simple, ps_irq_t *irq, cspacepath_t *dest)
{
seL4_CPtr cap;
@@ -38,27 +37,25 @@
error = sel4platsupport_arch_copy_irq_cap(&simple->arch_simple, irq, dest);
}
- if (error != seL4_NoError) {
+ if (error != seL4_NoError) {
ZF_LOGE("Failed to get cap for irq");
vka_cspace_free(vka, cap);
}
return error;
}
-seL4_Error
-sel4platsupport_alloc_frame_at(vka_t *vka, uintptr_t paddr, size_t size_bits, vka_object_t *frame)
+seL4_Error sel4platsupport_alloc_frame_at(vka_t *vka, uintptr_t paddr, size_t size_bits, vka_object_t *frame)
{
/* find the physical frame */
int error = vka_alloc_frame_at(vka, size_bits, paddr, frame);
if (error) {
- ZF_LOGE("Failed to find frame at paddr %p", (void*)paddr);
+ ZF_LOGE("Failed to find frame at paddr %p", (void *)paddr);
}
return error;
}
-void *
-sel4platsupport_map_frame_at(vka_t *vka, vspace_t *vspace, uintptr_t paddr, size_t size_bits, vka_object_t *frame)
+void *sel4platsupport_map_frame_at(vka_t *vka, vspace_t *vspace, uintptr_t paddr, size_t size_bits, vka_object_t *frame)
{
int error;
error = sel4platsupport_alloc_frame_at(vka, paddr, size_bits, frame);
@@ -67,7 +64,7 @@
}
void *vaddr = vspace_map_pages(vspace, &frame->cptr, &frame->ut, seL4_AllRights, 1, size_bits, 0);
if (!vaddr) {
- ZF_LOGE("Failed to map frame at paddr %p", (void*)paddr);
+ ZF_LOGE("Failed to map frame at paddr %p", (void *)paddr);
vka_free_object(vka, frame);
}
return vaddr;
diff --git a/libsel4platsupport/src/io.c b/libsel4platsupport/src/io.c
index 20433be..fa2c870 100644
--- a/libsel4platsupport/src/io.c
+++ b/libsel4platsupport/src/io.c
@@ -48,8 +48,7 @@
io_mapping_t *head;
} sel4platsupport_io_mapper_cookie_t;
-static void
-free_node(io_mapping_t *node)
+static void free_node(io_mapping_t *node)
{
assert(node);
if (node->caps) {
@@ -61,8 +60,7 @@
free(node);
}
-static io_mapping_t *
-new_node(size_t num_pages)
+static io_mapping_t *new_node(size_t num_pages)
{
io_mapping_t *ret = calloc(1, sizeof(io_mapping_t));
@@ -86,8 +84,7 @@
return ret;
}
-static void
-destroy_node(vka_t *vka, io_mapping_t *mapping)
+static void destroy_node(vka_t *vka, io_mapping_t *mapping)
{
cspacepath_t path;
for (size_t i = 0; i < mapping->num_pages; i++) {
@@ -102,8 +99,7 @@
free_node(mapping);
}
-static void
-insert_node(sel4platsupport_io_mapper_cookie_t *io_mapper, io_mapping_t *node)
+static void insert_node(sel4platsupport_io_mapper_cookie_t *io_mapper, io_mapping_t *node)
{
node->prev = NULL;
node->next = io_mapper->head;
@@ -113,8 +109,7 @@
io_mapper->head = node;
}
-static io_mapping_t *
-find_node(sel4platsupport_io_mapper_cookie_t *io_mapper, void *returned_addr)
+static io_mapping_t *find_node(sel4platsupport_io_mapper_cookie_t *io_mapper, void *returned_addr)
{
io_mapping_t *current;
for (current = io_mapper->head; current; current = current->next) {
@@ -125,8 +120,7 @@
return NULL;
}
-static void
-remove_node(sel4platsupport_io_mapper_cookie_t *io_mapper, io_mapping_t *node)
+static void remove_node(sel4platsupport_io_mapper_cookie_t *io_mapper, io_mapping_t *node)
{
if (node->prev) {
node->prev->next = node->next;
@@ -139,8 +133,8 @@
}
}
-static void *
-sel4platsupport_map_paddr_with_page_size(sel4platsupport_io_mapper_cookie_t *io_mapper, uintptr_t paddr, size_t size, size_t page_size_bits, bool cached)
+static void *sel4platsupport_map_paddr_with_page_size(sel4platsupport_io_mapper_cookie_t *io_mapper, uintptr_t paddr,
+ size_t size, size_t page_size_bits, bool cached)
{
vka_t *vka = &io_mapper->vka;
@@ -190,7 +184,8 @@
}
/* Now map the frames in */
- mapping->mapped_addr = vspace_map_pages(vspace, mapping->caps, mapping->alloc_cookies, seL4_AllRights, mapping->num_pages,
+ mapping->mapped_addr = vspace_map_pages(vspace, mapping->caps, mapping->alloc_cookies, seL4_AllRights,
+ mapping->num_pages,
mapping->page_size_bits, cached);
if (mapping->mapped_addr != NULL) {
/* fill out and insert node */
@@ -203,10 +198,10 @@
return NULL;
}
-static void *
-sel4platsupport_map_paddr(void *cookie, uintptr_t paddr, size_t size, int cached, UNUSED ps_mem_flags_t flags)
+static void *sel4platsupport_map_paddr(void *cookie, uintptr_t paddr, size_t size, int cached,
+ UNUSED ps_mem_flags_t flags)
{
- sel4platsupport_io_mapper_cookie_t* io_mapper = (sel4platsupport_io_mapper_cookie_t*)cookie;
+ sel4platsupport_io_mapper_cookie_t *io_mapper = (sel4platsupport_io_mapper_cookie_t *)cookie;
int frame_size_index = 0;
/* find the largest reasonable frame size */
while (frame_size_index + 1 < SEL4_NUM_PAGE_SIZES) {
@@ -229,10 +224,9 @@
return NULL;
}
-static void
-sel4platsupport_unmap_vaddr(void * cookie, void *vaddr, UNUSED size_t size)
+static void sel4platsupport_unmap_vaddr(void *cookie, void *vaddr, UNUSED size_t size)
{
- sel4platsupport_io_mapper_cookie_t* io_mapper = cookie;
+ sel4platsupport_io_mapper_cookie_t *io_mapper = cookie;
vspace_t *vspace = &io_mapper->vspace;
vka_t *vka = &io_mapper->vka;
@@ -252,8 +246,7 @@
destroy_node(vka, mapping);
}
-int
-sel4platsupport_new_io_mapper(vspace_t vspace, vka_t vka, ps_io_mapper_t *io_mapper)
+int sel4platsupport_new_io_mapper(vspace_t vspace, vka_t vka, ps_io_mapper_t *io_mapper)
{
sel4platsupport_io_mapper_cookie_t *cookie = calloc(1, sizeof(sel4platsupport_io_mapper_cookie_t));
if (!cookie) {
@@ -269,8 +262,7 @@
return 0;
}
-int
-sel4platsupport_new_malloc_ops(ps_malloc_ops_t *ops)
+int sel4platsupport_new_malloc_ops(ps_malloc_ops_t *ops)
{
ps_new_stdlib_malloc_ops(ops);
return 0;
@@ -282,8 +274,7 @@
gpio_sys_t gpio_sys;
#endif
-void *
-get_mux_dependencies(void)
+void *get_mux_dependencies(void)
{
#ifdef CONFIG_PLAT_TK1
/* The TK1's mux depends on an instance of the GPIO driver. */
@@ -294,8 +285,7 @@
#endif
}
-int
-sel4platsupport_new_io_ops(vspace_t vspace, vka_t vka, ps_io_ops_t *io_ops)
+int sel4platsupport_new_io_ops(vspace_t vspace, vka_t vka, ps_io_ops_t *io_ops)
{
memset(io_ops, 0, sizeof(ps_io_ops_t));
diff --git a/libsel4platsupport/src/plat/pc99/device.c b/libsel4platsupport/src/plat/pc99/device.c
index ffd482d..d1592e3 100644
--- a/libsel4platsupport/src/plat/pc99/device.c
+++ b/libsel4platsupport/src/plat/pc99/device.c
@@ -19,15 +19,15 @@
int sel4platsupport_arch_copy_irq_cap(arch_simple_t *arch_simple, ps_irq_t *irq, cspacepath_t *dest)
{
switch (irq->type) {
- case PS_MSI:
- return arch_simple_get_msi(arch_simple, *dest, irq->msi.pci_bus, irq->msi.pci_dev,
- irq->msi.pci_func, irq->msi.handle, irq->msi.vector);
- case PS_IOAPIC:
- return arch_simple_get_ioapic(arch_simple, *dest, irq->ioapic.ioapic, irq->ioapic.pin,
- irq->ioapic.level, irq->ioapic.polarity,
- irq->ioapic.vector);
- default:
- ZF_LOGE("unknown irq type");
- return -1;
+ case PS_MSI:
+ return arch_simple_get_msi(arch_simple, *dest, irq->msi.pci_bus, irq->msi.pci_dev,
+ irq->msi.pci_func, irq->msi.handle, irq->msi.vector);
+ case PS_IOAPIC:
+ return arch_simple_get_ioapic(arch_simple, *dest, irq->ioapic.ioapic, irq->ioapic.pin,
+ irq->ioapic.level, irq->ioapic.polarity,
+ irq->ioapic.vector);
+ default:
+ ZF_LOGE("unknown irq type");
+ return -1;
}
}
diff --git a/libsel4serialserver/CMakeLists.txt b/libsel4serialserver/CMakeLists.txt
index b648874..d59d111 100644
--- a/libsel4serialserver/CMakeLists.txt
+++ b/libsel4serialserver/CMakeLists.txt
@@ -29,10 +29,7 @@
set(deps src/clientapi.c src/parentapi.c src/server.c)
add_library(sel4serialserver STATIC EXCLUDE_FROM_ALL ${deps})
-target_include_directories(sel4serialserver
- PUBLIC
- include
-)
+target_include_directories(sel4serialserver PUBLIC include)
target_link_libraries(
sel4serialserver
PUBLIC
diff --git a/libsel4serialserver/src/server.c b/libsel4serialserver/src/server.c
index 0771a30..c13c198 100644
--- a/libsel4serialserver/src/server.c
+++ b/libsel4serialserver/src/server.c
@@ -66,8 +66,7 @@
#define NUM_COLORS ARRAY_SIZE(colors)
#define BADGE_TO_COLOR(badge) (colors[(badge) % NUM_COLORS])
-serial_server_context_t *
-get_serial_server(void)
+serial_server_context_t *get_serial_server(void)
{
return &serial_server;
}
@@ -82,25 +81,23 @@
api_reply(get_serial_server()->server_thread.reply.cptr, tag);
}
-serial_server_registry_entry_t *
-serial_server_registry_get_entry_by_badge(seL4_Word badge_value)
+serial_server_registry_entry_t *serial_server_registry_get_entry_by_badge(seL4_Word badge_value)
{
if (badge_value == SERIAL_SERVER_BADGE_VALUE_EMPTY
- || get_serial_server()->registry == NULL
- || badge_value > get_serial_server()->registry_n_entries) {
+ || get_serial_server()->registry == NULL
+ || badge_value > get_serial_server()->registry_n_entries) {
return NULL;
}
/* If the badge value has been released, return NULL. */
if (get_serial_server()->registry[badge_value - 1].badge_value
- == SERIAL_SERVER_BADGE_VALUE_EMPTY) {
+ == SERIAL_SERVER_BADGE_VALUE_EMPTY) {
return NULL;
}
return &get_serial_server()->registry[badge_value - 1];
}
-bool
-serial_server_badge_is_allocated(seL4_Word badge_value)
+bool serial_server_badge_is_allocated(seL4_Word badge_value)
{
serial_server_registry_entry_t *tmp;
@@ -112,8 +109,7 @@
return tmp->badge_value != SERIAL_SERVER_BADGE_VALUE_EMPTY;
}
-seL4_Word
-serial_server_badge_value_get_unused(void)
+seL4_Word serial_server_badge_value_get_unused(void)
{
if (get_serial_server()->registry == NULL) {
return SERIAL_SERVER_BADGE_VALUE_EMPTY;
@@ -134,8 +130,7 @@
return SERIAL_SERVER_BADGE_VALUE_EMPTY;
}
-seL4_Word
-serial_server_badge_value_alloc(void)
+seL4_Word serial_server_badge_value_alloc(void)
{
serial_server_registry_entry_t *tmp;
seL4_Word ret;
@@ -166,8 +161,7 @@
return serial_server_badge_value_get_unused();
}
-void
-serial_server_badge_value_free(seL4_Word badge_value)
+void serial_server_badge_value_free(seL4_Word badge_value)
{
serial_server_registry_entry_t *tmp;
@@ -183,10 +177,9 @@
tmp->badge_value = SERIAL_SERVER_BADGE_VALUE_EMPTY;
}
-static void
-serial_server_registry_insert(seL4_Word badge_value, void *shmem,
- seL4_CPtr *shmem_frame_caps,
- size_t shmem_size)
+static void serial_server_registry_insert(seL4_Word badge_value, void *shmem,
+ seL4_CPtr *shmem_frame_caps,
+ size_t shmem_size)
{
serial_server_registry_entry_t *tmp;
@@ -204,8 +197,7 @@
tmp->shmem_frame_caps = shmem_frame_caps;
}
-static void
-serial_server_registry_remove(seL4_Word badge_value)
+static void serial_server_registry_remove(seL4_Word badge_value)
{
serial_server_registry_entry_t *tmp;
@@ -216,8 +208,7 @@
serial_server_badge_value_free(badge_value);
}
-static void
-serial_server_set_frame_recv_path(void)
+static void serial_server_set_frame_recv_path(void)
{
seL4_SetCapReceivePath(get_serial_server()->server_cspace,
get_serial_server()->frame_cap_recv_cspaths[0].capPtr,
@@ -231,10 +222,9 @@
* map in order to establish shared mem with those clients. In this function,
* the library maps the client's frames into the server's VSpace.
*/
-seL4_Error
-serial_server_func_connect(seL4_MessageInfo_t tag,
- seL4_Word client_badge_value,
- size_t client_shmem_size)
+seL4_Error serial_server_func_connect(seL4_MessageInfo_t tag,
+ seL4_Word client_badge_value,
+ size_t client_shmem_size)
{
seL4_Error error;
size_t client_shmem_n_pages;
@@ -255,7 +245,7 @@
* is resized as well, so badge allocation is also metadata allocation.
*/
if (client_badge_value == SERIAL_SERVER_BADGE_VALUE_EMPTY
- || !serial_server_badge_is_allocated(client_badge_value)) {
+ || !serial_server_badge_is_allocated(client_badge_value)) {
ZF_LOGW(SERSERVS"connect: Please allocate a badge value to this new "
"client.\n");
return -1;
@@ -368,9 +358,8 @@
return error;
}
-static int
-serial_server_func_write(serial_server_registry_entry_t *client_data,
- size_t message_len, size_t *bytes_written)
+static int serial_server_func_write(serial_server_registry_entry_t *client_data,
+ size_t message_len, size_t *bytes_written)
{
*bytes_written = 0;
@@ -395,8 +384,7 @@
return 0;
}
-static void
-serial_server_func_disconnect(serial_server_registry_entry_t *client_data)
+static void serial_server_func_disconnect(serial_server_registry_entry_t *client_data)
{
/* Tear down shmem and release the badge value for reuse. */
vspace_unmap_pages(get_serial_server()->server_vspace,
@@ -407,15 +395,14 @@
serial_server_registry_remove(client_data->badge_value);
}
-static void
-serial_server_func_kill(void)
+static void serial_server_func_kill(void)
{
/* Tear down all existing connections. */
for (int i = 0; i < get_serial_server()->registry_n_entries; i++) {
serial_server_registry_entry_t *curr = &get_serial_server()->registry[i];
if (curr->badge_value == SERIAL_SERVER_BADGE_VALUE_EMPTY
- || BYTES_TO_4K_PAGES(curr->shmem_size) == 0) {
+ || BYTES_TO_4K_PAGES(curr->shmem_size) == 0) {
continue;
}
@@ -454,8 +441,7 @@
}
}
-void
-serial_server_main(void)
+void serial_server_main(void)
{
seL4_MessageInfo_t tag;
seL4_Word sender_badge;
diff --git a/libsel4test/CMakeLists.txt b/libsel4test/CMakeLists.txt
index a652148..7a05154 100644
--- a/libsel4test/CMakeLists.txt
+++ b/libsel4test/CMakeLists.txt
@@ -44,10 +44,7 @@
list(SORT deps)
add_library(sel4test STATIC EXCLUDE_FROM_ALL ${deps})
-target_include_directories(
- sel4test
- PUBLIC include
-)
+target_include_directories(sel4test PUBLIC include)
target_link_libraries(
sel4test
muslc
diff --git a/libsel4test/src/testutil.c b/libsel4test/src/testutil.c
index 3909655..241ce9f 100644
--- a/libsel4test/src/testutil.c
+++ b/libsel4test/src/testutil.c
@@ -39,8 +39,7 @@
static test_result_t current_test_result = SUCCESS;
#undef printf
-void
-sel4test_printf(const char *string)
+void sel4test_printf(const char *string)
{
if (!do_buffer_printf) {
printf("%s", string);
diff --git a/libsel4utils/CMakeLists.txt b/libsel4utils/CMakeLists.txt
index f017e72..35dc686 100644
--- a/libsel4utils/CMakeLists.txt
+++ b/libsel4utils/CMakeLists.txt
@@ -55,10 +55,7 @@
add_library(sel4utils STATIC EXCLUDE_FROM_ALL ${deps})
target_include_directories(
sel4utils
- PUBLIC
- include
- "sel4_arch_include/${KernelSel4Arch}"
- "arch_include/${KernelArch}"
+ PUBLIC include "sel4_arch_include/${KernelSel4Arch}" "arch_include/${KernelArch}"
)
target_link_libraries(
sel4utils
diff --git a/libsel4utils/include/sel4utils/benchmark.h b/libsel4utils/include/sel4utils/benchmark.h
index fa8b7b8..31a0696 100644
--- a/libsel4utils/include/sel4utils/benchmark.h
+++ b/libsel4utils/include/sel4utils/benchmark.h
@@ -25,16 +25,15 @@
* either edit .config manually or add it using "make menuconfig" by selecting
* "Kernel" -> "seL4 System Parameters" -> "Adds a log buffer to the kernel for instrumentation."
*/
-static inline void
-seL4_BenchmarkTraceDumpFullLog(benchmark_tracepoint_log_entry_t *logBuffer, size_t logSize)
+static inline void seL4_BenchmarkTraceDumpFullLog(benchmark_tracepoint_log_entry_t *logBuffer, size_t logSize)
{
seL4_Word index = 0;
FILE *fd = stdout;
while ((index * sizeof(benchmark_tracepoint_log_entry_t)) < logSize) {
- if(logBuffer[index].duration != 0) {
- fprintf(fd, "tracepoint id = %u \tduration = %u\n", logBuffer[index].id, logBuffer[index].duration);
- }
+ if (logBuffer[index].duration != 0) {
+ fprintf(fd, "tracepoint id = %u \tduration = %u\n", logBuffer[index].id, logBuffer[index].duration);
+ }
index++;
}
diff --git a/libsel4utils/include/sel4utils/benchmark_track.h b/libsel4utils/include/sel4utils/benchmark_track.h
index f1a443a..199542d 100644
--- a/libsel4utils/include/sel4utils/benchmark_track.h
+++ b/libsel4utils/include/sel4utils/benchmark_track.h
@@ -19,8 +19,7 @@
#include <sel4/benchmark_track_types.h>
/* Print out a summary of what has been tracked */
-static inline void
-seL4_BenchmarkTrackDumpSummary(benchmark_track_kernel_entry_t *logBuffer, size_t logSize)
+static inline void seL4_BenchmarkTrackDumpSummary(benchmark_track_kernel_entry_t *logBuffer, size_t logSize)
{
seL4_Word index = 0;
seL4_Word syscall_entries = 0;
@@ -53,25 +52,26 @@
}
/* Print out logged system call invocations */
-static inline void
-seL4_BenchmarkTrackDumpFullSyscallLog(benchmark_track_kernel_entry_t *logBuffer, size_t logSize)
+static inline void seL4_BenchmarkTrackDumpFullSyscallLog(benchmark_track_kernel_entry_t *logBuffer, size_t logSize)
{
seL4_Word index = 0;
FILE *fd = stdout;
/* Get details of each system call invocation */
- fprintf(fd, "-----------------------------------------------------------------------------------------------------------------------------\n");
+ fprintf(fd,
+ "-----------------------------------------------------------------------------------------------------------------------------\n");
fprintf(fd, "| %-15s| %-15s| %-15s| %-15s| %-15s| %-15s| %-15s|\n",
"Log ID", "System Call ID", "Start Time", "Duration", "Capability Type",
"Invocation Tag", "Fastpath?");
- fprintf(fd, "-----------------------------------------------------------------------------------------------------------------------------\n");
+ fprintf(fd,
+ "-----------------------------------------------------------------------------------------------------------------------------\n");
while (logBuffer[index].start_time != 0 && (index * sizeof(benchmark_track_kernel_entry_t)) < logSize) {
if (logBuffer[index].entry.path == Entry_Syscall) {
fprintf(fd, "| %-15d| %-15d| %-15llu| %-15d| %-15d| %-15d| %-15d|\n",
index,
logBuffer[index].entry.syscall_no,
- (uint64_t ) logBuffer[index].start_time,
+ (uint64_t) logBuffer[index].start_time,
logBuffer[index].duration,
logBuffer[index].entry.cap_type,
logBuffer[index].entry.invocation_tag,
@@ -82,17 +82,18 @@
}
/* Print out logged interrupt invocations */
-static inline void
-seL4_BenchmarkTrackDumpFullInterruptLog(benchmark_track_kernel_entry_t *logBuffer, size_t logSize)
+static inline void seL4_BenchmarkTrackDumpFullInterruptLog(benchmark_track_kernel_entry_t *logBuffer, size_t logSize)
{
seL4_Word index = 0;
FILE *fd = stdout;
/* Get details of each invocation */
- fprintf(fd, "-----------------------------------------------------------------------------------------------------------------------------\n");
+ fprintf(fd,
+ "-----------------------------------------------------------------------------------------------------------------------------\n");
fprintf(fd, "| %-15s| %-15s| %-15s| %-15s|\n", "Log ID", "IRQ", "Start Time",
"Duration");
- fprintf(fd, "-----------------------------------------------------------------------------------------------------------------------------\n");
+ fprintf(fd,
+ "-----------------------------------------------------------------------------------------------------------------------------\n");
while (logBuffer[index].start_time != 0 && (index * sizeof(benchmark_track_kernel_entry_t)) < logSize) {
if (logBuffer[index].entry.path == Entry_Interrupt) {
diff --git a/libsel4utils/include/sel4utils/elf.h b/libsel4utils/include/sel4utils/elf.h
index 8f06b9c..deb720b 100644
--- a/libsel4utils/include/sel4utils/elf.h
+++ b/libsel4utils/include/sel4utils/elf.h
@@ -134,7 +134,7 @@
*
* @return Address of section or 0 if not found
*/
-uintptr_t sel4utils_elf_get_section(elf_t *elf, const char *section_name, uint64_t* section_size);
+uintptr_t sel4utils_elf_get_section(elf_t *elf, const char *section_name, uint64_t *section_size);
/**
* Parses an elf file and returns the number of phdrs. The result of this
diff --git a/libsel4utils/include/sel4utils/iommu_dma.h b/libsel4utils/include/sel4utils/iommu_dma.h
index 578ab89..1ab3a43 100644
--- a/libsel4utils/include/sel4utils/iommu_dma.h
+++ b/libsel4utils/include/sel4utils/iommu_dma.h
@@ -38,7 +38,8 @@
* @param iospaces Pointer to list of cptrs representing the iospaces to map into
* @return 0 on success
*/
-int sel4utils_make_iommu_dma_alloc(vka_t *vka, vspace_t *vspace, ps_dma_man_t *dma_man, unsigned int num_iospaces, seL4_CPtr *iospaces);
+int sel4utils_make_iommu_dma_alloc(vka_t *vka, vspace_t *vspace, ps_dma_man_t *dma_man, unsigned int num_iospaces,
+ seL4_CPtr *iospaces);
/**
* Variant of ps_dma_alloc that allows the caller to allocate memory in their address space for use
diff --git a/libsel4utils/include/sel4utils/mapping.h b/libsel4utils/include/sel4utils/mapping.h
index 248cca7..e45b97d 100644
--- a/libsel4utils/include/sel4utils/mapping.h
+++ b/libsel4utils/include/sel4utils/mapping.h
@@ -59,7 +59,7 @@
*
* @return virtual address of mapping
*/
-void * sel4utils_dup_and_map(vka_t *vka, vspace_t *vspace, seL4_CPtr page, size_t size_bits);
+void *sel4utils_dup_and_map(vka_t *vka, vspace_t *vspace, seL4_CPtr page, size_t size_bits);
/* Unmap a duplicated page cap and free any resources. Is the opposite
* of sel4utils_dup_and_map
@@ -81,7 +81,8 @@
#ifdef CONFIG_VTX
int sel4utils_map_ept_page(vka_t *vka, seL4_CPtr pd, seL4_CPtr frame, seL4_Word vaddr,
- seL4_CapRights_t rights, int cacheable, seL4_Word size_bits, vka_object_t *pagetable, vka_object_t *pagedir, vka_object_t *pdpt);
+ seL4_CapRights_t rights, int cacheable, seL4_Word size_bits, vka_object_t *pagetable, vka_object_t *pagedir,
+ vka_object_t *pdpt);
#endif /* CONFIG_VTX */
diff --git a/libsel4utils/include/sel4utils/process.h b/libsel4utils/include/sel4utils/process.h
index 20eca6a..a9e0f1b 100644
--- a/libsel4utils/include/sel4utils/process.h
+++ b/libsel4utils/include/sel4utils/process.h
@@ -246,7 +246,8 @@
*
* @return 0 on failure, otherwise the slot in the cspace where the new cap is.
*/
-seL4_CPtr sel4utils_mint_cap_to_process(sel4utils_process_t *process, cspacepath_t src, seL4_CapRights_t rights, seL4_Word data);
+seL4_CPtr sel4utils_mint_cap_to_process(sel4utils_process_t *process, cspacepath_t src, seL4_CapRights_t rights,
+ seL4_Word data);
/**
* Destroy a process.
@@ -297,4 +298,5 @@
*
* @return 0 on success.
*/
-int sel4utils_copy_timer_caps_to_process(timer_objects_t *to, timer_objects_t *from, vka_t *vka, sel4utils_process_t *process);
+int sel4utils_copy_timer_caps_to_process(timer_objects_t *to, timer_objects_t *from, vka_t *vka,
+ sel4utils_process_t *process);
diff --git a/libsel4utils/include/sel4utils/process_config.h b/libsel4utils/include/sel4utils/process_config.h
index c3c7c5a..2acd883 100644
--- a/libsel4utils/include/sel4utils/process_config.h
+++ b/libsel4utils/include/sel4utils/process_config.h
@@ -65,30 +65,28 @@
seL4_CPtr asid_pool;
} sel4utils_process_config_t;
-static inline sel4utils_process_config_t
-process_config_asid_pool(sel4utils_process_config_t config, seL4_CPtr asid_pool)
+static inline sel4utils_process_config_t process_config_asid_pool(sel4utils_process_config_t config,
+ seL4_CPtr asid_pool)
{
config.asid_pool = asid_pool;
return config;
}
-static inline sel4utils_process_config_t
-process_config_auth(sel4utils_process_config_t config, seL4_CPtr auth)
+static inline sel4utils_process_config_t process_config_auth(sel4utils_process_config_t config, seL4_CPtr auth)
{
config.sched_params.auth = auth;
return config;
}
-static inline sel4utils_process_config_t
-process_config_new(simple_t *simple)
+static inline sel4utils_process_config_t process_config_new(simple_t *simple)
{
sel4utils_process_config_t config = {0};
config = process_config_auth(config, simple_get_tcb(simple));
return process_config_asid_pool(config, simple_get_init_cap(simple, seL4_CapInitThreadASIDPool));
}
-static inline sel4utils_process_config_t
-process_config_elf(sel4utils_process_config_t config, const char *image_name, bool preload)
+static inline sel4utils_process_config_t process_config_elf(sel4utils_process_config_t config, const char *image_name,
+ bool preload)
{
config.is_elf = true;
config.image_name = image_name;
@@ -96,8 +94,8 @@
return config;
}
-static inline sel4utils_process_config_t
-process_config_noelf(sel4utils_process_config_t config, void *entry_point, uintptr_t sysinfo)
+static inline sel4utils_process_config_t process_config_noelf(sel4utils_process_config_t config, void *entry_point,
+ uintptr_t sysinfo)
{
config.is_elf = false;
config.entry_point = entry_point;
@@ -105,24 +103,22 @@
return config;
}
-static inline sel4utils_process_config_t
-process_config_cnode(sel4utils_process_config_t config, vka_object_t cnode)
+static inline sel4utils_process_config_t process_config_cnode(sel4utils_process_config_t config, vka_object_t cnode)
{
config.create_cspace = false;
config.cnode = cnode;
return config;
}
-static inline sel4utils_process_config_t
-process_config_create_cnode(sel4utils_process_config_t config, int size_bits)
+static inline sel4utils_process_config_t process_config_create_cnode(sel4utils_process_config_t config, int size_bits)
{
config.create_cspace = true;
config.one_level_cspace_size_bits = size_bits;
return config;
}
-static inline sel4utils_process_config_t
-process_config_vspace(sel4utils_process_config_t config, vspace_t *vspace, vka_object_t page_dir)
+static inline sel4utils_process_config_t process_config_vspace(sel4utils_process_config_t config, vspace_t *vspace,
+ vka_object_t page_dir)
{
config.create_vspace = false;
config.vspace = vspace;
@@ -130,9 +126,9 @@
return config;
}
-static inline sel4utils_process_config_t
-process_config_create_vspace(sel4utils_process_config_t config, sel4utils_elf_region_t *reservations,
- int num_reservations)
+static inline sel4utils_process_config_t process_config_create_vspace(sel4utils_process_config_t config,
+ sel4utils_elf_region_t *reservations,
+ int num_reservations)
{
config.create_vspace = true;
config.reservations = reservations;
@@ -140,45 +136,41 @@
return config;
}
-static inline sel4utils_process_config_t
-process_config_priority(sel4utils_process_config_t config, uint8_t priority)
+static inline sel4utils_process_config_t process_config_priority(sel4utils_process_config_t config, uint8_t priority)
{
config.sched_params.priority = priority;
return config;
}
-static inline sel4utils_process_config_t
-process_config_mcp(sel4utils_process_config_t config, uint8_t mcp)
+static inline sel4utils_process_config_t process_config_mcp(sel4utils_process_config_t config, uint8_t mcp)
{
config.sched_params.mcp = mcp;
return config;
}
-static inline sel4utils_process_config_t
-process_config_create_fault_endpoint(sel4utils_process_config_t config)
+static inline sel4utils_process_config_t process_config_create_fault_endpoint(sel4utils_process_config_t config)
{
config.create_fault_endpoint = true;
return config;
}
-static inline sel4utils_process_config_t
-process_config_fault_endpoint(sel4utils_process_config_t config, vka_object_t fault_endpoint)
+static inline sel4utils_process_config_t process_config_fault_endpoint(sel4utils_process_config_t config,
+ vka_object_t fault_endpoint)
{
config.fault_endpoint = fault_endpoint;
config.create_fault_endpoint = false;
return config;
}
-static inline sel4utils_process_config_t
-process_config_fault_cptr(sel4utils_process_config_t config, seL4_CPtr fault_cptr)
+static inline sel4utils_process_config_t process_config_fault_cptr(sel4utils_process_config_t config,
+ seL4_CPtr fault_cptr)
{
config.fault_endpoint.cptr = fault_cptr;
config.create_fault_endpoint = false;
return config;
}
-static inline sel4utils_process_config_t
-process_config_default(const char *image_name, seL4_CPtr asid_pool)
+static inline sel4utils_process_config_t process_config_default(const char *image_name, seL4_CPtr asid_pool)
{
sel4utils_process_config_t config = {0};
config = process_config_asid_pool(config, asid_pool);
@@ -188,8 +180,8 @@
return process_config_create_fault_endpoint(config);
}
-static inline sel4utils_process_config_t
-process_config_default_simple(simple_t *simple, const char *image_name, uint8_t prio)
+static inline sel4utils_process_config_t process_config_default_simple(simple_t *simple, const char *image_name,
+ uint8_t prio)
{
sel4utils_process_config_t config = process_config_new(simple);
config = process_config_elf(config, image_name, true);
diff --git a/libsel4utils/include/sel4utils/thread.h b/libsel4utils/include/sel4utils/thread.h
index 879e965..7b15e96 100644
--- a/libsel4utils/include/sel4utils/thread.h
+++ b/libsel4utils/include/sel4utils/thread.h
@@ -222,14 +222,12 @@
*/
int sel4utils_set_sched_affinity(sel4utils_thread_t *thread, sched_params_t params);
-static inline seL4_TCB
-sel4utils_get_tcb(sel4utils_thread_t *thread)
+static inline seL4_TCB sel4utils_get_tcb(sel4utils_thread_t *thread)
{
return thread->tcb.cptr;
}
-static inline int
-sel4utils_suspend_thread(sel4utils_thread_t *thread)
+static inline int sel4utils_suspend_thread(sel4utils_thread_t *thread)
{
return seL4_TCB_Suspend(thread->tcb.cptr);
}
diff --git a/libsel4utils/include/sel4utils/thread_config.h b/libsel4utils/include/sel4utils/thread_config.h
index d0167df..3799a9b 100644
--- a/libsel4utils/include/sel4utils/thread_config.h
+++ b/libsel4utils/include/sel4utils/thread_config.h
@@ -25,7 +25,7 @@
/* Threads and processes use this struct as both need scheduling config parameters */
typedef struct sched_params {
- /* seL4 priority for the thread to be scheduled with. */
+ /* seL4 priority for the thread to be scheduled with. */
uint8_t priority;
/* seL4 maximum controlled priority for the thread. */
uint8_t mcp;
@@ -49,7 +49,7 @@
typedef struct sel4utils_thread_config {
/* fault_endpoint endpoint to set as the threads fault endpoint. Can be seL4_CapNull. */
seL4_CPtr fault_endpoint;
- /* root of the cspace to start the thread in */
+ /* root of the cspace to start the thread in */
seL4_CNode cspace;
/* data for cspace access */
seL4_Word cspace_root_data;
@@ -67,9 +67,9 @@
seL4_CPtr reply;
} sel4utils_thread_config_t;
-static inline sched_params_t
-sched_params_periodic(sched_params_t params, simple_t *simple, seL4_Word core, uint64_t period_us,
- uint64_t budget_us, seL4_Word extra_refills, seL4_Word badge)
+static inline sched_params_t sched_params_periodic(sched_params_t params, simple_t *simple, seL4_Word core,
+ uint64_t period_us,
+ uint64_t budget_us, seL4_Word extra_refills, seL4_Word badge)
{
if (!config_set(CONFIG_KERNEL_RT)) {
ZF_LOGW("Setting sched params on non-RT kernel will have no effect");
@@ -83,14 +83,13 @@
return params;
}
-static inline sched_params_t
-sched_params_round_robin(sched_params_t params, simple_t *simple, seL4_Word core, uint64_t timeslice_us)
+static inline sched_params_t sched_params_round_robin(sched_params_t params, simple_t *simple, seL4_Word core,
+ uint64_t timeslice_us)
{
return sched_params_periodic(params, simple, core, timeslice_us, timeslice_us, 0, 0);
}
-static inline sched_params_t
-sched_params_core(sched_params_t params, seL4_Word core)
+static inline sched_params_t sched_params_core(sched_params_t params, seL4_Word core)
{
if (!config_set(CONFIG_KERNEL_RT)) {
ZF_LOGW("Setting core on RT kernel will have no effect - sched ctrl required");
@@ -99,46 +98,42 @@
return params;
}
-static inline sel4utils_thread_config_t
-thread_config_create_reply(sel4utils_thread_config_t config)
+static inline sel4utils_thread_config_t thread_config_create_reply(sel4utils_thread_config_t config)
{
config.create_reply = true;
return config;
}
-static inline sel4utils_thread_config_t
-thread_config_reply(sel4utils_thread_config_t config, seL4_CPtr reply)
+static inline sel4utils_thread_config_t thread_config_reply(sel4utils_thread_config_t config, seL4_CPtr reply)
{
config.create_reply = false;
config.reply = reply;
return config;
}
-static inline sel4utils_thread_config_t
-thread_config_sched_context(sel4utils_thread_config_t config, seL4_CPtr sched_context)
+static inline sel4utils_thread_config_t thread_config_sched_context(sel4utils_thread_config_t config,
+ seL4_CPtr sched_context)
{
config.sched_params.create_sc = false;
config.sched_params.sched_context = sched_context;
return config;
}
-static inline sel4utils_thread_config_t
-thread_config_cspace(sel4utils_thread_config_t config, seL4_CPtr cspace_root, seL4_Word cspace_root_data)
+static inline sel4utils_thread_config_t thread_config_cspace(sel4utils_thread_config_t config, seL4_CPtr cspace_root,
+ seL4_Word cspace_root_data)
{
config.cspace = cspace_root;
config.cspace_root_data = cspace_root_data;
return config;
}
-static inline sel4utils_thread_config_t
-thread_config_auth(sel4utils_thread_config_t config, seL4_CPtr tcb)
+static inline sel4utils_thread_config_t thread_config_auth(sel4utils_thread_config_t config, seL4_CPtr tcb)
{
config.sched_params.auth = tcb;
return config;
}
-static inline sel4utils_thread_config_t
-thread_config_new(simple_t *simple)
+static inline sel4utils_thread_config_t thread_config_new(simple_t *simple)
{
sel4utils_thread_config_t config = {0};
seL4_Word data = api_make_guard_skip_word(seL4_WordBits - simple_get_cnode_size_bits(simple));
@@ -146,44 +141,40 @@
return thread_config_cspace(config, simple_get_cnode(simple), data);
}
-static inline sel4utils_thread_config_t
-thread_config_priority(sel4utils_thread_config_t config, uint8_t priority)
+static inline sel4utils_thread_config_t thread_config_priority(sel4utils_thread_config_t config, uint8_t priority)
{
config.sched_params.priority = priority;
return config;
}
-static inline sel4utils_thread_config_t
-thread_config_mcp(sel4utils_thread_config_t config, uint8_t mcp)
+static inline sel4utils_thread_config_t thread_config_mcp(sel4utils_thread_config_t config, uint8_t mcp)
{
config.sched_params.mcp = mcp;
return config;
}
-static inline sel4utils_thread_config_t
-thread_config_stack_size(sel4utils_thread_config_t config, seL4_Word size)
+static inline sel4utils_thread_config_t thread_config_stack_size(sel4utils_thread_config_t config, seL4_Word size)
{
config.stack_size = size;
config.custom_stack_size = true;
return config;
}
-static inline sel4utils_thread_config_t
-thread_config_no_ipc_buffer(sel4utils_thread_config_t config)
+static inline sel4utils_thread_config_t thread_config_no_ipc_buffer(sel4utils_thread_config_t config)
{
config.no_ipc_buffer = true;
return config;
}
-static inline sel4utils_thread_config_t
-thread_config_fault_endpoint(sel4utils_thread_config_t config, seL4_CPtr fault_ep)
+static inline sel4utils_thread_config_t thread_config_fault_endpoint(sel4utils_thread_config_t config,
+ seL4_CPtr fault_ep)
{
config.fault_endpoint = fault_ep;
return config;
}
-static inline sel4utils_thread_config_t
-thread_config_default(simple_t *simple, seL4_CPtr cnode, seL4_Word data, seL4_CPtr fault_ep, uint8_t prio)
+static inline sel4utils_thread_config_t thread_config_default(simple_t *simple, seL4_CPtr cnode, seL4_Word data,
+ seL4_CPtr fault_ep, uint8_t prio)
{
sel4utils_thread_config_t config = thread_config_new(simple);
config = thread_config_cspace(config, cnode, data);
diff --git a/libsel4utils/include/sel4utils/util.h b/libsel4utils/include/sel4utils/util.h
index 85672b2..96a0604 100644
--- a/libsel4utils/include/sel4utils/util.h
+++ b/libsel4utils/include/sel4utils/util.h
@@ -54,7 +54,7 @@
{
seL4_SetMR(offset, (seL4_Word) value);
if (SEL4UTILS_64_WORDS == 2) {
- seL4_SetMR(offset + 1, (seL4_Word) (value >> 32llu));
+ seL4_SetMR(offset + 1, (seL4_Word)(value >> 32llu));
}
assert(sel4utils_64_get_mr(offset) == value);
}
diff --git a/libsel4utils/include/sel4utils/vspace.h b/libsel4utils/include/sel4utils/vspace.h
index 7905143..17d589d 100644
--- a/libsel4utils/include/sel4utils/vspace.h
+++ b/libsel4utils/include/sel4utils/vspace.h
@@ -56,7 +56,8 @@
uintptr_t cookie[VSPACE_LEVEL_SIZE];
} vspace_bottom_level_t;
-typedef int(*sel4utils_map_page_fn)(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights, int cacheable, size_t size_bits);
+typedef int(*sel4utils_map_page_fn)(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights,
+ int cacheable, size_t size_bits);
struct sel4utils_res {
uintptr_t start;
@@ -80,8 +81,7 @@
sel4utils_res_t *reservation_head;
} sel4utils_alloc_data_t;
-static inline sel4utils_res_t *
-reservation_to_res(reservation_t res)
+static inline sel4utils_res_t *reservation_to_res(reservation_t res)
{
return (sel4utils_res_t *) res.res;
}
@@ -195,34 +195,32 @@
/* Wrapper function that configures a vspaceator such that all allocated objects are not
* tracked.
*/
-static inline int
-sel4utils_get_vspace_leaky(vspace_t *loader, vspace_t *new_vspace, sel4utils_alloc_data_t *data,
- vka_t *vka, seL4_CPtr vspace_root)
+static inline int sel4utils_get_vspace_leaky(vspace_t *loader, vspace_t *new_vspace, sel4utils_alloc_data_t *data,
+ vka_t *vka, seL4_CPtr vspace_root)
{
return sel4utils_get_vspace(loader, new_vspace, data, vka, vspace_root,
(vspace_allocated_object_fn) NULL, NULL);
}
#ifdef CONFIG_VTX
-static inline int
-sel4utils_get_vspace_ept_leaky(vspace_t *loader, vspace_t *new_vspace,
- vka_t *vka, seL4_CPtr vspace_root)
+static inline int sel4utils_get_vspace_ept_leaky(vspace_t *loader, vspace_t *new_vspace,
+ vka_t *vka, seL4_CPtr vspace_root)
{
return sel4utils_get_vspace_ept(loader, new_vspace, vka, vspace_root,
(vspace_allocated_object_fn) NULL, NULL);
}
#endif /* CONFIG_VTX */
-static inline int
-sel4utils_bootstrap_vspace_with_bootinfo_leaky(vspace_t *vspace, sel4utils_alloc_data_t *data, seL4_CPtr vspace_root,
- vka_t *vka, seL4_BootInfo *info)
+static inline int sel4utils_bootstrap_vspace_with_bootinfo_leaky(vspace_t *vspace, sel4utils_alloc_data_t *data,
+ seL4_CPtr vspace_root,
+ vka_t *vka, seL4_BootInfo *info)
{
return sel4utils_bootstrap_vspace_with_bootinfo(vspace, data, vspace_root, vka, info, NULL, NULL);
}
-static inline int
-sel4utils_bootstrap_vspace_leaky(vspace_t *vspace, sel4utils_alloc_data_t *data, seL4_CPtr vspace_root, vka_t *vka,
- void *existing_frames[])
+static inline int sel4utils_bootstrap_vspace_leaky(vspace_t *vspace, sel4utils_alloc_data_t *data,
+ seL4_CPtr vspace_root, vka_t *vka,
+ void *existing_frames[])
{
return sel4utils_bootstrap_vspace(vspace, data, vspace_root, vka, NULL, NULL, existing_frames);
}
diff --git a/libsel4utils/include/sel4utils/vspace_internal.h b/libsel4utils/include/sel4utils/vspace_internal.h
index b62f127..55f545d 100644
--- a/libsel4utils/include/sel4utils/vspace_internal.h
+++ b/libsel4utils/include/sel4utils/vspace_internal.h
@@ -36,7 +36,8 @@
void *create_level(vspace_t *vspace, size_t size);
void *bootstrap_create_level(vspace_t *vspace, size_t size);
-static inline void *create_mid_level(vspace_t *vspace, uintptr_t init) {
+static inline void *create_mid_level(vspace_t *vspace, uintptr_t init)
+{
vspace_mid_level_t *level = create_level(vspace, sizeof(vspace_mid_level_t));
if (level) {
for (int i = 0; i < VSPACE_LEVEL_SIZE; i++) {
@@ -46,7 +47,8 @@
return level;
}
-static inline void *create_bottom_level(vspace_t *vspace, uintptr_t init) {
+static inline void *create_bottom_level(vspace_t *vspace, uintptr_t init)
+{
vspace_bottom_level_t *level = create_level(vspace, sizeof(vspace_bottom_level_t));
if (level) {
for (int i = 0; i < VSPACE_LEVEL_SIZE; i++) {
@@ -57,14 +59,13 @@
return level;
}
-static inline sel4utils_alloc_data_t *
-get_alloc_data(vspace_t *vspace)
+static inline sel4utils_alloc_data_t *get_alloc_data(vspace_t *vspace)
{
return (sel4utils_alloc_data_t *) vspace->data;
}
-static int
-reserve_entries_bottom(vspace_t *vspace, vspace_bottom_level_t *level, uintptr_t start, uintptr_t end, bool preserve_frames)
+static int reserve_entries_bottom(vspace_t *vspace, vspace_bottom_level_t *level, uintptr_t start, uintptr_t end,
+ bool preserve_frames)
{
while (start < end) {
int index = INDEX_FOR_LEVEL(start, 0);
@@ -83,8 +84,8 @@
return 0;
}
-static int
-reserve_entries_mid(vspace_t *vspace, vspace_mid_level_t *level, int level_num, uintptr_t start, uintptr_t end, bool preserve_frames)
+static int reserve_entries_mid(vspace_t *vspace, vspace_mid_level_t *level, int level_num, uintptr_t start,
+ uintptr_t end, bool preserve_frames)
{
/* walk entries at this level until we complete this range */
while (start < end) {
@@ -126,9 +127,10 @@
if (next_table != RESERVED) {
int error;
if (level_num == 1) {
- error = reserve_entries_bottom(vspace, (vspace_bottom_level_t*)next_table, start, next_start, preserve_frames);
+ error = reserve_entries_bottom(vspace, (vspace_bottom_level_t *)next_table, start, next_start, preserve_frames);
} else {
- error = reserve_entries_mid(vspace, (vspace_mid_level_t*)next_table, level_num - 1, start, next_start, preserve_frames);
+ error = reserve_entries_mid(vspace, (vspace_mid_level_t *)next_table, level_num - 1, start, next_start,
+ preserve_frames);
}
if (error) {
return error;
@@ -139,8 +141,8 @@
return 0;
}
-static int
-clear_entries_bottom(vspace_t *vspace, vspace_bottom_level_t *level, uintptr_t start, uintptr_t end, bool only_reserved)
+static int clear_entries_bottom(vspace_t *vspace, vspace_bottom_level_t *level, uintptr_t start, uintptr_t end,
+ bool only_reserved)
{
while (start < end) {
int index = INDEX_FOR_LEVEL(start, 0);
@@ -155,8 +157,8 @@
return 0;
}
-static int
-clear_entries_mid(vspace_t *vspace, vspace_mid_level_t *level, int level_num, uintptr_t start, uintptr_t end, bool only_reserved)
+static int clear_entries_mid(vspace_t *vspace, vspace_mid_level_t *level, int level_num, uintptr_t start, uintptr_t end,
+ bool only_reserved)
{
/* walk entries at this level until we complete this range */
while (start < end) {
@@ -176,9 +178,9 @@
if (next_table != EMPTY) {
int error;
if (level_num == 1) {
- error = clear_entries_bottom(vspace, (vspace_bottom_level_t*)next_table, start, next_start, only_reserved);
+ error = clear_entries_bottom(vspace, (vspace_bottom_level_t *)next_table, start, next_start, only_reserved);
} else {
- error = clear_entries_mid(vspace, (vspace_mid_level_t*)next_table, level_num - 1, start, next_start, only_reserved);
+ error = clear_entries_mid(vspace, (vspace_mid_level_t *)next_table, level_num - 1, start, next_start, only_reserved);
}
if (error) {
return error;
@@ -189,8 +191,8 @@
return 0;
}
-static int
-update_entries_bottom(vspace_t *vspace, vspace_bottom_level_t *level, uintptr_t start, uintptr_t end, seL4_CPtr cap, uintptr_t cookie)
+static int update_entries_bottom(vspace_t *vspace, vspace_bottom_level_t *level, uintptr_t start, uintptr_t end,
+ seL4_CPtr cap, uintptr_t cookie)
{
while (start < end) {
int index = INDEX_FOR_LEVEL(start, 0);
@@ -206,8 +208,8 @@
return 0;
}
-static int
-update_entries_mid(vspace_t *vspace, vspace_mid_level_t *level, int level_num, uintptr_t start, uintptr_t end, seL4_CPtr cap, uintptr_t cookie)
+static int update_entries_mid(vspace_t *vspace, vspace_mid_level_t *level, int level_num, uintptr_t start,
+ uintptr_t end, seL4_CPtr cap, uintptr_t cookie)
{
/* walk entries at this level until we complete this range */
while (start < end) {
@@ -235,9 +237,9 @@
}
int error;
if (level_num == 1) {
- error = update_entries_bottom(vspace, (vspace_bottom_level_t*)next_table, start, next_start, cap, cookie);
+ error = update_entries_bottom(vspace, (vspace_bottom_level_t *)next_table, start, next_start, cap, cookie);
} else {
- error = update_entries_mid(vspace, (vspace_mid_level_t*)next_table, level_num - 1, start, next_start, cap, cookie);
+ error = update_entries_mid(vspace, (vspace_mid_level_t *)next_table, level_num - 1, start, next_start, cap, cookie);
}
if (error) {
return error;
@@ -247,8 +249,8 @@
return 0;
}
-static bool
-is_reserved_or_empty_bottom(vspace_bottom_level_t *level, uintptr_t start, uintptr_t end, uintptr_t good, uintptr_t bad)
+static bool is_reserved_or_empty_bottom(vspace_bottom_level_t *level, uintptr_t start, uintptr_t end, uintptr_t good,
+ uintptr_t bad)
{
while (start < end) {
int index = INDEX_FOR_LEVEL(start, 0);
@@ -261,8 +263,8 @@
return true;
}
-static bool
-is_reserved_or_empty_mid(vspace_mid_level_t *level, int level_num, uintptr_t start, uintptr_t end, uintptr_t good, uintptr_t bad)
+static bool is_reserved_or_empty_mid(vspace_mid_level_t *level, int level_num, uintptr_t start, uintptr_t end,
+ uintptr_t good, uintptr_t bad)
{
/* walk entries at this level until we complete this range */
while (start < end) {
@@ -281,9 +283,9 @@
if (next_table != good) {
int succ;
if (level_num == 1) {
- succ = is_reserved_or_empty_bottom((vspace_bottom_level_t*)next_table, start, next_start, good, bad);
+ succ = is_reserved_or_empty_bottom((vspace_bottom_level_t *)next_table, start, next_start, good, bad);
} else {
- succ = is_reserved_or_empty_mid((vspace_mid_level_t*)next_table, level_num - 1, start, next_start, good, bad);
+ succ = is_reserved_or_empty_mid((vspace_mid_level_t *)next_table, level_num - 1, start, next_start, good, bad);
}
if (!succ) {
return false;
@@ -295,8 +297,7 @@
}
/* update entry in page table and handle large pages */
-static inline int
-update_entries(vspace_t *vspace, uintptr_t vaddr, seL4_CPtr cap, size_t size_bits, uintptr_t cookie)
+static inline int update_entries(vspace_t *vspace, uintptr_t vaddr, seL4_CPtr cap, size_t size_bits, uintptr_t cookie)
{
uintptr_t start = vaddr;
uintptr_t end = vaddr + BIT(size_bits);
@@ -304,23 +305,20 @@
return update_entries_mid(vspace, data->top_level, VSPACE_NUM_LEVELS - 1, start, end, cap, cookie);
}
-static inline int
-reserve_entries_range(vspace_t *vspace, uintptr_t start, uintptr_t end, bool preserve_frames)
+static inline int reserve_entries_range(vspace_t *vspace, uintptr_t start, uintptr_t end, bool preserve_frames)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
return reserve_entries_mid(vspace, data->top_level, VSPACE_NUM_LEVELS - 1, start, end, preserve_frames);
}
-static inline int
-reserve_entries(vspace_t *vspace, uintptr_t vaddr, size_t size_bits)
+static inline int reserve_entries(vspace_t *vspace, uintptr_t vaddr, size_t size_bits)
{
uintptr_t start = vaddr;
uintptr_t end = vaddr + BIT(size_bits);
return reserve_entries_range(vspace, start, end, false);
}
-static inline int
-clear_entries_range(vspace_t *vspace, uintptr_t start, uintptr_t end, bool only_reserved)
+static inline int clear_entries_range(vspace_t *vspace, uintptr_t start, uintptr_t end, bool only_reserved)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
int error = clear_entries_mid(vspace, data->top_level, VSPACE_NUM_LEVELS - 1, start, end, only_reserved);
@@ -335,54 +333,48 @@
return 0;
}
-static inline int
-clear_entries(vspace_t *vspace, uintptr_t vaddr, size_t size_bits)
+static inline int clear_entries(vspace_t *vspace, uintptr_t vaddr, size_t size_bits)
{
uintptr_t start = vaddr;
uintptr_t end = vaddr + BIT(size_bits);
return clear_entries_range(vspace, start, end, false);
}
-static inline bool
-is_reserved_or_empty_range(vspace_mid_level_t *top_level, uintptr_t start, uintptr_t end, uintptr_t good, uintptr_t bad)
+static inline bool is_reserved_or_empty_range(vspace_mid_level_t *top_level, uintptr_t start, uintptr_t end,
+ uintptr_t good, uintptr_t bad)
{
return is_reserved_or_empty_mid(top_level, VSPACE_NUM_LEVELS - 1, start, end, good, bad);
}
-static inline bool
-is_reserved_or_empty(vspace_mid_level_t *top_level, uintptr_t vaddr, size_t size_bits, uintptr_t good, uintptr_t bad)
+static inline bool is_reserved_or_empty(vspace_mid_level_t *top_level, uintptr_t vaddr, size_t size_bits,
+ uintptr_t good, uintptr_t bad)
{
uintptr_t start = vaddr;
uintptr_t end = vaddr + BIT(size_bits);
return is_reserved_or_empty_range(top_level, start, end, good, bad);
}
-static inline bool
-is_available_range(vspace_mid_level_t *top_level, uintptr_t start, uintptr_t end)
+static inline bool is_available_range(vspace_mid_level_t *top_level, uintptr_t start, uintptr_t end)
{
return is_reserved_or_empty_range(top_level, start, end, EMPTY, RESERVED);
}
-static inline bool
-is_available(vspace_mid_level_t *top_level, uintptr_t vaddr, size_t size_bits)
+static inline bool is_available(vspace_mid_level_t *top_level, uintptr_t vaddr, size_t size_bits)
{
return is_reserved_or_empty(top_level, vaddr, size_bits, EMPTY, RESERVED);
}
-static inline bool
-is_reserved_range(vspace_mid_level_t *top_level, uintptr_t start, uintptr_t end)
+static inline bool is_reserved_range(vspace_mid_level_t *top_level, uintptr_t start, uintptr_t end)
{
return is_reserved_or_empty_range(top_level, start, end, RESERVED, EMPTY);
}
-static inline bool
-is_reserved(vspace_mid_level_t *top_level, uintptr_t vaddr, size_t size_bits)
+static inline bool is_reserved(vspace_mid_level_t *top_level, uintptr_t vaddr, size_t size_bits)
{
return is_reserved_or_empty(top_level, vaddr, size_bits, RESERVED, EMPTY);
}
-static inline seL4_CPtr
-get_cap(vspace_mid_level_t *top, uintptr_t vaddr)
+static inline seL4_CPtr get_cap(vspace_mid_level_t *top, uintptr_t vaddr)
{
vspace_mid_level_t *level = top;
for (int i = VSPACE_NUM_LEVELS - 1; i > 1; i--) {
@@ -391,18 +383,17 @@
if (next == EMPTY || next == RESERVED) {
return 0;
}
- level = (vspace_mid_level_t*)next;
+ level = (vspace_mid_level_t *)next;
}
uintptr_t next = level->table[INDEX_FOR_LEVEL(vaddr, 1)];
if (next == EMPTY || next == RESERVED) {
return 0;
}
- vspace_bottom_level_t *bottom = (vspace_bottom_level_t*)next;
+ vspace_bottom_level_t *bottom = (vspace_bottom_level_t *)next;
return bottom->cap[INDEX_FOR_LEVEL(vaddr, 0)];
}
-static inline uintptr_t
-get_cookie(vspace_mid_level_t *top, uintptr_t vaddr)
+static inline uintptr_t get_cookie(vspace_mid_level_t *top, uintptr_t vaddr)
{
vspace_mid_level_t *level = top;
for (int i = VSPACE_NUM_LEVELS - 1; i > 1; i--) {
@@ -411,23 +402,26 @@
if (next == EMPTY || next == RESERVED) {
return 0;
}
- level = (vspace_mid_level_t*)next;
+ level = (vspace_mid_level_t *)next;
}
uintptr_t next = level->table[INDEX_FOR_LEVEL(vaddr, 1)];
if (next == EMPTY || next == RESERVED) {
return 0;
}
- vspace_bottom_level_t *bottom = (vspace_bottom_level_t*)next;
+ vspace_bottom_level_t *bottom = (vspace_bottom_level_t *)next;
return bottom->cookie[INDEX_FOR_LEVEL(vaddr, 0)];
}
/* Internal interface functions */
-int sel4utils_map_page_pd(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights, int cacheable, size_t size_bits);
+int sel4utils_map_page_pd(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights, int cacheable,
+ size_t size_bits);
#ifdef CONFIG_VTX
-int sel4utils_map_page_ept(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights, int cacheable, size_t size_bits);
+int sel4utils_map_page_ept(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights, int cacheable,
+ size_t size_bits);
#endif /* CONFIG_VTX */
#ifdef CONFIG_IOMMU
-int sel4utils_map_page_iommu(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights, int cacheable, size_t size_bits);
+int sel4utils_map_page_iommu(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights, int cacheable,
+ size_t size_bits);
#endif /* CONFIG_IOMMU */
/* interface functions */
diff --git a/libsel4utils/sel4_arch_include/aarch32/sel4utils/sel4_arch/util.h b/libsel4utils/sel4_arch_include/aarch32/sel4utils/sel4_arch/util.h
index 47160d4..c52971a 100644
--- a/libsel4utils/sel4_arch_include/aarch32/sel4utils/sel4_arch/util.h
+++ b/libsel4utils/sel4_arch_include/aarch32/sel4utils/sel4_arch/util.h
@@ -19,8 +19,7 @@
#define ARCH_SYSCALL_INSTRUCTION_SIZE 4
-static inline int
-sel4utils_is_read_fault(void)
+static inline int sel4utils_is_read_fault(void)
{
seL4_Word fsr = seL4_GetMR(seL4_VMFault_FSR);
#if defined(CONFIG_ARM_HYPERVISOR_SUPPORT)
@@ -30,32 +29,27 @@
#endif
}
-static inline void
-sel4utils_set_instruction_pointer(seL4_UserContext *regs, seL4_Word value)
+static inline void sel4utils_set_instruction_pointer(seL4_UserContext *regs, seL4_Word value)
{
regs->pc = value;
}
-static inline seL4_Word
-sel4utils_get_instruction_pointer(seL4_UserContext regs)
+static inline seL4_Word sel4utils_get_instruction_pointer(seL4_UserContext regs)
{
return regs.pc;
}
-static inline void
-sel4utils_set_stack_pointer(seL4_UserContext *regs, seL4_Word value)
+static inline void sel4utils_set_stack_pointer(seL4_UserContext *regs, seL4_Word value)
{
regs->sp = value;
}
-static inline void
-sel4utils_set_arg0(seL4_UserContext *regs, seL4_Word value)
+static inline void sel4utils_set_arg0(seL4_UserContext *regs, seL4_Word value)
{
regs->r0 = value;
}
-static inline seL4_Word
-sel4utils_get_sp(seL4_UserContext regs)
+static inline seL4_Word sel4utils_get_sp(seL4_UserContext regs)
{
return regs.sp;
}
diff --git a/libsel4utils/src/arch/riscv/arch.c b/libsel4utils/src/arch/riscv/arch.c
index 3f34b55..45303f4 100644
--- a/libsel4utils/src/arch/riscv/arch.c
+++ b/libsel4utils/src/arch/riscv/arch.c
@@ -15,8 +15,7 @@
#include <sel4utils/thread.h>
#include <stdbool.h>
-int
-sel4utils_arch_init_context(void *entry_point, void *stack_top, seL4_UserContext *context)
+int sel4utils_arch_init_context(void *entry_point, void *stack_top, seL4_UserContext *context)
{
context->pc = (seL4_Word) entry_point;
context->sp = (seL4_Word) stack_top;
@@ -27,10 +26,9 @@
return 0;
}
-int
-sel4utils_arch_init_context_with_args(void *entry_point, void *arg0, void *arg1, void *arg2,
- bool local_stack, void *stack_top, seL4_UserContext *context,
- vka_t *vka, vspace_t *local_vspace, vspace_t *remote_vspace)
+int sel4utils_arch_init_context_with_args(void *entry_point, void *arg0, void *arg1, void *arg2,
+ bool local_stack, void *stack_top, seL4_UserContext *context,
+ vka_t *vka, vspace_t *local_vspace, vspace_t *remote_vspace)
{
extern char __global_pointer$[];
diff --git a/libsel4utils/src/elf.c b/libsel4utils/src/elf.c
index 47495b2..996e484 100644
--- a/libsel4utils/src/elf.c
+++ b/libsel4utils/src/elf.c
@@ -27,8 +27,7 @@
* @param permissions elf permissions
* @return seL4 permissions
*/
-static inline seL4_CapRights_t
-rights_from_elf(unsigned long permissions)
+static inline seL4_CapRights_t rights_from_elf(unsigned long permissions)
{
bool canRead = permissions & PF_R || permissions & PF_X;
bool canWrite = permissions & PF_W;
@@ -36,11 +35,10 @@
return seL4_CapRights_new(false, false, canRead, canWrite);
}
-static int
-load_segment(vspace_t *loadee_vspace, vspace_t *loader_vspace,
- vka_t *loadee_vka, vka_t *loader_vka,
- char *src, size_t file_size, int num_regions,
- sel4utils_elf_region_t regions[num_regions], int region_index)
+static int load_segment(vspace_t *loadee_vspace, vspace_t *loader_vspace,
+ vka_t *loadee_vka, vka_t *loader_vka,
+ char *src, size_t file_size, int num_regions,
+ sel4utils_elf_region_t regions[num_regions], int region_index)
{
int error = seL4_NoError;
sel4utils_elf_region_t region = regions[region_index];
@@ -66,7 +64,7 @@
unsigned int pos = 0;
while (pos < segment_size && error == seL4_NoError) {
void *loader_vaddr = 0;
- void *loadee_vaddr = (void *) ((seL4_Word)ROUND_DOWN(dst, PAGE_SIZE_4K));
+ void *loadee_vaddr = (void *)((seL4_Word)ROUND_DOWN(dst, PAGE_SIZE_4K));
/* Find the reservation that this frame belongs to.
* The reservation may belong to an adjacent region */
@@ -77,14 +75,14 @@
ZF_LOGE("Invalid regions: bad elf file.");
return 1;
}
- reservation = regions[region_index-1].reservation;
+ reservation = regions[region_index - 1].reservation;
} else if (loadee_vaddr + (MIN(segment_size - pos, PAGE_SIZE_4K)) >
- (region.reservation_vstart + region.reservation_size)) {
+ (region.reservation_vstart + region.reservation_size)) {
if ((region_index + 1) >= num_regions) {
ZF_LOGE("Invalid regions: bad elf file.");
return 1;
}
- reservation = regions[region_index+1].reservation;
+ reservation = regions[region_index + 1].reservation;
} else {
reservation = region.reservation;
}
@@ -124,7 +122,7 @@
/* finally copy the data */
int nbytes = PAGE_SIZE_4K - (dst & PAGE_MASK_4K);
if (pos < file_size) {
- memcpy(loader_vaddr + (dst % PAGE_SIZE_4K), (void*)src, MIN(nbytes, file_size - pos));
+ memcpy(loader_vaddr + (dst % PAGE_SIZE_4K), (void *)src, MIN(nbytes, file_size - pos));
}
/* Note that we don't need to explicitly zero frames as seL4 gives us zero'd frames */
@@ -167,10 +165,10 @@
*
* @return 0 on success.
*/
-static int
-load_segments(vspace_t *loadee_vspace, vspace_t *loader_vspace,
- vka_t *loadee_vka, vka_t *loader_vka, elf_t *elf_file,
- int num_regions, sel4utils_elf_region_t regions[num_regions]) {
+static int load_segments(vspace_t *loadee_vspace, vspace_t *loader_vspace,
+ vka_t *loadee_vka, vka_t *loader_vka, elf_t *elf_file,
+ int num_regions, sel4utils_elf_region_t regions[num_regions])
+{
for (int i = 0; i < num_regions; i++) {
int segment_index = regions[i].segment_index;
char *source_addr = elf_getProgramSegment(elf_file, segment_index);
@@ -188,12 +186,13 @@
return 0;
}
-static bool is_loadable_section(elf_t *elf_file, int index) {
+static bool is_loadable_section(elf_t *elf_file, int index)
+{
return elf_getProgramHeaderType(elf_file, index) == PT_LOAD;
}
-static int
-count_loadable_regions(elf_t *elf_file) {
+static int count_loadable_regions(elf_t *elf_file)
+{
int num_headers = elf_getNumProgramHeaders(elf_file);
int loadable_headers = 0;
@@ -206,8 +205,7 @@
return loadable_headers;
}
-int
-sel4utils_elf_num_regions(elf_t *elf_file)
+int sel4utils_elf_num_regions(elf_t *elf_file)
{
return count_loadable_regions(elf_file);
}
@@ -225,23 +223,24 @@
*
* @return 0 on success.
*/
-static int
-create_reservations(vspace_t *loadee, size_t total_regions, sel4utils_elf_region_t regions[total_regions], int anywhere) {
+static int create_reservations(vspace_t *loadee, size_t total_regions, sel4utils_elf_region_t regions[total_regions],
+ int anywhere)
+{
for (int i = 0; i < total_regions; i++) {
if (regions[i].reservation_size == 0) {
ZF_LOGD("Empty reservation detected. This should indicate that this segments"
- "data is entirely stored in other section reservations.");
+ "data is entirely stored in other section reservations.");
continue;
}
if (anywhere) {
regions[i].reservation = vspace_reserve_range(loadee, regions[i].reservation_size,
- regions[i].rights, regions[i].cacheable, (void**)®ions[i].reservation_vstart);
+ regions[i].rights, regions[i].cacheable, (void **)®ions[i].reservation_vstart);
} else {
regions[i].reservation = vspace_reserve_range_at(loadee,
- regions[i].reservation_vstart,
- regions[i].reservation_size,
- regions[i].rights,
- regions[i].cacheable);
+ regions[i].reservation_vstart,
+ regions[i].reservation_size,
+ regions[i].rights,
+ regions[i].cacheable);
}
if (regions[i].reservation.res == NULL) {
ZF_LOGE("Failed to make reservation: %p, %zd", regions[i].reservation_vstart, regions[i].reservation_size);
@@ -266,8 +265,8 @@
*
* @return 0 on success.
*/
-static int
-cap_writes_check_move_frame(seL4_CapRights_t a, seL4_CapRights_t b, bool *result) {
+static int cap_writes_check_move_frame(seL4_CapRights_t a, seL4_CapRights_t b, bool *result)
+{
if (!seL4_CapRights_get_capAllowRead(a) || !seL4_CapRights_get_capAllowRead(b)) {
ZF_LOGE("Regions do not have read rights.");
return -1;
@@ -298,8 +297,8 @@
*
* @return 0 on success.
*/
-static int
-prepare_reservations(size_t total_regions, sel4utils_elf_region_t regions[total_regions]) {
+static int prepare_reservations(size_t total_regions, sel4utils_elf_region_t regions[total_regions])
+{
uintptr_t prev_res_start = 0;
size_t prev_res_size = 0;
seL4_CapRights_t prev_rights = seL4_NoRights;
@@ -321,14 +320,14 @@
if (should_move) {
/* Frame needs to be moved from the last reservation into this one */
ZF_LOGF_IF(i == 0, "Should not need to adjust first element in list");
- ZF_LOGF_IF(regions[i-1].reservation_size < PAGE_SIZE_4K, "Invalid previous region");
- regions[i-1].reservation_size -= PAGE_SIZE_4K;
+ ZF_LOGF_IF(regions[i - 1].reservation_size < PAGE_SIZE_4K, "Invalid previous region");
+ regions[i - 1].reservation_size -= PAGE_SIZE_4K;
} else {
/* Frame stays in previous reservation and we update our reservation start address and size */
current_res_start = ROUND_UP((prev_res_start + prev_res_size) + 1, PAGE_SIZE_4K);
current_res_size = current_res_top - current_res_start;
ZF_LOGF_IF(ROUND_UP(regions[i].size, PAGE_SIZE_4K) - current_res_size == PAGE_SIZE_4K,
- "Regions shouldn't overlap by more than a single 4k frame");
+ "Regions shouldn't overlap by more than a single 4k frame");
}
}
/* Record this reservation layout */
@@ -352,8 +351,8 @@
*
* @return 0 on success.
*/
-static int
-read_regions(elf_t *elf_file, size_t total_regions, sel4utils_elf_region_t regions[total_regions]) {
+static int read_regions(elf_t *elf_file, size_t total_regions, sel4utils_elf_region_t regions[total_regions])
+{
int num_headers = elf_getNumProgramHeaders(elf_file);
int region_id = 0;
for (int i = 0; i < num_headers; i++) {
@@ -391,8 +390,8 @@
*
* @return 1 for a > b, -1 for b > a
*/
-static int
-compare_regions(sel4utils_elf_region_t a, sel4utils_elf_region_t b) {
+static int compare_regions(sel4utils_elf_region_t a, sel4utils_elf_region_t b)
+{
if (a.elf_vstart + a.size <= b.elf_vstart) {
return -1;
} else if (b.elf_vstart + b.size <= a.elf_vstart) {
@@ -418,9 +417,9 @@
*
* @return 0 on success.
*/
-static int
-elf_reserve_regions_in_vspace(vspace_t *loadee, elf_t *elf_file,
- int num_regions, sel4utils_elf_region_t regions[num_regions], int mapanywhere) {
+static int elf_reserve_regions_in_vspace(vspace_t *loadee, elf_t *elf_file,
+ int num_regions, sel4utils_elf_region_t regions[num_regions], int mapanywhere)
+{
int error = read_regions(elf_file, num_regions, regions);
if (error) {
ZF_LOGE("Failed to read regions");
@@ -443,21 +442,20 @@
return 0;
}
-static void *
-entry_point(elf_t *elf_file) {
+static void *entry_point(elf_t *elf_file)
+{
uint64_t entry_point = elf_getEntryPoint(elf_file);
- if ((uint32_t) (entry_point >> 32) != 0) {
+ if ((uint32_t)(entry_point >> 32) != 0) {
ZF_LOGE("ERROR: this code hasn't been tested for 64bit!");
return NULL;
}
assert(entry_point != 0);
- return (void*)(seL4_Word)entry_point;
+ return (void *)(seL4_Word)entry_point;
}
-void *
-sel4utils_elf_reserve(vspace_t *loadee, elf_t *elf_file, sel4utils_elf_region_t *regions)
+void *sel4utils_elf_reserve(vspace_t *loadee, elf_t *elf_file, sel4utils_elf_region_t *regions)
{
/* Count number of loadable segments */
int num_regions = count_loadable_regions(elf_file);
@@ -473,8 +471,8 @@
return entry_point(elf_file);
}
-void *
-sel4utils_elf_load_record_regions(vspace_t *loadee, vspace_t *loader, vka_t *loadee_vka, vka_t *loader_vka, elf_t *elf_file, sel4utils_elf_region_t *regions, int mapanywhere)
+void *sel4utils_elf_load_record_regions(vspace_t *loadee, vspace_t *loader, vka_t *loadee_vka, vka_t *loader_vka,
+ elf_t *elf_file, sel4utils_elf_region_t *regions, int mapanywhere)
{
/* Calculate number of loadable regions. Use stack array if one wasn't passed in */
int num_regions = count_loadable_regions(elf_file);
@@ -514,7 +512,7 @@
uintptr_t sel4utils_elf_get_vsyscall(elf_t *elf_file)
{
- uintptr_t* addr = (uintptr_t*)sel4utils_elf_get_section(elf_file, "__vsyscall", NULL);
+ uintptr_t *addr = (uintptr_t *)sel4utils_elf_get_section(elf_file, "__vsyscall", NULL);
if (addr) {
return *addr;
} else {
@@ -522,7 +520,7 @@
}
}
-uintptr_t sel4utils_elf_get_section(elf_t *elf_file, const char *section_name, uint64_t* section_size)
+uintptr_t sel4utils_elf_get_section(elf_t *elf_file, const char *section_name, uint64_t *section_size)
{
/* See if we can find the section */
size_t section_id;
@@ -537,20 +535,17 @@
}
}
-void *
-sel4utils_elf_load(vspace_t *loadee, vspace_t *loader, vka_t *loadee_vka, vka_t *loader_vka, elf_t *elf_file)
+void *sel4utils_elf_load(vspace_t *loadee, vspace_t *loader, vka_t *loadee_vka, vka_t *loader_vka, elf_t *elf_file)
{
return sel4utils_elf_load_record_regions(loadee, loader, loadee_vka, loader_vka, elf_file, NULL, 0);
}
-uint32_t
-sel4utils_elf_num_phdrs(elf_t *elf_file)
+uint32_t sel4utils_elf_num_phdrs(elf_t *elf_file)
{
return elf_getNumProgramHeaders(elf_file);
}
-void
-sel4utils_elf_read_phdrs(elf_t *elf_file, size_t max_phdrs, Elf_Phdr *phdrs)
+void sel4utils_elf_read_phdrs(elf_t *elf_file, size_t max_phdrs, Elf_Phdr *phdrs)
{
size_t num_phdrs = elf_getNumProgramHeaders(elf_file);
for (size_t i = 0; i < num_phdrs && i < max_phdrs; i++) {
diff --git a/libsel4utils/src/iommu_dma.c b/libsel4utils/src/iommu_dma.c
index 2673c7d..9282113 100644
--- a/libsel4utils/src/iommu_dma.c
+++ b/libsel4utils/src/iommu_dma.c
@@ -37,14 +37,14 @@
uintptr_t end = addr + size;
for (uintptr_t addr = start; addr < end; addr += PAGE_SIZE_4K) {
for (int i = 0; i < dma->num_iospaces; i++) {
- uintptr_t *cookie = (uintptr_t*)vspace_get_cookie(dma->iospaces + i, (void*)addr);
+ uintptr_t *cookie = (uintptr_t *)vspace_get_cookie(dma->iospaces + i, (void *)addr);
assert(cookie);
(*cookie)--;
if (*cookie == 0) {
- seL4_CPtr page = vspace_get_cap(dma->iospaces + i, (void*)addr);
+ seL4_CPtr page = vspace_get_cap(dma->iospaces + i, (void *)addr);
cspacepath_t page_path;
assert(page);
- vspace_unmap_pages(dma->iospaces + i, (void*)addr, 1, seL4_PageBits, NULL);
+ vspace_unmap_pages(dma->iospaces + i, (void *)addr, 1, seL4_PageBits, NULL);
vka_cspace_make_path(&dma->vka, page, &page_path);
vka_cnode_delete(&page_path);
vka_cspace_free(&dma->vka, page);
@@ -54,9 +54,9 @@
}
}
-int sel4utils_iommu_dma_alloc_iospace(void* cookie, void *vaddr, size_t size)
+int sel4utils_iommu_dma_alloc_iospace(void *cookie, void *vaddr, size_t size)
{
- dma_man_t *dma = (dma_man_t*)cookie;
+ dma_man_t *dma = (dma_man_t *)cookie;
int error;
/* for each page duplicate and map it into all the iospaces */
@@ -65,7 +65,7 @@
seL4_CPtr last_page = 0;
for (uintptr_t addr = start; addr < end; addr += PAGE_SIZE_4K) {
cspacepath_t page_path;
- seL4_CPtr page = vspace_get_cap(&dma->vspace, (void*)addr);
+ seL4_CPtr page = vspace_get_cap(&dma->vspace, (void *)addr);
if (!page) {
ZF_LOGE("Failed to retrieve frame cap for malloc region. "
"Is your malloc backed by the correct vspace? "
@@ -84,7 +84,7 @@
/* work out the size of this page */
for (int i = 0; i < dma->num_iospaces; i++) {
/* see if its already mapped */
- uintptr_t *cookie = (uintptr_t*)vspace_get_cookie(dma->iospaces + i, (void*)addr);
+ uintptr_t *cookie = (uintptr_t *)vspace_get_cookie(dma->iospaces + i, (void *)addr);
if (cookie) {
/* increment the counter */
(*cookie)++;
@@ -106,7 +106,7 @@
return -1;
}
/* now map it in */
- reservation_t res = vspace_reserve_range_at(dma->iospaces + i, (void*)addr, PAGE_SIZE_4K, seL4_AllRights, 1);
+ reservation_t res = vspace_reserve_range_at(dma->iospaces + i, (void *)addr, PAGE_SIZE_4K, seL4_AllRights, 1);
if (!res.res) {
ZF_LOGE("Failed to create a reservation");
vka_cnode_delete(©_path);
@@ -124,7 +124,8 @@
return -1;
}
*cookie = 1;
- error = vspace_map_pages_at_vaddr(dma->iospaces + i, ©_path.capPtr, (uintptr_t*)&cookie, (void*)addr, 1, seL4_PageBits, res);
+ error = vspace_map_pages_at_vaddr(dma->iospaces + i, ©_path.capPtr, (uintptr_t *)&cookie, (void *)addr, 1,
+ seL4_PageBits, res);
if (error) {
ZF_LOGE("Failed to map frame into iospace");
free(cookie);
@@ -142,7 +143,7 @@
return 0;
}
-static void* dma_alloc(void *cookie, size_t size, int align, int cached, ps_mem_flags_t flags)
+static void *dma_alloc(void *cookie, size_t size, int align, int cached, ps_mem_flags_t flags)
{
int error;
if (cached || flags != PS_MEM_NORMAL) {
@@ -192,7 +193,8 @@
#endif
}
-int sel4utils_make_iommu_dma_alloc(vka_t *vka, vspace_t *vspace, ps_dma_man_t *dma_man, unsigned int num_iospaces, seL4_CPtr *iospaces)
+int sel4utils_make_iommu_dma_alloc(vka_t *vka, vspace_t *vspace, ps_dma_man_t *dma_man, unsigned int num_iospaces,
+ seL4_CPtr *iospaces)
{
dma_man_t *dma = calloc(1, sizeof(*dma));
if (!dma) {
@@ -217,7 +219,8 @@
goto error;
}
for (unsigned int i = 0; i < num_iospaces; i++) {
- int err = sel4utils_get_vspace_with_map(&dma->vspace, dma->iospaces + i, dma->iospace_data + i, &dma->vka, iospaces[i], NULL, NULL, sel4utils_map_page_iommu);
+ int err = sel4utils_get_vspace_with_map(&dma->vspace, dma->iospaces + i, dma->iospace_data + i, &dma->vka, iospaces[i],
+ NULL, NULL, sel4utils_map_page_iommu);
if (err) {
for (unsigned int j = 0; j < i; j++) {
vspace_tear_down(dma->iospaces + i, &dma->vka);
diff --git a/libsel4utils/src/page_dma.c b/libsel4utils/src/page_dma.c
index 26d12a5..f63ca47 100644
--- a/libsel4utils/src/page_dma.c
+++ b/libsel4utils/src/page_dma.c
@@ -36,7 +36,7 @@
static void dma_free(void *cookie, void *addr, size_t size)
{
dma_man_t *dma = cookie;
- dma_alloc_t *alloc = (dma_alloc_t*)vspace_get_cookie(&dma->vspace, addr);
+ dma_alloc_t *alloc = (dma_alloc_t *)vspace_get_cookie(&dma->vspace, addr);
assert(alloc);
assert(alloc->base == addr);
int num_pages = BIT(alloc->ut.size_bits) / PAGE_SIZE_4K;
@@ -55,7 +55,7 @@
static uintptr_t dma_pin(void *cookie, void *addr, size_t size)
{
dma_man_t *dma = cookie;
- dma_alloc_t *alloc = (dma_alloc_t*)vspace_get_cookie(&dma->vspace, addr);
+ dma_alloc_t *alloc = (dma_alloc_t *)vspace_get_cookie(&dma->vspace, addr);
if (!alloc) {
return 0;
}
@@ -63,7 +63,7 @@
return alloc->paddr + diff;
}
-static void* dma_alloc(void *cookie, size_t size, int align, int cached, ps_mem_flags_t flags)
+static void *dma_alloc(void *cookie, size_t size, int align, int cached, ps_mem_flags_t flags)
{
dma_man_t *dma = cookie;
cspacepath_t *frames = NULL;
@@ -108,7 +108,8 @@
if (error) {
goto handle_error;
}
- error = seL4_Untyped_Retype(ut.cptr, kobject_get_type(KOBJECT_FRAME, PAGE_BITS_4K), size_bits, frames[i].root, frames[i].dest, frames[i].destDepth, frames[i].offset, 1);
+ error = seL4_Untyped_Retype(ut.cptr, kobject_get_type(KOBJECT_FRAME, PAGE_BITS_4K), size_bits, frames[i].root,
+ frames[i].dest, frames[i].destDepth, frames[i].offset, 1);
if (error != seL4_NoError) {
goto handle_error;
}
@@ -128,7 +129,8 @@
alloc->paddr = paddr;
/* Map in all the pages */
for (unsigned i = 0; i < num_frames; i++) {
- error = vspace_map_pages_at_vaddr(&dma->vspace, &frames[i].capPtr, (uintptr_t*)&alloc, base + i * PAGE_SIZE_4K, 1, PAGE_BITS_4K, res);
+ error = vspace_map_pages_at_vaddr(&dma->vspace, &frames[i].capPtr, (uintptr_t *)&alloc, base + i * PAGE_SIZE_4K, 1,
+ PAGE_BITS_4K, res);
if (error) {
goto handle_error;
}
diff --git a/libsel4utils/src/sel4_arch/aarch32/arch.c b/libsel4utils/src/sel4_arch/aarch32/arch.c
index 1135c3b..46d1723 100644
--- a/libsel4utils/src/sel4_arch/aarch32/arch.c
+++ b/libsel4utils/src/sel4_arch/aarch32/arch.c
@@ -18,8 +18,7 @@
#include <utils/stack.h>
#include <stdbool.h>
-int
-sel4utils_arch_init_context(void *entry_point, void *stack_top, seL4_UserContext *context)
+int sel4utils_arch_init_context(void *entry_point, void *stack_top, seL4_UserContext *context)
{
context->pc = (seL4_Word) entry_point;
context->sp = (seL4_Word) stack_top;
@@ -30,12 +29,11 @@
return 0;
}
-int
-sel4utils_arch_init_context_with_args(sel4utils_thread_entry_fn entry_point,
- void *arg0, void *arg1, void *arg2,
- bool local_stack, void *stack_top,
- seL4_UserContext *context,
- vka_t *vka, vspace_t *local_vspace, vspace_t *remote_vspace)
+int sel4utils_arch_init_context_with_args(sel4utils_thread_entry_fn entry_point,
+ void *arg0, void *arg1, void *arg2,
+ bool local_stack, void *stack_top,
+ seL4_UserContext *context,
+ vka_t *vka, vspace_t *local_vspace, vspace_t *remote_vspace)
{
context->r0 = (seL4_Word) arg0;
diff --git a/libsel4utils/src/sel4_arch/aarch64/arch.c b/libsel4utils/src/sel4_arch/aarch64/arch.c
index 98e63c5..d0b950e 100644
--- a/libsel4utils/src/sel4_arch/aarch64/arch.c
+++ b/libsel4utils/src/sel4_arch/aarch64/arch.c
@@ -19,8 +19,7 @@
#include <utils/stack.h>
#include <stdbool.h>
-int
-sel4utils_arch_init_context(void *entry_point, void *stack_top, seL4_UserContext *context)
+int sel4utils_arch_init_context(void *entry_point, void *stack_top, seL4_UserContext *context)
{
context->pc = (seL4_Word) entry_point;
context->sp = (seL4_Word) stack_top;
@@ -31,12 +30,11 @@
return 0;
}
-int
-sel4utils_arch_init_context_with_args(sel4utils_thread_entry_fn entry_point,
- void *arg0, void *arg1, void *arg2,
- bool local_stack, void *stack_top,
- seL4_UserContext *context,
- vka_t *vka, vspace_t *local_vspace, vspace_t *remote_vspace)
+int sel4utils_arch_init_context_with_args(sel4utils_thread_entry_fn entry_point,
+ void *arg0, void *arg1, void *arg2,
+ bool local_stack, void *stack_top,
+ seL4_UserContext *context,
+ vka_t *vka, vspace_t *local_vspace, vspace_t *remote_vspace)
{
context->x0 = (seL4_Word) arg0;
diff --git a/libsel4utils/src/sel4_arch/x86_64/arch.c b/libsel4utils/src/sel4_arch/x86_64/arch.c
index 7436dda..8d1653a 100644
--- a/libsel4utils/src/sel4_arch/x86_64/arch.c
+++ b/libsel4utils/src/sel4_arch/x86_64/arch.c
@@ -18,8 +18,7 @@
#include <utils/stack.h>
#include <stdbool.h>
-int
-sel4utils_arch_init_context(void *entry_point, void *stack_top, seL4_UserContext *context)
+int sel4utils_arch_init_context(void *entry_point, void *stack_top, seL4_UserContext *context)
{
context->rsp = (seL4_Word) stack_top;
/* set edx to zero in case we are setting this when spawning a process as
@@ -29,11 +28,10 @@
return 0;
}
-int
-sel4utils_arch_init_context_with_args(sel4utils_thread_entry_fn entry_point,
- void *arg0, void *arg1, void *arg2,
- bool local_stack, void *stack_top, seL4_UserContext *context,
- vka_t *vka, vspace_t *local_vspace, vspace_t *remote_vspace)
+int sel4utils_arch_init_context_with_args(sel4utils_thread_entry_fn entry_point,
+ void *arg0, void *arg1, void *arg2,
+ bool local_stack, void *stack_top, seL4_UserContext *context,
+ vka_t *vka, vspace_t *local_vspace, vspace_t *remote_vspace)
{
if (!IS_ALIGNED((uintptr_t)stack_top, STACK_CALL_ALIGNMENT_BITS)) {
@@ -45,7 +43,7 @@
* by entry_point, the stack pointer is aligned as if a return address had
* been pushed onto the stack, which is what the compiler assumes */
uintptr_t stack_top_after_call = (uintptr_t) stack_top - sizeof(uintptr_t);
- sel4utils_arch_init_context(entry_point, (void*)stack_top_after_call, context);
+ sel4utils_arch_init_context(entry_point, (void *)stack_top_after_call, context);
context->rdi = (seL4_Word) arg0;
context->rsi = (seL4_Word) arg1;
/* if we are setting args then we must not be spawning a process, therefore
diff --git a/libsel4utils/src/vspace/bootstrap.c b/libsel4utils/src/vspace/bootstrap.c
index 7220c60..655fdf2 100644
--- a/libsel4utils/src/vspace/bootstrap.c
+++ b/libsel4utils/src/vspace/bootstrap.c
@@ -39,9 +39,8 @@
#define VSPACE_RESERVE_SIZE (MID_LEVEL_STRUCTURES_SIZE + BOTTOM_LEVEL_STRUCTURES_SIZE + sizeof(vspace_mid_level_t))
#define VSPACE_RESERVE_START (KERNEL_RESERVED_START - VSPACE_RESERVE_SIZE)
-static int
-common_init(vspace_t *vspace, vka_t *vka, seL4_CPtr vspace_root,
- vspace_allocated_object_fn allocated_object_fn, void *cookie)
+static int common_init(vspace_t *vspace, vka_t *vka, seL4_CPtr vspace_root,
+ vspace_allocated_object_fn allocated_object_fn, void *cookie)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
data->vka = vka;
@@ -55,14 +54,13 @@
return 0;
}
-static void
-common_init_post_bootstrap(vspace_t *vspace, sel4utils_map_page_fn map_page)
+static void common_init_post_bootstrap(vspace_t *vspace, sel4utils_map_page_fn map_page)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
/* reserve the kernel region, we do this by marking the
* top level entry as RESERVED */
for (int i = TOP_LEVEL_INDEX(KERNEL_RESERVED_START);
- i < VSPACE_LEVEL_SIZE; i++) {
+ i < VSPACE_LEVEL_SIZE; i++) {
data->top_level->table[i] = RESERVED;
}
@@ -88,16 +86,17 @@
vspace->share_mem_at_vaddr = sel4utils_share_mem_at_vaddr;
}
-static void *alloc_and_map(vspace_t *vspace, size_t size) {
+static void *alloc_and_map(vspace_t *vspace, size_t size)
+{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
- if ( (size % PAGE_SIZE_4K) != 0) {
+ if ((size % PAGE_SIZE_4K) != 0) {
ZF_LOGE("Object must be multiple of base page size");
return NULL;
}
if (data->next_bootstrap_vaddr) {
- void *first_addr = (void*)data->next_bootstrap_vaddr;
+ void *first_addr = (void *)data->next_bootstrap_vaddr;
while (size > 0) {
- void *vaddr = (void*)data->next_bootstrap_vaddr;
+ void *vaddr = (void *)data->next_bootstrap_vaddr;
vka_object_t frame;
int error = vka_alloc_frame(data->vka, seL4_PageBits, &frame);
if (error) {
@@ -134,8 +133,7 @@
return NULL;
}
-static int
-reserve_range_bottom(vspace_t *vspace, vspace_bottom_level_t *level, uintptr_t start, uintptr_t end)
+static int reserve_range_bottom(vspace_t *vspace, vspace_bottom_level_t *level, uintptr_t start, uintptr_t end)
{
while (start < end) {
int index = INDEX_FOR_LEVEL(start, 0);
@@ -156,8 +154,7 @@
return 0;
}
-static int
-reserve_range_mid(vspace_t *vspace, vspace_mid_level_t *level, int level_num, uintptr_t start, uintptr_t end)
+static int reserve_range_mid(vspace_t *vspace, vspace_mid_level_t *level, int level_num, uintptr_t start, uintptr_t end)
{
/* walk entries at this level until we complete this range */
while (start < end) {
@@ -195,9 +192,9 @@
if (next_table != RESERVED) {
int error;
if (level_num == 1) {
- error = reserve_range_bottom(vspace, (vspace_bottom_level_t*)next_table, start, next_start);
+ error = reserve_range_bottom(vspace, (vspace_bottom_level_t *)next_table, start, next_start);
} else {
- error = reserve_range_mid(vspace, (vspace_mid_level_t*)next_table, level_num - 1, start, next_start);
+ error = reserve_range_mid(vspace, (vspace_mid_level_t *)next_table, level_num - 1, start, next_start);
}
if (error) {
return error;
@@ -208,8 +205,7 @@
return 0;
}
-static int
-reserve_range(vspace_t *vspace, uintptr_t start, uintptr_t end)
+static int reserve_range(vspace_t *vspace, uintptr_t start, uintptr_t end)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
return reserve_range_mid(vspace, data->top_level, VSPACE_NUM_LEVELS - 1, start, end);
@@ -220,8 +216,7 @@
* crt0.S or your linker script, such that we can figure out
* what virtual addresses are taken up by the current task
*/
-void
-sel4utils_get_image_region(uintptr_t *va_start, uintptr_t *va_end)
+void sel4utils_get_image_region(uintptr_t *va_start, uintptr_t *va_end)
{
extern char __executable_start[];
extern char _end[];
@@ -231,8 +226,7 @@
*va_end = (uintptr_t) ROUND_UP(*va_end, PAGE_SIZE_4K);
}
-static int
-reserve_initial_task_regions(vspace_t *vspace, void *existing_frames[])
+static int reserve_initial_task_regions(vspace_t *vspace, void *existing_frames[])
{
/* mark the code and data segments as used */
@@ -251,7 +245,7 @@
if (existing_frames != NULL) {
for (int i = 0; existing_frames[i] != NULL; i++) {
if (reserve_range(vspace, (uintptr_t) existing_frames[i], (uintptr_t) existing_frames[i]
- + PAGE_SIZE_4K)) {
+ + PAGE_SIZE_4K)) {
ZF_LOGE("Error reserving frame at %p", existing_frames[i]);
return -1;
}
@@ -268,8 +262,7 @@
* need to allocate memory to create structures to mark etc etc. To prevent this recursive
* dependency we will mark, right now, as reserved a region large enough such that we could
* allocate all possible book keeping tables from it */
-static int
-bootstrap_page_table(vspace_t *vspace)
+static int bootstrap_page_table(vspace_t *vspace)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
@@ -285,18 +278,16 @@
return 0;
}
-void *
-bootstrap_create_level(vspace_t *vspace, size_t size)
+void *bootstrap_create_level(vspace_t *vspace, size_t size)
{
return alloc_and_map(vspace, size);
}
/* Interface functions */
-int
-sel4utils_get_vspace_with_map(vspace_t *loader, vspace_t *new_vspace, sel4utils_alloc_data_t *data,
- vka_t *vka, seL4_CPtr vspace_root,
- vspace_allocated_object_fn allocated_object_fn, void *allocated_object_cookie, sel4utils_map_page_fn map_page)
+int sel4utils_get_vspace_with_map(vspace_t *loader, vspace_t *new_vspace, sel4utils_alloc_data_t *data,
+ vka_t *vka, seL4_CPtr vspace_root,
+ vspace_allocated_object_fn allocated_object_fn, void *allocated_object_cookie, sel4utils_map_page_fn map_page)
{
new_vspace->data = (void *) data;
@@ -318,12 +309,12 @@
return 0;
}
-int
-sel4utils_get_vspace(vspace_t *loader, vspace_t *new_vspace, sel4utils_alloc_data_t *data,
- vka_t *vka, seL4_CPtr vspace_root,
- vspace_allocated_object_fn allocated_object_fn, void *allocated_object_cookie)
+int sel4utils_get_vspace(vspace_t *loader, vspace_t *new_vspace, sel4utils_alloc_data_t *data,
+ vka_t *vka, seL4_CPtr vspace_root,
+ vspace_allocated_object_fn allocated_object_fn, void *allocated_object_cookie)
{
- return sel4utils_get_vspace_with_map(loader, new_vspace, data, vka, vspace_root, allocated_object_fn, allocated_object_cookie, sel4utils_map_page_pd);
+ return sel4utils_get_vspace_with_map(loader, new_vspace, data, vka, vspace_root, allocated_object_fn,
+ allocated_object_cookie, sel4utils_map_page_pd);
}
#ifdef CONFIG_VTX
@@ -335,14 +326,14 @@
return -1;
}
- return sel4utils_get_vspace_with_map(loader, new_vspace, data, vka, ept, allocated_object_fn, allocated_object_cookie, sel4utils_map_page_ept);
+ return sel4utils_get_vspace_with_map(loader, new_vspace, data, vka, ept, allocated_object_fn, allocated_object_cookie,
+ sel4utils_map_page_ept);
}
#endif /* CONFIG_VTX */
-int
-sel4utils_bootstrap_vspace(vspace_t *vspace, sel4utils_alloc_data_t *data,
- seL4_CPtr vspace_root, vka_t *vka,
- vspace_allocated_object_fn allocated_object_fn, void *cookie, void *existing_frames[])
+int sel4utils_bootstrap_vspace(vspace_t *vspace, sel4utils_alloc_data_t *data,
+ seL4_CPtr vspace_root, vka_t *vka,
+ vspace_allocated_object_fn allocated_object_fn, void *cookie, void *existing_frames[])
{
vspace->data = (void *) data;
@@ -365,21 +356,20 @@
return 0;
}
-int
-sel4utils_bootstrap_vspace_with_bootinfo(vspace_t *vspace, sel4utils_alloc_data_t *data,
- seL4_CPtr vspace_root,
- vka_t *vka, seL4_BootInfo *info, vspace_allocated_object_fn allocated_object_fn,
- void *allocated_object_cookie)
+int sel4utils_bootstrap_vspace_with_bootinfo(vspace_t *vspace, sel4utils_alloc_data_t *data,
+ seL4_CPtr vspace_root,
+ vka_t *vka, seL4_BootInfo *info, vspace_allocated_object_fn allocated_object_fn,
+ void *allocated_object_cookie)
{
size_t extra_pages = BYTES_TO_4K_PAGES(info->extraLen);
uintptr_t extra_base = (uintptr_t)info + PAGE_SIZE_4K;
void *existing_frames[extra_pages + 3];
existing_frames[0] = info;
/* We assume the IPC buffer is less than a page and fits into one page */
- existing_frames[1] = (void *) (seL4_Word)ROUND_DOWN(((seL4_Word)(info->ipcBuffer)), PAGE_SIZE_4K);
+ existing_frames[1] = (void *)(seL4_Word)ROUND_DOWN(((seL4_Word)(info->ipcBuffer)), PAGE_SIZE_4K);
size_t i;
for (i = 0; i < extra_pages; i++) {
- existing_frames[i + 2] = (void*)(extra_base + i * PAGE_SIZE_4K);
+ existing_frames[i + 2] = (void *)(extra_base + i * PAGE_SIZE_4K);
}
existing_frames[i + 2] = NULL;
@@ -387,8 +377,7 @@
allocated_object_cookie, existing_frames);
}
-int
-sel4utils_bootstrap_clone_into_vspace(vspace_t *current, vspace_t *clone, reservation_t image)
+int sel4utils_bootstrap_clone_into_vspace(vspace_t *current, vspace_t *clone, reservation_t image)
{
sel4utils_res_t *res = reservation_to_res(image);
seL4_CPtr slot;
diff --git a/libsel4utils/src/vspace/vspace.c b/libsel4utils/src/vspace/vspace.c
index 04d0550..032cfb8 100644
--- a/libsel4utils/src/vspace/vspace.c
+++ b/libsel4utils/src/vspace/vspace.c
@@ -27,8 +27,7 @@
#include <utils/util.h>
-void *
-create_level(vspace_t *vspace, size_t size)
+void *create_level(vspace_t *vspace, size_t size)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
@@ -50,22 +49,20 @@
}
/* check that vaddr is actually in the reservation */
-static int
-check_reservation_bounds(sel4utils_res_t *reservation, uintptr_t start, uintptr_t end)
+static int check_reservation_bounds(sel4utils_res_t *reservation, uintptr_t start, uintptr_t end)
{
return start >= reservation->start &&
end <= reservation->end;
}
-static int
-check_reservation(vspace_mid_level_t *top_level, sel4utils_res_t *reservation, uintptr_t start, uintptr_t end)
+static int check_reservation(vspace_mid_level_t *top_level, sel4utils_res_t *reservation, uintptr_t start,
+ uintptr_t end)
{
- return check_reservation_bounds(reservation, start,end) &&
- is_reserved_range(top_level, start,end);
+ return check_reservation_bounds(reservation, start, end) &&
+ is_reserved_range(top_level, start, end);
}
-static void
-insert_reservation(sel4utils_alloc_data_t *data, sel4utils_res_t *reservation)
+static void insert_reservation(sel4utils_alloc_data_t *data, sel4utils_res_t *reservation)
{
assert(data != NULL);
@@ -99,8 +96,7 @@
prev->next = reservation;
}
-static void
-remove_reservation(sel4utils_alloc_data_t *data, sel4utils_res_t *reservation)
+static void remove_reservation(sel4utils_alloc_data_t *data, sel4utils_res_t *reservation)
{
/* remove head */
if (reservation == data->reservation_head) {
@@ -128,9 +124,8 @@
reservation->next = NULL;
}
-static void
-perform_reservation(vspace_t *vspace, sel4utils_res_t *reservation, uintptr_t vaddr, size_t bytes,
- seL4_CapRights_t rights, int cacheable)
+static void perform_reservation(vspace_t *vspace, sel4utils_res_t *reservation, uintptr_t vaddr, size_t bytes,
+ seL4_CapRights_t rights, int cacheable)
{
assert(reservation != NULL);
@@ -150,9 +145,8 @@
insert_reservation(get_alloc_data(vspace), reservation);
}
-int
-sel4utils_map_page_pd(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights,
- int cacheable, size_t size_bits)
+int sel4utils_map_page_pd(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights,
+ int cacheable, size_t size_bits)
{
vka_object_t objects[VSPACE_MAP_PAGING_OBJECTS];
int num = VSPACE_MAP_PAGING_OBJECTS;
@@ -174,9 +168,8 @@
}
#ifdef CONFIG_VTX
-int
-sel4utils_map_page_ept(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights,
- int cacheable, size_t size_bits)
+int sel4utils_map_page_ept(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights,
+ int cacheable, size_t size_bits)
{
struct sel4utils_alloc_data *data = get_alloc_data(vspace);
vka_object_t pagetable = {0};
@@ -210,9 +203,8 @@
#endif /* CONFIG_VTX */
#ifdef CONFIG_IOMMU
-int
-sel4utils_map_page_iommu(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights,
- int cacheable, size_t size_bits)
+int sel4utils_map_page_iommu(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights,
+ int cacheable, size_t size_bits)
{
struct sel4utils_alloc_data *data = get_alloc_data(vspace);
int num_pts = 0;
@@ -234,16 +226,14 @@
}
#endif /* CONFIG_IOMMU */
-static int
-map_page(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights,
- int cacheable, size_t size_bits)
+static int map_page(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights,
+ int cacheable, size_t size_bits)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
return data->map_page(vspace, cap, vaddr, rights, cacheable, size_bits);
}
-static sel4utils_res_t *
-find_reserve(sel4utils_alloc_data_t *data, uintptr_t vaddr)
+static sel4utils_res_t *find_reserve(sel4utils_alloc_data_t *data, uintptr_t vaddr)
{
sel4utils_res_t *current = data->reservation_head;
@@ -259,8 +249,7 @@
return NULL;
}
-static void *
-find_range(sel4utils_alloc_data_t *data, size_t num_pages, size_t size_bits)
+static void *find_range(sel4utils_alloc_data_t *data, size_t num_pages, size_t size_bits)
{
/* look for a contiguous range that is free.
* We use first-fit with the optimisation that we store
@@ -296,10 +285,9 @@
return (void *) start;
}
-static int
-map_pages_at_vaddr(vspace_t *vspace, seL4_CPtr caps[], uintptr_t cookies[],
- void *vaddr, size_t num_pages,
- size_t size_bits, seL4_CapRights_t rights, int cacheable)
+static int map_pages_at_vaddr(vspace_t *vspace, seL4_CPtr caps[], uintptr_t cookies[],
+ void *vaddr, size_t num_pages,
+ size_t size_bits, seL4_CapRights_t rights, int cacheable)
{
int error = seL4_NoError;
@@ -309,15 +297,14 @@
if (error == seL4_NoError) {
uintptr_t cookie = cookies == NULL ? 0 : cookies[i];
error = update_entries(vspace, (uintptr_t) vaddr, caps[i], size_bits, cookie);
- vaddr = (void *) ((uintptr_t) vaddr + (BIT(size_bits)));
+ vaddr = (void *)((uintptr_t) vaddr + (BIT(size_bits)));
}
}
return error;
}
-static int
-new_pages_at_vaddr(vspace_t *vspace, void *vaddr, size_t num_pages, size_t size_bits,
- seL4_CapRights_t rights, int cacheable, bool can_use_dev)
+static int new_pages_at_vaddr(vspace_t *vspace, void *vaddr, size_t num_pages, size_t size_bits,
+ seL4_CapRights_t rights, int cacheable, bool can_use_dev)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
int i;
@@ -337,7 +324,7 @@
if (error == seL4_NoError) {
error = update_entries(vspace, (uintptr_t) vaddr, object.cptr, size_bits, object.ut);
- vaddr = (void *) ((uintptr_t) vaddr + (BIT(size_bits)));
+ vaddr = (void *)((uintptr_t) vaddr + (BIT(size_bits)));
} else {
vka_free_object(data->vka, &object);
break;
@@ -354,9 +341,8 @@
/* VSPACE INTERFACE FUNCTIONS */
-int
-sel4utils_map_pages_at_vaddr(vspace_t *vspace, seL4_CPtr caps[], uintptr_t cookies[], void *vaddr,
- size_t num_pages, size_t size_bits, reservation_t reservation)
+int sel4utils_map_pages_at_vaddr(vspace_t *vspace, seL4_CPtr caps[], uintptr_t cookies[], void *vaddr,
+ size_t num_pages, size_t size_bits, reservation_t reservation)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
sel4utils_res_t *res = reservation_to_res(reservation);
@@ -375,10 +361,9 @@
res->rights, res->cacheable);
}
-void *
-sel4utils_map_pages(vspace_t *vspace, seL4_CPtr caps[], uintptr_t cookies[],
- seL4_CapRights_t rights, size_t num_pages, size_t size_bits,
- int cacheable)
+void *sel4utils_map_pages(vspace_t *vspace, seL4_CPtr caps[], uintptr_t cookies[],
+ seL4_CapRights_t rights, size_t num_pages, size_t size_bits,
+ int cacheable)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
int error;
@@ -405,8 +390,7 @@
return ret_vaddr;
}
-seL4_CPtr
-sel4utils_get_cap(vspace_t *vspace, void *vaddr)
+seL4_CPtr sel4utils_get_cap(vspace_t *vspace, void *vaddr)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
seL4_CPtr cap = get_cap(data->top_level, (uintptr_t) vaddr);
@@ -417,15 +401,13 @@
return cap;
}
-uintptr_t
-sel4utils_get_cookie(vspace_t *vspace, void *vaddr)
+uintptr_t sel4utils_get_cookie(vspace_t *vspace, void *vaddr)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
return get_cookie(data->top_level, (uintptr_t) vaddr);
}
-void
-sel4utils_unmap_pages(vspace_t *vspace, void *vaddr, size_t num_pages, size_t size_bits, vka_t *vka)
+void sel4utils_unmap_pages(vspace_t *vspace, void *vaddr, size_t num_pages, size_t size_bits, vka_t *vka)
{
uintptr_t v = (uintptr_t) vaddr;
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
@@ -458,7 +440,7 @@
vka_cspace_free(vka, cap);
if (sel4utils_get_cookie(vspace, vaddr)) {
vka_utspace_free(vka, kobject_get_type(KOBJECT_FRAME, size_bits),
- size_bits, sel4utils_get_cookie(vspace, vaddr));
+ size_bits, sel4utils_get_cookie(vspace, vaddr));
}
}
@@ -475,9 +457,8 @@
}
}
-int
-sel4utils_new_pages_at_vaddr(vspace_t *vspace, void *vaddr, size_t num_pages,
- size_t size_bits, reservation_t reservation, bool can_use_dev)
+int sel4utils_new_pages_at_vaddr(vspace_t *vspace, void *vaddr, size_t num_pages,
+ size_t size_bits, reservation_t reservation, bool can_use_dev)
{
struct sel4utils_alloc_data *data = get_alloc_data(vspace);
sel4utils_res_t *res = reservation_to_res(reservation);
@@ -490,9 +471,8 @@
return new_pages_at_vaddr(vspace, vaddr, num_pages, size_bits, res->rights, res->cacheable, can_use_dev);
}
-void *
-sel4utils_new_pages(vspace_t *vspace, seL4_CapRights_t rights,
- size_t num_pages, size_t size_bits)
+void *sel4utils_new_pages(vspace_t *vspace, seL4_CapRights_t rights,
+ size_t num_pages, size_t size_bits)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
int error;
@@ -550,9 +530,8 @@
rights, cacheable, result);
}
-reservation_t
-sel4utils_reserve_range_aligned(vspace_t *vspace, size_t bytes, size_t size_bits, seL4_CapRights_t rights,
- int cacheable, void **result)
+reservation_t sel4utils_reserve_range_aligned(vspace_t *vspace, size_t bytes, size_t size_bits, seL4_CapRights_t rights,
+ int cacheable, void **result)
{
reservation_t reservation = {
.res = NULL,
@@ -587,7 +566,7 @@
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
if (!is_available_range(data->top_level, (uintptr_t) vaddr, (uintptr_t)vaddr + size)) {
- ZF_LOGE("Range not available at %p, size %p", vaddr, (void*)size);
+ ZF_LOGE("Range not available at %p, size %p", vaddr, (void *)size);
return -1;
}
reservation->malloced = 0;
@@ -595,9 +574,8 @@
return 0;
}
-reservation_t
-sel4utils_reserve_range_at(vspace_t *vspace, void *vaddr, size_t size, seL4_CapRights_t
- rights, int cacheable)
+reservation_t sel4utils_reserve_range_at(vspace_t *vspace, void *vaddr, size_t size, seL4_CapRights_t
+ rights, int cacheable)
{
reservation_t reservation;
reservation.res = malloc(sizeof(sel4utils_res_t));
@@ -619,8 +597,7 @@
return reservation;
}
-void
-sel4utils_free_reservation(vspace_t *vspace, reservation_t reservation)
+void sel4utils_free_reservation(vspace_t *vspace, reservation_t reservation)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
sel4utils_res_t *res = reservation.res;
@@ -632,8 +609,7 @@
}
}
-void
-sel4utils_free_reservation_by_vaddr(vspace_t *vspace, void *vaddr)
+void sel4utils_free_reservation_by_vaddr(vspace_t *vspace, void *vaddr)
{
reservation_t reservation;
@@ -641,16 +617,15 @@
sel4utils_free_reservation(vspace, reservation);
}
-int
-sel4utils_move_resize_reservation(vspace_t *vspace, reservation_t reservation, void *vaddr,
- size_t bytes)
+int sel4utils_move_resize_reservation(vspace_t *vspace, reservation_t reservation, void *vaddr,
+ size_t bytes)
{
assert(reservation.res != NULL);
sel4utils_res_t *res = reservation.res;
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
uintptr_t new_start = ROUND_DOWN((uintptr_t) vaddr, PAGE_SIZE_4K);
- uintptr_t new_end = ROUND_UP(((uintptr_t) (vaddr)) + bytes, PAGE_SIZE_4K);
+ uintptr_t new_end = ROUND_UP(((uintptr_t)(vaddr)) + bytes, PAGE_SIZE_4K);
uintptr_t v = 0;
/* Sanity checks that newly asked reservation space is available. */
@@ -704,14 +679,14 @@
return 0;
}
-seL4_CPtr
-sel4utils_get_root(vspace_t *vspace)
+seL4_CPtr sel4utils_get_root(vspace_t *vspace)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
return data->vspace_root;
}
-static void free_page(vspace_t *vspace, vka_t *vka, uintptr_t vaddr) {
+static void free_page(vspace_t *vspace, vka_t *vka, uintptr_t vaddr)
+{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
vspace_mid_level_t *level = data->top_level;
/* see if we should free the thing here or not */
@@ -724,12 +699,12 @@
test_vaddr += PAGE_SIZE_4K;
num_4k_entries++;
}
- sel4utils_unmap_pages(vspace, (void*)vaddr, 1, PAGE_BITS_4K * num_4k_entries, vka);
+ sel4utils_unmap_pages(vspace, (void *)vaddr, 1, PAGE_BITS_4K * num_4k_entries, vka);
}
}
-static void
-free_pages_at_level(vspace_t *vspace, vka_t *vka, int table_level, uintptr_t vaddr) {
+static void free_pages_at_level(vspace_t *vspace, vka_t *vka, int table_level, uintptr_t vaddr)
+{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
vspace_mid_level_t *level = data->top_level;
/* walk down to the level that we want */
@@ -740,7 +715,7 @@
case EMPTY:
return;
}
- level = (vspace_mid_level_t*)level->table[index];
+ level = (vspace_mid_level_t *)level->table[index];
}
if (table_level == 0) {
int index = INDEX_FOR_LEVEL(vaddr, 1);
@@ -749,7 +724,7 @@
case EMPTY:
return;
}
- vspace_bottom_level_t *bottom = (vspace_bottom_level_t*)level->table[index];
+ vspace_bottom_level_t *bottom = (vspace_bottom_level_t *)level->table[index];
index = INDEX_FOR_LEVEL(vaddr, 0);
if (bottom->cap[index] != EMPTY && bottom->cap[index] != RESERVED) {
free_page(vspace, vka, vaddr);
@@ -767,13 +742,13 @@
table_level - 1,
vaddr + j * BYTES_FOR_LEVEL(table_level - 1));
}
- vspace_unmap_pages(data->bootstrap, (void*)level->table[index],
- (table_level == 1 ? sizeof(vspace_bottom_level_t) : sizeof(vspace_mid_level_t)) / PAGE_SIZE_4K, PAGE_BITS_4K, VSPACE_FREE);
+ vspace_unmap_pages(data->bootstrap, (void *)level->table[index],
+ (table_level == 1 ? sizeof(vspace_bottom_level_t) : sizeof(vspace_mid_level_t)) / PAGE_SIZE_4K, PAGE_BITS_4K,
+ VSPACE_FREE);
}
}
-void
-sel4utils_tear_down(vspace_t *vspace, vka_t *vka)
+void sel4utils_tear_down(vspace_t *vspace, vka_t *vka)
{
sel4utils_alloc_data_t *data = get_alloc_data(vspace);
@@ -798,13 +773,13 @@
for (int i = 0; i < BIT(VSPACE_LEVEL_BITS); i++) {
free_pages_at_level(vspace, vka, VSPACE_NUM_LEVELS - 1, BYTES_FOR_LEVEL(VSPACE_NUM_LEVELS - 1) * i);
}
- vspace_unmap_pages(data->bootstrap, data->top_level, sizeof(vspace_mid_level_t) / PAGE_SIZE_4K, PAGE_BITS_4K, VSPACE_FREE);
+ vspace_unmap_pages(data->bootstrap, data->top_level, sizeof(vspace_mid_level_t) / PAGE_SIZE_4K, PAGE_BITS_4K,
+ VSPACE_FREE);
}
}
-int
-sel4utils_share_mem_at_vaddr(vspace_t *from, vspace_t *to, void *start, int num_pages,
- size_t size_bits, void *vaddr, reservation_t reservation)
+int sel4utils_share_mem_at_vaddr(vspace_t *from, vspace_t *to, void *start, int num_pages,
+ size_t size_bits, void *vaddr, reservation_t reservation)
{
int error = 0; /* no error */
sel4utils_alloc_data_t *from_data = get_alloc_data(from);
@@ -868,8 +843,7 @@
return error;
}
-uintptr_t
-sel4utils_get_paddr(vspace_t *vspace, void *vaddr, seL4_Word type, seL4_Word size_bits)
+uintptr_t sel4utils_get_paddr(vspace_t *vspace, void *vaddr, seL4_Word type, seL4_Word size_bits)
{
vka_t *vka = get_alloc_data(vspace)->vka;
return vka_utspace_paddr(vka, vspace_get_cookie(vspace, vaddr), type, size_bits);
diff --git a/libsel4vka/arch_include/arm/vka/arch/kobject_t.h b/libsel4vka/arch_include/arm/vka/arch/kobject_t.h
index eab4016..2dc4a50 100644
--- a/libsel4vka/arch_include/arm/vka/arch/kobject_t.h
+++ b/libsel4vka/arch_include/arm/vka/arch/kobject_t.h
@@ -29,33 +29,31 @@
* Get the size (in bits) of the untyped memory required to
* create an object of the given size
*/
-static inline seL4_Word
-arch_kobject_get_size(kobject_t type, seL4_Word objectSize)
+static inline seL4_Word arch_kobject_get_size(kobject_t type, seL4_Word objectSize)
{
switch (type) {
- /* ARM-specific frames. */
+ /* ARM-specific frames. */
case KOBJECT_FRAME:
switch (objectSize) {
case seL4_PageBits:
case seL4_LargePageBits:
return objectSize;
}
- /* If frame size was unknown fall through to default case as it
- * might be a mode specific frame size */
+ /* If frame size was unknown fall through to default case as it
+ * might be a mode specific frame size */
default:
return arm_mode_kobject_get_size(type, objectSize);
}
}
-static inline seL4_Word
-arch_kobject_get_type(kobject_t type, seL4_Word objectSize)
+static inline seL4_Word arch_kobject_get_type(kobject_t type, seL4_Word objectSize)
{
switch (type) {
case KOBJECT_PAGE_DIRECTORY:
return seL4_ARM_PageDirectoryObject;
case KOBJECT_PAGE_TABLE:
return seL4_ARM_PageTableObject;
- /* ARM-specific frames. */
+ /* ARM-specific frames. */
case KOBJECT_FRAME:
switch (objectSize) {
case seL4_PageBits:
diff --git a/libsel4vka/arch_include/riscv/vka/arch/kobject_t.h b/libsel4vka/arch_include/riscv/vka/arch/kobject_t.h
index 046db5f..1be3976 100644
--- a/libsel4vka/arch_include/riscv/vka/arch/kobject_t.h
+++ b/libsel4vka/arch_include/riscv/vka/arch/kobject_t.h
@@ -31,8 +31,7 @@
* Get the size (in bits) of the untyped memory required to
* create an object of the given size.
*/
-static inline seL4_Word
-arch_kobject_get_size(kobject_t type, seL4_Word objectSize)
+static inline seL4_Word arch_kobject_get_size(kobject_t type, seL4_Word objectSize)
{
switch (type) {
case KOBJECT_FRAME:
@@ -41,8 +40,8 @@
case seL4_LargePageBits:
return objectSize;
}
- /* If frame size was unknown fall through to default case as it
- * might be a mode specific frame size */
+ /* If frame size was unknown fall through to default case as it
+ * might be a mode specific frame size */
default:
ZF_LOGE("Unknown object type");
return 0;
@@ -50,8 +49,7 @@
}
-static inline seL4_Word
-arch_kobject_get_type(int type, seL4_Word objectSize)
+static inline seL4_Word arch_kobject_get_type(int type, seL4_Word objectSize)
{
switch (type) {
case KOBJECT_PAGE_DIRECTORY:
@@ -76,8 +74,8 @@
return -1;
}
default:
- ZF_LOGE("Unknown object type %d", type);
- return -1;
+ ZF_LOGE("Unknown object type %d", type);
+ return -1;
}
}
diff --git a/libsel4vka/arch_include/x86/vka/arch/kobject_t.h b/libsel4vka/arch_include/x86/vka/arch/kobject_t.h
index 8497806..ee3f31e 100644
--- a/libsel4vka/arch_include/x86/vka/arch/kobject_t.h
+++ b/libsel4vka/arch_include/x86/vka/arch/kobject_t.h
@@ -30,8 +30,7 @@
* Get the size (in bits) of the untyped memory required to
* create an object of the given size.
*/
-static inline seL4_Word
-arch_kobject_get_size(kobject_t type, seL4_Word objectSize)
+static inline seL4_Word arch_kobject_get_size(kobject_t type, seL4_Word objectSize)
{
switch (type) {
case KOBJECT_IO_PAGETABLE:
@@ -42,15 +41,14 @@
case seL4_LargePageBits:
return objectSize;
}
- /* If frame size was unknown fall through to default case as it
- * might be a mode specific frame size */
+ /* If frame size was unknown fall through to default case as it
+ * might be a mode specific frame size */
default:
return x86_mode_kobject_get_size(type, objectSize);
}
}
-static inline seL4_Word
-arch_kobject_get_type(int type, seL4_Word objectSize)
+static inline seL4_Word arch_kobject_get_type(int type, seL4_Word objectSize)
{
switch (type) {
case KOBJECT_PAGE_DIRECTORY:
diff --git a/libsel4vka/include/vka/capops.h b/libsel4vka/include/vka/capops.h
index b04c535..d684884 100644
--- a/libsel4vka/include/vka/capops.h
+++ b/libsel4vka/include/vka/capops.h
@@ -24,8 +24,7 @@
#include <vka/object.h>
#ifndef CONFIG_KERNEL_RT
-static inline int
-vka_cnode_saveCaller(const cspacepath_t* src)
+static inline int vka_cnode_saveCaller(const cspacepath_t *src)
{
return seL4_CNode_SaveCaller(
/* _service */ src->root,
@@ -35,8 +34,7 @@
}
#endif
-static inline int
-vka_cnode_copy(const cspacepath_t* dest, const cspacepath_t* src, seL4_CapRights_t rights)
+static inline int vka_cnode_copy(const cspacepath_t *dest, const cspacepath_t *src, seL4_CapRights_t rights)
{
return seL4_CNode_Copy(
/* _service */ dest->root,
@@ -49,8 +47,7 @@
);
}
-static inline int
-vka_cnode_delete(const cspacepath_t* src)
+static inline int vka_cnode_delete(const cspacepath_t *src)
{
return seL4_CNode_Delete(
/* _service */ src->root,
@@ -59,9 +56,8 @@
);
}
-static inline int
-vka_cnode_mint(const cspacepath_t* dest, const cspacepath_t* src,
- seL4_CapRights_t rights, seL4_Word badge)
+static inline int vka_cnode_mint(const cspacepath_t *dest, const cspacepath_t *src,
+ seL4_CapRights_t rights, seL4_Word badge)
{
return seL4_CNode_Mint(
/* _service */ dest->root,
@@ -75,8 +71,7 @@
);
}
-static inline int
-vka_cnode_move(const cspacepath_t* dest, const cspacepath_t* src)
+static inline int vka_cnode_move(const cspacepath_t *dest, const cspacepath_t *src)
{
return seL4_CNode_Move(
/* _service */ dest->root,
@@ -88,9 +83,8 @@
);
}
-static inline int
-vka_cnode_mutate(const cspacepath_t* dest, const cspacepath_t* src,
- seL4_Word badge)
+static inline int vka_cnode_mutate(const cspacepath_t *dest, const cspacepath_t *src,
+ seL4_Word badge)
{
return seL4_CNode_Mutate(
/* _service */ dest->root,
@@ -103,8 +97,7 @@
);
}
-static inline int
-vka_cnode_cancelBadgedSends(const cspacepath_t* src)
+static inline int vka_cnode_cancelBadgedSends(const cspacepath_t *src)
{
return seL4_CNode_CancelBadgedSends(
/* _service */ src->root,
@@ -113,8 +106,7 @@
);
}
-static inline int
-vka_cnode_revoke(const cspacepath_t* src)
+static inline int vka_cnode_revoke(const cspacepath_t *src)
{
return seL4_CNode_Revoke(
/* _service */ src->root,
@@ -123,9 +115,8 @@
);
}
-static inline int
-vka_cnode_rotate(const cspacepath_t *dest, seL4_Word dest_badge, const cspacepath_t *pivot,
- seL4_Word pivot_badge, const cspacepath_t *src)
+static inline int vka_cnode_rotate(const cspacepath_t *dest, seL4_Word dest_badge, const cspacepath_t *pivot,
+ seL4_Word pivot_badge, const cspacepath_t *src)
{
return seL4_CNode_Rotate(dest->root, dest->capPtr, dest->capDepth, dest_badge,
pivot->root, pivot->capPtr, pivot->capDepth, pivot_badge,
@@ -139,10 +130,11 @@
*
* size_bits is only relevant for dynamically sized objects - untypeds + captables
*/
-static inline int
-vka_untyped_retype(vka_object_t *untyped, int type, int size_bits, int num_objects, const cspacepath_t *dest)
+static inline int vka_untyped_retype(vka_object_t *untyped, int type, int size_bits, int num_objects,
+ const cspacepath_t *dest)
{
size_bits = vka_get_object_size(type, size_bits);
- return seL4_Untyped_Retype(untyped->cptr, type, size_bits, dest->root, dest->dest, dest->destDepth, dest->offset, num_objects);
+ return seL4_Untyped_Retype(untyped->cptr, type, size_bits, dest->root, dest->dest, dest->destDepth, dest->offset,
+ num_objects);
}
diff --git a/libsel4vka/include/vka/ipcbuffer.h b/libsel4vka/include/vka/ipcbuffer.h
index 95684ad..3156280 100644
--- a/libsel4vka/include/vka/ipcbuffer.h
+++ b/libsel4vka/include/vka/ipcbuffer.h
@@ -18,12 +18,11 @@
#include <vka/cspacepath_t.h>
#include <vka/object.h>
-static inline void
-vka_set_cap_receive_path(const cspacepath_t* src)
+static inline void vka_set_cap_receive_path(const cspacepath_t *src)
{
seL4_SetCapReceivePath(
- /* _service */ src->root,
- /* index */ src->capPtr,
- /* depth */ src->capDepth
- );
+ /* _service */ src->root,
+ /* index */ src->capPtr,
+ /* depth */ src->capDepth
+ );
}
diff --git a/libsel4vka/include/vka/kobject_t.h b/libsel4vka/include/vka/kobject_t.h
index 6b6f9c5..cad1865 100644
--- a/libsel4vka/include/vka/kobject_t.h
+++ b/libsel4vka/include/vka/kobject_t.h
@@ -44,11 +44,10 @@
* Get the size (in bits) of the untyped memory required to
* create an object of the given size.
*/
-static inline seL4_Word
-kobject_get_size(kobject_t type, seL4_Word objectSize)
+static inline seL4_Word kobject_get_size(kobject_t type, seL4_Word objectSize)
{
switch (type) {
- /* Generic objects. */
+ /* Generic objects. */
case KOBJECT_TCB:
return seL4_TCBBits;
case KOBJECT_CNODE:
@@ -80,11 +79,10 @@
}
}
-static inline seL4_Word
-kobject_get_type(kobject_t type, seL4_Word objectSize)
+static inline seL4_Word kobject_get_type(kobject_t type, seL4_Word objectSize)
{
switch (type) {
- /* Generic objects. */
+ /* Generic objects. */
case KOBJECT_TCB:
return seL4_TCBObject;
case KOBJECT_CNODE:
diff --git a/libsel4vka/include/vka/vka.h b/libsel4vka/include/vka/vka.h
index 48c767a..542c7cd 100644
--- a/libsel4vka/include/vka/vka.h
+++ b/libsel4vka/include/vka/vka.h
@@ -59,7 +59,8 @@
* @param res pointer to a location to store the cookie representing this allocation
* @return 0 on success
*/
-typedef int (*vka_utspace_alloc_fn)(void *data, const cspacepath_t *dest, seL4_Word type, seL4_Word size_bits, seL4_Word *res);
+typedef int (*vka_utspace_alloc_fn)(void *data, const cspacepath_t *dest, seL4_Word type, seL4_Word size_bits,
+ seL4_Word *res);
/**
* Allocate a portion of an untyped into an object
@@ -72,7 +73,8 @@
* @param cookie pointer to a location to store the cookie representing this allocation
* @return 0 on success
*/
-typedef int (*vka_utspace_alloc_at_fn)(void *data, const cspacepath_t *dest, seL4_Word type, seL4_Word size_bits, uintptr_t paddr, seL4_Word *cookie);
+typedef int (*vka_utspace_alloc_at_fn)(void *data, const cspacepath_t *dest, seL4_Word type, seL4_Word size_bits,
+ uintptr_t paddr, seL4_Word *cookie);
/**
* Allocate a portion of an untyped into an object
@@ -85,7 +87,8 @@
* @param res pointer to a location to store the cookie representing this allocation
* @return 0 on success
*/
-typedef int (*vka_utspace_alloc_maybe_device_fn)(void *data, const cspacepath_t *dest, seL4_Word type, seL4_Word size_bits, bool can_use_dev, seL4_Word *res);
+typedef int (*vka_utspace_alloc_maybe_device_fn)(void *data, const cspacepath_t *dest, seL4_Word type,
+ seL4_Word size_bits, bool can_use_dev, seL4_Word *res);
/**
* Free a portion of an allocated untyped. Is the responsibility of the caller to
@@ -133,8 +136,7 @@
vka_utspace_paddr_fn utspace_paddr;
} vka_t;
-static inline int
-vka_cspace_alloc(vka_t *vka, seL4_CPtr *res)
+static inline int vka_cspace_alloc(vka_t *vka, seL4_CPtr *res)
{
if (!vka) {
ZF_LOGE("vka is NULL");
@@ -154,8 +156,7 @@
return vka->cspace_alloc(vka->data, res);
}
-static inline void
-vka_cspace_make_path(vka_t *vka, seL4_CPtr slot, cspacepath_t *res)
+static inline void vka_cspace_make_path(vka_t *vka, seL4_CPtr slot, cspacepath_t *res)
{
if (!res) {
@@ -176,8 +177,7 @@
/*
* Wrapper functions to make calls more convenient
*/
-static inline int
-vka_cspace_alloc_path(vka_t *vka, cspacepath_t *res)
+static inline int vka_cspace_alloc_path(vka_t *vka, cspacepath_t *res)
{
seL4_CPtr slot;
int error = vka_cspace_alloc(vka, &slot);
@@ -189,8 +189,7 @@
return error;
}
-static inline void
-vka_cspace_free(vka_t *vka, seL4_CPtr slot)
+static inline void vka_cspace_free(vka_t *vka, seL4_CPtr slot)
{
#ifdef CONFIG_DEBUG_BUILD
if (seL4_DebugCapIdentify(slot) != 0) {
@@ -207,14 +206,13 @@
vka->cspace_free(vka->data, slot);
}
-static inline void
-vka_cspace_free_path(vka_t *vka, cspacepath_t path)
+static inline void vka_cspace_free_path(vka_t *vka, cspacepath_t path)
{
vka_cspace_free(vka, path.capPtr);
}
-static inline int
-vka_utspace_alloc(vka_t *vka, const cspacepath_t *dest, seL4_Word type, seL4_Word size_bits, seL4_Word *res)
+static inline int vka_utspace_alloc(vka_t *vka, const cspacepath_t *dest, seL4_Word type, seL4_Word size_bits,
+ seL4_Word *res)
{
if (!vka) {
ZF_LOGE("vka is NULL");
@@ -234,9 +232,8 @@
return vka->utspace_alloc(vka->data, dest, type, size_bits, res);
}
-static inline int
-vka_utspace_alloc_maybe_device(vka_t *vka, const cspacepath_t *dest, seL4_Word type,
- seL4_Word size_bits, bool can_use_dev, seL4_Word *res)
+static inline int vka_utspace_alloc_maybe_device(vka_t *vka, const cspacepath_t *dest, seL4_Word type,
+ seL4_Word size_bits, bool can_use_dev, seL4_Word *res)
{
if (!vka) {
ZF_LOGE("vka is NULL");
@@ -256,9 +253,8 @@
return vka->utspace_alloc_maybe_device(vka->data, dest, type, size_bits, can_use_dev, res);
}
-static inline int
-vka_utspace_alloc_at(vka_t *vka, const cspacepath_t *dest, seL4_Word type, seL4_Word size_bits,
- uintptr_t paddr, seL4_Word *cookie)
+static inline int vka_utspace_alloc_at(vka_t *vka, const cspacepath_t *dest, seL4_Word type, seL4_Word size_bits,
+ uintptr_t paddr, seL4_Word *cookie)
{
if (!vka) {
ZF_LOGE("vka is NULL");
@@ -276,8 +272,7 @@
return vka->utspace_alloc_at(vka->data, dest, type, size_bits, paddr, cookie);
}
-static inline void
-vka_utspace_free(vka_t *vka, seL4_Word type, seL4_Word size_bits, seL4_Word target)
+static inline void vka_utspace_free(vka_t *vka, seL4_Word type, seL4_Word size_bits, seL4_Word target)
{
if (!vka) {
ZF_LOGE("vka is NULL");
@@ -295,8 +290,7 @@
vka->utspace_free(vka->data, type, size_bits, target);
}
-static inline uintptr_t
-vka_utspace_paddr(vka_t *vka, seL4_Word target, seL4_Word type, seL4_Word size_bits)
+static inline uintptr_t vka_utspace_paddr(vka_t *vka, seL4_Word target, seL4_Word type, seL4_Word size_bits)
{
if (!vka) {
diff --git a/libsel4vka/sel4_arch_include/aarch32/vka/sel4_arch/kobject_t.h b/libsel4vka/sel4_arch_include/aarch32/vka/sel4_arch/kobject_t.h
index a2ec217..17b5d37 100644
--- a/libsel4vka/sel4_arch_include/aarch32/vka/sel4_arch/kobject_t.h
+++ b/libsel4vka/sel4_arch_include/aarch32/vka/sel4_arch/kobject_t.h
@@ -29,11 +29,10 @@
* Get the size (in bits) of the untyped memory required to
* create an object of the given size
*/
-static inline seL4_Word
-arm_mode_kobject_get_size(kobject_t type, seL4_Word objectSize)
+static inline seL4_Word arm_mode_kobject_get_size(kobject_t type, seL4_Word objectSize)
{
switch (type) {
- /* ARM-specific frames. */
+ /* ARM-specific frames. */
case KOBJECT_FRAME:
switch (objectSize) {
case seL4_SectionBits:
@@ -49,8 +48,7 @@
}
}
-static inline seL4_Word
-arm_mode_kobject_get_type(kobject_t type, seL4_Word objectSize)
+static inline seL4_Word arm_mode_kobject_get_type(kobject_t type, seL4_Word objectSize)
{
switch (type) {
case KOBJECT_FRAME:
diff --git a/libsel4vka/sel4_arch_include/aarch32/vka/sel4_arch/object.h b/libsel4vka/sel4_arch_include/aarch32/vka/sel4_arch/object.h
index 53c784d..783722a 100644
--- a/libsel4vka/sel4_arch_include/aarch32/vka/sel4_arch/object.h
+++ b/libsel4vka/sel4_arch_include/aarch32/vka/sel4_arch/object.h
@@ -27,8 +27,7 @@
* Get the size (in bits) of the untyped memory required to create an object of
* the given size.
*/
-static inline unsigned long
-vka_arm_mode_get_object_size(seL4_Word objectType)
+static inline unsigned long vka_arm_mode_get_object_size(seL4_Word objectType)
{
switch (objectType) {
case seL4_ARM_SectionObject:
diff --git a/libsel4vka/sel4_arch_include/aarch64/vka/sel4_arch/kobject_t.h b/libsel4vka/sel4_arch_include/aarch64/vka/sel4_arch/kobject_t.h
index 0421af2..46aab67 100644
--- a/libsel4vka/sel4_arch_include/aarch64/vka/sel4_arch/kobject_t.h
+++ b/libsel4vka/sel4_arch_include/aarch64/vka/sel4_arch/kobject_t.h
@@ -31,11 +31,10 @@
* Get the size (in bits) of the untyped memory required to
* create an object of the given size
*/
-static inline seL4_Word
-arm_mode_kobject_get_size(kobject_t type, seL4_Word objectSize)
+static inline seL4_Word arm_mode_kobject_get_size(kobject_t type, seL4_Word objectSize)
{
switch (type) {
- /* ARM-specific frames. */
+ /* ARM-specific frames. */
case KOBJECT_FRAME:
switch (objectSize) {
case seL4_HugePageBits:
@@ -52,8 +51,7 @@
}
}
-static inline seL4_Word
-arm_mode_kobject_get_type(kobject_t type, seL4_Word objectSize)
+static inline seL4_Word arm_mode_kobject_get_type(kobject_t type, seL4_Word objectSize)
{
switch (type) {
case KOBJECT_FRAME:
diff --git a/libsel4vka/sel4_arch_include/ia32/vka/sel4_arch/kobject_t.h b/libsel4vka/sel4_arch_include/ia32/vka/sel4_arch/kobject_t.h
index 6f888b6..78b3894 100644
--- a/libsel4vka/sel4_arch_include/ia32/vka/sel4_arch/kobject_t.h
+++ b/libsel4vka/sel4_arch_include/ia32/vka/sel4_arch/kobject_t.h
@@ -30,8 +30,7 @@
* Get the size (in bits) of the untyped memory required to
* create an object of the given size.
*/
-static inline seL4_Word
-x86_mode_kobject_get_size(kobject_t type, seL4_Word UNUSED objectSize)
+static inline seL4_Word x86_mode_kobject_get_size(kobject_t type, seL4_Word UNUSED objectSize)
{
switch (type) {
case KOBJECT_PDPT:
@@ -42,8 +41,7 @@
}
}
-static inline seL4_Word
-x86_mode_kobject_get_type(kobject_t type, seL4_Word UNUSED objectSize)
+static inline seL4_Word x86_mode_kobject_get_type(kobject_t type, seL4_Word UNUSED objectSize)
{
switch (type) {
case KOBJECT_PDPT:
diff --git a/libsel4vka/sel4_arch_include/x86_64/vka/sel4_arch/kobject_t.h b/libsel4vka/sel4_arch_include/x86_64/vka/sel4_arch/kobject_t.h
index 55a908c..1d92939 100644
--- a/libsel4vka/sel4_arch_include/x86_64/vka/sel4_arch/kobject_t.h
+++ b/libsel4vka/sel4_arch_include/x86_64/vka/sel4_arch/kobject_t.h
@@ -31,8 +31,7 @@
* Get the size (in bits) of the untyped memory required to
* create an object of the given size.
*/
-static inline seL4_Word
-x86_mode_kobject_get_size(kobject_t type, seL4_Word objectSize)
+static inline seL4_Word x86_mode_kobject_get_size(kobject_t type, seL4_Word objectSize)
{
switch (type) {
case KOBJECT_FRAME:
@@ -50,8 +49,7 @@
}
}
-static inline seL4_Word
-x86_mode_kobject_get_type(kobject_t type, seL4_Word objectSize)
+static inline seL4_Word x86_mode_kobject_get_type(kobject_t type, seL4_Word objectSize)
{
switch (type) {
case KOBJECT_FRAME:
diff --git a/libsel4vka/src/debug-vka.c b/libsel4vka/src/debug-vka.c
index 6503567..4fda2d3 100644
--- a/libsel4vka/src/debug-vka.c
+++ b/libsel4vka/src/debug-vka.c
@@ -115,7 +115,7 @@
{
assert(data != NULL);
- state_t *s = (state_t*)data;
+ state_t *s = (state_t *)data;
vka_t *v = s->underlying;
int result = v->cspace_alloc(v->data, res);
if (result == 0 && res != NULL) {
@@ -143,7 +143,7 @@
{
assert(data != NULL);
- state_t *s = (state_t*)data;
+ state_t *s = (state_t *)data;
if (slot != 0) {
/* Let's assume malloc semantics, i.e. that it's always OK to free
@@ -163,7 +163,7 @@
{
assert(data != NULL);
- state_t *s = (state_t*)data;
+ state_t *s = (state_t *)data;
vka_t *v = s->underlying;
v->cspace_make_path(v->data, slot, res);
}
@@ -209,7 +209,7 @@
{
assert(data != NULL);
- state_t *s = (state_t*)data;
+ state_t *s = (state_t *)data;
/* At this point I guess we could check that dest is a path that was
* previously returned from cspace_make_path, but there seems to be nothing
@@ -226,11 +226,11 @@
}
static int utspace_alloc_maybe_device(void *data, const cspacepath_t *dest, seL4_Word type,
- seL4_Word size_bits, bool can_use_dev, seL4_Word *res)
+ seL4_Word size_bits, bool can_use_dev, seL4_Word *res)
{
assert(data != NULL);
- state_t *s = (state_t*)data;
+ state_t *s = (state_t *)data;
vka_t *v = s->underlying;
int result = v->utspace_alloc_maybe_device(v->data, dest, type, size_bits, can_use_dev, res);
@@ -245,7 +245,7 @@
{
assert(data != NULL);
- state_t *s = (state_t*)data;
+ state_t *s = (state_t *)data;
/* At this point I guess we could check that dest is a path that was
* previously returned from cspace_make_path, but there seems to be nothing
@@ -271,11 +271,11 @@
if (state->live_objs[i].cookie == cookie) {
if (state->live_objs[i].type != type) {
fatal("attempt to free object with type %d that was allocated "
- "with type %d", (int)type, (int)state->live_objs[i].type);
+ "with type %d", (int)type, (int)state->live_objs[i].type);
}
if (state->live_objs[i].size_bits != size_bits) {
fatal("attempt to free object with size %d that was allocated "
- "with size %d", (int)size_bits, (int)state->live_objs[i].size_bits);
+ "with size %d", (int)size_bits, (int)state->live_objs[i].size_bits);
}
state->live_objs[i].cookie = 0;
return;
@@ -290,7 +290,7 @@
{
assert(data != NULL);
- state_t *s = (state_t*)data;
+ state_t *s = (state_t *)data;
vka_t *v = s->underlying;
if (target != 0) {
/* Again, assume malloc semantics that freeing NULL is fine. */
@@ -303,7 +303,7 @@
{
assert(vka != NULL);
- state_t *s = (state_t*)malloc(sizeof(state_t));
+ state_t *s = (state_t *)malloc(sizeof(state_t));
if (s == NULL) {
goto fail;
}
@@ -313,7 +313,7 @@
s->live_slots_sz = live_slots_sz;
if (live_slots_sz > 0) {
- s->live_slots = (seL4_CPtr*)malloc(sizeof(seL4_CPtr) * live_slots_sz);
+ s->live_slots = (seL4_CPtr *)malloc(sizeof(seL4_CPtr) * live_slots_sz);
if (s->live_slots == NULL) {
goto fail;
}
@@ -321,13 +321,13 @@
s->live_objs_sz = live_objs_sz;
if (live_objs_sz > 0) {
- s->live_objs = (struct obj*)malloc(sizeof(struct obj) * live_objs_sz);
+ s->live_objs = (struct obj *)malloc(sizeof(struct obj) * live_objs_sz);
if (s->live_objs == NULL) {
goto fail;
}
}
- vka->data = (void*)s;
+ vka->data = (void *)s;
vka->cspace_alloc = cspace_alloc;
vka->cspace_make_path = cspace_make_path;
vka->utspace_alloc = utspace_alloc;
diff --git a/libsel4vmm/CMakeLists.txt b/libsel4vmm/CMakeLists.txt
index d667622..5694a60 100644
--- a/libsel4vmm/CMakeLists.txt
+++ b/libsel4vmm/CMakeLists.txt
@@ -83,11 +83,7 @@
add_library(sel4vmm STATIC EXCLUDE_FROM_ALL ${sources})
-target_include_directories(
- sel4vmm
- PUBLIC
- include
-)
+target_include_directories(sel4vmm PUBLIC include)
target_link_libraries(
sel4vmm
PUBLIC
diff --git a/libsel4vmm/include/vmm/debug.h b/libsel4vmm/include/vmm/debug.h
index 4dcf6ff..e9a407b 100644
--- a/libsel4vmm/include/vmm/debug.h
+++ b/libsel4vmm/include/vmm/debug.h
@@ -17,19 +17,19 @@
#include "vmm/vmm.h"
#ifndef COLOUR
- #define COLOUR "\033[;1;%dm"
- #define COLOUR_R "\033[;1;31m"
- #define COLOUR_G "\033[;1;32m"
- #define COLOUR_Y "\033[;1;33m"
- #define COLOUR_B "\033[;1;34m"
- #define COLOUR_M "\033[;1;35m"
- #define COLOUR_C "\033[;1;36m"
- #define COLOUR_RESET "\033[0m"
+#define COLOUR "\033[;1;%dm"
+#define COLOUR_R "\033[;1;31m"
+#define COLOUR_G "\033[;1;32m"
+#define COLOUR_Y "\033[;1;33m"
+#define COLOUR_B "\033[;1;34m"
+#define COLOUR_M "\033[;1;35m"
+#define COLOUR_C "\033[;1;36m"
+#define COLOUR_RESET "\033[0m"
#endif
#ifdef CONFIG_LIB_VMM_DEBUG
- #define DPRINTF(lvl, ...) \
+#define DPRINTF(lvl, ...) \
do{ \
if(lvl <= 0 || lvl < CONFIG_LIB_VMM_DEBUG_LEVEL){ \
printf("%s:%d | ", __func__, __LINE__); \
@@ -37,7 +37,7 @@
} \
}while(0)
- #define drun(lvl, cmd) \
+#define drun(lvl, cmd) \
do{ \
if(lvl < LIB_VMM_DEBUG_LEVEL){ \
cmd; \
@@ -46,13 +46,13 @@
#else /* CONFIG_LIB_VMM_DEBUG */
- #define DPRINTF(lvl, ...) do{ /* nothing */ }while(0)
- #define drun() do{ /* nothing */ }while(0)
+#define DPRINTF(lvl, ...) do{ /* nothing */ }while(0)
+#define drun() do{ /* nothing */ }while(0)
#endif /* CONFIG_LIB_VMM_DEBUG */
#ifndef panic
- #define panic(msg) \
+#define panic(msg) \
do{ \
printf(COLOUR_R "!!!!!!!!!!!! LIBVMM PANIC !!!!!!!!!!!!! \n"\
" @ %s: %d | %s\n" COLOUR_RESET, __func__, __LINE__, msg);\
@@ -61,5 +61,5 @@
}while(0)
#endif
-void vmm_print_guest_context(int, vmm_vcpu_t*);
+void vmm_print_guest_context(int, vmm_vcpu_t *);
diff --git a/libsel4vmm/include/vmm/platform/guest_vspace.h b/libsel4vmm/include/vmm/platform/guest_vspace.h
index 11f6e72..d0a1fb3 100644
--- a/libsel4vmm/include/vmm/platform/guest_vspace.h
+++ b/libsel4vmm/include/vmm/platform/guest_vspace.h
@@ -20,23 +20,26 @@
/* Constructs a vspace that will duplicate mappings between an ept
* and several IO spaces as well as translation to mappings in the VMM vspace */
-int vmm_get_guest_vspace(vspace_t *loader, vspace_t *vmm_vspace, vspace_t *new_vspace, vka_t *vka, seL4_CPtr page_directory);
+int vmm_get_guest_vspace(vspace_t *loader, vspace_t *vmm_vspace, vspace_t *new_vspace, vka_t *vka,
+ seL4_CPtr page_directory);
/* Helpers for use with touch below */
int vmm_guest_get_phys_data_help(uintptr_t addr, void *vaddr, size_t size,
- size_t offset, void *cookie);
+ size_t offset, void *cookie);
int vmm_guest_set_phys_data_help(uintptr_t addr, void *vaddr, size_t size,
- size_t offset, void *cookie);
+ size_t offset, void *cookie);
/* callback used for each portion of vmm_guest_vspace_touch.
* if the return value is non zero this signals the parent
* loop to stop and return the given value */
-typedef int (*vmm_guest_vspace_touch_callback)(uintptr_t guest_phys, void *vmm_vaddr, size_t size, size_t offset, void *cookie);
+typedef int (*vmm_guest_vspace_touch_callback)(uintptr_t guest_phys, void *vmm_vaddr, size_t size, size_t offset,
+ void *cookie);
/* 'touch' a series of guest physical addresses by invoking the callback function
* each equivalent range of addresses in the vmm vspace */
-int vmm_guest_vspace_touch(vspace_t *guest_vspace, uintptr_t addr, size_t size, vmm_guest_vspace_touch_callback callback, void *cookie);
+int vmm_guest_vspace_touch(vspace_t *guest_vspace, uintptr_t addr, size_t size,
+ vmm_guest_vspace_touch_callback callback, void *cookie);
#ifdef CONFIG_IOMMU
/* Attach an additional IO space to the vspace */
diff --git a/libsel4vmm/src/driver/virtio_emul.c b/libsel4vmm/src/driver/virtio_emul.c
index 44eae04..80bfb0d 100644
--- a/libsel4vmm/src/driver/virtio_emul.c
+++ b/libsel4vmm/src/driver/virtio_emul.c
@@ -44,44 +44,57 @@
void *vaddr;
} emul_tx_cookie_t;
-static int read_guest_mem(uintptr_t phys, void *vaddr, size_t size, size_t offset, void *cookie) {
+static int read_guest_mem(uintptr_t phys, void *vaddr, size_t size, size_t offset, void *cookie)
+{
memcpy(cookie + offset, vaddr, size);
return 0;
}
-static int write_guest_mem(uintptr_t phys, void *vaddr, size_t size, size_t offset, void *cookie) {
+static int write_guest_mem(uintptr_t phys, void *vaddr, size_t size, size_t offset, void *cookie)
+{
memcpy(vaddr, cookie + offset, size);
return 0;
}
-static uint16_t ring_avail_idx(ethif_virtio_emul_t *emul, struct vring *vring) {
+static uint16_t ring_avail_idx(ethif_virtio_emul_t *emul, struct vring *vring)
+{
uint16_t idx;
- vmm_guest_vspace_touch(&emul->internal->guest_vspace, (uintptr_t)&vring->avail->idx, sizeof(vring->avail->idx), read_guest_mem, &idx);
+ vmm_guest_vspace_touch(&emul->internal->guest_vspace, (uintptr_t)&vring->avail->idx, sizeof(vring->avail->idx),
+ read_guest_mem, &idx);
return idx;
}
-static uint16_t ring_avail(ethif_virtio_emul_t *emul, struct vring *vring, uint16_t idx) {
+static uint16_t ring_avail(ethif_virtio_emul_t *emul, struct vring *vring, uint16_t idx)
+{
uint16_t elem;
- vmm_guest_vspace_touch(&emul->internal->guest_vspace, (uintptr_t)&(vring->avail->ring[idx % vring->num]), sizeof(elem), read_guest_mem, &elem);
+ vmm_guest_vspace_touch(&emul->internal->guest_vspace, (uintptr_t) & (vring->avail->ring[idx % vring->num]),
+ sizeof(elem), read_guest_mem, &elem);
return elem;
}
-static struct vring_desc ring_desc(ethif_virtio_emul_t *emul, struct vring *vring, uint16_t idx) {
+static struct vring_desc ring_desc(ethif_virtio_emul_t *emul, struct vring *vring, uint16_t idx)
+{
struct vring_desc desc;
- vmm_guest_vspace_touch(&emul->internal->guest_vspace, (uintptr_t)&(vring->desc[idx]), sizeof(desc), read_guest_mem, &desc);
+ vmm_guest_vspace_touch(&emul->internal->guest_vspace, (uintptr_t) & (vring->desc[idx]), sizeof(desc), read_guest_mem,
+ &desc);
return desc;
}
-static void ring_used_add(ethif_virtio_emul_t *emul, struct vring *vring, struct vring_used_elem elem) {
+static void ring_used_add(ethif_virtio_emul_t *emul, struct vring *vring, struct vring_used_elem elem)
+{
uint16_t guest_idx;
- vmm_guest_vspace_touch(&emul->internal->guest_vspace, (uintptr_t)&vring->used->idx, sizeof(vring->used->idx), read_guest_mem, &guest_idx);
- vmm_guest_vspace_touch(&emul->internal->guest_vspace, (uintptr_t)&vring->used->ring[guest_idx % vring->num], sizeof(elem), write_guest_mem, &elem);
+ vmm_guest_vspace_touch(&emul->internal->guest_vspace, (uintptr_t)&vring->used->idx, sizeof(vring->used->idx),
+ read_guest_mem, &guest_idx);
+ vmm_guest_vspace_touch(&emul->internal->guest_vspace, (uintptr_t)&vring->used->ring[guest_idx % vring->num],
+ sizeof(elem), write_guest_mem, &elem);
guest_idx++;
- vmm_guest_vspace_touch(&emul->internal->guest_vspace, (uintptr_t)&vring->used->idx, sizeof(vring->used->idx), write_guest_mem, &guest_idx);
+ vmm_guest_vspace_touch(&emul->internal->guest_vspace, (uintptr_t)&vring->used->idx, sizeof(vring->used->idx),
+ write_guest_mem, &guest_idx);
}
-static uintptr_t emul_allocate_rx_buf(void *iface, size_t buf_size, void **cookie) {
- ethif_virtio_emul_t *emul = (ethif_virtio_emul_t*)iface;
+static uintptr_t emul_allocate_rx_buf(void *iface, size_t buf_size, void **cookie)
+{
+ ethif_virtio_emul_t *emul = (ethif_virtio_emul_t *)iface;
ethif_virtio_emul_internal_t *net = emul->internal;
if (buf_size > BUF_SIZE) {
return 0;
@@ -95,8 +108,9 @@
return phys;
}
-static void emul_rx_complete(void *iface, unsigned int num_bufs, void **cookies, unsigned int *lens) {
- ethif_virtio_emul_t *emul = (ethif_virtio_emul_t*)iface;
+static void emul_rx_complete(void *iface, unsigned int num_bufs, void **cookies, unsigned int *lens)
+{
+ ethif_virtio_emul_t *emul = (ethif_virtio_emul_t *)iface;
ethif_virtio_emul_internal_t *net = emul->internal;
unsigned int tot_len = 0;
int i;
@@ -136,7 +150,8 @@
}
copy = MIN(copy, desc.len - desc_written);
/* copy it */
- vmm_guest_vspace_touch(&net->guest_vspace, (uintptr_t)desc.addr + desc_written, copy, write_guest_mem, buf_base + buf_written);
+ vmm_guest_vspace_touch(&net->guest_vspace, (uintptr_t)desc.addr + desc_written, copy, write_guest_mem,
+ buf_base + buf_written);
/* update amounts */
tot_written += copy;
desc_written += copy;
@@ -178,10 +193,11 @@
}
}
-static void emul_tx_complete(void *iface, void *cookie) {
- ethif_virtio_emul_t *emul = (ethif_virtio_emul_t*)iface;
+static void emul_tx_complete(void *iface, void *cookie)
+{
+ ethif_virtio_emul_t *emul = (ethif_virtio_emul_t *)iface;
ethif_virtio_emul_internal_t *net = emul->internal;
- emul_tx_cookie_t *tx_cookie = (emul_tx_cookie_t*)cookie;
+ emul_tx_cookie_t *tx_cookie = (emul_tx_cookie_t *)cookie;
/* free the dma memory */
ps_dma_unpin(&net->dma_man, tx_cookie->vaddr, BUF_SIZE);
ps_dma_free(&net->dma_man, tx_cookie->vaddr, BUF_SIZE);
@@ -193,7 +209,8 @@
net->driver.i_fn.raw_handleIRQ(&net->driver, 0);
}
-static void emul_notify_tx(ethif_virtio_emul_t *emul) {
+static void emul_notify_tx(ethif_virtio_emul_t *emul)
+{
ethif_virtio_emul_internal_t *net = emul->internal;
struct vring *vring = &net->vring[TX_QUEUE];
/* read the index */
@@ -260,7 +277,8 @@
net->last_idx[TX_QUEUE] = idx;
}
-static void emul_tx_complete_external(void *iface, void *cookie) {
+static void emul_tx_complete_external(void *iface, void *cookie)
+{
emul_tx_complete(iface, cookie);
/* space may have cleared for additional transmits */
emul_notify_tx(iface);
@@ -272,8 +290,9 @@
.allocate_rx_buf = emul_allocate_rx_buf
};
-static int emul_io_in(struct ethif_virtio_emul *emul, unsigned int offset, unsigned int size, unsigned int *result) {
- switch(offset) {
+static int emul_io_in(struct ethif_virtio_emul *emul, unsigned int offset, unsigned int size, unsigned int *result)
+{
+ switch (offset) {
case VIRTIO_PCI_HOST_FEATURES:
assert(size == 4);
*result = BIT(VIRTIO_NET_F_MAC);
@@ -305,8 +324,9 @@
return 0;
}
-static int emul_io_out(struct ethif_virtio_emul *emul, unsigned int offset, unsigned int size, unsigned int value) {
- switch(offset) {
+static int emul_io_out(struct ethif_virtio_emul *emul, unsigned int offset, unsigned int size, unsigned int value)
+{
+ switch (offset) {
case VIRTIO_PCI_GUEST_FEATURES:
assert(size == 4);
assert(value == BIT(VIRTIO_NET_F_MAC));
@@ -324,7 +344,8 @@
assert(size == 4);
int queue = emul->internal->queue;
emul->internal->queue_pfn[queue] = value;
- vring_init(&emul->internal->vring[queue], emul->internal->queue_size[queue], (void*)(uintptr_t)(value << 12), VIRTIO_PCI_VRING_ALIGN);
+ vring_init(&emul->internal->vring[queue], emul->internal->queue_size[queue], (void *)(uintptr_t)(value << 12),
+ VIRTIO_PCI_VRING_ALIGN);
break;
}
case VIRTIO_PCI_QUEUE_NOTIFY:
@@ -343,7 +364,8 @@
return 0;
}
-static int emul_notify(ethif_virtio_emul_t *emul) {
+static int emul_notify(ethif_virtio_emul_t *emul)
+{
if (emul->internal->status != VIRTIO_CONFIG_S_DRIVER_OK) {
return -1;
}
@@ -351,7 +373,9 @@
return 0;
}
-ethif_virtio_emul_t *ethif_virtio_emul_init(ps_io_ops_t io_ops, int queue_size, vspace_t *guest_vspace, ethif_driver_init driver, void *config) {
+ethif_virtio_emul_t *ethif_virtio_emul_init(ps_io_ops_t io_ops, int queue_size, vspace_t *guest_vspace,
+ ethif_driver_init driver, void *config)
+{
ethif_virtio_emul_t *emul = NULL;
ethif_virtio_emul_internal_t *internal = NULL;
int err;
diff --git a/libsel4vmm/src/platform/boot.c b/libsel4vmm/src/platform/boot.c
index 9b01ab3..d9eadf1 100644
--- a/libsel4vmm/src/platform/boot.c
+++ b/libsel4vmm/src/platform/boot.c
@@ -29,7 +29,9 @@
#include "vmm/processor/apicdef.h"
#include "vmm/processor/lapic.h"
-int vmm_init(vmm_t *vmm, allocman_t *allocman, simple_t simple, vka_t vka, vspace_t vspace, platform_callbacks_t callbacks) {
+int vmm_init(vmm_t *vmm, allocman_t *allocman, simple_t simple, vka_t vka, vspace_t vspace,
+ platform_callbacks_t callbacks)
+{
int err;
memset(vmm, 0, sizeof(vmm_t));
vmm->allocman = allocman;
@@ -61,12 +63,14 @@
return 0;
}
-int vmm_init_host(vmm_t *vmm) {
+int vmm_init_host(vmm_t *vmm)
+{
vmm->done_host_init = 1;
return 0;
}
-static int vmm_init_vcpu(vmm_t *vmm, unsigned int vcpu_num, int priority) {
+static int vmm_init_vcpu(vmm_t *vmm, unsigned int vcpu_num, int priority)
+{
int UNUSED error;
assert(vcpu_num < vmm->num_vcpus);
vmm_vcpu_t *vcpu = &vmm->vcpus[vcpu_num];
@@ -90,11 +94,13 @@
return 0;
}
-int vmm_init_guest(vmm_t *vmm, int priority) {
+int vmm_init_guest(vmm_t *vmm, int priority)
+{
return vmm_init_guest_multi(vmm, priority, 1);
}
-int vmm_init_guest_multi(vmm_t *vmm, int priority, int num_vcpus) {
+int vmm_init_guest_multi(vmm_t *vmm, int priority, int num_vcpus)
+{
int error;
assert(vmm->done_host_init);
@@ -121,7 +127,7 @@
assert(error == seL4_NoError);
/* Initialize a vspace for the guest */
error = vmm_get_guest_vspace(&vmm->host_vspace, &vmm->host_vspace,
- &vmm->guest_mem.vspace, &vmm->vka, vmm->guest_pd);
+ &vmm->guest_mem.vspace, &vmm->vka, vmm->guest_pd);
if (error) {
return error;
}
@@ -136,8 +142,8 @@
vmm->guest_mem.ram_regions = malloc(0);
vmm_mmio_add_handler(&vmm->mmio_list, APIC_DEFAULT_PHYS_BASE,
- APIC_DEFAULT_PHYS_BASE + sizeof(struct local_apic_regs) - 1,
- NULL, "Local APIC", vmm_apic_mmio_read, vmm_apic_mmio_write);
+ APIC_DEFAULT_PHYS_BASE + sizeof(struct local_apic_regs) - 1,
+ NULL, "Local APIC", vmm_apic_mmio_read, vmm_apic_mmio_write);
vmm->done_guest_init = 1;
return 0;
diff --git a/libsel4vmm/src/platform/boot_guest.c b/libsel4vmm/src/platform/boot_guest.c
index 857de19..00d3dc0 100644
--- a/libsel4vmm/src/platform/boot_guest.c
+++ b/libsel4vmm/src/platform/boot_guest.c
@@ -50,17 +50,20 @@
FILE *file;
} boot_guest_cookie_t;
-static int guest_elf_write_address(uintptr_t paddr, void *vaddr, size_t size, size_t offset, void *cookie) {
+static int guest_elf_write_address(uintptr_t paddr, void *vaddr, size_t size, size_t offset, void *cookie)
+{
memcpy(vaddr, cookie + offset, size);
return 0;
}
-static int guest_elf_read_address(uintptr_t paddr, void *vaddr, size_t size, size_t offset, void *cookie) {
+static int guest_elf_read_address(uintptr_t paddr, void *vaddr, size_t size, size_t offset, void *cookie)
+{
memcpy(cookie + offset, vaddr, size);
return 0;
}
-void vmm_plat_guest_elf_relocate(vmm_t *vmm, const char *relocs_filename) {
+void vmm_plat_guest_elf_relocate(vmm_t *vmm, const char *relocs_filename)
+{
guest_image_t *image = &vmm->guest_image;
int delta = image->relocation_offset;
if (delta == 0) {
@@ -77,12 +80,12 @@
size_t relocs_size = 0;
FILE *file = fopen(relocs_filename, "r");
- if(!file) {
+ if (!file) {
printf(COLOUR_Y "ERROR: Guest OS kernel relocation is required, but corresponding"
- "%s was not found. This is most likely due to a Makefile"
- "error, or configuration error.\n", relocs_filename);
- panic("Relocation required but relocation data file not found.");
- return;
+ "%s was not found. This is most likely due to a Makefile"
+ "error, or configuration error.\n", relocs_filename);
+ panic("Relocation required but relocation data file not found.");
+ return;
}
fseek(file, 0, SEEK_END);
relocs_size = ftell(file);
@@ -107,7 +110,7 @@
for (int i = 0; ; i++) {
uint32_t vaddr;
/* Get the next relocation from the relocs file. */
- uint32_t offset = relocs_size - (sizeof(uint32_t) * (i+1));
+ uint32_t offset = relocs_size - (sizeof(uint32_t) * (i + 1));
fseek(file, offset, SEEK_SET);
size_t result = fread(&vaddr, sizeof(uint32_t), 1, file);
ZF_LOGF_IF(result != 1, "Read failed unexpectedly");
@@ -121,17 +124,17 @@
allocated and mapped the ELF contents into. */
assert(vaddr >= (uint32_t)image->link_vaddr);
uintptr_t guest_paddr = (uintptr_t)vaddr - (uintptr_t)image->link_vaddr +
- (uintptr_t)(load_addr + delta);
+ (uintptr_t)(load_addr + delta);
// assert(vmm_guest_mem_check_elf_segment(resource, guest_paddr, guest_paddr + 4));
/* Perform the relocation. */
DPRINTF(5, " reloc vaddr 0x%x guest_addr 0x%x\n", (unsigned int)vaddr, (unsigned int)guest_paddr);
uint32_t addr;
vmm_guest_vspace_touch(&vmm->guest_mem.vspace, guest_paddr, sizeof(int),
- guest_elf_read_address, &addr);
+ guest_elf_read_address, &addr);
addr += delta;
vmm_guest_vspace_touch(&vmm->guest_mem.vspace, guest_paddr, sizeof(int),
- guest_elf_write_address, &addr);
+ guest_elf_write_address, &addr);
if (i && i % 50000 == 0) {
DPRINTF(2, " %u relocs done.\n", i);
@@ -149,8 +152,9 @@
}
-static int vmm_guest_load_boot_module_continued(uintptr_t paddr, void *addr, size_t size, size_t offset, void *cookie) {
- boot_guest_cookie_t *pass = ( boot_guest_cookie_t *) cookie;
+static int vmm_guest_load_boot_module_continued(uintptr_t paddr, void *addr, size_t size, size_t offset, void *cookie)
+{
+ boot_guest_cookie_t *pass = (boot_guest_cookie_t *) cookie;
fseek(pass->file, offset, SEEK_SET);
size_t result = fread(addr, size, 1, pass->file);
ZF_LOGF_IF(result != 1, "Read failed unexpectedly");
@@ -158,7 +162,8 @@
return 0;
}
-int vmm_guest_load_boot_module(vmm_t *vmm, const char *name) {
+int vmm_guest_load_boot_module(vmm_t *vmm, const char *name)
+{
uintptr_t load_addr = guest_ram_largest_free_region_start(&vmm->guest_mem);
printf("Loading boot module \"%s\" at 0x%x\n", name, (unsigned int)load_addr);
@@ -191,12 +196,14 @@
return 0;
}
-static inline uint32_t vmm_plat_vesa_fbuffer_size(seL4_VBEModeInfoBlock_t *block) {
+static inline uint32_t vmm_plat_vesa_fbuffer_size(seL4_VBEModeInfoBlock_t *block)
+{
assert(block);
return ALIGN_UP(block->vbe_common.bytesPerScanLine * block->vbe12_part1.yRes, 65536);
}
-static int make_guest_page_dir_continued(uintptr_t guest_phys, void *vaddr, size_t size, size_t offset, void *cookie) {
+static int make_guest_page_dir_continued(uintptr_t guest_phys, void *vaddr, size_t size, size_t offset, void *cookie)
+{
assert(offset == 0);
assert(size == BIT(seL4_PageBits));
/* Write into this frame as the init page directory: 4M pages, 1 to 1 mapping. */
@@ -208,7 +215,8 @@
return 0;
}
-static int make_guest_page_dir(vmm_t *vmm) {
+static int make_guest_page_dir(vmm_t *vmm)
+{
/* Create a 4K Page to be our 1-1 pd */
/* This is constructed with magical new memory that we will not tell Linux about */
uintptr_t pd = (uintptr_t)vspace_new_pages(&vmm->guest_mem.vspace, seL4_AllRights, 1, seL4_PageBits);
@@ -221,14 +229,16 @@
return vmm_guest_vspace_touch(&vmm->guest_mem.vspace, pd, BIT(seL4_PageBits), make_guest_page_dir_continued, NULL);
}
-static int make_guest_cmd_line_continued(uintptr_t phys, void *vaddr, size_t size, size_t offset, void *cookie) {
+static int make_guest_cmd_line_continued(uintptr_t phys, void *vaddr, size_t size, size_t offset, void *cookie)
+{
/* Copy the string to this area. */
- const char *cmdline = (const char*)cookie;
+ const char *cmdline = (const char *)cookie;
memcpy(vaddr, cmdline + offset, size);
return 0;
}
-static int make_guest_cmd_line(vmm_t *vmm, const char *cmdline) {
+static int make_guest_cmd_line(vmm_t *vmm, const char *cmdline)
+{
/* Allocate command line from guest ram */
int len = strlen(cmdline);
uintptr_t cmd_addr = guest_ram_allocate(&vmm->guest_mem, len + 1);
@@ -239,15 +249,18 @@
printf("Constructing guest cmdline at 0x%x of size %d\n", (unsigned int)cmd_addr, len);
vmm->guest_image.cmd_line = cmd_addr;
vmm->guest_image.cmd_line_len = len;
- return vmm_guest_vspace_touch(&vmm->guest_mem.vspace, cmd_addr, len + 1, make_guest_cmd_line_continued, (void*)cmdline);
+ return vmm_guest_vspace_touch(&vmm->guest_mem.vspace, cmd_addr, len + 1, make_guest_cmd_line_continued,
+ (void *)cmdline);
}
-static void make_guest_screen_info(vmm_t *vmm, struct screen_info *info) {
+static void make_guest_screen_info(vmm_t *vmm, struct screen_info *info)
+{
/* VESA information */
seL4_X86_BootInfo_VBE vbeinfo;
ssize_t result;
int error;
- result = simple_get_extended_bootinfo(&vmm->host_simple, SEL4_BOOTINFO_HEADER_X86_VBE, &vbeinfo, sizeof(seL4_X86_BootInfo_VBE));
+ result = simple_get_extended_bootinfo(&vmm->host_simple, SEL4_BOOTINFO_HEADER_X86_VBE, &vbeinfo,
+ sizeof(seL4_X86_BootInfo_VBE));
uintptr_t base = 0;
size_t fbuffer_size;
if (config_set(CONFIG_VMM_VESA_FRAMEBUFFER) && result != -1) {
@@ -298,7 +311,8 @@
}
}
-static int make_guest_e820_map(struct e820entry *e820, guest_memory_t *guest_memory) {
+static int make_guest_e820_map(struct e820entry *e820, guest_memory_t *guest_memory)
+{
int i;
int entry = 0;
printf("Constructing e820 memory map for guest with:\n");
@@ -339,25 +353,27 @@
e820[entry].type = E820_RESERVED;
printf("Final e820 map is:\n");
for (i = 0; i <= entry; i++) {
- printf("\t0x%x - 0x%x type %d\n", (unsigned int)e820[i].addr, (unsigned int)(e820[i].addr + e820[i].size), e820[i].type);
+ printf("\t0x%x - 0x%x type %d\n", (unsigned int)e820[i].addr, (unsigned int)(e820[i].addr + e820[i].size),
+ e820[i].type);
assert(e820[i].addr < e820[i].addr + e820[i].size);
}
return entry + 1;
}
-static int make_guest_boot_info(vmm_t *vmm) {
+static int make_guest_boot_info(vmm_t *vmm)
+{
/* TODO: Bootinfo struct needs to be allocated in location accessable by real mode? */
uintptr_t addr = guest_ram_allocate(&vmm->guest_mem, sizeof(struct boot_params));
if (addr == 0) {
ZF_LOGE("Failed to allocate %zu bytes for guest boot info struct", sizeof(struct boot_params));
return -1;
}
- printf("Guest boot info allocated at %p. Populating...\n", (void*)addr);
+ printf("Guest boot info allocated at %p. Populating...\n", (void *)addr);
vmm->guest_image.boot_info = addr;
/* Map in BIOS boot info structure. */
struct boot_params boot_info;
- memset(&boot_info, 0, sizeof (struct boot_params));
+ memset(&boot_info, 0, sizeof(struct boot_params));
/* Initialise basic bootinfo structure. Src: Linux kernel Documentation/x86/boot.txt */
boot_info.hdr.header = 0x53726448; /* Magic number 'HdrS' */
@@ -396,7 +412,8 @@
}
/* Init the guest page directory, cmd line args and boot info structures. */
-void vmm_plat_init_guest_boot_structure(vmm_t *vmm, const char *cmdline) {
+void vmm_plat_init_guest_boot_structure(vmm_t *vmm, const char *cmdline)
+{
int UNUSED err;
err = make_guest_page_dir(vmm);
@@ -412,7 +429,8 @@
assert(!err);
}
-void vmm_init_guest_thread_state(vmm_vcpu_t *vcpu) {
+void vmm_init_guest_thread_state(vmm_vcpu_t *vcpu)
+{
vmm_set_user_context(&vcpu->guest_state, USER_CONTEXT_EAX, 0);
vmm_set_user_context(&vcpu->guest_state, USER_CONTEXT_EBX, 0);
vmm_set_user_context(&vcpu->guest_state, USER_CONTEXT_ECX, 0);
@@ -444,7 +462,8 @@
/* TODO: Refactor and stop rewriting fucking elf loading code */
static int vmm_load_guest_segment(vmm_t *vmm, seL4_Word source_offset,
- seL4_Word dest_addr, unsigned int segment_size, unsigned int file_size, FILE *file) {
+ seL4_Word dest_addr, unsigned int segment_size, unsigned int file_size, FILE *file)
+{
int ret;
unsigned int page_size = vmm->page_size;
@@ -463,9 +482,9 @@
while (current < segment_size) {
/* Retrieve the mapping */
seL4_CPtr cap;
- cap = vspace_get_cap(&vmm->guest_mem.vspace, (void*)dest_addr);
+ cap = vspace_get_cap(&vmm->guest_mem.vspace, (void *)dest_addr);
if (!cap) {
- ZF_LOGE("Failed to find frame cap while loading elf segment at %p", (void*)dest_addr);
+ ZF_LOGE("Failed to find frame cap while loading elf segment at %p", (void *)dest_addr);
return -1;
}
cspacepath_t cap_path;
@@ -492,7 +511,7 @@
}
DPRINTF(5, "load page src %zu dest %p remain %zu offset %zu copy vaddr %p "
- "copy len %zu\n", source_offset, (void*)dest_addr, remain, offset, copy_vaddr, copy_len);
+ "copy len %zu\n", source_offset, (void *)dest_addr, remain, offset, copy_vaddr, copy_len);
fseek(file, source_offset, SEEK_SET);
size_t result = fread(copy_vaddr, copy_len, 1, file);
@@ -523,7 +542,8 @@
*/
/* TODO: refactor yet more elf loading code */
-int vmm_load_guest_elf(vmm_t *vmm, const char *elfname, size_t alignment) {
+int vmm_load_guest_elf(vmm_t *vmm, const char *elfname, size_t alignment)
+{
int ret;
char elf_file[256];
elf_t elf;
@@ -536,7 +556,7 @@
}
ret = vmm_read_elf_headers(elf_file, vmm, file, sizeof(elf_file), &elf);
- if(ret < 0) {
+ if (ret < 0) {
ZF_LOGE("Guest elf \"%s\" invalid.", elfname);
return -1;
}
@@ -566,13 +586,13 @@
}
printf("Guest kernel is compiled to be located at paddr 0x%x vaddr 0x%x\n",
- (unsigned int)guest_kernel_addr, (unsigned int)guest_kernel_vaddr);
+ (unsigned int)guest_kernel_addr, (unsigned int)guest_kernel_vaddr);
printf("Guest kernel allocated 1:1 start is at paddr = 0x%x\n", (unsigned int)load_addr);
int guest_relocation_offset = (int)((int64_t)load_addr - (int64_t)guest_kernel_addr);
printf("Therefore relocation offset is %d (%s0x%x)\n",
- guest_relocation_offset,
- guest_relocation_offset < 0 ? "-" : "",
- abs(guest_relocation_offset));
+ guest_relocation_offset,
+ guest_relocation_offset < 0 ? "-" : "",
+ abs(guest_relocation_offset));
for (int i = 0; i < n_headers; i++) {
seL4_Word source_offset, dest_addr;
diff --git a/libsel4vmm/src/platform/guest_memory.c b/libsel4vmm/src/platform/guest_memory.c
index eb50ab5..418fcc1 100644
--- a/libsel4vmm/src/platform/guest_memory.c
+++ b/libsel4vmm/src/platform/guest_memory.c
@@ -25,9 +25,12 @@
#include "vmm/debug.h"
#include "vmm/platform/guest_memory.h"
-static void push_guest_ram_region(guest_memory_t *guest_memory, uintptr_t start, size_t size, int allocated) {
+static void push_guest_ram_region(guest_memory_t *guest_memory, uintptr_t start, size_t size, int allocated)
+{
int last_region = guest_memory->num_ram_regions;
- if (size == 0) return;
+ if (size == 0) {
+ return;
+ }
guest_memory->ram_regions = realloc(guest_memory->ram_regions, sizeof(guest_ram_region_t) * (last_region + 1));
assert(guest_memory->ram_regions);
@@ -37,26 +40,32 @@
guest_memory->num_ram_regions++;
}
-static int ram_region_cmp(const void *a, const void *b) {
+static int ram_region_cmp(const void *a, const void *b)
+{
const guest_ram_region_t *aa = a;
const guest_ram_region_t *bb = b;
return aa->start - bb->start;
}
-static void sort_guest_ram_regions(guest_memory_t *guest_memory) {
+static void sort_guest_ram_regions(guest_memory_t *guest_memory)
+{
qsort(guest_memory->ram_regions, guest_memory->num_ram_regions, sizeof(guest_ram_region_t), ram_region_cmp);
}
-static void guest_ram_remove_region(guest_memory_t *guest_memory, int region) {
+static void guest_ram_remove_region(guest_memory_t *guest_memory, int region)
+{
assert(region < guest_memory->num_ram_regions);
guest_memory->num_ram_regions--;
- memcpy(&guest_memory->ram_regions[region], &guest_memory->ram_regions[region + 1], sizeof(guest_ram_region_t) * (guest_memory->num_ram_regions - region));
+ memcpy(&guest_memory->ram_regions[region], &guest_memory->ram_regions[region + 1],
+ sizeof(guest_ram_region_t) * (guest_memory->num_ram_regions - region));
/* realloc it smaller */
- guest_memory->ram_regions = realloc(guest_memory->ram_regions, sizeof(guest_ram_region_t) * guest_memory->num_ram_regions);
+ guest_memory->ram_regions = realloc(guest_memory->ram_regions,
+ sizeof(guest_ram_region_t) * guest_memory->num_ram_regions);
assert(guest_memory->ram_regions);
}
-static void collapse_guest_ram_regions(guest_memory_t *guest_memory) {
+static void collapse_guest_ram_regions(guest_memory_t *guest_memory)
+{
int i;
for (i = 1; i < guest_memory->num_ram_regions;) {
/* Only collapse regions with the same allocation flag that are contiguous */
@@ -73,7 +82,8 @@
}
}
-static int expand_guest_ram_region(guest_memory_t *guest_memory, uintptr_t start, size_t bytes) {
+static int expand_guest_ram_region(guest_memory_t *guest_memory, uintptr_t start, size_t bytes)
+{
/* blindly put a new region at the end */
push_guest_ram_region(guest_memory, start, bytes, 0);
/* sort the region we just added */
@@ -83,7 +93,8 @@
return 0;
}
-uintptr_t guest_ram_largest_free_region_start(guest_memory_t *guest_memory) {
+uintptr_t guest_ram_largest_free_region_start(guest_memory_t *guest_memory)
+{
int largest = -1;
int i;
/* find a first region */
@@ -102,7 +113,8 @@
return guest_memory->ram_regions[largest].start;
}
-void print_guest_ram_regions(guest_memory_t *guest_memory) {
+void print_guest_ram_regions(guest_memory_t *guest_memory)
+{
int i;
for (i = 0; i < guest_memory->num_ram_regions; i++) {
char size_char = 'B';
@@ -123,7 +135,8 @@
}
}
-void guest_ram_mark_allocated(guest_memory_t *guest_memory, uintptr_t start, size_t bytes) {
+void guest_ram_mark_allocated(guest_memory_t *guest_memory, uintptr_t start, size_t bytes)
+{
/* Find the region */
int i;
int region = -1;
@@ -148,7 +161,8 @@
collapse_guest_ram_regions(guest_memory);
}
-uintptr_t guest_ram_allocate(guest_memory_t *guest_memory, size_t bytes) {
+uintptr_t guest_ram_allocate(guest_memory_t *guest_memory, size_t bytes)
+{
/* Do the obvious dumb search through the regions */
for (int i = 0; i < guest_memory->num_ram_regions; i++) {
if (!guest_memory->ram_regions[i].allocated && guest_memory->ram_regions[i].size >= bytes) {
@@ -161,7 +175,8 @@
return 0;
}
-static int vmm_alloc_guest_ram_one_to_one(vmm_t *vmm, size_t bytes) {
+static int vmm_alloc_guest_ram_one_to_one(vmm_t *vmm, size_t bytes)
+{
int ret;
int i;
int page_size = vmm->page_size;
@@ -187,13 +202,15 @@
ZF_LOGE("Allocated frame has no physical address");
return -1;
}
- reservation_t reservation = vspace_reserve_range_at(&guest_memory->vspace, (void*)paddr, BIT(page_size), seL4_AllRights, 1);
+ reservation_t reservation = vspace_reserve_range_at(&guest_memory->vspace, (void *)paddr, BIT(page_size),
+ seL4_AllRights, 1);
if (!reservation.res) {
ZF_LOGI("Failed to reserve address 0x%x in guest vspace. Skipping frame and leaking memory!", (unsigned int)paddr);
continue;
}
/* Map in */
- ret = vspace_map_pages_at_vaddr(&guest_memory->vspace, &objects[i].cptr, NULL, (void*)paddr, 1, page_size, reservation);
+ ret = vspace_map_pages_at_vaddr(&guest_memory->vspace, &objects[i].cptr, NULL, (void *)paddr, 1, page_size,
+ reservation);
if (ret) {
ZF_LOGE("Failed to map page %d/%d into guest vspace at 0x%x\n", i, num_pages, (unsigned int)paddr);
return -1;
@@ -215,7 +232,8 @@
return 0;
}
-int vmm_alloc_guest_device_at(vmm_t *vmm, uintptr_t start, size_t bytes) {
+int vmm_alloc_guest_device_at(vmm_t *vmm, uintptr_t start, size_t bytes)
+{
int page_size = vmm->page_size;
int num_pages = ROUND_UP(bytes, BIT(page_size)) >> page_size;
int ret;
@@ -223,16 +241,21 @@
guest_memory_t *guest_memory = &vmm->guest_mem;
uintptr_t page_start = ROUND_DOWN(start, BIT(page_size));
printf("Add guest memory region 0x%x-0x%x\n", (unsigned int)start, (unsigned int)(start + bytes));
- printf("Will be allocating region 0x%x-0x%x after page alignment\n", (unsigned int)page_start, (unsigned int)(page_start + num_pages * BIT(page_size)));
+ printf("Will be allocating region 0x%x-0x%x after page alignment\n", (unsigned int)page_start,
+ (unsigned int)(page_start + num_pages * BIT(page_size)));
for (i = 0; i < num_pages; i++) {
- reservation_t reservation = vspace_reserve_range_at(&guest_memory->vspace, (void*)(page_start + i * BIT(page_size)), 1, seL4_AllRights, 1);
+ reservation_t reservation = vspace_reserve_range_at(&guest_memory->vspace, (void *)(page_start + i * BIT(page_size)), 1,
+ seL4_AllRights, 1);
if (!reservation.res) {
- ZF_LOGI("Failed to create reservation for guest memory page 0x%x size %d, assuming already allocated", (unsigned int)(page_start + i * BIT(page_size)), page_size);
+ ZF_LOGI("Failed to create reservation for guest memory page 0x%x size %d, assuming already allocated",
+ (unsigned int)(page_start + i * BIT(page_size)), page_size);
continue;
}
- ret = vspace_new_pages_at_vaddr(&guest_memory->vspace, (void*)(page_start + i * BIT(page_size)), 1, page_size, reservation);
+ ret = vspace_new_pages_at_vaddr(&guest_memory->vspace, (void *)(page_start + i * BIT(page_size)), 1, page_size,
+ reservation);
if (ret) {
- ZF_LOGE("Failed to create page 0x%x size %d in guest memory region", (unsigned int)(page_start + i * BIT(page_size)), page_size);
+ ZF_LOGE("Failed to create page 0x%x size %d in guest memory region", (unsigned int)(page_start + i * BIT(page_size)),
+ page_size);
return -1;
}
vspace_free_reservation(&guest_memory->vspace, reservation);
@@ -240,38 +263,46 @@
return 0;
}
-static int vmm_map_guest_device_reservation(vmm_t *vmm, uintptr_t paddr, size_t bytes, reservation_t reservation, uintptr_t map_base) {
+static int vmm_map_guest_device_reservation(vmm_t *vmm, uintptr_t paddr, size_t bytes, reservation_t reservation,
+ uintptr_t map_base)
+{
int page_size = vmm->page_size;
int error;
guest_memory_t *guest_memory = &vmm->guest_mem;
- ZF_LOGI("Mapping passthrough device region 0x%x-0x%x to 0x%x", (unsigned int)paddr, (unsigned int)(paddr + bytes), (unsigned int)map_base);
+ ZF_LOGI("Mapping passthrough device region 0x%x-0x%x to 0x%x", (unsigned int)paddr, (unsigned int)(paddr + bytes),
+ (unsigned int)map_base);
/* Go through and try and map all the frames */
uintptr_t current_paddr;
uintptr_t current_map;
- for (current_paddr = paddr, current_map = map_base; current_paddr < paddr + bytes; current_paddr += BIT(page_size), current_map += BIT(page_size)) {
+ for (current_paddr = paddr, current_map = map_base; current_paddr < paddr + bytes;
+ current_paddr += BIT(page_size), current_map += BIT(page_size)) {
cspacepath_t path;
error = vka_cspace_alloc_path(&vmm->vka, &path);
if (error) {
ZF_LOGE("Failed to allocate cslot");
return error;
}
- error = simple_get_frame_cap(&vmm->host_simple, (void*)current_paddr, page_size, &path);
+ error = simple_get_frame_cap(&vmm->host_simple, (void *)current_paddr, page_size, &path);
uintptr_t cookie;
bool allocated = false;
if (error) {
/* attempt to allocate */
allocated = true;
- error = vka_utspace_alloc_at(&vmm->vka, &path, kobject_get_type(KOBJECT_FRAME, page_size), page_size, current_paddr, &cookie);
+ error = vka_utspace_alloc_at(&vmm->vka, &path, kobject_get_type(KOBJECT_FRAME, page_size), page_size, current_paddr,
+ &cookie);
}
if (error) {
- ZF_LOGE("Failed to find device frame 0x%x size 0x%x for region 0x%x 0x%x", (unsigned int)current_paddr, (unsigned int)BIT(page_size), (unsigned int)paddr, (unsigned int)bytes);
+ ZF_LOGE("Failed to find device frame 0x%x size 0x%x for region 0x%x 0x%x", (unsigned int)current_paddr,
+ (unsigned int)BIT(page_size), (unsigned int)paddr, (unsigned int)bytes);
vka_cnode_delete(&path);
vka_cspace_free(&vmm->vka, path.capPtr);
return error;
}
- error = vspace_map_pages_at_vaddr(&guest_memory->vspace, &path.capPtr, NULL, (void*)current_map, 1, page_size, reservation);
+ error = vspace_map_pages_at_vaddr(&guest_memory->vspace, &path.capPtr, NULL, (void *)current_map, 1, page_size,
+ reservation);
if (error) {
- ZF_LOGE("Failed to map device page 0x%x at 0x%x from region 0x%x 0x%x\n", (unsigned int)current_paddr, (unsigned int)current_map, (unsigned int)paddr, (unsigned int)bytes);
+ ZF_LOGE("Failed to map device page 0x%x at 0x%x from region 0x%x 0x%x\n", (unsigned int)current_paddr,
+ (unsigned int)current_map, (unsigned int)paddr, (unsigned int)bytes);
if (allocated) {
vka_utspace_free(&vmm->vka, kobject_get_type(KOBJECT_FRAME, page_size), page_size, cookie);
}
@@ -283,14 +314,16 @@
return 0;
}
-uintptr_t vmm_map_guest_device(vmm_t *vmm, uintptr_t paddr, size_t bytes, size_t align) {
+uintptr_t vmm_map_guest_device(vmm_t *vmm, uintptr_t paddr, size_t bytes, size_t align)
+{
int error;
/* Reserve a region that is guaranteed to have an aligned region in it */
guest_memory_t *guest_memory = &vmm->guest_mem;
uintptr_t reservation_base;
- reservation_t reservation = vspace_reserve_range(&guest_memory->vspace, bytes + align, seL4_AllRights, 1, (void**)&reservation_base);
+ reservation_t reservation = vspace_reserve_range(&guest_memory->vspace, bytes + align, seL4_AllRights, 1,
+ (void **)&reservation_base);
if (!reservation.res) {
- ZF_LOGE("Failed to allocate reservation of size %zu when mapping memory from %p", bytes + align, (void*)paddr);
+ ZF_LOGE("Failed to allocate reservation of size %zu when mapping memory from %p", bytes + align, (void *)paddr);
return 0;
}
/* Round up reservation so it is aligned. Hopefully it also ends up page aligned with the
@@ -304,13 +337,15 @@
return map_base;
}
-int vmm_map_guest_device_at(vmm_t *vmm, uintptr_t vaddr, uintptr_t paddr, size_t bytes) {
+int vmm_map_guest_device_at(vmm_t *vmm, uintptr_t vaddr, uintptr_t paddr, size_t bytes)
+{
int error;
/* Reserve a region that is guaranteed to have an aligned region in it */
guest_memory_t *guest_memory = &vmm->guest_mem;
- reservation_t reservation = vspace_reserve_range_at(&guest_memory->vspace, (void*)vaddr, bytes, seL4_AllRights, 1);
+ reservation_t reservation = vspace_reserve_range_at(&guest_memory->vspace, (void *)vaddr, bytes, seL4_AllRights, 1);
if (!reservation.res) {
- ZF_LOGE("Failed to allocate reservation of size %zu when mapping device from %p at %p", bytes, (void*)paddr, (void*)vaddr);
+ ZF_LOGE("Failed to allocate reservation of size %zu when mapping device from %p at %p", bytes, (void *)paddr,
+ (void *)vaddr);
return -1;
}
error = vmm_map_guest_device_reservation(vmm, paddr, bytes, reservation, vaddr);
@@ -318,7 +353,8 @@
return error;
}
-int vmm_alloc_guest_ram_at(vmm_t *vmm, uintptr_t start, size_t bytes) {
+int vmm_alloc_guest_ram_at(vmm_t *vmm, uintptr_t start, size_t bytes)
+{
int ret;
ret = vmm_alloc_guest_device_at(vmm, start, bytes);
if (ret) {
@@ -333,7 +369,8 @@
return 0;
}
-int vmm_alloc_guest_ram(vmm_t *vmm, size_t bytes, int onetoone) {
+int vmm_alloc_guest_ram(vmm_t *vmm, size_t bytes, int onetoone)
+{
if (onetoone) {
return vmm_alloc_guest_ram_one_to_one(vmm, bytes);
}
@@ -343,7 +380,8 @@
uintptr_t base;
int error;
int num_pages = ROUND_UP(bytes, BIT(page_size)) >> page_size;
- reservation_t reservation = vspace_reserve_range(&guest_memory->vspace, num_pages * BIT(page_size), seL4_AllRights, 1, (void**)&base);
+ reservation_t reservation = vspace_reserve_range(&guest_memory->vspace, num_pages * BIT(page_size), seL4_AllRights, 1,
+ (void **)&base);
if (!reservation.res) {
ZF_LOGE("Failed to create reservation for %zu guest ram bytes", bytes);
return -1;
@@ -357,12 +395,14 @@
ZF_LOGE("Failed to allocate path");
return -1;
}
- cookie = allocman_utspace_alloc(vmm->allocman, page_size, kobject_get_type(KOBJECT_FRAME, page_size), &path, true, &error);
+ cookie = allocman_utspace_alloc(vmm->allocman, page_size, kobject_get_type(KOBJECT_FRAME, page_size), &path, true,
+ &error);
if (error) {
ZF_LOGE("Failed to allocate page");
return -1;
}
- error = vspace_map_pages_at_vaddr(&guest_memory->vspace, &path.capPtr, &cookie, (void*)(base + i * BIT(page_size)), 1, page_size, reservation);
+ error = vspace_map_pages_at_vaddr(&guest_memory->vspace, &path.capPtr, &cookie, (void *)(base + i * BIT(page_size)), 1,
+ page_size, reservation);
if (error) {
ZF_LOGE("Failed to map page");
return -1;
diff --git a/libsel4vmm/src/platform/guest_vspace.c b/libsel4vmm/src/platform/guest_vspace.c
index 74c8845..5d1d96f 100644
--- a/libsel4vmm/src/platform/guest_vspace.c
+++ b/libsel4vmm/src/platform/guest_vspace.c
@@ -50,15 +50,15 @@
#endif
} guest_vspace_t;
-static int
-guest_vspace_map(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights,
- int cacheable, size_t size_bits) {
+static int guest_vspace_map(vspace_t *vspace, seL4_CPtr cap, void *vaddr, seL4_CapRights_t rights,
+ int cacheable, size_t size_bits)
+{
struct sel4utils_alloc_data *data = get_alloc_data(vspace);
int error;
/* this type cast works because the alloc data was at the start of the struct
* so it has the same address.
* This conversion is guaranteed to work by the C standard */
- guest_vspace_t *guest_vspace = (guest_vspace_t*) data;
+ guest_vspace_t *guest_vspace = (guest_vspace_t *) data;
/* perfrom the ept mapping */
error = sel4utils_map_page_ept(vspace, cap, vaddr, rights, cacheable, size_bits);
if (error) {
@@ -76,15 +76,16 @@
error = vka_cnode_copy(&new_path, &orig_path, seL4_AllRights);
assert(error == seL4_NoError);
/* perform the regular mapping */
- void *vmm_vaddr = vspace_map_pages(&guest_vspace->vmm_vspace, &new_path.capPtr, NULL, seL4_AllRights, 1, size_bits, cacheable);
- if (!vmm_vaddr){
+ void *vmm_vaddr = vspace_map_pages(&guest_vspace->vmm_vspace, &new_path.capPtr, NULL, seL4_AllRights, 1, size_bits,
+ cacheable);
+ if (!vmm_vaddr) {
ZF_LOGE("Failed to map into VMM vspace");
return -1;
}
/* add translation information. give dummy cap value of 42 as it cannot be zero
* but we really just want to store information in the cookie */
error = update_entries(&guest_vspace->translation_vspace, (uintptr_t)vaddr, 42, size_bits, (uintptr_t)vmm_vaddr);
- if (error){
+ if (error) {
ZF_LOGE("Failed to add translation information");
return error;
}
@@ -125,9 +126,10 @@
return 0;
}
-void guest_vspace_unmap(vspace_t *vspace, void *vaddr, size_t num_pages, size_t size_bits, vka_t *vka) {
+void guest_vspace_unmap(vspace_t *vspace, void *vaddr, size_t num_pages, size_t size_bits, vka_t *vka)
+{
struct sel4utils_alloc_data *data = get_alloc_data(vspace);
- guest_vspace_t *guest_vspace = (guest_vspace_t*) data;
+ guest_vspace_t *guest_vspace = (guest_vspace_t *) data;
int error;
@@ -142,10 +144,10 @@
for (int i = 0; i < num_pages; i++) {
- void *page_vaddr = (void*)(vaddr + i * page_size);
+ void *page_vaddr = (void *)(vaddr + i * page_size);
// look up vaddr in vmm vspace by consulting entry in translation vspace
- void *vmm_vaddr = (void*)vspace_get_cookie(&guest_vspace->translation_vspace, page_vaddr);
+ void *vmm_vaddr = (void *)vspace_get_cookie(&guest_vspace->translation_vspace, page_vaddr);
// remove mapping from vmm vspace
vspace_unmap_pages(&guest_vspace->vmm_vspace, vmm_vaddr, 1 /* num pages */, size_bits, vka);
@@ -192,9 +194,10 @@
}
#ifdef CONFIG_IOMMU
-int vmm_guest_vspace_add_iospace(vspace_t *loader, vspace_t *vspace, seL4_CPtr iospace) {
+int vmm_guest_vspace_add_iospace(vspace_t *loader, vspace_t *vspace, seL4_CPtr iospace)
+{
struct sel4utils_alloc_data *data = get_alloc_data(vspace);
- guest_vspace_t *guest_vspace = (guest_vspace_t*) data;
+ guest_vspace_t *guest_vspace = (guest_vspace_t *) data;
assert(!guest_vspace->done_mapping);
@@ -215,7 +218,8 @@
}
#endif
-int vmm_get_guest_vspace(vspace_t *loader, vspace_t *vmm, vspace_t *new_vspace, vka_t *vka, seL4_CPtr page_directory) {
+int vmm_get_guest_vspace(vspace_t *loader, vspace_t *vmm, vspace_t *new_vspace, vka_t *vka, seL4_CPtr page_directory)
+{
int error;
guest_vspace_t *vspace = malloc(sizeof(*vspace));
if (!vspace) {
@@ -229,12 +233,14 @@
assert(vspace->iospaces);
#endif
vspace->vmm_vspace = *vmm;
- error = sel4utils_get_vspace(loader, &vspace->translation_vspace, &vspace->translation_vspace_data, vka, page_directory, NULL, NULL);
+ error = sel4utils_get_vspace(loader, &vspace->translation_vspace, &vspace->translation_vspace_data, vka, page_directory,
+ NULL, NULL);
if (error) {
ZF_LOGE("Failed to create translation vspace");
return error;
}
- error = sel4utils_get_vspace_with_map(loader, new_vspace, &vspace->vspace_data, vka, page_directory, NULL, NULL, guest_vspace_map);
+ error = sel4utils_get_vspace_with_map(loader, new_vspace, &vspace->vspace_data, vka, page_directory, NULL, NULL,
+ guest_vspace_map);
if (error) {
ZF_LOGE("Failed to create guest vspace");
return error;
@@ -247,22 +253,26 @@
/* Helpers for use with touch below */
int vmm_guest_get_phys_data_help(uintptr_t addr, void *vaddr, size_t size,
- size_t offset, void *cookie) {
+ size_t offset, void *cookie)
+{
memcpy(cookie, vaddr, size);
return 0;
}
int vmm_guest_set_phys_data_help(uintptr_t addr, void *vaddr, size_t size,
- size_t offset, void *cookie) {
+ size_t offset, void *cookie)
+{
memcpy(vaddr, cookie, size);
return 0;
}
-int vmm_guest_vspace_touch(vspace_t *vspace, uintptr_t addr, size_t size, vmm_guest_vspace_touch_callback callback, void *cookie) {
+int vmm_guest_vspace_touch(vspace_t *vspace, uintptr_t addr, size_t size, vmm_guest_vspace_touch_callback callback,
+ void *cookie)
+{
struct sel4utils_alloc_data *data = get_alloc_data(vspace);
- guest_vspace_t *guest_vspace = (guest_vspace_t*) data;
+ guest_vspace_t *guest_vspace = (guest_vspace_t *) data;
uintptr_t current_addr;
uintptr_t next_addr;
uintptr_t end_addr = (uintptr_t)(addr + size);
@@ -270,12 +280,13 @@
uintptr_t current_aligned = PAGE_ALIGN_4K(current_addr);
uintptr_t next_page_start = current_aligned + PAGE_SIZE_4K;
next_addr = MIN(end_addr, next_page_start);
- void *vaddr = (void*)sel4utils_get_cookie(&guest_vspace->translation_vspace, (void*)current_aligned);
+ void *vaddr = (void *)sel4utils_get_cookie(&guest_vspace->translation_vspace, (void *)current_aligned);
if (!vaddr) {
- ZF_LOGE("Failed to get cookie at %p", (void*)current_aligned);
+ ZF_LOGE("Failed to get cookie at %p", (void *)current_aligned);
return -1;
}
- int result = callback(current_addr, (void*)(vaddr + (current_addr - current_aligned)), next_addr - current_addr, current_addr - addr, cookie);
+ int result = callback(current_addr, (void *)(vaddr + (current_addr - current_aligned)), next_addr - current_addr,
+ current_addr - addr, cookie);
if (result) {
return result;
}
diff --git a/libsel4vmm/src/vmm/vmx_timer.c b/libsel4vmm/src/vmm/vmx_timer.c
index 0edef16..422e38c 100644
--- a/libsel4vmm/src/vmm/vmx_timer.c
+++ b/libsel4vmm/src/vmm/vmx_timer.c
@@ -22,7 +22,8 @@
#include "vmm/vmm.h"
#include "vmm/platform/vmcs.h"
-int vmm_vmx_timer_handler(vmm_vcpu_t *vcpu) {
+int vmm_vmx_timer_handler(vmm_vcpu_t *vcpu)
+{
#ifdef CONFIG_LIB_VMM_VMX_TIMER_DEBUG
vmm_print_guest_context(0, vcpu);
// vmm_vmcs_write(vmm->guest_vcpu, VMX_CONTROL_PIN_EXECUTION_CONTROLS, vmm_vmcs_read(vmm->guest_vcpu, VMX_CONTROL_PIN_EXECUTION_CONTROLS) | BIT(6));