28.08.2015 Views

The Design and Implementation of the Anykernel and Rump Kernels

1F3KDce

1F3KDce

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

77<br />

3.2.3 <strong>The</strong> Hypercall Interface<br />

<strong>The</strong> hypercall library implements <strong>the</strong> hypercall interface for <strong>the</strong> particular host. On<br />

a POSIX host, <strong>the</strong> library is called librumpuser <strong>and</strong> <strong>the</strong> source code can be found<br />

from lib/librumpuser. For historical reasons, <strong>the</strong> interface itself is also called<br />

rumpuser, although for example rumphyper would be a more descriptive name.<br />

As an example <strong>of</strong> a hypercall implementation we consider allocating“physical”memory<br />

from <strong>the</strong> host. This hypercall is implemented by <strong>the</strong> hypercall library with a<br />

call to posix_memalign() 4 . Conversely, <strong>the</strong> hypercall for releasing memory back<br />

to <strong>the</strong> system is implemented with a call to free().<br />

<strong>The</strong>oretically, a rump kernel can accomplish this by calling <strong>the</strong> host directly. However,<br />

<strong>the</strong>re are a number <strong>of</strong> reasons a separate hypercall interface is better.<br />

1. <strong>The</strong> user namespace is not available in <strong>the</strong> kernel. To for example make<br />

<strong>the</strong> posix_memalign() call, <strong>the</strong> rump kernel has to define <strong>the</strong> prototype for<br />

<strong>the</strong> function itself. If <strong>the</strong> prototype matches what libc expects, <strong>the</strong> call is<br />

correctly resolved at link time. <strong>The</strong> downside is that duplicated information<br />

can always go out-<strong>of</strong>-date.<br />

Fur<strong>the</strong>rmore, calling out <strong>of</strong> <strong>the</strong> kernel is not<br />

directly possible due to <strong>the</strong> symbol renaming we presented in Section 3.2.1.<br />

2. A separate interface helps when hosting a rump kernel on a platform which<br />

is not native to <strong>the</strong> rump kernel version.<br />

For example, while all POSIX<br />

platforms provide stat(const char *path, struct stat *sb), <strong>the</strong>re is<br />

no st<strong>and</strong>ard for <strong>the</strong> binary representation <strong>of</strong> struct stat.<br />

<strong>The</strong>refore, a<br />

reference to <strong>the</strong> structure cannot be passed over <strong>the</strong> interface as binary data,<br />

4 posix_memalign() is essentially malloc(), but it takes an alignment parameter in addition<br />

to <strong>the</strong> size parameter. Kernel code assumes that allocating a page <strong>of</strong> memory will return it from<br />

a page-aligned <strong>of</strong>fset, <strong>and</strong> using posix_memalign() instead <strong>of</strong> malloc() allows to guarantee that<br />

memory allocated by <strong>the</strong> hypercall will be page-aligned.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!