Juergen Gross [Sun, 16 Jan 2022 08:33:18 +0000 (09:33 +0100)]
remove gnttab specific member from struct file
The gnttab specific union member in struct file is no longer
needed, so remove it.
The gnttab file type and its associated handling can be removed, too,
as libxengnttab is now supplying a struct file_ops via a call of
alloc_file_type().
This removes all contents of CONFIG_LIBXENGNTTAB guarded sections, so
this config option can be removed.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Sun, 16 Jan 2022 08:33:17 +0000 (09:33 +0100)]
remove event channel specific struct file definitions
The event channel specific union member in struct file is no longer
needed, so remove it together with the associated structure
definitions.
The event channel file type and its associated handling can be removed,
too, as libxenevtchn is now supplying a struct file_ops via a call of
alloc_file_type().
This removes all contents of CONFIG_LIBXENEVTCHN guarded sections, so
this config option can be removed.
Add an extern declaration for event_queue as it is used by
libxenevtchn.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Sun, 16 Jan 2022 06:45:27 +0000 (07:45 +0100)]
add CONFIG_LIBXS item
Mini-OS contains a stripped down version of libxenstore in lib/xs.c.
Today it is being built always if CONFIG_XENBUS is set and libc
support is enabled.
In order to allow a Mini-OS specific build of libxenstore to be used
instead add a new CONFIG_LIBXS item which per default will have the
same setting as CONFIG_XENBUS. A user wanting to replace lib/xs.c
with libxenstore would just need to set CONFIG_XENBUS=y and
CONFIG_LIBXS=n.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Sun, 16 Jan 2022 06:45:26 +0000 (07:45 +0100)]
use function vectors instead of switch for file operations
Introduce file type specific function vectors for all the needed file
operations which are file type specific in order to prepare replacing
the large switch statements in each generic file function.
Add a function to allocate a new file type dynamically in order to
prepare removing direct dependencies to external components in the
future. For this reason switch the file type from an enum to an
unsigned int. Prepare removal of some statically defines file types
by putting them at the end of the defined list.
Change the debug output for the file type from a single character to
a string in order to support a future removal of the file_types[]
array.
Provide some functions useful for file_ops in future patches.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Sun, 16 Jan 2022 06:45:25 +0000 (07:45 +0100)]
remove file type FTYPE_XC
The only reason for the file type FTYPE_XC has been gone long time
ago: it was needed for xc_map_foreign_bulk(), which has been switched
to use libxenforeignmemory and doesn't need this special file any
more.
So remove everything related to FTYPE_XC.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Tue, 21 Dec 2021 08:46:36 +0000 (09:46 +0100)]
mini-os: modify grant mappings to work in PVH mode
For being able to use the grant mapping interface in PVH mode some
changes are required, as the guest needs to specify a physical address
in the hypercall interface.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Tue, 21 Dec 2021 08:46:35 +0000 (09:46 +0100)]
mini-os: prepare grantmap entry interface for use by PVH mode
Instead of passing the pointer of a grantmap entry to the
_gntmap_[un]map_grant_ref() sub-functions use the map pointer and the
entry index instead. This will be needed for PVH mode usage.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Tue, 21 Dec 2021 08:46:33 +0000 (09:46 +0100)]
mini-os: move x86 specific gnttab coding into arch/x86/gnttab.c
Having grant table code in arch/x86/mm.c seems wrong. Move it to the
new file arch/x86/gnttab.c, especially as the amount of code is
expected to grow further.
While doing that replace type casts to pte_t with the more appropriate
__pte() macro.
No functional change.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Tue, 21 Dec 2021 08:46:30 +0000 (09:46 +0100)]
mini-os: respect memory map when ballooning up
Today Mini-OS won't look at the memory map when ballooning up. This can
result in problems for PVH domains with more than 4 GB of RAM, as
ballooning will happily run into the ACPI area.
Fix that by adding only pages being marked as RAM in the memory map and
by distinguishing between the current number of RAM pages and the first
unallocated page.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Mon, 4 Oct 2021 09:40:00 +0000 (11:40 +0200)]
xenbus: support large messages
Today the implementation of the xenbus protocol in Mini-OS will only
allow to transfer the complete message to or from the ring page buffer.
This is limiting the maximum message size to lower values as the xenbus
protocol normally would allow.
Change that by allowing to transfer the xenbus message in chunks as
soon as they are available.
Avoid crashing Mini-OS in case of illegal data read from the ring
buffer.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Mon, 4 Oct 2021 14:19:24 +0000 (16:19 +0200)]
mini-os: add config options for xen libraries
Today close hooks into libxenctrl, libxenevtchn and libxengnttab are
under the CONFIG_XC umbrella. In order to support Mini-OS builds using
stable Xen libraries only, add CONFIG_LIBXENCTRL, CONFIG_LIBXENEVTCHN
and CONFIG_LIBXENGNTTAB config options.
In case CONFIG_XC was specified in the Mini-OS config explicitly, set
the three new variables to the specified value.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Thu, 19 Aug 2021 05:30:56 +0000 (07:30 +0200)]
mini-os: netfront: fix initialization without ip address in xenstore
Commit 4821876fcd2ff ("mini-os: netfront: fix suspend/resume handling")
introduced a NULL pointer dereference in the initialization of netfront
in the case of no IP address being set in Xenstore.
Fix that by testing this condition. At the same time fix a long
standing bug for the same condition if someone used init_netfront()
with a non-NULL ip parameter.
Costin Lupu [Tue, 15 Dec 2020 16:50:12 +0000 (16:50 +0000)]
mini-os: netfront: Handle init failure when no vifs are provided
These changes deal with the case when no vifs are created. This can happen when
no vif is provided in the config file for mini-os images with netfront support.
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro> Reviewed-by: Samuel Thibault <samuel.thibault@@ens-lyon.org>
Suspend/resume handling of netfront is completely broken from the
beginning. Commit d225f4012d69a1 ("Save/Restore Support: Add
suspend/restore support for netfront") introduced a new structure
netfront_dev_list referencing the real struct netfront_dev elements.
This list is used to setup the devices when resuming again.
Unfortunately the netfront_dev elements are released during suspend,
so at resume time those references will be stale.
Fix this whole mess by dropping struct netfront_dev_list again and
link the netfront_dev elements directly into a list. When suspending
don't free those elements.
The ip-address, netmask and gateway strings can just be released when
suspending and reread from xenstore at resume time.
Fixes: d225f4012d69a1 ("Save/Restore Support: Add suspend/restore support for netfront") Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
mini-os: netfront: retrieve netmask and gateway via extra function
Commit 1b8ed31f4ce40 ("mini-os: netfront: Read netmask and gateway from
Xenstore") modified init_netfront() to take two additional parameters.
This broke the Xen build as init_netfront() is used in grub stubdom,
too.
So instead of tightly coupling Mini-OS and Xen build via this interface
modification undo this change of init_netfront() and add two other
functions for retrieving the netmask and gateway for a network device.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Costin Lupu [Wed, 19 Aug 2020 16:41:08 +0000 (19:41 +0300)]
mini-os: Add suspend stubs for ARM
This patch introduces the missing suspend-related stubs for ARM. It also
introduces the new arch_suspend() function in order to keep the logic in
kernel_suspend() arch independent.
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Costin Lupu [Wed, 19 Aug 2020 15:45:36 +0000 (18:45 +0300)]
mini-os: Use a single start_info_ptr variable
The second definition of the `start_info_ptr` variable was introduced by commit
e05eb0 which was part of a series trying to add suspend/resume support to
mini-os. This patch removes the second definition by reverting some changes of
the mentioned commit and of commit 892b66.
However the logic in shutdown.c is still left in an inconsistent state because
it still doesn't work for ARM. The solution should be part of a future patch.
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Costin Lupu [Wed, 19 Aug 2020 12:49:00 +0000 (15:49 +0300)]
mini-os: netfront: Read netmask and gateway from Xenstore
When providing the IP address via the config file, one can also add the
netmask and gateway address, e.g. "ip=192.168.0.2 255.255.255.0
192.168.0.1", which will be further published to Xenstore. This patch adds
support for reading the netmask and gateway values.
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Costin Lupu [Tue, 18 Aug 2020 13:44:06 +0000 (16:44 +0300)]
mini-os: console.c: Rename static variable from buf to __print_buf
lwip soure code also has a static variable called 'buf' in ip_frag.c. This can
get confusing when inspecting the binary (e.g. with objdump or something
similar). Therefore this patch renames the 'buf' variable used by print()
function to '__print_buf'.
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Juergen Gross [Sat, 15 Aug 2020 11:15:57 +0000 (13:15 +0200)]
mini-os: correct memory access rights for pvh mode
When running as a PVH guest the memory access rights are not set
correctly: _PAGE_USER should not be set and CR0.WP should be set.
Especially CR0.WP is important in order to let the allocate on
demand feature work, as it requires a page fault when writing to a
read-only page.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Mini-OS shouldn't use Xen internal paths for building. Import the
needed paths from Xen and fall back to the current values only if
the import was not possible.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Jason Andryuk [Mon, 27 Apr 2020 03:40:19 +0000 (23:40 -0400)]
mini-os: Avoid segfaults in tc{g,s}etattr
Commit c96c22f1d94 "mini-os: minimal implementations of some termios
functions" introduced implementations of tcgetattr and tcsetattr.
However, they do not check if files[fildes].cons.dev is non-NULL before
dereferencing. This is not a problem for FDs allocated through
alloc_fd, but the files array pre-allocates FDs 0-2 for stdio. Those
entries have a NULL .dev, so tc{g,s}etattr on them segfault.
ioemu-stubdom segfaults when term_init() calls tcgetattr on FD 0.
Restore tcgetattr and tcsetattr behavior when .dev is NULL equivalent to
unsupported_function as it was before c96c22f1d94.
Signed-off-by: Jason Andryuk <jandryuk@gmail.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
mini-os: allow 4096 event channels for 64-bit mini-os
Limiting the number of event channels to 1024 is fine for 32-bit
builds, but not for 64-bit ones. This might be a problem when using
Xenstore-stubdom as the number of domains which can be supported is
then limited to a little bit more than 1000.
So raise the number of event channels to 4096 in 64-bit builds.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Provide a mini-os binary stripped from debug information in order to
have a smaller resulting kernel file. The binary with debug
information is kept with the suffix "-debug".
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Using the standard -m elf_x86_64 for 64-bit mini-os results in the
first section (.text) to start only at offset 2MB in the binary file.
Quoting Andrew Cooper on that topic:
Specifically, 64bit emulation appears to include "align primary
sections to 2M so your OS can make better use of superpages even when
mmap()ing", with no way I can spot to override this in the linker
file.
Using -m elf_i386 avoids that problem without any visible disadvantage.
Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
mini-os: fix several memory leaks related to xenbus
There are several instances of calls to xenbus functions which don't
test for an error and in consequence are not freeing the returned
error strings, or which are just not freeing the string after e.g.
printing it.
Fix that by either adding the needed calls of free().
Coverity-ID: 1433632 Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Wei Liu <wl@xen.org> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Commit 973ad0c4de1b48 ("Save/Restore Support: Add suspend/restore
support for xenbus") introduced a double free of some memory and leaked
another memory allocation.
Fix those.
Coverity-ID: 1433640 Fixes: 973ad0c4de1b48 ("Save/Restore Support: Add suspend/restore support for xenbus") Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Wei Liu <wl@xen.org> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Commit d225f4012d69a19 ("Save/Restore Support: Add suspend/restore
support for netfront") introduced a regression in form of freeing a
netfront device structure twice.
Fix that.
Coverity-ID: 1433637 Fixes: d225f4012d69a19 ("Save/Restore Support: Add suspend/restore support for netfront") Signed-off-by: Juergen Gross <jgross@suse.com> Acked-by: Wei Liu <wl@xen.org> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Bruno Alvisio [Mon, 11 Dec 2017 16:05:18 +0000 (08:05 -0800)]
Save/Restore Support: Implement code for arch suspend/resume
Before suspending the domain the shared_info_page is unmapped and for PVs the
pagetables should be canonicalized. After resume the shared_info_page should be
mapped again.
Signed-off-by: Bruno Alvisio <bruno.alvisio@gmail.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Bruno Alvisio [Mon, 11 Dec 2017 16:21:48 +0000 (08:21 -0800)]
Save/Restore Support: Add suspend/restore support for xenbus
Currently the watch path is not saved in the watch struct when it is registered.
During xenbus resume the path is needed so that the watches can be registered again.
Thus, 'path' field is added to struct watch so that watches can be re-registered
during xenbus resume.
Signed-off-by: Bruno Alvisio <bruno.alvisio@gmail.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
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>