GSOC - Emulating missing linux syscalls

Vasyl Maksym Lanko <[email protected]>
Newsgroups gmane.os.netbsd.devel.kernel
Message-ID <[email protected]>
Hello!
I have some questions about GSOC - Emulating missing linux syscalls ( 
https://wiki.netbsd.org/projects/project/linux_timer/ ).
I have been using Linux for some years but never touched NetBSD, so I'm 
going to describe the project using Linux names/tools instead.

"Not all Linux syscalls are implemented. This means some programs cannot 
run.

This project is about identifying critical missing syscalls and adding 
support for them."

Here I can see 2 approaches, first one being synthetic and focused only 
on finding the missing/incorrect syscalls: compile binaries that 
exclusively have inline assembly that just set syscall NR register and 
invoke syscall, then exit with code 0. We can then see which ones 
failed, possibly the ones who didn't exit with code 0 (wouldn't work for 
the exit() syscall but that's an exception).

Second approach would be closer to a real-world scenario, where we are 
running a program but it crashes. What we could do then is launch the 
program again under strace (I know it's Linux specific but from what 
I've seen I think Dtrace and ktrace would be equivalent for this 
context) and inspect the log looking from the bottom, where it crashed.

"This project is about identifying critical missing syscalls and adding 
support for them."

Well, I never touched the kernel and it seems compat-linux uses kernel 
internal structs, but from my quick look it doesn't seem too scary.

I found in src/sys/compat/linux/arch/aarch64/syscalls.master the list of 
linux syscalls (for my arch) and their implementation status, so this is 
probably a better way to see what syscalls aren't implemented.
Then I looked into the simplest syscall I know, getpid(), and from 
src/sys/compat/linux/arch/aarch64/ line 795 I can see it's calling some 
sys_getpid, looking some lines down at line 813 there's linux_sys_gettid 
so it seems that getpid() is executed natively while gettid() uses a 
function to virtualize gettid().

Looking at stc/sys/compat/linux/common at line 669 there's the 
implementation of linux_sys_gettid!

So, my questions:
1. Is this mostly correct?
2. Is this project mostly about identifying the missing syscall used in 
a Linux Binary and porting it to NetBSD?
3. I have never programmed a Kernel but I have worked with system calls 
in Linux, namely replaying them in userspace, (so just copying a saved 
syscall result and populating a needed arg, like void* buf from read()), 
and also I like learning how things work and low-level programming, do 
you think this project would be in my reach?
4. What would you consider to be a successful gsoc contribution to 
compat-linux? I see this project estimated at 350h with the goal of 
finding a Linux binary that crashes and... begin implementing the 
missing features to compat_linux. Is it that complicated that the 
missing syscalls would take so much effort?

Best Regards, Vasyl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.