Cooperative

Linux

Cooperative Linux

How it works

Current state of development

Uses and applications

Cooperative Linux
How it works

A kernel patch, kernel code and user space tools that provide the means to load and run Linux under the driver context of another running kernel.

The loaded Linux kernel runs in the same protection level as the standalone kernel, alongside it.

The loaded guest kernel is given a fixed amount of physical memory by the driver to use for itself.

It has its own page tables and full control of the MMU and 4GB address space.

Overview of the Cooperative Linux architecture

Guest Kernel

Host Kernel

coLinux

Kernel

driver

Run

ioctl()

(ring0)

(ring0)

Normal

Linux

Userspace

(unmodified

binaries)

(ring3)

Host Userspace

colinux-daemon

process

Main

Loop

colinux-bridged-net-daemon

process

colinux-net-daemon

process

colinux-serial-daemon

process

colinux-console-nt

process

IPC using

named pipes

Passage

page

entry

entry

Running the Linux context

In the host OS, a userspace daemon (colinux-daemon) constantly calls a ioctl in the driver.

The driver switches to the guest kernel using a carefully written low level i386 code. All the state of the CPU is preserved (the general purpose registers and control registers).

When the guest wants to request data from the host or when an hardware interrupt occurs, a switch is made back to the host OS driver.

Kernel Space Overview (ring0)

Passage

Page

Host Kernel

Guest Kernel

(ring0)

(ring0)

(ring0)

entry

entry

cobd

conet

cobd

cobd

cocon

cobd

Interrupt

forwarding

Etc..

coLinux

host kernel

driver

(linux.sys,

colinux.ko)

Run

ioctl()

Contents of the passage page (4KB)

ESP

EBX

ECX

EDX

ESI

EBP

EDI

EIP

DS

EAX

CS

ES

FS

GS

FLAGS

CR2

CR0

CR3

CR4

GDTR

IDTR

LDTR

TR

MMX

SSE

SSE2

FP

ESP

EBX

ECX

EDX

ESI

EBP

EDI

EIP

DS

EAX

CS

ES

FS

GS

FLAGS

CR2

CR0

CR3

CR4

GDTR

IDTR

LDTR

TR

MMX

SSE

SSE2

FP

Guest state

Host state

Passage page context switch code -

Switches between the currently active

and currently passive states.

Data

Code

DEBUG

DEBUG

Mapping of the passage page

CR3 change

CR3 change

JMP

Guest address space

Temporary address space

Host address space

Interrupt and Exception Handling

Passage

Page

Host Kernel

Guest Kernel

(ring0)

(ring0)

(ring0)

entry

entry

ISR YY

ISR XX

Page

Fault

(internal)

IDE0

(external)

Guest ISR table

ISR XX

Host ISR table

IDE0

handling

code

Internal

handling

YY < 32

XX >= 32

text

Memory Management and Mapping

Physical Memory

Guest Kernel

Virtual Address Space

FFFFFFFF

C0000000

data

bss

pseudo

physical

ram

page tables that

map this address

space

fixmaps

Reverse address

translation tables

Cooperative Linux
How it works - The kernel patch

Adds CONFIG_COOPERATIVE to make all the changes compile-time optional.

Adds a method of interfacing with the host OS driver.

Changes MMU macros which read and write PTEs.

Adds a few virtual drivers that implement block devices, console video output, network device.

Deny access from userspace to hardware (ioperm() and iopl() are designed to fail).

Hardware abstraction using the aforementioned drivers is used instead.

Cooperative Linux
How it works – The various components

Message passing between Linux, the kernel driver, and the user space daemons is being performed.

Block devices (i.e disks) are host OS files or raw devices – these are read and written directly from the host OS kernel.

Virtual Network is done on Windows using the TAP Win32 driver which provides virtual Ethernet for applications (on Linux we use the tuntap driver).

Bridged Networking is possible using PCAP without TAP Win32.

The virtual console is a VGA-like console which is implemented by message passing.

Cooperative Linux
Current state of development

Runs a slightly modified Linux 2.6.8.1 kernel under a standalone Linux system based on Linux 2.6.8.1.

Current size of the kernel patch : 135KB

Can also run under NTOSKRNL (kernels compatible to Windows 2000's kernel), thus providing an unemulated Linux to Windows users for free.

Almost completely passes the LTP (Linux Test Project)

Cooperative Linux
Uses

Migration from other operating systems - can provide fast and easy point-and-click Linux setups for Linux newbies on Windows (see Japanese KNOPPIX)

Adding Windows machines to Linux clusters (openMosix patch combined with the Cooperative Linux patch)

Running an otherwise-dual-booted Linux system from another OS

Using Linux's iptables firewall on an another operating system

Linux kernel development, research and debugging

Provides a development platform for porting software to and from Linux

Thanks

Jun OKAJIMA, Digital Infra, Inc.

Kuniyasu SUZAKI, AIST

Kazuhiko KATO, University of Tsukuba

2004-09-01T20:57:54