mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
arch/x64:Syscall support is enabled by default
Syscall enablement is controlled by CONFIG_ARCH_HAVE_SYSCALL Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
This commit is contained in:
parent
0e4d291156
commit
794c325947
7 changed files with 21 additions and 18 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue