For PV guests the pagetables reference the real MFNs rather than PFNs, so when
the guest is resumed into a different area of a hosts memory, these will need to
be rewritten.
PVH guests are auto-translated so no memory operation is needed.
Signed-off-by: Bruno Alvisio <bruno.alvisio@gmail.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Bruno Alvisio [Mon, 11 Dec 2017 15:07:08 +0000 (07:07 -0800)]
Save/Restore Support: Declare kernel and arch pre/post suspend functions
For mini-OS to support suspend and restore, the kernel will have to suspend
different modules such as xenbus, console, irq, etc. During save/restore the
kernel and arch pre_suspend and post_suspend functions will be invoked to
suspend/resume each of the modules.
Signed-off-by: Bruno Alvisio <bruno.alvisio@gmail.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Bruno Alvisio [Thu, 14 Dec 2017 00:30:10 +0000 (16:30 -0800)]
Save/Restore Support: Refactor trap_init() and setup vector callbacks
Currently the setup of the IDT and the request to set the HVM vector callbacks
are performed both in the trap_init function.
As part of the post-suspend operation, the HVM vector callback needs to be setup
again while the IDT does not. Thus, the trap_init function is split into two
separate functions: trap_init (sets up IDT) and xen_callback_vector (sets the
HVM vector callback). During the post-suspend operations the xen_callback_vector
function will be invoked.
Signed-off-by: Bruno Alvisio <bruno.alvisio@gmail.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Directly using the SHUTDOWN_suspend macro as a parameter for the schedop
hypercall causes an error in the Xen hypercall handler. Also for consistency,
the SHUTDOWN_suspend param is wrapped in the sched_shutdown struct.
Signed-off-by: Bruno Alvisio <bruno.alvisio@gmail.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Ian Jackson [Tue, 3 Oct 2017 18:45:19 +0000 (19:45 +0100)]
Link against libxentoolcore
Bringing this commit into xen.git needs coordination with the
corresponding change to introduce the new library: this commit needs to
be introduced to xen.git immediately after
xentoolcore, _restrict_all: Introduce new library and implementation
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Acked-by: Wei Liu <wei.liu2@citrix.com>
Paul Durrant [Wed, 22 Feb 2017 11:03:37 +0000 (11:03 +0000)]
Include libxendevicemodel with libxc
libxendevicemodel has just been split out from libxc. From mini-os's
point of view we don't care about the distinction, so keep things
simple by just including libxendevicemodel if libxc is enabled.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Wei Liu [Tue, 13 Dec 2016 15:02:02 +0000 (15:02 +0000)]
build: prepend OBJ_DIR to linker script
After 5623e2d2 ("x86: use unified linker script") the linker script for
x86 build is generated. But the special rule to generate linker script
doesn't have OBJ_DIR prepended so in parallel build the same file is
written multiple times. This is racy and would cause parallel build to
fail.
Fix this by prepending OBJ_DIR to the path of linker script. Change
other variables where necessary.
Signed-off-by: Wei Liu <wei.liu2@citrix.com> Reviewed-by: Juergen Gross <jgross@suse.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Commit e35295d724d64e6e025ec31c2e510e448b8641d1 ("mini-os: fix builds
with uncommon config settings") introduced a bug which will break
the build, as xc_minios.c will have defined those macros via
xc_private.h.
Fix this by defining the macros only if compiling a minios source.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
minios: make mini-os_app.o depend on included xen libraries
When building Mini-OS with an app which is using xen libraries like
libxenguest.a let mini-os_app.o depend on the library binaries as it
is statically linked with them.
While at it add "-T" before app.lds for linking mini-os_app.o to avoid
a linker warning.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Add a "testbuild" target to the Makefile to test building a set of
pre-defined configurations.
Configurations tested are stored under arch/<arch>/testbuild in form
of configuration files. All configurations found there are built in
a local directory.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Tue, 30 Aug 2016 11:51:23 +0000 (13:51 +0200)]
mini-os: support "make config" for out-of-tree users
Mini-OS applications being compiled using Mini-OS headers without
being integrated in the make environment of Mini-OS need a way to set
CONFIG_* defines according to their Mini-OS configuration.
Add a new make target "config" for that purpose creating a Makefile
snipplet $(CONFIG_FILE) (defaults to ./minios-config.mk) containing
the needed information.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Tue, 30 Aug 2016 11:51:21 +0000 (13:51 +0200)]
mini-os: support newer xen interface
Mini-OS is currently setting __XEN_INTERFACE_VERSION__ to a rather
ancient version.
To be able to use a more recent variant garnt_entry_t must be changed
to grant_entry_v1_t. In balloon.c we omit initializing elements of
struct xen_memory_reservation with 0 to avoid problems with different
named structure elements in different Xen interface versions.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Mon, 29 Aug 2016 14:18:26 +0000 (16:18 +0200)]
mini-os: partially revert "remove using start_info ..."
Commit e33452c4f5547ed14defe6382b3b53664ac5bd8a ("remove using
start_info in architecture independent code") removed the start_info
variable completely. grub stubdom needs the start_info structure.
Readd the start_info structure, but make it dependent on
CONFIG_PARAVIRT.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Tue, 23 Aug 2016 14:45:08 +0000 (16:45 +0200)]
mini-os: support idle for HVMlite
Instead of calling HYPERVISOR_sched_op(SCHEDOP_block, 0) we need to use
the "hlt" instruction with interrupts enabled to switch to idle when
running as HVMlite domain.
This requires to setup a new timer in the timer handler as there is no
guarantee the original timer event we are waiting for won't fire
between enabling interrupts and calling "hlt".
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Mon, 22 Aug 2016 07:01:09 +0000 (09:01 +0200)]
mini-os: remove using start_info in architecture independent code
The start_info structure should be used only in case of CONFIG_PARAVIRT
defined. Remove it from being used in other places. Especially the
usage as parameter for applications linked to the kernel is no good
idea.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Mon, 22 Aug 2016 08:45:03 +0000 (10:45 +0200)]
mini-os: map shared info page for HVMlite
Add a service function to map the shared info page on a
non-paravirtualized system. The code is already existing on ARM side,
just move it to hypervisor.c.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Mon, 22 Aug 2016 06:22:15 +0000 (08:22 +0200)]
mini-os: add get_cmdline() function
The command line parameters are passed in start_info structure for pv,
but via hvm_start_info for HVMlite. Add a generic function to fill a
local cmdline variable with the command line string.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Sun, 21 Aug 2016 09:29:44 +0000 (11:29 +0200)]
mini-os: setup xenbus interface parameters
In order to support HVMlite we need to get the ring page and event
channel from the hypervisor via hypercalls. Move the already existing
get_xenbus() function from arm specific coding to xenbus/xenbus.c and
provide a similar paravirtualized function.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Tue, 16 Aug 2016 14:10:58 +0000 (16:10 +0200)]
mini-os: setup console interface parameters
In order to support HVMlite we need to get the ring page and event
channel from the hypervisor via hypercalls. Move the already existing
get_console() function from arm specific coding to
console/xencons_ring.c and provide a similar paravirtualized function.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Thu, 18 Aug 2016 11:36:36 +0000 (13:36 +0200)]
mini-os: add map_frame_virt() function
Add a function map_frame_virt() to map a given frame and return its
virtual address.
On arm we just use the frame physical address, while on x86 we take a
page from the virtual kernel area. For this purpose make this area
available even in case of undefined CONFIG_BALLOON.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Thu, 18 Aug 2016 11:58:42 +0000 (13:58 +0200)]
mini-os: correct wrong calculation of alloc bitmap size
When remapping the page allocator's bitmap for the ballooning support
the calculation of the needed size is wrong. This doesn't really
matter today as nothing is allocated after that bitmap, but it should
be corrected nevertheless.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Thu, 18 Aug 2016 11:00:27 +0000 (13:00 +0200)]
mini-os: add static page tables for virtual kernel area for HVMlite
In HVMlite mode we need the virtual kernel area for mapping of the
console and xenbus ring pages as especially on 32 bit architecture
their pfns might be above the supported maximum memory size.
Add the page tables needed for doing the mapping.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Thu, 18 Aug 2016 11:00:27 +0000 (13:00 +0200)]
mini-os: make p2m related code depend on CONFIG_PARAVIRT
All handling related to p2m is needed for paravirtualized environment
only. So put all functions operating on p2m list in #ifdef
CONFIG_PARAVIRT sections. Add a paravirt.h header defining dummy
functions for non-paravirtualized environments. Instead of using
references to start_info use dedicated variables initialized from
start_info on boot.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Thu, 18 Aug 2016 11:00:27 +0000 (13:00 +0200)]
mini-os: add boot code for HVMlite support
A HVMlite domain is always starting in 32 bit mode. Add the appropriate
boot code to arch/x86 for the non-paravirtualized case.
For this boot code to become active we need to suppress the pv related
elfnotes and add an appropriate elfnote for HVMlite.
As the HVMlite boot code is more or less the same for 32- and 64-bit
Mini-OS #include the new code from x86_[32|64].S in order to avoid
error prone code duplication. The specific parts of 32- or 64-bit code
are added to x86_[32|64].S
This enables Mini-OS to start the boot process in HVMlite mode until it
enters C code. This is working for 32- and for 64-bit mode.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Thu, 18 Aug 2016 11:00:27 +0000 (13:00 +0200)]
mini-os: make some memory management related macros usable from assembler
Especially page table entry definitions are currently not usable from
assembler sources on x86 as the constants are defined with ULL suffix.
Change this by adding the suffix only when the header is included from
a C source.
Hide some C prototypes when in assembler environment.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Thu, 18 Aug 2016 11:00:27 +0000 (13:00 +0200)]
mini-os: add CONFIG_PARAVIRT
Add a new config macro CONFIG_PARAVIRT which defaults to be defined on
x86. This is the first step for supporting a HVMlite Mini-OS.
Doing this via CONFIG_PARAVIRT instead of something like CONFIG_HVMLITE
was chosen as the arm port can then drop some dummy routines needed for
para-virtualization only.
Add include/paravirt.h for future support of paravirt specific
handling.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Wei Liu [Thu, 18 Aug 2016 10:15:26 +0000 (11:15 +0100)]
x86: use unified linker script
There are only a few differences between i386 and x86-64 linker scripts.
Unify them into one. Re-indent the file at the same time.
Construct a special rule in top-level directory to cope with the change.
Ideally the build system should also be made more elegant, but
overhauling the build system is out of scope of this patch.
Signed-off-by: Wei Liu <wei.liu2@citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Juergen Gross <jgross@suse.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Wei Liu [Thu, 18 Aug 2016 10:15:25 +0000 (11:15 +0100)]
x86: switch to use elfnote
Use the newer ELF note interface. The generated ELF notes results in
equivalent configuration.
Also need to modify linker script to provide a note section.
Signed-off-by: Wei Liu <wei.liu2@citrix.com> Reviewed-by: Juergen Gross <jgross@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Wei Liu [Thu, 18 Aug 2016 10:15:24 +0000 (11:15 +0100)]
Introduce asm_macros.h
Ported from Xen Test Framework project (BSD license).
Signed-off-by: Wei Liu <wei.liu2@citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Juergen Gross <jgross@suse.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Wed, 10 Aug 2016 13:47:27 +0000 (15:47 +0200)]
mini-os: repair build system
The build system of Mini-OS is using different settings for arch/*/*
than for the rest of the tree. The main reasons are that Config.mk is
included only conditionally in the top level Makefile, while minios.mk
isn't included by the arch Makefiles.
Repairing this mess enables us to move the CONFIG_* handling to
Config.mk enabling the arch sources to make use of those even if no
MINIOS_CONFIG was specified by the caller.
Most of the files under config were not used. Integrate the used ones
into Config.mk and delete the rest.
The CONFIG_* defines should be set for assembler sources, too.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Fri, 5 Aug 2016 14:27:53 +0000 (16:27 +0200)]
mini-os: balloon up in case of oom
If a memory shortage is detected balloon up.
Be careful to always leave some pages free as ballooning up might need
some memory, too:
- new p2m frames
- page tables for addressing new p2m frame
- new frame for page allocation bitmap
- page table for addressing new page allocation bitmap frame
- page tables for addressing new 1:1 mapped frames
For the moment we only balloon up synchronously when memory shortage
is detected in allocation routines with irqs on.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Wed, 3 Aug 2016 07:11:37 +0000 (09:11 +0200)]
mini-os: add support for ballooning up
Add support for ballooning the domain up by a specified amount of
pages. Following steps are performed:
- extending the p2m map
- extending the page allocator's bitmap
- getting new memory pages from the hypervisor
- adding the memory at the current end of guest memory
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Mon, 1 Aug 2016 08:11:23 +0000 (10:11 +0200)]
mini-os: map page allocator's bitmap to virtual kernel area for ballooning
In case of CONFIG_BALLOON the page allocator's bitmap needs some space
to be able to grow. Remap it to kernel virtual area if the preallocated
area isn't large enough.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Mon, 1 Aug 2016 07:26:08 +0000 (09:26 +0200)]
mini-os: remap p2m list in case of ballooning
In case of enabled ballooning we must be prepared for a growing p2m
list. If the maximum memory size of the domain can't be covered by the
actual p2m list remap it to the kernel virtual mapping area and leave
enough space at the end.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Fri, 5 Aug 2016 08:15:50 +0000 (10:15 +0200)]
mini-os: move p2m related macros to header file
In order to be able to use p2m related macros for ballooning move
their definitions to arch/x86/mm.h.
There is no need to define different macros regarding index masks and
number of entries for the different levels, as all levels share the
same entry format (a plain mfn). So reduce the number of macros
accordingly.
Add some macros to get the indices into p2m pages from a pfn and make
use of them in current p2m code.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Mon, 1 Aug 2016 06:51:26 +0000 (08:51 +0200)]
mini-os: don't allocate new pages for level 1 p2m tree
When constructing the 3 level p2m tree there is no need to allocate
new pages for the level 1 containing the p2m info for all pages. The
pages from the linear p2m list constructed by the hypervisor can be
used for that purpose.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
mini-os: modify virtual memory layout for support of ballooning
In order to be able to support ballooning the virtual memory layout
of Mini-OS has to be modified: instead of a (nearly) consecutive
area used for physical memory mapping, on demand mappings, and heap
we need enough spare place for adding new memory.
So instead of dynamically place the different regions based on found
memory size locate them statically at fixed virtual addresses:
This will enable Mini-OS to support up to 512GB of domain memory with
a 64 bit kernel and nearly 1GB with a 32 bit kernel.
For a 32 bit Mini-OS we have to avoid a conflict between heap and
m2p table which the hypervisor maps at f5600000. So the demand mapping
size is reduced by 256MB in order to keep the heap at about 1GB.
The kernel virtual mappings are a new area needed for being able to
grow the p2m list without having to relocate it in physical memory.
Modify the placement of the demand mappings and heap and adjust the
memory layout description.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
mm.c contains unused code inside #ifdef MM_DEBUG areas. Its usability
is rather questionable and some parts are even wrong (e.g.
print_chunks() called with nr_pages > 1000 will clobber an arbitrary
stack content with a 0 byte).
Remove this code.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
The first free pfn available for allocation is calculated by adding the
number of page table frames to the pfn of the first page table and
then the magic number 3 to account for start info page et al.
As the start info page, xenstore page and console page are allocated
_before_ the page tables leaving room for these pages behind the page
tables makes no sense.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>