diff --git a/arch/x86_64/include/irq.h b/arch/x86_64/include/irq.h index 8a1db30b81c..89f6eaa1867 100644 --- a/arch/x86_64/include/irq.h +++ b/arch/x86_64/include/irq.h @@ -76,7 +76,7 @@ struct intel64_cpu_s struct tcb_s *this_task; -#ifdef CONFIG_LIB_SYSCALL +#ifdef CONFIG_ARCH_HAVE_SYSCALL /* Current user RSP for syscall */ uint64_t *ustack; diff --git a/arch/x86_64/src/common/CMakeLists.txt b/arch/x86_64/src/common/CMakeLists.txt index c797d00619e..045b1aeece8 100644 --- a/arch/x86_64/src/common/CMakeLists.txt +++ b/arch/x86_64/src/common/CMakeLists.txt @@ -38,7 +38,7 @@ if(CONFIG_ARCH_HAVE_FORK) list(APPEND SRCS x86_64_fork.c fork.S) endif() -if(CONFIG_LIB_SYSCALL) +if(CONFIG_ARCH_HAVE_SYSCALL) list(APPEND SRCS x86_64_syscall.c) endif() diff --git a/arch/x86_64/src/common/Make.defs b/arch/x86_64/src/common/Make.defs index f63e2cbce82..47e1dc16a19 100644 --- a/arch/x86_64/src/common/Make.defs +++ b/arch/x86_64/src/common/Make.defs @@ -34,7 +34,7 @@ CMN_CSRCS += x86_64_fork.c CMN_ASRCS += fork.S endif -ifeq ($(CONFIG_LIB_SYSCALL),y) +ifeq ($(CONFIG_ARCH_HAVE_SYSCALL),y) CMN_CSRCS += x86_64_syscall.c endif diff --git a/arch/x86_64/src/common/x86_64_syscall.c b/arch/x86_64/src/common/x86_64_syscall.c index 960b992bb02..833c191bf5b 100644 --- a/arch/x86_64/src/common/x86_64_syscall.c +++ b/arch/x86_64/src/common/x86_64_syscall.c @@ -109,7 +109,10 @@ uint64_t *x86_64_syscall(uint64_t *regs) uint64_t arg4 = regs[REG_R10]; uint64_t arg5 = regs[REG_R8]; uint64_t arg6 = regs[REG_R9]; - uintptr_t ret = 0; + + UNUSED(arg4); + UNUSED(arg5); + UNUSED(arg6); /* The syscall command is in RAX on entry */ @@ -293,11 +296,13 @@ uint64_t *x86_64_syscall(uint64_t *regs) default: { +#ifdef CONFIG_LIB_SYSCALL int nbr = cmd - CONFIG_SYS_RESERVED; - struct tcb_s *rtcb = nxsched_self(); syscall_stub_t stub = (syscall_stub_t)g_stublookup[nbr]; #ifdef CONFIG_ARCH_KERNEL_STACK + struct tcb_s *rtcb = nxsched_self(); + /* Store reference to user RSP for signals */ rtcb->xcp.saved_ursp = regs[REG_RSP]; @@ -312,20 +317,18 @@ uint64_t *x86_64_syscall(uint64_t *regs) up_irq_restore(X86_64_RFLAGS_IF); } - /* Call syscall function */ - - ret = stub(nbr, arg1, arg2, arg3, arg4, arg5, arg6); + /* Call syscall function and store return value in RAX register */ + regs[REG_RAX] = stub(nbr, arg1, arg2, arg3, arg4, arg5, arg6); +#else + svcerr("ERROR: Bad SYS call: %" PRId32 "\n", cmd); +#endif break; } } dump_syscall("Exit", regs); - /* Store return value in RAX register */ - - regs[REG_RAX] = ret; - /* Return pointer to regs */ return regs; diff --git a/arch/x86_64/src/intel64/intel64_cpu.c b/arch/x86_64/src/intel64/intel64_cpu.c index f93289ae789..2f91da3f15b 100644 --- a/arch/x86_64/src/intel64/intel64_cpu.c +++ b/arch/x86_64/src/intel64/intel64_cpu.c @@ -244,7 +244,7 @@ void x86_64_cpu_init(void) g_cpu_priv[i].loapic_id = lapic->apic_id; g_cpu_priv[i].id = i; g_cpu_priv[i].ready = false; -#ifdef CONFIG_LIB_SYSCALL +#ifdef CONFIG_ARCH_HAVE_SYSCALL g_cpu_priv[i].ustack = NULL; g_cpu_priv[i].uvbase = (uint64_t *)CONFIG_ARCH_TEXT_VBASE; #endif @@ -383,7 +383,7 @@ void x86_64_cpu_priv_set(uint8_t cpu) write_gsbase((uintptr_t)&g_cpu_priv[cpu]); -#ifdef CONFIG_LIB_SYSCALL +#ifdef CONFIG_ARCH_HAVE_SYSCALL /* Configure SYSCALL instruction entry point */ write_msr(MSR_LSTAR, (uintptr_t)x86_64_syscall_entry); diff --git a/arch/x86_64/src/intel64/intel64_head.S b/arch/x86_64/src/intel64/intel64_head.S index 154c849344f..f10fe93f1a5 100644 --- a/arch/x86_64/src/intel64/intel64_head.S +++ b/arch/x86_64/src/intel64/intel64_head.S @@ -80,7 +80,7 @@ .global __enable_sse_avx .global __enable_pcid .global __revoke_low_memory -#ifdef CONFIG_LIB_SYSCALL +#ifdef CONFIG_ARCH_HAVE_SYSCALL .global x86_64_syscall_entry .global x86_64_syscall #endif @@ -348,7 +348,7 @@ start64_init: movl $MSR_EFER, %ecx rdmsr -#ifdef CONFIG_LIB_SYSCALL +#ifdef CONFIG_ARCH_HAVE_SYSCALL or $(EFER_LME | EFER_SCE), %eax #else or $EFER_LME, %eax @@ -536,7 +536,7 @@ __enable_pcid: .size __enable_pcid, . - __enable_pcid -#ifdef CONFIG_LIB_SYSCALL +#ifdef CONFIG_ARCH_HAVE_SYSCALL /**************************************************************************** * Name: x86_64_syscall_entry * diff --git a/arch/x86_64/src/intel64/intel64_saveusercontext.S b/arch/x86_64/src/intel64/intel64_saveusercontext.S index 7e40f91035d..78151d09030 100644 --- a/arch/x86_64/src/intel64/intel64_saveusercontext.S +++ b/arch/x86_64/src/intel64/intel64_saveusercontext.S @@ -105,7 +105,7 @@ up_saveusercontext: movq %rbp, (8*REG_RBP)(%rdi) -#ifdef CONFIG_LIB_SYSCALL +#ifdef CONFIG_ARCH_HAVE_SYSCALL /* Save CS and SS if we support syscalls */ xor %rax, %rax mov %cs, %ax