Hello Clemens,

I changed subject line and started a new mail thread.

On 09.04.2011 19:52, Clemens Eisserer wrote:
1. Just to make sure - does coLinux allocate any pageable memory for
itself or for memory the kernel uses? As far as I've seen it only
allocates from NonPagedPool.

For all the memory used by Linux guest is from non paged pool.
For the internal driver space on Windows host side a normal memory pool is used (can be swapped out).

2. When communicating from a windows kernel-level driver with the
colinux linux-kernel, you mentioned shared-memory as well as message
queues.
I had a look at the code, but couldn't find the functions. Which
functions do I need?
When using such a message-queue, will there be a context-switch to the
coLinux kernel thread (if there is something like this at all), or
will the message-data processed without any context switch simply by
calling inside the linux kernel directly?

It is a message queue for command and small data (< 4K), For data like write to disk the Windows host driver maps the page(s) from the Linux guest, like shared memory. For the read data from disk, the Linux spend the buffer and the Windows side will fill the data, also like shared memory.
Serial and network data goes though a message queue without shared memory.

All commands goes over a single function co_switch_wrapper from Linux to Windows (see examples in linux-2.6.33.7-source/drivers/video/console/cocon.c). The way from Windows to Linux goes over the function co_user_monitor_message_send for user space programs. Internally both functions will do a context switch.

The normal way is, that Linux side calls a function on Windows. The way back exist only for small thinks, like keyboard, network, serial and "power". All these have a correspond "interrupt" entry inside Linux kernel, that will handle this injections.

Data from Windows kernel to Linux kernel will not send with shared memory. For this exist only a message queue. You can use the function co_monitor_message_from_user in Windows kernel space for that. An example you can see inside scsi_send_intr (src/colinux/os/winnt/kernel/scsi.c). The code sends an "interrupt acknowledge" to the block driver.

An other injection from Windows to Linux is the Shutdown request. Grep for CO_LINUX_MESSAGE_POWER_SHUTDOWN on coLinux kernel and inside Linux kernel. src/colinux/user/daemon.c linux-2.6.33.7-source/arch/x86/kernel/reboot_cooperative.c. The related function is co_user_monitor_message_send for a Windows user land program.

An other User space example is the serial driver. That will post chars in both directions. Search for CO_"DEVICE_SERIAL" to find the callings. But, this driver (and the network too) is complicated to understand, because they use a way to read and write on two open devices in blocking mode, like "select" under Linux. But is more complicated under Windows. Inside coLinux we have a framework, that is named "Reactor" and used co_reactor_select as main entry. The Reactor is for reading and writing stream data in two directions.

Of curse the single interrupt injection from a call of co_monitor_message_from_user or co_user_monitor_message_send will also use the Reactor inside. Reactor handles the message queue for all commands from Windows to Linux. Such injections typically have no return code, unless the Linux kernel side will self send back something via co_switch_wrapper.

A kernel space example for sending from Windows kernel to Linux kernel is the network driver ndis. src/colinux/os/winnt/kernel/conet.c. There you will find the way to send bigger data (>4k) with a delayed work queue. The data package will create in function co_conet_proto_receive.

Summary:
From Linux kernel to Windows use co_switch_wrapper.
From Window kernel to Linux kernel use co_monitor_message_from_user.
-- 
Henry N.