Re: Interface for communicating from kernel to user mode

2025-03-11 Thread Peter Skvarka
Resolved, vmspace initialization was missing. I used uio_setup_sysspace(&my_uio); Now I am seeing message in kernel which was sent through socket pair from user space. Thanks for all your detailed answers. Peter

Re: Interface for communicating from kernel to user mode

2025-03-11 Thread Mouse
>> Could you break into ddb? A stack trace of the freeze might be useful. > 1. I have NetBSD 10.1. Okay. That limits the amount I can help with details, since I don't run it. (Even at work, the latest NetBSD I use is 9.1.) > I found crash dump: > crash> bt > __kernel_end() at 0 > kern_reboot(

Re: Interface for communicating from kernel to user mode

2025-03-11 Thread Peter Skvarka
Could you break into ddb? A stack trace of the freeze might be useful. Two things: 1. I have NetBSD 10.1. I found crash dump: crash> bt __kernel_end() at 0 kern_reboot() at sys_reboot vpanic() at vpanic+0x192 panic() at device_printf trap() at startlwp --- trap (number 6) --- uiomove() at u

Re: Interface for communicating from kernel to user mode

2025-03-11 Thread Mouse
> [...reached the point of having the struct socket *...] > What I cannot resolve is which function to use for receiving data > sent from user mode on retrieved file_fd in kernel module. When I > tried soo_read(file_fd,...) then OS freezes and need to reboot. I > call soo_read() in kernel thread

Re: Interface for communicating from kernel to user mode

2025-03-11 Thread Peter Skvarka
Thanks for detailed answer. With help of your description I reached valid file_t* file_fd in kernel module. In kernel module I used file_fd = fd_getfile2(lwp_ptr->l_proc, user_fd); which encapsulates your older code. Also test for descriptor type: if(file_fd->f_type != DTYPE_SOCKET) {...} is o

Re: Interface for communicating from kernel to user mode

2025-03-09 Thread Brian Buhrow
Hello. Depending on the amount of data yu want to pass between kernel space and user space, you might consider writing a simple device driver kernel module which implements ioctl(2) functions or read(2) and write(2) functionality. Ioctl commands are good for passing data in chunks of

Re: Interface for communicating from kernel to user mode

2025-03-08 Thread Mouse
> I am trying to implement user<->kernel communication with > socketpair() in user space and then passing one of descriptors to > kernel. > I am investigating socket.h and socketvar.h > There are functions working with sockets in kernel space, they [use] > struct socket in their parameters and use

Re: Interface for communicating from kernel to user mode

2025-03-06 Thread Jörg Sonnenberger
On 3/5/25 1:53 PM, Peter Skvarka wrote: Described AF_LOCAL sockets are for me candidate no.1. You can also consider a custom kevent filter for this. It really depends on what kind of communication you want. Joerg

Re: Interface for communicating from kernel to user mode

2025-03-05 Thread Thor Lancelot Simon
On Wed, Mar 05, 2025 at 01:53:22PM +0100, Peter Skvarka wrote: > Thank you, I have this commit on my machine and investigating it. > > Described AF_LOCAL sockets are for me candidate no.1. > I am also considering using signal (siginfo.h and signalvar.h) for sending > signal from kernel to user pro

Re: Interface for communicating from kernel to user mode

2025-03-05 Thread Mouse
> Thank you, I have this commit on my machine and investigating it. Yes, I see the upload-pack connection in my logs. I'll be happy to explain anything that's unclear there (well, as best I can; my memory may be a bit fuzzy after twenty-plus years). Of course, you probably will want only a small

Re: Interface for communicating from kernel to user mode

2025-03-02 Thread Mouse
>> - Userland creates an AF_LOCAL SOCK_STREAM socketpair and passes one >>of the resulting socket fds to the kernel, which takes over the >>referenced socket and uses it, with userland reading from and >>writing to the other socket. > I need this for notifying about some event in kernel

Re: Interface for communicating from kernel to user mode

2025-03-02 Thread Peter Skvarka
- Userland creates an AF_LOCAL SOCK_STREAM socketpair and passes one of the resulting socket fds to the kernel, which takes over the referenced socket and uses it, with userland reading from and writing to the other socket. I need this for notifying about some event in kernel modu

Re: Interface for communicating from kernel to user mode

2025-02-28 Thread Michael van Elst
mo...@rodents-montreal.org (Mouse) writes: >- Userland creates an AF_LOCAL SOCK_STREAM socketpair and passes one of > the resulting socket fds to the kernel, which takes over the > referenced socket and uses it, with userland reading from and > writing to the other socket. That's about how

Re: Interface for communicating from kernel to user mode

2025-02-28 Thread Mouse
> what is suitable interface or mechanism on NetBSD to send message > with some data from kernel-mode code to user-mode process ? There are lots of options. Depending on tradeoffs such as the typical size of a message, the bandwidth required, and how many such comm channels need to be supported a