VM -- pager for L4 interface with cache coloring

1 SERVER

vm --cbits num [ --verbose num ] [ --pftwice ]

1.1 Description

VM can work as pager for any L4 task. The special feature of this pager is the cache coloring (have a look to an instresting paper at
[here]).

Cache coloring allows you to separate the cache memory for exclusiv access for some important tasks. Some selected bits of the physical address will be used to assign to a part of the cache memory. If you have a special pager - VM - you can manage the physical memory so that each task has his own part of cache memory. So you can allways plan the use of this very fast memory to speedup you task.

To calculate the number of bits do you need to know the cache memory size, the size of a physical page an the associativity of the cache architecture. Divide the cache size by the page size * assoziativity and you get the number of colors. Take log2 of this number an you get the number of bits. (For example: 32 colors -> 5 bits)

1.2 Arguments

--cbits num
Set the number of bits which are used to specify the colors. This option is nessesary to set, because each systems cache architecture is different in this number.
--verbose num
Set the verbosity of debugging output of the VM server. Values between 0 and 3 are allowed.
--pftwice
Turns on the page fault happend twice-facility. If a task generated two requests for the same page VM goes to the kernel debugger. This could be helpfull for find buggy memory access routines.

1.3 Startup

VM have to be the pager for each task. So VM has to start these tasks. In the acutally L4 environment we use GRUB to load the task modules. The RMGR take this modules an start them up - normaly.

RMGR allows you to specify a set of modules wich will be passed to any other module. We use this feature as follows:

1.4 Module specific commandline arguments

After a % in the commandline you can specify the module specific options.

%:col:[0,0x]map
%colb:map
%mcp:num
%small:bool

Indicated by col can be specified a decimal, octal or hexadecimal map. (Use 0x and 0 to denote hexadecimal resp. octal maps.)

If you want zu specify binary maps use colb .

To specify the mcp write the number after mcp .

Small address page support can be turned on with small.

2 VM SPECIFIC PROTOCOL

The VM pager is a single task. Each further task who should be controled by VM will be started with VM as standard pager. So each page fault will be handled by VM.

Some special tasks may want to allocate pages with a special color or need some information from VM. Therefore there exists a special protocol.

You can use this blank protocol if you want. But there is a CLIENT LIBRARY (next section) that provides you a set of C functions. If you want to know the protocoll please have a look in the detailed documentation in vm/doc/vm.lyx.

3 CLIENT LIBRARY

To hide the the VM SPECIFIC PROTOCOL (see previews section) there is client library which provides a set of C functions to call the server with the special IPC call.

3.1 Synopsis

#include <l4/vm/vm.h>

void vm_init(void);

int vm_map(vm_offset_t page,vm_offset_t va);
int vm_unmap(vm_offset_t va);
vm_offset_t vm_map_from_color(unsigned color);
vm_offset_t vm_virt_to_phys(vm_offset_t va);
int vm_get_valid_colors(dword_t *d0, dword_t *d1);
unsigned vm_get_max_colors(void);
int vm_ping(void);
dword_t vm_request_contiguous(vm_offset_t va, dword_t size);

3.2 Description

In the case of IPC error all functions returns with -1.

vm_map(page,va)
To allocate a special page even it's not a page of the valid color for this task you can use this function. You give the wanted page and the virtual address va as arguments.

Results
If the requested pages is still not mapped to any other task VM mapps page to the address va in your address space and returns true (1), otherwise false(0).

vm_unmap(va)
Try to unmap the page at the give virtual address.

Results
vm_unmap returns with false (0) if the page is not mapped or true (1) if request is proceeded.

vm_map_from_color(color)
To get any page of a specific color call vm_map_from_color with color as color number.

Results
If there is a page of this color left it will be mapped in your address space and returns the address, -2 if no page of this color is available or -3 if the requested color isn't valid for the requester.

vm_virt_to_phys(va)
Call this function with va as virtual address and you'll get back the physical address or -2 if it isn't mapped from VM to you.
vm_get_valid_colors(*col_t)
Givs back the bitmap of valid colors as special typ col_t.
vm_get_max_colors(void)
Givs back the maximal number of colors.
vm_ping(void)
Return with true of the VM server responsed correctly.
vm_request_contiguous(vm_offset_t va, dword_t size)
Reserves a set of physically contigous pages with size bytes size. If the request could be successfully proceeded vm_request_contigous returns the start address of the region or NULL otherwise.
The pages are only resereved - not mapped!

4 See Also

L4 documentation
[here]
Lukas Grützmacher