forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 157
lkl: add make_syscall_tbl.sh to create syscall definition #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,3 +24,83 @@ | |
| __ASCII_MAP(x, __SC_ASCII, __VA_ARGS__) ")\\n\"\n" \ | ||
| ".ascii \"#endif\\n\"\n" \ | ||
| ".section .text\n"); | ||
|
|
||
| /* | ||
| * Unsupported system calls due to lack of support in LKL (e.g. related to | ||
| * virtual memory, signal, user processes). We also only support 64bit version | ||
| * of system calls where we have two version to keep the same API across 32 and | ||
| * 64 bit hosts. | ||
| */ | ||
|
|
||
| #define __IGNORE_restart_syscall | ||
| #define __IGNORE_exit | ||
| #define __IGNORE_fork | ||
| #define __IGNORE_execve | ||
| #define __IGNORE_ptrace | ||
| #define __IGNORE_alarm | ||
| #define __IGNORE_pause | ||
| #define __IGNORE_kill | ||
| #define __IGNORE_brk | ||
| #define __IGNORE_uselib | ||
| #define __IGNORE_swapon | ||
| #define __IGNORE_mmap | ||
| #define __IGNORE_munmap | ||
| #define __IGNORE_swapoff | ||
| #define __IGNORE_clone | ||
| #define __IGNORE_mprotect | ||
| #define __IGNORE_init_module | ||
| #define __IGNORE_quotactl | ||
| #define __IGNORE_msync | ||
| #define __IGNORE_mlock | ||
| #define __IGNORE_munlock | ||
| #define __IGNORE_mlockall | ||
| #define __IGNORE_munlockall | ||
| #define __IGNORE_mremap | ||
| #define __IGNORE_rt_sigreturn | ||
| #define __IGNORE_rt_sigaction | ||
| #define __IGNORE_rt_sigprocmask | ||
| #define __IGNORE_rt_sigpending | ||
| #define __IGNORE_rt_sigtimedwait | ||
| #define __IGNORE_rt_sigqueueinfo | ||
| #define __IGNORE_rt_sigsuspend | ||
| #define __IGNORE_sigaltstack | ||
| #define __IGNORE_vfork | ||
| #define __IGNORE_mincore | ||
| #define __IGNORE_madvise | ||
| #define __IGNORE_getdents /* we use the 64 bit counter part instead */ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "counterpart" should be just one word. |
||
| #define __IGNORE_tkill | ||
| #define __IGNORE_exit_group | ||
| #define __IGNORE_remap_file_pages | ||
| #define __IGNORE_fstatfs /* we use the 64 bit counter part instead */ | ||
| #define __IGNORE_mbind | ||
| #define __IGNORE_get_mempolicy | ||
| #define __IGNORE_set_mempolicy | ||
| #define __IGNORE_mq_open | ||
| #define __IGNORE_mq_unlink | ||
| #define __IGNORE_mq_timedsend | ||
| #define __IGNORE_mq_timedreceive | ||
| #define __IGNORE_mq_getsetattr | ||
| #define __IGNORE_kexec_load | ||
| #define __IGNORE_migrate_pages | ||
| #define __IGNORE_unshare | ||
| #define __IGNORE_set_robust_list | ||
| #define __IGNORE_get_robust_list | ||
| #define __IGNORE_sync_file_range | ||
| #define __IGNORE_vmsplice | ||
| #define __IGNORE_move_pages | ||
| #define __IGNORE_mq_notify | ||
| #define __IGNORE_delete_module | ||
| #define __IGNORE_signalfd4 | ||
| #define __IGNORE_preadv /* we use the 64 bit counter part instead */ | ||
| #define __IGNORE_pwritev /* we use the 64 bit counter part instead */ | ||
| #define __IGNORE_rt_tgsigqueueinfo | ||
| #define __IGNORE_perf_event_open | ||
| #define __IGNORE_setns | ||
| #define __IGNORE_process_vm_readv | ||
| #define __IGNORE_process_vm_writev | ||
| #define __IGNORE_kcmp | ||
| #define __IGNORE_finit_module | ||
| #define __IGNORE_seccomp | ||
| #define __IGNORE_memfd_create | ||
| #define __IGNORE_bpf | ||
| #define __IGNORE_execveat | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,13 @@ | ||
| extra-y := vmlinux.lds | ||
| SYSCALL_DEFS_HDR := ../include/generated/uapi/asm/syscall_defs.h | ||
| UNISTD_HDR = arch/lkl/include/asm/unistd.h | ||
|
|
||
| extra-y := vmlinux.lds $(SYSCALL_DEFS_HDR) | ||
| obj-y = setup.o threads.o irq.o time.o syscalls.o misc.o mem.o console.o | ||
|
|
||
|
|
||
| quiet_cmd_syscall_def = CALL $< | ||
| cmd_syscall_def = $< sysdef $(UNISTD_HDR) arch/lkl/include/generated/uapi/asm/syscall_defs.h | ||
|
|
||
| arch/lkl/kernel/$(SYSCALL_DEFS_HDR): arch/lkl/scripts/make_syscall_tbl.sh $(UNISTD_HDR) | ||
| @mkdir -p arch/lkl/include/generated/uapi/asm/ | ||
| $(call cmd,syscall_def) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| #!/bin/bash | ||
|
|
||
| #set -x | ||
|
|
||
| # requires: bash-4.0 (hashtable), cpp, grep, sed, cat | ||
|
|
||
| ## | ||
| ## Usage: $0 | ||
| ## ARGV[0]: (OPT: "systbl" oe "sysdef") | ||
| ## ARGV[1]: (IN: asm/unistd.h) | ||
| ## ARGV[2]: (OUT: syscall_table.h(systbl) or syscall_defs.h (sysdef)) | ||
| ## | ||
|
|
||
| mode=$1 | ||
| in=$2 | ||
| out=$3 | ||
|
|
||
| if [ "$mode" != "systbl" ] && [ "$mode" != "sysdef" ] ; then | ||
| echo "Usage: $0 [systbl|sysdef] (unistd.h) (output file)" | ||
| exit | ||
| fi | ||
|
|
||
| echo "" > $out | ||
|
|
||
| # obtain the blacklist of syscall | ||
| declare -A ignore_syscall | ||
|
|
||
| ## | ||
| ## step 1: create ignored syscall table entries based on | ||
| ## | ||
| while read def nr ; do | ||
| name=$(echo $nr | sed "s/__IGNORE_/__NR_/") | ||
| ignore_syscall[$name]="ignored" | ||
|
|
||
| if [ $mode = "systbl" ] ; then | ||
| cat << EOF >> $out | ||
| #define __SYSCALL_STE_${name}(nr,sym) [nr] = (syscall_handler_t)sys_ni_syscall, | ||
| __SYSCALL_STE_${name}(${name},dummy) | ||
| EOF | ||
| fi | ||
| done < <(${CROSS_COMPILE}cpp ${LINUXINCLUDE} -dM -fdirectives-only $in | grep '__IGNORE_') | ||
|
|
||
| ## | ||
| ## stop if systbl is specified | ||
| ## | ||
| if [ $mode = "systbl" ] ; then | ||
| exit | ||
| fi | ||
|
|
||
|
|
||
| ## | ||
| ## step 2-1: grep SYSCALL_DEFINE in whole tree with specific | ||
| ## directories ($SYSCALL_DIRS) | ||
| ## | ||
| SYSCALL_DIRS="block drivers/pci drivers/char fs init ipc kernel mm net" | ||
| SYSCALL_FILES=$(find ${SYSCALL_DIRS} -name \*.c | \ | ||
| xargs grep -E "^SYSCALL_DEFINE[0-6]" -l) | ||
|
|
||
| ## | ||
| ## step 2-2: dump lkl syscall definitions from preprocessor's ouptut | ||
| ## | ||
| set -f | ||
| for file in ${SYSCALL_FILES} ; | ||
| do | ||
| while read syscall; do | ||
| func=$(echo $syscall | sed "s/SYSCALL_DEFINE.*(\([^,]*\).*/\1/") | ||
| #echo "syscall= "$syscall | ||
| #echo "func= "$func | ||
|
|
||
| # 0) pull the system call name | ||
| funcname=$(echo $func | sed "s/(.*//" | sed "s/long sys_//") | ||
| #echo "funcname ="$funcname | ||
|
|
||
| # 1) skip if the syscall is unsupported | ||
| if [ "${ignore_syscall[__NR_$funcname]}" = "ignored" ] ; then | ||
| #echo $funcname " ignore= " "${ignore_syscall[__NR_$funcname]}" | ||
| continue | ||
| fi | ||
|
|
||
| # 2) count the number of argument | ||
| func_l=/$func/ | ||
| IFS=',' | ||
| set -- $func_l | ||
| argc=0 | ||
| if [ $(echo $func | sed "s/.*(//") != "void)" ] ; then | ||
| argc=`expr $(($#-1)) + 1` | ||
| fi | ||
| #echo "argc = $argc" | ||
| IFS=' ' | ||
|
|
||
| # 3) pull arg name template | ||
| args=$(echo $func | sed "s/.*(/(/" | sed "s/__lkl__kernel_//g"\ | ||
| | sed "s/lkl_//g" | sed "s/[()]//g") | ||
| OIFS="$IFS"; IFS=',' | ||
| arg=($args); IFS="$OIFS" | ||
| #echo "arg ="$arg > /dev/stdout | ||
|
|
||
| param="" | ||
| for i in {1..6} ; do | ||
| if [ $i -gt ${argc} ] ; then | ||
| break | ||
| fi | ||
| if [ $i -ne 1 ] ; then | ||
| param="${param}, " | ||
| fi | ||
| nparam=$(echo ${arg[$((i-1))]} | \ | ||
| sed "s/\(.*\) \(.*\)$/\1, \2/") | ||
| param="${param}${nparam}" | ||
| done | ||
| #echo ${param} > /dev/stdout | ||
| IFS=' ' | ||
|
|
||
| # 4) give a template based on funcname, args | ||
| cat << EOF >> $out | ||
|
|
||
| #ifdef __NR_$funcname | ||
| SYSCALL_DEFINE$argc(_$funcname, $param); | ||
| #endif /* __NR_$funcname */ | ||
| EOF | ||
| done < <(${CROSS_COMPILE}cpp -P ${LINUXINCLUDE} $file 2>/dev/null \ | ||
| | grep "long sys_" | sed "s/^; / /" \ | ||
| | sed "s/\(.*\) __attribute.*/\1/" | grep -vE ";|,$") | ||
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this supposed to be an underscore instead of a comma?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is intentional.