Skip to content

Commit

Permalink
[new release] mirage-xen (v6.0.0)
Browse files Browse the repository at this point in the history
CHANGES:

Version 6.0.0 is a re-write of the MirageOS Xen platform stack, with the
overall goal of replacing Mini-OS and moving to a minimal, legacy-free codebase
which builds MirageOS unikernels as Xen PVHv2 domUs only. At the same time,
this change aligns the Xen backend with existing Solo5 backends as much as is
practical and replaces the OCaml runtime with that provided by
ocaml-freestanding.

This is a breaking change. MirageOS libraries and applications that make use of
Xen-specific APIs will need to be updated. See below for a list of the
interfaces that have changed.

Requirements changes:

* OCaml 4.08 or later and Dune 2.6 or later are required.
* Xen version 4.10 or later is required, as this is the earliest version which
  provides production-quality and stable PVHv2 APIs.
* Additionally, the custom Xen version 4.8 used by Qubes OS 4.0 is supported,
  as this has enough of PVHv2 backported to it.
* Only x86\_64 hosts with HAP (EPT) are supported. Support for ARM32 has been
  removed. Support for ARM64 may be added at a later date if there is interest.

Security posture improvements:

With the move to a Solo5 and ocaml-freestanding base MirageOS gains several
notable improvements to security posture for unikernels on Xen:

* Stack smashing protection is enabled unconditionally for all C code.
* W^X is enforced throughout, i.e. `.text` is read-execute, `.rodata` is
  read-only, non-executable and `.data`, heap and stack are read-write and
  non-executable.
* The memory allocator used by the OCaml runtime is now dlmalloc (provided by
  ocaml-freestanding), which is a big improvement over the Mini-OS malloc, and
  incorporates features such as heap canaries.

Interface changes:

* The `Eventchn` and `Generation` modules, previously provided by `xen-evtchn`
  have been folded into `mirage-xen` as `OS.Eventchn` and `OS.Generation`
  respectively.  Applications and libraries should replace any dependency on
  `xen-evtchn` with one on `mirage-xen {>= "6.0.0"}` and use the corresponding
  submodules in `OS` directly.
* The `OS.MM` module has been replaced with a new `OS.Memory` module, with a
  statistics interface modeled after stdlib's `Gc` stat type. All units use the
  system word size rather than pages, which were ill-defined.
* `OS.Sched` has been removed. These interfaces (notably domain suspend/resume)
  were present but never fully implemented in the old Xen stack.  They are not
  required for PVH domains or full-system suspend/resume and
  applications/libraries should remove any calls to them.
* `OS.Start_info` has been removed. These interfaces were specific to Xen PV,
  and don't have a direct equivalent for PVH domains.
* `OS.Xenctrl` has been removed. There are no known users of these interfaces,
  which appear to be a left-over from earlier versions of the Xen stack.
* `OS.Xen.virt_to_mfn` has been removed. This is a little-used low-level
  vestige of Mini-OS, and in the Solo5-based virtual memory arrangement should
  be replaced with the equivalent computation (`addr >> 12`) in application
  code directly.

Dependency changes:

* Now depends on `solo5-bindings-xen` (for the low-level VCPU initialisation
  and startup) and `ocaml-freestanding` (for the OCaml runtime). It follows
  that `-freestanding` variants of existing packages such as `zarith` and `gmp`
  are used instead of `-xen` variants.
* The `io-page-xen` package is no longer used. Applications/libraries depending
  on it should replace the dependency with one on `io-page`.
* As mentioned above, the `xen-evtchn` package is no longer used and
  applications/libraries should replace their dependency with one on
  `mirage-xen {>= "6.0.0"}`.

C stubs changes:

* `alloc_pages_stubs.c`: added, provides stubs for `Io_page`, as in `mirage-solo5`.
* `checksum_stubs.c`: added, provides stubs for `Tcpip`, as in `mirage-solo5`.
* `exit_stubs.c`: removed, equivalent provided by `ocaml-freestanding`.
* `sched_stubs.c`: removed, no longer required.
* `start_info_stubs.c`: removed, no longer required.
* `xb_stubs.c`: removed, no users and no longer required.

Apart from the above, the majority of C stubs which are used by `mirage-xen`
have been renamed to follow the `mirage_xen_XXX` rather than `stub_XXX`
convention.

The low-level C interfaces to Xen event channels (`evtchn.c`) and grant tables
(`gnttab.c`) have been re-written from scratch. Some additional interfaces have
been added to `main.c` to replace functionality that was previously part of
`start_info_stubs.c` (obtaining initial PV console and Xenstore ports and I/O
rings from Xen).

Due to issues with mixing PIC and non-PIC code when compiling the C stubs with
Dune, the build system has been adapted to use a foreign Makefile for
`libmirage-xen_bindings.a`. This is the recommended method to use when building
libraries containing C code for use with MirageOS. See conversation in mirage/mirage-xen#23 for
details.

Relationship with the Solo5 Xen bindings:

For Xen, Solo5 only provides the initial PVH boot, VCPU setup/traps and C-side
PV console code. Some Mirage-internal private APIs are provided to allow
`mirage-xen` to interact with the hypervisor -- this is fully explained in
Solo5 commit Solo5/solo5@f4b47d1 and follow-ups.
  • Loading branch information
hannesm committed Oct 20, 2020
1 parent 6382193 commit b900e51
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions packages/mirage-xen/mirage-xen.v6.0.0/opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
opam-version: "2.0"
maintainer: "[email protected]"
authors: "The MirageOS team"
homepage: "https://github.com/mirage/mirage-xen"
bug-reports: "https://github.com/mirage/mirage-xen/issues/"
dev-repo: "git+https://github.com/mirage/mirage-xen.git"
doc: "https://mirage.github.io/mirage-xen/"
license: "ISC"
tags: ["org:mirage"]

build: [
[ "dune" "subst" ] {pinned}
[ "dune" "build" "-p" name "-j" jobs ]
]
depends: [
"ocaml" {>= "4.08.0"}
"dune" {>= "2.6.0"}
"cstruct" {>= "1.0.1"}
"lwt" {>= "2.4.3"}
"shared-memory-ring-lwt"
"xenstore" {>= "1.2.5"}
"conf-pkg-config"
"lwt-dllist"
"mirage-profile" {>= "0.3"}
"io-page" {>= "2.0.0"}
"mirage-runtime" {>= "3.7.0"}
"logs"
"fmt"
"ocaml-freestanding" {>= "0.6.2"}
"solo5-bindings-xen" {>= "0.6.7"}
"bheap" {>= "2.0.0"}
"duration"
]
available: [
(arch = "x86_64" ) &
(os = "linux" | os = "freebsd" | os = "openbsd")
]
synopsis: "Xen core platform libraries for MirageOS"
description: """
This package provides the MirageOS `OS` library for
Xen targets, which handles the main loop and timers. It also provides
the low level C startup code and C stubs required by the OCaml code.
"""
x-commit-hash: "7a72265b73e90fb24efcff5c73dd6eb45f820546"
url {
src:
"https://github.com/mirage/mirage-xen/releases/download/v6.0.0/mirage-xen-v6.0.0.tbz"
checksum: [
"sha256=f991e972059b27993c287ad010d9281fee061efaa1dd475d0955179f93710fbd"
"sha512=14761bff47a2823997ed08761baa9a6abde34c6db606c2f50567f7207d03af2f53ad8ed75ee15040343a1282c983e97149a16b38620677d2374267cc500a9ffb"
]
}

0 comments on commit b900e51

Please sign in to comment.