[GSoC] Questions about emulating missing linux system calls project

2024-03-31 Thread Jamgadepatil Shivraj Shashikant
Hello,
For the past few days, I have been trying to assess support for Linux
system calls on a NetBSD system. I am using Linux Test Project
for identifying system calls that are yet to be emulated on NetBSD.
I have setup QEMU with GENERIC kernel for testing purpose
(Thanks iMil for helping me out!) with COMPAT_LINUX option
enabled.

I have following particular questions:


  1.
I wish to emulate support for pidfd_* family of system calls,
open_tree, openat2, clone3. I believe they still lack
emulation support. Where should I look to identify the
possible mappings for these system calls in NetBSD
kernel?

  2.
I found around 40 system calls that currently lack
emulation support. Most of them are the system calls

that aren't popular or are more relevant to Linux kernel. Only
some of the newer system calls seem more likely to be able
to be mapped directly to NetBSD system calls. Is it expected
to actually implement some of them in NetBSD kernel and
then add them to compat layer as part of this project?

Also, what's the state of splice and sendfile system calls? I
can see that they have been implemented as part of
GSoC 2022 but the test cases relating to them still can't
find these system calls.


  1.
With respect to system calls relating to scheduler, I get error
relating to not finding some particular files in proc directory.
I have set up proc as mentioned in documentation but I still
get these errors when I run schedular related system calls.
Does proc need to be configured in different way or do schedular
related system calls actually lack emulation support?


I would also like to thank Theodore for helping me understand the work he did 
last year.

Thanking you,
Shivraj


Re: [GSOC][NEWBIE]

2024-03-28 Thread Jamgadepatil Shivraj Shashikant
Hello iMil,
Thanks a lot for the help. I was able to set up the qemu VM following the 
commands you specified.
Once again thanks a lot for your help.

Thanking you,
Shivraj


From: Emile 'iMil' Heitor 
Sent: Thursday, March 28, 2024 10:23 PM
To: Jamgadepatil Shivraj Shashikant ; tech-kern@netbsd.org 

Subject: Re: [GSOC][NEWBIE]

External Email


On 3/28/24 17:44, Jamgadepatil Shivraj Shashikant wrote:

> I even tried gziped kernel image stored in releasedir directory, so I
> guess it's not only PVH boot that was causing the problem. I suspected I
> might have built the kernel incorrectly, so I also tried booting from
> the daily kernel build provided on the github but the kvm error persists.
> qemu command I am using for booting the system is: qemu-system-x86_64 -m
> 2048 -kernel netbsd-GENERIC.gz -drive
> if=virtio,file=disk.qcow2,format=qcow2 -enable-kvm

Don't gzip the kernel, here's an example session:

$ git branch
* perf
$ ./build.sh -U -u -j4 -T obj/tooldir -m amd64 tools
$ ./build.sh -U -u -j4 -T obj/tooldir -m amd64 kernel=MICROVM
$ KERNEL=sys/arch/amd64/compile/obj/MICROVM/netbsd
$ IMG=NetBSD-10.99.10-amd64-live.img # fetch and gunzip this from
https://nycdn.netbsd.org/pub/NetBSD-daily/HEAD/202403200640Z/images/NetBSD-10.99.
10-amd64-live.img.gz
$ qemu-system-x86_64 \
 -M microvm,x-option-roms=off,rtc=on,acpi=off,pic=off \
 -enable-kvm -m 512 -cpu host,+invtsc \
 -append "root=ld0a console=com rw -v" -display none \
 -device virtio-blk-device,drive=hd0 \
 -drive file=${IMG},format=raw,id=hd0 \
 -netdev user,id=net0,hostfwd=tcp::10022-:22 \
 -device virtio-net-device,netdev=net0 \
 -kernel ${KERNEL} -serial mon:stdio

FYI I'll be mostly AFK till next Tuesday.

Cheers,

--

Emile `iMil' Heitor  | https://imil.net


Re: [GSOC][NEWBIE]

2024-03-28 Thread Jamgadepatil Shivraj Shashikant
Hello iMil,
Thanks for your suggestions. I built the kernel from the sources available on 
the github link you provided. I am still running into the similar issues

[GSOC][NEWBIE]

2024-03-28 Thread Jamgadepatil Shivraj Shashikant
Hello, I am Shivraj. I found the project about "adding support for emulation of 
missing linux syscalls" to NetBSD kernel intriguing.
I have previously worked on projects involving the Linux kernel. I have worked 
on adding system calls to Linux kernel for isolating cores, implementing a 
different scheduler in the kernel for normal processes and to provide support 
for anonymous memory checkpointing for a user process by writing a custom page 
fault handler.
I have been exploring NetBSD source tree for a few days. I am trying to set up 
my development environment with qemu to check out some ideas and understand 
things more clearly. I tried to boot from the kernel compiled from sources, but 
I am still unable to do so. I would appreciate all the help people here can 
provide to guide me to set up the development environment.
I am using Linux as my host OS and have cross-compiled the NetBSD kernel but 
loading the custom kernel results in a KVM emulation error. I am unable to find 
the path where compressed kernel image is generated. Images generated in 
releasedir results in errors or a frozen qemu screen.

Thanking you,
Shivraj Jamgade
MTech CSA
Indian Institute of Science, Bangalore