diff --git a/src/libos/Makefile b/src/libos/Makefile index 884bc5f5..16309c25 100644 --- a/src/libos/Makefile +++ b/src/libos/Makefile @@ -2,8 +2,8 @@ include ../sgxenv.mk DEBUG=1 -LIBOS_ENCLAVE := librusgx.signed.so -LIBOS_SO := librusgx.so # Link $(LIBOS_A), $(C_OBJS) and all dependencies +LIBOS_ENCLAVE := libocclum.signed.so +LIBOS_SO := libocclum.so # Link $(LIBOS_A), $(C_OBJS) and all dependencies LIBOS_A := liblibos.a # Built from Rust code RUST_SRCS := $(wildcard src/*.rs) diff --git a/src/libos/src/errno.h b/src/libos/src/errno.h index 47ad6616..8412421f 100644 --- a/src/libos/src/errno.h +++ b/src/libos/src/errno.h @@ -1,5 +1,5 @@ -#ifndef __RUSGX_ERRNO_H_ -#define __RUSGX_ERRNO_H_ +#ifndef __OCCLUM_ERRNO_H_ +#define __OCCLUM_ERRNO_H_ /* Copied from glibc headers for x86-64 */ @@ -157,4 +157,4 @@ #endif -#endif /* __RUSGX_ERRNO_H_ */ +#endif /* __OCCLUM_ERRNO_H_ */ diff --git a/src/libos/src/lib.rs b/src/libos/src/lib.rs index df013ae7..60b31647 100644 --- a/src/libos/src/lib.rs +++ b/src/libos/src/lib.rs @@ -45,7 +45,7 @@ pub extern "C" fn libos_boot(path_buf: *const i8) -> i32 { }; println!("LibOS boots: {}", path_str); - let _ = backtrace::enable_backtrace("librusgx.signed.so", PrintFormat::Short); + let _ = backtrace::enable_backtrace("libocclum.signed.so", PrintFormat::Short); panic::catch_unwind(||{ backtrace::__rust_begin_short_backtrace(||{ process::do_spawn(&path_str); @@ -57,7 +57,7 @@ pub extern "C" fn libos_boot(path_buf: *const i8) -> i32 { #[no_mangle] pub extern "C" fn libos_run() -> i32 { - let _ = backtrace::enable_backtrace("librusgx.signed.so", PrintFormat::Short); + let _ = backtrace::enable_backtrace("libocclum.signed.so", PrintFormat::Short); panic::catch_unwind(||{ backtrace::__rust_begin_short_backtrace(||{ let _ = process::run_task(); diff --git a/src/libos/src/process.rs b/src/libos/src/process.rs index e9f2fb2c..cabd01eb 100644 --- a/src/libos/src/process.rs +++ b/src/libos/src/process.rs @@ -276,7 +276,7 @@ impl Process { fn link_syscalls(self: &mut Process, elf_file: &ElfFile) -> Result<(), Error> { - let syscall_addr = rusgx_syscall as *const () as usize; + let syscall_addr = __occlum_syscall as *const () as usize; let rela_entries = elf_helper::get_pltrel_entries(&elf_file)?; let dynsym_entries = elf_helper::get_dynsym_entries(&elf_file)?; @@ -287,7 +287,7 @@ impl Process { .map_err(|e| Error::new(Errno::ENOEXEC, "Failed to get the name of dynamic symbol"))?; - if dynsym_str == "rusgx_syscall" { + if dynsym_str == "__occlum_syscall" { let rela_addr = self.program_base_addr + rela_entry.get_offset() as usize; unsafe { std::ptr::write_unaligned(rela_addr as *mut usize, syscall_addr); @@ -356,5 +356,5 @@ extern { fn ocall_run_new_task(ret: *mut i32) -> sgx_status_t; fn do_run_task(task: *const Task) -> i32; fn do_exit_task(); - fn rusgx_syscall(num: i32, arg0: u64, arg1: u64, arg2: u64, arg3: u64, arg4: u64) -> i64; + fn __occlum_syscall(num: i32, arg0: u64, arg1: u64, arg2: u64, arg3: u64, arg4: u64) -> i64; } diff --git a/src/libos/src/syscall.h b/src/libos/src/syscall.h index d040b719..ff0820dc 100644 --- a/src/libos/src/syscall.h +++ b/src/libos/src/syscall.h @@ -1,5 +1,5 @@ -#ifndef __RUSGX_SYSCALL_H__ -#define __RUSGX_SYSCALL_H__ +#ifndef __OCCLUM_SYSCALL_H__ +#define __OCCLUM_SYSCALL_H__ #include #include "syscall_nr.h" @@ -8,19 +8,19 @@ extern "C" { #endif -extern int rusgx_open(const char* path, int flags, int mode); -extern int rusgx_close(int fd); -extern ssize_t rusgx_read(int fd, void* buf, size_t size); -extern ssize_t rusgx_write(int fd, const void* buf, size_t size); -extern int rusgx_spawn(int* child_pid, const char* path, +extern int occlum_open(const char* path, int flags, int mode); +extern int occlum_close(int fd); +extern ssize_t occlum_read(int fd, void* buf, size_t size); +extern ssize_t occlum_write(int fd, const void* buf, size_t size); +extern int occlum_spawn(int* child_pid, const char* path, const char** argv, const char** envp); -extern int rusgx_wait4(int child_pid, int* status, int options/*, struct rusage* rusage*/); -extern unsigned int rusgx_getpid(void); -extern void rusgx_exit(int status); +extern int occlum_wait4(int child_pid, int* status, int options/*, struct rusage* rusage*/); +extern unsigned int occlum_getpid(void); +extern void occlum_exit(int status); #ifdef __cplusplus } #endif -#endif /* __RUSGX_SYSCALL_H__ */ +#endif /* __OCCLUM_SYSCALL_H__ */ diff --git a/src/libos/src/syscall.rs b/src/libos/src/syscall.rs index 08c0dbb6..db5cbb6b 100644 --- a/src/libos/src/syscall.rs +++ b/src/libos/src/syscall.rs @@ -11,7 +11,7 @@ use std::ffi::CStr; // a borrowed C string */ #[no_mangle] -pub extern "C" fn rusgx_open(path_buf: * const c_char, flags: c_int, mode: c_int) -> c_int { +pub extern "C" fn occlum_open(path_buf: * const c_char, flags: c_int, mode: c_int) -> c_int { let path = unsafe { CStr::from_ptr(path_buf as * const i8).to_string_lossy().into_owned() }; @@ -26,7 +26,7 @@ pub extern "C" fn rusgx_open(path_buf: * const c_char, flags: c_int, mode: c_int } #[no_mangle] -pub extern "C" fn rusgx_close(fd: c_int) -> c_int { +pub extern "C" fn occlum_close(fd: c_int) -> c_int { match fs::do_close(fd as file_table::FileDesc) { Ok(()) => { 0 @@ -38,7 +38,7 @@ pub extern "C" fn rusgx_close(fd: c_int) -> c_int { } #[no_mangle] -pub extern "C" fn rusgx_read(fd: c_int, buf: * mut c_void, size: size_t) -> ssize_t { +pub extern "C" fn occlum_read(fd: c_int, buf: * mut c_void, size: size_t) -> ssize_t { let buf = unsafe { std::slice::from_raw_parts_mut(buf as *mut u8, size as usize) }; @@ -53,11 +53,11 @@ pub extern "C" fn rusgx_read(fd: c_int, buf: * mut c_void, size: size_t) -> ssiz } #[no_mangle] -pub extern "C" fn rusgx_write(fd: c_int, buf: * const c_void, size: size_t) -> ssize_t { +pub extern "C" fn occlum_write(fd: c_int, buf: * const c_void, size: size_t) -> ssize_t { /* let str_from_c = unsafe { CStr::from_ptr(buf as * const i8).to_string_lossy().into_owned() }; - println!("rusgx_write: {}", str_from_c); + println!("occlum_write: {}", str_from_c); size as ssize_t */ let buf = unsafe { @@ -74,19 +74,19 @@ pub extern "C" fn rusgx_write(fd: c_int, buf: * const c_void, size: size_t) -> s } #[no_mangle] -pub extern "C" fn rusgx_getpid() -> c_uint +pub extern "C" fn occlum_getpid() -> c_uint { process::do_getpid() } #[no_mangle] -pub extern "C" fn rusgx_exit(status: i32) +pub extern "C" fn occlum_exit(status: i32) { process::do_exit(status); } #[no_mangle] -pub extern "C" fn rusgx_spawn(child_pid: *mut c_int, path: *const c_char, +pub extern "C" fn occlum_spawn(child_pid: *mut c_int, path: *const c_char, argv: *const *const c_char, envp: *const *const c_char) -> c_int { let mut ret = 0; @@ -105,7 +105,7 @@ pub extern "C" fn rusgx_spawn(child_pid: *mut c_int, path: *const c_char, } #[no_mangle] -pub extern "C" fn rusgx_wait4(child_pid: c_int, _exit_code: *mut c_int, +pub extern "C" fn occlum_wait4(child_pid: c_int, _exit_code: *mut c_int, options: c_int/*, rusage: *mut Rusage*/) -> c_int { match process::do_wait4(child_pid as u32) { diff --git a/src/libos/src/syscall_entry.c b/src/libos/src/syscall_entry.c index c975dcb7..96dab001 100644 --- a/src/libos/src/syscall_entry.c +++ b/src/libos/src/syscall_entry.c @@ -10,7 +10,7 @@ long dispatch_syscall(int num, long arg0, long arg1, long arg2, long arg3, long switch (num) { case SYS_exit: { DECL_SYSCALL_ARG(int, status, arg0); - rusgx_exit(status); + occlum_exit(status); do_exit_task(); break; } @@ -18,26 +18,26 @@ long dispatch_syscall(int num, long arg0, long arg1, long arg2, long arg3, long DECL_SYSCALL_ARG(const void*, path, arg0); DECL_SYSCALL_ARG(int, flags, arg1); DECL_SYSCALL_ARG(int, mode, arg2); - ret = rusgx_open(path, flags, mode); + ret = occlum_open(path, flags, mode); break; } case SYS_close: { DECL_SYSCALL_ARG(int, fd, arg0); - ret = rusgx_close(fd); + ret = occlum_close(fd); break; } case SYS_write: { DECL_SYSCALL_ARG(int, fd, arg0); DECL_SYSCALL_ARG(const void*, buf, arg1); DECL_SYSCALL_ARG(size_t, buf_size, arg2); - ret = rusgx_write(fd, buf, buf_size); + ret = occlum_write(fd, buf, buf_size); break; } case SYS_read: { DECL_SYSCALL_ARG(int, fd, arg0); DECL_SYSCALL_ARG(void*, buf, arg1); DECL_SYSCALL_ARG(size_t, buf_size, arg2); - ret = rusgx_read(fd, buf, buf_size); + ret = occlum_read(fd, buf, buf_size); break; } case SYS_spawn: { @@ -45,7 +45,7 @@ long dispatch_syscall(int num, long arg0, long arg1, long arg2, long arg3, long DECL_SYSCALL_ARG(const char*, path, arg1); DECL_SYSCALL_ARG(const char**, argv, arg2); DECL_SYSCALL_ARG(const char**, envp, arg3); - ret = rusgx_spawn(child_pid, path, argv, envp); + ret = occlum_spawn(child_pid, path, argv, envp); break; } case SYS_wait4: { @@ -53,11 +53,11 @@ long dispatch_syscall(int num, long arg0, long arg1, long arg2, long arg3, long DECL_SYSCALL_ARG(int*, status, arg1); DECL_SYSCALL_ARG(int, options, arg2); //DECL_SYSCALL_ARG(struct rusage*, rusage, arg3); - ret = rusgx_wait4(child_pid, status, options/*, rusage*/); + ret = occlum_wait4(child_pid, status, options/*, rusage*/); break; } case SYS_getpid: { - ret = rusgx_getpid(); + ret = occlum_getpid(); break; } default: diff --git a/src/libos/src/syscall_entry_x86-64.S b/src/libos/src/syscall_entry_x86-64.S index be1c3e5a..4b5c5665 100644 --- a/src/libos/src/syscall_entry_x86-64.S +++ b/src/libos/src/syscall_entry_x86-64.S @@ -2,9 +2,9 @@ #include "task.h" .file "syscall_entry_x86-64.S" - .global rusgx_syscall - .type rusgx_syscall, @function -rusgx_syscall: + .global __occlum_syscall + .type __occlum_syscall, @function +__occlum_syscall: push %rbp movq %rsp, %rbp diff --git a/src/libos/src/syscall_nr.h b/src/libos/src/syscall_nr.h index a94ea311..07f734b9 100644 --- a/src/libos/src/syscall_nr.h +++ b/src/libos/src/syscall_nr.h @@ -1,5 +1,5 @@ -#ifndef __RUSGX_SYSCALL_NR_H__ -#define __RUSGX_SYSCALL_NR_H__ +#ifndef __OCCLUM_SYSCALL_NR_H__ +#define __OCCLUM_SYSCALL_NR_H__ /* Macros are copied from glibc headers for x86-64 */ @@ -713,4 +713,4 @@ #define __NR_spawn 360 -#endif /* __RUSGX_SYSCALL_NR_H__ */ +#endif /* __OCCLUM_SYSCALL_NR_H__ */ diff --git a/src/libos/src/task.c b/src/libos/src/task.c index ccf751cc..d3e00e13 100644 --- a/src/libos/src/task.c +++ b/src/libos/src/task.c @@ -33,7 +33,7 @@ int do_run_task(struct Task* task) { __run_task(task->user_entry_addr, task->user_stack_addr); } - // From rusgx_exit + // From occlum_exit RESET_CURRENT_TASK(); return 0; } diff --git a/src/libos/src/task.h b/src/libos/src/task.h index c7693b26..833df503 100644 --- a/src/libos/src/task.h +++ b/src/libos/src/task.h @@ -1,5 +1,5 @@ -#ifndef __RUSGX_TASK_H__ -#define __RUSGX_TASK_H__ +#ifndef __OCCLUM_TASK_H__ +#define __OCCLUM_TASK_H__ #ifndef __ASSEMBLY__ @@ -41,4 +41,4 @@ void do_exit_task(void); #endif /* __ASSEMBLY__ */ -#endif /* __RUSGX_TASK_H__ */ +#endif /* __OCCLUM_TASK_H__ */ diff --git a/src/pal/pal.c b/src/pal/pal.c index f7f60192..d11d5d8e 100644 --- a/src/pal/pal.c +++ b/src/pal/pal.c @@ -214,7 +214,7 @@ int SGX_CDECL main(int argc, char *argv[]) } const char* executable_path = argv[1]; - const char* enclave_path = "librusgx.signed.so"; + const char* enclave_path = "libocclum.signed.so"; /* Initialize the enclave */ if(initialize_enclave(enclave_path) < 0){ printf("Enter a character before exit ...\n"); diff --git a/test/Makefile b/test/Makefile index 27b57e13..a16384a2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -31,10 +31,10 @@ run: build $(RUN_TEST_SUITES) pal: $(PROJECT_DIR)/src/pal/pal cp $< pal -librusgx.signed.so: $(PROJECT_DIR)/src/libos/librusgx.signed.so - cp $< librusgx.signed.so +libocclum.signed.so: $(PROJECT_DIR)/src/libos/libocclum.signed.so + cp $< libocclum.signed.so -$(RUN_TEST_SUITES): run-%: % pal librusgx.signed.so +$(RUN_TEST_SUITES): run-%: % pal libocclum.signed.so @$(MAKE) -C $< run ############################################################################# @@ -43,7 +43,7 @@ $(RUN_TEST_SUITES): run-%: % pal librusgx.signed.so clean: $(CLEAN_TEST_SUITES) @$(MAKE) -C rusgx_stub clean - @$(RM) -f pal librusgx.signed.so + @$(RM) -f pal libocclum.signed.so $(CLEAN_TEST_SUITES): clean-%: @$(MAKE) -C $(patsubst clean-%,%,$@) clean diff --git a/test/include/rusgx_stub.h b/test/include/rusgx_stub.h index 33ee7680..e925c600 100644 --- a/test/include/rusgx_stub.h +++ b/test/include/rusgx_stub.h @@ -46,20 +46,20 @@ #define O_SYNC 0x00101000U -long rusgx_syscall(int num, long arg0, long arg1, long arg2, long arg3, long arg4); +long __occlum_syscall(int num, long arg0, long arg1, long arg2, long arg3, long arg4); #define RUSGX_SYSCALL0(num) \ - rusgx_syscall((num), (long)0, (long)0, (long)0, (long)0, (long)0) + __occlum_syscall((num), (long)0, (long)0, (long)0, (long)0, (long)0) #define RUSGX_SYSCALL1(num, arg0) \ - rusgx_syscall((num), (long)(arg0), (long)0, (long)0, (long)0, (long)0) + __occlum_syscall((num), (long)(arg0), (long)0, (long)0, (long)0, (long)0) #define RUSGX_SYSCALL2(num, arg0, arg1) \ - rusgx_syscall((num), (long)(arg0), (long)(arg1), (long)0, (long)0, (long)0) + __occlum_syscall((num), (long)(arg0), (long)(arg1), (long)0, (long)0, (long)0) #define RUSGX_SYSCALL3(num, arg0, arg1, arg2) \ - rusgx_syscall((num), (long)(arg0), (long)(arg1), (long)(arg2), (long)0, (long)0) + __occlum_syscall((num), (long)(arg0), (long)(arg1), (long)(arg2), (long)0, (long)0) #define RUSGX_SYSCALL4(num, arg0, arg1, arg2, arg3) \ - rusgx_syscall((num), (long)(arg0), (long)(arg1), (long)(arg2), (long)(arg3), (long)0) + __occlum_syscall((num), (long)(arg0), (long)(arg1), (long)(arg2), (long)(arg3), (long)0) #define RUSGX_SYSCALL5(num, arg0, arg1, arg2, arg3, arg4) \ - rusgx_syscall((num), (long)(arg0), (long)(arg1), (long)(arg2), (long)(arg3), (long)(arg4)) + __occlum_syscall((num), (long)(arg0), (long)(arg1), (long)(arg2), (long)(arg3), (long)(arg4)) static inline ssize_t __rusgx_read(int fd, void* buf, unsigned long size) { diff --git a/test/rusgx_stub/stub_impl.c b/test/rusgx_stub/stub_impl.c index 4d764aac..47899d0d 100644 --- a/test/rusgx_stub/stub_impl.c +++ b/test/rusgx_stub/stub_impl.c @@ -52,7 +52,7 @@ static void __exit(int status) { return; } -long rusgx_syscall(int num, long arg0, long arg1, long arg2, long arg3, long arg4) { +long __occlum_syscall(int num, long arg0, long arg1, long arg2, long arg3, long arg4) { long ret = 0; switch (num) { case SYS_exit: