Use new name Occlum in code

This commit is contained in:
Tate, Hongliang Tian 2018-11-18 22:08:44 +08:00
parent 65826cb1b6
commit a4f37f8917
15 changed files with 61 additions and 61 deletions

@ -2,8 +2,8 @@ include ../sgxenv.mk
DEBUG=1 DEBUG=1
LIBOS_ENCLAVE := librusgx.signed.so LIBOS_ENCLAVE := libocclum.signed.so
LIBOS_SO := librusgx.so # Link $(LIBOS_A), $(C_OBJS) and all dependencies LIBOS_SO := libocclum.so # Link $(LIBOS_A), $(C_OBJS) and all dependencies
LIBOS_A := liblibos.a # Built from Rust code LIBOS_A := liblibos.a # Built from Rust code
RUST_SRCS := $(wildcard src/*.rs) RUST_SRCS := $(wildcard src/*.rs)

@ -1,5 +1,5 @@
#ifndef __RUSGX_ERRNO_H_ #ifndef __OCCLUM_ERRNO_H_
#define __RUSGX_ERRNO_H_ #define __OCCLUM_ERRNO_H_
/* Copied from glibc headers for x86-64 */ /* Copied from glibc headers for x86-64 */
@ -157,4 +157,4 @@
#endif #endif
#endif /* __RUSGX_ERRNO_H_ */ #endif /* __OCCLUM_ERRNO_H_ */

@ -45,7 +45,7 @@ pub extern "C" fn libos_boot(path_buf: *const i8) -> i32 {
}; };
println!("LibOS boots: {}", path_str); 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(||{ panic::catch_unwind(||{
backtrace::__rust_begin_short_backtrace(||{ backtrace::__rust_begin_short_backtrace(||{
process::do_spawn(&path_str); process::do_spawn(&path_str);
@ -57,7 +57,7 @@ pub extern "C" fn libos_boot(path_buf: *const i8) -> i32 {
#[no_mangle] #[no_mangle]
pub extern "C" fn libos_run() -> i32 { 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(||{ panic::catch_unwind(||{
backtrace::__rust_begin_short_backtrace(||{ backtrace::__rust_begin_short_backtrace(||{
let _ = process::run_task(); let _ = process::run_task();

@ -276,7 +276,7 @@ impl Process {
fn link_syscalls(self: &mut Process, elf_file: &ElfFile) fn link_syscalls(self: &mut Process, elf_file: &ElfFile)
-> Result<(), Error> -> 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 rela_entries = elf_helper::get_pltrel_entries(&elf_file)?;
let dynsym_entries = elf_helper::get_dynsym_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, .map_err(|e| Error::new(Errno::ENOEXEC,
"Failed to get the name of dynamic symbol"))?; "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; let rela_addr = self.program_base_addr + rela_entry.get_offset() as usize;
unsafe { unsafe {
std::ptr::write_unaligned(rela_addr as *mut usize, syscall_addr); 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 ocall_run_new_task(ret: *mut i32) -> sgx_status_t;
fn do_run_task(task: *const Task) -> i32; fn do_run_task(task: *const Task) -> i32;
fn do_exit_task(); 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;
} }

@ -1,5 +1,5 @@
#ifndef __RUSGX_SYSCALL_H__ #ifndef __OCCLUM_SYSCALL_H__
#define __RUSGX_SYSCALL_H__ #define __OCCLUM_SYSCALL_H__
#include <sys/types.h> #include <sys/types.h>
#include "syscall_nr.h" #include "syscall_nr.h"
@ -8,19 +8,19 @@
extern "C" { extern "C" {
#endif #endif
extern int rusgx_open(const char* path, int flags, int mode); extern int occlum_open(const char* path, int flags, int mode);
extern int rusgx_close(int fd); extern int occlum_close(int fd);
extern ssize_t rusgx_read(int fd, void* buf, size_t size); extern ssize_t occlum_read(int fd, void* buf, size_t size);
extern ssize_t rusgx_write(int fd, const void* buf, size_t size); extern ssize_t occlum_write(int fd, const void* buf, size_t size);
extern int rusgx_spawn(int* child_pid, const char* path, extern int occlum_spawn(int* child_pid, const char* path,
const char** argv, const char** argv,
const char** envp); const char** envp);
extern int rusgx_wait4(int child_pid, int* status, int options/*, struct rusage* rusage*/); extern int occlum_wait4(int child_pid, int* status, int options/*, struct rusage* rusage*/);
extern unsigned int rusgx_getpid(void); extern unsigned int occlum_getpid(void);
extern void rusgx_exit(int status); extern void occlum_exit(int status);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* __RUSGX_SYSCALL_H__ */ #endif /* __OCCLUM_SYSCALL_H__ */

@ -11,7 +11,7 @@ use std::ffi::CStr; // a borrowed C string
*/ */
#[no_mangle] #[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 { let path = unsafe {
CStr::from_ptr(path_buf as * const i8).to_string_lossy().into_owned() 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] #[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) { match fs::do_close(fd as file_table::FileDesc) {
Ok(()) => { Ok(()) => {
0 0
@ -38,7 +38,7 @@ pub extern "C" fn rusgx_close(fd: c_int) -> c_int {
} }
#[no_mangle] #[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 { let buf = unsafe {
std::slice::from_raw_parts_mut(buf as *mut u8, size as usize) 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] #[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 { /* let str_from_c = unsafe {
CStr::from_ptr(buf as * const i8).to_string_lossy().into_owned() 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 size as ssize_t
*/ */
let buf = unsafe { 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] #[no_mangle]
pub extern "C" fn rusgx_getpid() -> c_uint pub extern "C" fn occlum_getpid() -> c_uint
{ {
process::do_getpid() process::do_getpid()
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn rusgx_exit(status: i32) pub extern "C" fn occlum_exit(status: i32)
{ {
process::do_exit(status); process::do_exit(status);
} }
#[no_mangle] #[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 argv: *const *const c_char, envp: *const *const c_char) -> c_int
{ {
let mut ret = 0; 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] #[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 options: c_int/*, rusage: *mut Rusage*/) -> c_int
{ {
match process::do_wait4(child_pid as u32) { match process::do_wait4(child_pid as u32) {

@ -10,7 +10,7 @@ long dispatch_syscall(int num, long arg0, long arg1, long arg2, long arg3, long
switch (num) { switch (num) {
case SYS_exit: { case SYS_exit: {
DECL_SYSCALL_ARG(int, status, arg0); DECL_SYSCALL_ARG(int, status, arg0);
rusgx_exit(status); occlum_exit(status);
do_exit_task(); do_exit_task();
break; 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(const void*, path, arg0);
DECL_SYSCALL_ARG(int, flags, arg1); DECL_SYSCALL_ARG(int, flags, arg1);
DECL_SYSCALL_ARG(int, mode, arg2); DECL_SYSCALL_ARG(int, mode, arg2);
ret = rusgx_open(path, flags, mode); ret = occlum_open(path, flags, mode);
break; break;
} }
case SYS_close: { case SYS_close: {
DECL_SYSCALL_ARG(int, fd, arg0); DECL_SYSCALL_ARG(int, fd, arg0);
ret = rusgx_close(fd); ret = occlum_close(fd);
break; break;
} }
case SYS_write: { case SYS_write: {
DECL_SYSCALL_ARG(int, fd, arg0); DECL_SYSCALL_ARG(int, fd, arg0);
DECL_SYSCALL_ARG(const void*, buf, arg1); DECL_SYSCALL_ARG(const void*, buf, arg1);
DECL_SYSCALL_ARG(size_t, buf_size, arg2); DECL_SYSCALL_ARG(size_t, buf_size, arg2);
ret = rusgx_write(fd, buf, buf_size); ret = occlum_write(fd, buf, buf_size);
break; break;
} }
case SYS_read: { case SYS_read: {
DECL_SYSCALL_ARG(int, fd, arg0); DECL_SYSCALL_ARG(int, fd, arg0);
DECL_SYSCALL_ARG(void*, buf, arg1); DECL_SYSCALL_ARG(void*, buf, arg1);
DECL_SYSCALL_ARG(size_t, buf_size, arg2); DECL_SYSCALL_ARG(size_t, buf_size, arg2);
ret = rusgx_read(fd, buf, buf_size); ret = occlum_read(fd, buf, buf_size);
break; break;
} }
case SYS_spawn: { 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*, path, arg1);
DECL_SYSCALL_ARG(const char**, argv, arg2); DECL_SYSCALL_ARG(const char**, argv, arg2);
DECL_SYSCALL_ARG(const char**, envp, arg3); DECL_SYSCALL_ARG(const char**, envp, arg3);
ret = rusgx_spawn(child_pid, path, argv, envp); ret = occlum_spawn(child_pid, path, argv, envp);
break; break;
} }
case SYS_wait4: { 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*, status, arg1);
DECL_SYSCALL_ARG(int, options, arg2); DECL_SYSCALL_ARG(int, options, arg2);
//DECL_SYSCALL_ARG(struct rusage*, rusage, arg3); //DECL_SYSCALL_ARG(struct rusage*, rusage, arg3);
ret = rusgx_wait4(child_pid, status, options/*, rusage*/); ret = occlum_wait4(child_pid, status, options/*, rusage*/);
break; break;
} }
case SYS_getpid: { case SYS_getpid: {
ret = rusgx_getpid(); ret = occlum_getpid();
break; break;
} }
default: default:

@ -2,9 +2,9 @@
#include "task.h" #include "task.h"
.file "syscall_entry_x86-64.S" .file "syscall_entry_x86-64.S"
.global rusgx_syscall .global __occlum_syscall
.type rusgx_syscall, @function .type __occlum_syscall, @function
rusgx_syscall: __occlum_syscall:
push %rbp push %rbp
movq %rsp, %rbp movq %rsp, %rbp

@ -1,5 +1,5 @@
#ifndef __RUSGX_SYSCALL_NR_H__ #ifndef __OCCLUM_SYSCALL_NR_H__
#define __RUSGX_SYSCALL_NR_H__ #define __OCCLUM_SYSCALL_NR_H__
/* Macros are copied from glibc headers for x86-64 */ /* Macros are copied from glibc headers for x86-64 */
@ -713,4 +713,4 @@
#define __NR_spawn 360 #define __NR_spawn 360
#endif /* __RUSGX_SYSCALL_NR_H__ */ #endif /* __OCCLUM_SYSCALL_NR_H__ */

@ -33,7 +33,7 @@ int do_run_task(struct Task* task) {
__run_task(task->user_entry_addr, task->user_stack_addr); __run_task(task->user_entry_addr, task->user_stack_addr);
} }
// From rusgx_exit // From occlum_exit
RESET_CURRENT_TASK(); RESET_CURRENT_TASK();
return 0; return 0;
} }

@ -1,5 +1,5 @@
#ifndef __RUSGX_TASK_H__ #ifndef __OCCLUM_TASK_H__
#define __RUSGX_TASK_H__ #define __OCCLUM_TASK_H__
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
@ -41,4 +41,4 @@ void do_exit_task(void);
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#endif /* __RUSGX_TASK_H__ */ #endif /* __OCCLUM_TASK_H__ */

@ -214,7 +214,7 @@ int SGX_CDECL main(int argc, char *argv[])
} }
const char* executable_path = argv[1]; const char* executable_path = argv[1];
const char* enclave_path = "librusgx.signed.so"; const char* enclave_path = "libocclum.signed.so";
/* Initialize the enclave */ /* Initialize the enclave */
if(initialize_enclave(enclave_path) < 0){ if(initialize_enclave(enclave_path) < 0){
printf("Enter a character before exit ...\n"); printf("Enter a character before exit ...\n");

@ -31,10 +31,10 @@ run: build $(RUN_TEST_SUITES)
pal: $(PROJECT_DIR)/src/pal/pal pal: $(PROJECT_DIR)/src/pal/pal
cp $< pal cp $< pal
librusgx.signed.so: $(PROJECT_DIR)/src/libos/librusgx.signed.so libocclum.signed.so: $(PROJECT_DIR)/src/libos/libocclum.signed.so
cp $< librusgx.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 @$(MAKE) -C $< run
############################################################################# #############################################################################
@ -43,7 +43,7 @@ $(RUN_TEST_SUITES): run-%: % pal librusgx.signed.so
clean: $(CLEAN_TEST_SUITES) clean: $(CLEAN_TEST_SUITES)
@$(MAKE) -C rusgx_stub clean @$(MAKE) -C rusgx_stub clean
@$(RM) -f pal librusgx.signed.so @$(RM) -f pal libocclum.signed.so
$(CLEAN_TEST_SUITES): clean-%: $(CLEAN_TEST_SUITES): clean-%:
@$(MAKE) -C $(patsubst clean-%,%,$@) clean @$(MAKE) -C $(patsubst clean-%,%,$@) clean

@ -46,20 +46,20 @@
#define O_SYNC 0x00101000U #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) \ #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) \ #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) \ #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) \ #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) \ #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) \ #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) { static inline ssize_t __rusgx_read(int fd, void* buf, unsigned long size) {

@ -52,7 +52,7 @@ static void __exit(int status) {
return; 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; long ret = 0;
switch (num) { switch (num) {
case SYS_exit: case SYS_exit: