]> xenbits.xensource.com Git - mini-os.git/log
mini-os.git
8 months agomini-os: mm: introduce generic page table walk function
Juergen Gross [Tue, 20 Aug 2024 14:10:45 +0000 (16:10 +0200)]
mini-os: mm: introduce generic page table walk function

In x86 mm code there are multiple instances of page table walks for
different purposes.

Introduce a generic page table walker being able to cover the current
use cases. It will be used for other cases in future, too.

The page table walker needs some per-level data, so add a table for
that data. Merge it with the already existing pt_prot[] array.

Rewrite get_pgt() to use the new walker.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
9 months agomini-os: put sanity_check() under CONFIG_TEST
Juergen Gross [Tue, 30 Jul 2024 09:50:02 +0000 (11:50 +0200)]
mini-os: put sanity_check() under CONFIG_TEST

Hide the sanity_check() function, as it is used nowhere. By putting it
under #ifdef CONFIG_TEST it will stay around, but it won't be
included in normal production builds.

Call sanity_check() from the periodic thread of the test app, causing
a sanity check every second.

Since any application linked with Mini-OS can't call sanity_check()
(there is no EXPORT_SYMBOL for it), there is zero chance of breaking
any use case.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
9 months agomini-os: mm: don't have two large arrays of the same kind
Juergen Gross [Wed, 24 Jul 2024 10:03:26 +0000 (12:03 +0200)]
mini-os: mm: don't have two large arrays of the same kind

In the CONFIG_PARAVIRT case there are two identical static arrays of
more than 8kB size with function scope. As the two functions never
nest, a single array of file scope can replace the two existing
instances.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
9 months agomini-os: mm: reduce buddy allocator list administration data
Juergen Gross [Wed, 24 Jul 2024 10:03:13 +0000 (12:03 +0200)]
mini-os: mm: reduce buddy allocator list administration data

Today the administration data for the buddy allocator's lists consists
of 2 arrays: one pointer array and one list element array for easier
handling of the lists' tails.

Those arrays can be combined into one by dropping the pointer array and
using a different list end indicator.

Add enqueue and dequeue helpers for better readability.

Change the level member type to unsigned int.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
9 months agomini-os: mm: remove not needed struct chunk_tail_st
Juergen Gross [Wed, 24 Jul 2024 10:03:00 +0000 (12:03 +0200)]
mini-os: mm: remove not needed struct chunk_tail_st

The struct chunk_tail_st isn't really used other than writing to it.

Remove it in order to simplify the code.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
9 months agomini-os: make mm.c coding style compliant
Juergen Gross [Wed, 24 Jul 2024 10:02:43 +0000 (12:02 +0200)]
mini-os: make mm.c coding style compliant

Apply the coding style to mm.c.

No functional change.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
9 months agomini-os: simplify monotonic_clock()
Juergen Gross [Wed, 24 Jul 2024 10:02:25 +0000 (12:02 +0200)]
mini-os: simplify monotonic_clock()

monotonic_clock() in arch/x86/time.c is more complex than needed: it
has basically two nested loops making sure the time data obtained from
Xen are valid.

Simplify that by merging some of the used sub-functions into the main
function and using only a single loop. Further simplify the code by
using struct vcpu_time_info for the local instance instead of defining
a similar structure in the code.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
9 months agomini-os: remove some not needed stuff from arch/x86/time.c
Juergen Gross [Wed, 24 Jul 2024 10:02:07 +0000 (12:02 +0200)]
mini-os: remove some not needed stuff from arch/x86/time.c

Remove unused or not needed stuff from arch/x86/time.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
9 months agomini-os: apply coding style to arch/x86/time.c
Juergen Gross [Wed, 24 Jul 2024 10:01:52 +0000 (12:01 +0200)]
mini-os: apply coding style to arch/x86/time.c

Apply the preferred coding style to arch/x86/time.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
9 months agoMini-OS: add some macros for asm statements
Juergen Gross [Mon, 22 Jul 2024 10:46:43 +0000 (12:46 +0200)]
Mini-OS: add some macros for asm statements

Instead of having #ifdefs sprinkled around in x86 code, add some
macros defining constants for asm statements to address differences
between 32- and 64-bit mode.

Modify existing code to use those macros.

While at it convert the assembler parts of run_idle_thread() to a more
sane variant.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
10 months agomman: correct m{,un}lock() definitions xen-4.19.0-rc4 xen-RELEASE-4.19.0
Charles Arnold [Tue, 25 Jun 2024 07:50:11 +0000 (09:50 +0200)]
mman: correct m{,un}lock() definitions

gcc14 no longer (silently) accepts functions with no return type
specified.

Signed-off-by: Charles Arnold <carnold@suse.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
14 months agoMini-OS: add symbol exports for xenstore stubdom
Juergen Gross [Thu, 29 Feb 2024 07:01:03 +0000 (08:01 +0100)]
Mini-OS: add symbol exports for xenstore stubdom

Xenstore stubdom needs some more symbols exported.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
14 months agoMini-OS: fix 9pfront fix
Juergen Gross [Thu, 8 Feb 2024 13:43:13 +0000 (14:43 +0100)]
Mini-OS: fix 9pfront fix

There was a typo in the recent 9pfront fix.

Fixes: b119f0178fd8 ("Mini-OS: fix 9pfs frontend error path")
Reported-by: Julien Grall <julien@xen.org>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
14 months agoMini-OS: fix 9pfs frontend error path
Juergen Gross [Wed, 7 Feb 2024 12:52:13 +0000 (13:52 +0100)]
Mini-OS: fix 9pfs frontend error path

The early error exit in p9_stat() returns without zeroing the p9_stat
buffer, resulting in free() being called with an uninitialized pointer.

Fix that by calling free_stat() in p9_stat() in case of returning an
error and potentially having allocated strings.

Reported-by: Julien Grall <julien@xen.org>
Fixes: 2d1dfccd3aa3 ("Mini-OS: add read and write support to 9pfsfront")
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
15 months agox86/mm: add EXPORT_SYMBOL() for `pt_base`
Anthony PERARD [Fri, 19 Jan 2024 08:42:09 +0000 (09:42 +0100)]
x86/mm: add EXPORT_SYMBOL() for `pt_base`

Without this, building "ioemu-stubdom" fails on Debian Buster or
Bookworm, with:

/home/osstest/build.184372.build-amd64/xen/stubdom/mini-os-x86_64-ioemu/mini-os.o: in function `xenfb_pv_display_init':
ungetc.c:(.text+0x43533): undefined reference to `pt_base'

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
16 months agoMini-OS: cleanup hypervisor.c
Juergen Gross [Wed, 13 Dec 2023 09:50:17 +0000 (10:50 +0100)]
Mini-OS: cleanup hypervisor.c

Do the following cleanups in hypervisor.c:

- Let hypervisor.c conform to the coding style.
- Drop the bogus "inline" attributes of exported functions.
- Replace a always zero cpu variable with smp_processor_id() as
  elsewhere in the code.
- Replace "if () BUG()" with BUG_ON() in case the condition has no
  side effects.
- Drop the unused cpu parameter from the active_evtchns() macro.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
16 months agoMini-OS: drop in_callback variable
Juergen Gross [Wed, 13 Dec 2023 09:49:54 +0000 (10:49 +0100)]
Mini-OS: drop in_callback variable

Now that do_hypervisor_callback() is always called with interrupts off
the in_callback variable meant to handle recursive calls of
do_hypervisor_callback() can be dropped.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
16 months agoMini-OS: call event handlers always with interrupts off
Juergen Gross [Wed, 13 Dec 2023 09:49:40 +0000 (10:49 +0100)]
Mini-OS: call event handlers always with interrupts off

When unmasking an event channel the associated event handler can be
called with interrupts enabled when not running as a PV guest.

This can result in hard to debug races in case e.g. a handler is
registered for multiple events or when the handler is not using a lock
as it assumes to have interrupts disabled.

Instead of using the PV interrupt disabling points just before calling
the handler, do the disabling once at the very start of
force_evtchn_callback().

Replace the evtchn_upcall_mask test in unmask_evtchn() with the more
appropriate irqs_disabled() test.

As a precaution add a test to do_hypervisor_callback() that interrupts
are really disabled and crash in case this is not true.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
16 months agoMini-OS: use BUG() instead of dereferencing NULL
Juergen Gross [Wed, 13 Dec 2023 09:49:06 +0000 (10:49 +0100)]
Mini-OS: use BUG() instead of dereferencing NULL

There are some places using a dereference of NULL to cause a crash.

Use BUG() instead.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
16 months agox86: fix building with Clang
Jan Beulich [Wed, 13 Dec 2023 09:48:41 +0000 (10:48 +0100)]
x86: fix building with Clang

It doesn't understand -fno-reorder-blocks. Whether without that option
the resulting binary is actually functional I can't tell, though.

For $(cc-option ...) to be usable in arch.mk, at least CC needs setting
earlier in Config.mk. Move up the entire "Set tools" section.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
16 months agoMini-OS: don't use objcopy --dump-section
Juergen Gross [Wed, 6 Dec 2023 16:17:44 +0000 (17:17 +0100)]
Mini-OS: don't use objcopy --dump-section

The objcopy option "--dump-section" isn't supported in binutils before
version 2.25, which are still supported by the Xen build system.

Avoid that by using the "-O binary" format together with
"--only-section". This requires to set the "alloc" section flag.

Fixes: 33411a11f848 ("Mini-OS: hide all symbols not exported via EXPORT_SYMBOLS()")
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
17 months agoMini-OS: hide all symbols not exported via EXPORT_SYMBOLS()
Juergen Gross [Mon, 27 Nov 2023 10:25:23 +0000 (11:25 +0100)]
Mini-OS: hide all symbols not exported via EXPORT_SYMBOLS()

When doing the final linking of the Mini-OS kernel only keep the
symbols visible which have been marked via EXPORT_SYMBOL().

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to xenbus.c
Juergen Gross [Mon, 27 Nov 2023 10:25:22 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to xenbus.c

Add the needed instances of EXPORT_SYMBOL() to xenbus.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to tpm_tis.c
Juergen Gross [Mon, 27 Nov 2023 10:25:21 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to tpm_tis.c

Add the needed instances of EXPORT_SYMBOL() to tpm_tis.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to tpmfront.c
Juergen Gross [Mon, 27 Nov 2023 10:25:20 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to tpmfront.c

Add the needed instances of EXPORT_SYMBOL() to tpmfront.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to tpmback.c
Juergen Gross [Mon, 27 Nov 2023 10:25:19 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to tpmback.c

Add the needed instances of EXPORT_SYMBOL() to tpmback.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to pcifront.c
Juergen Gross [Mon, 27 Nov 2023 10:25:18 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to pcifront.c

Add the needed instances of EXPORT_SYMBOL() to pcifront.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to netfront.c
Juergen Gross [Mon, 27 Nov 2023 10:25:17 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to netfront.c

Add the needed instances of EXPORT_SYMBOL() to netfront.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to fbfront.c
Juergen Gross [Mon, 27 Nov 2023 10:25:16 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to fbfront.c

Add the needed instances of EXPORT_SYMBOL() to fbfront.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to blkfront.c
Juergen Gross [Mon, 27 Nov 2023 10:25:15 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to blkfront.c

Add the needed instances of EXPORT_SYMBOL() to blkfront.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to 9pfront.c
Juergen Gross [Mon, 27 Nov 2023 10:25:14 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to 9pfront.c

Add the needed instances of EXPORT_SYMBOL() to 9pfront.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to lwip-*.c
Juergen Gross [Mon, 27 Nov 2023 10:25:13 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to lwip-*.c

Add the needed instances of EXPORT_SYMBOL() to lwip-*.c.

Most added symbols are in LWIP, but we can't add the EXPORT_SYMBOL()
instances easily there.

Signed-off-by: Juergen Gross <jgross@suse.com>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to time.c
Juergen Gross [Mon, 27 Nov 2023 10:25:12 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to time.c

Add the needed instances of EXPORT_SYMBOL() to time.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to lock.c
Juergen Gross [Mon, 27 Nov 2023 10:25:11 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to lock.c

Add the needed instances of EXPORT_SYMBOL() to lock.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to ioremap.c
Juergen Gross [Mon, 27 Nov 2023 10:25:10 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to ioremap.c

Add the needed instances of EXPORT_SYMBOL() to ioremap.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to gnttab.c
Juergen Gross [Mon, 27 Nov 2023 10:25:09 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to gnttab.c

Add the needed instances of EXPORT_SYMBOL() to gnttab.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to gntmap.c
Juergen Gross [Mon, 27 Nov 2023 10:25:08 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to gntmap.c

Add the needed instances of EXPORT_SYMBOL() to gntmap.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to events.c
Juergen Gross [Mon, 27 Nov 2023 10:25:07 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to events.c

Add the needed instances of EXPORT_SYMBOL() to events.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to console.c
Juergen Gross [Mon, 27 Nov 2023 10:25:06 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to console.c

Add the needed instances of EXPORT_SYMBOL() to console.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to main.c
Juergen Gross [Mon, 27 Nov 2023 10:25:05 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to main.c

Add the needed instances of EXPORT_SYMBOL() to main.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to lib/xs.c
Juergen Gross [Mon, 27 Nov 2023 10:25:04 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to lib/xs.c

Add the needed instances of EXPORT_SYMBOL() to lib/xs.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to lib/xmalloc.c
Juergen Gross [Mon, 27 Nov 2023 10:25:03 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to lib/xmalloc.c

Add the needed instances of EXPORT_SYMBOL() to lib/xmalloc.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to lib/ctype.c
Juergen Gross [Mon, 27 Nov 2023 10:25:02 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to lib/ctype.c

Add the needed instances of EXPORT_SYMBOL() to lib/ctype.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to lib/printf.c
Juergen Gross [Mon, 27 Nov 2023 10:25:01 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to lib/printf.c

Add the needed instances of EXPORT_SYMBOL() to lib/printf.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to lib/math.c
Juergen Gross [Mon, 27 Nov 2023 10:25:00 +0000 (11:25 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to lib/math.c

Add the needed instances of EXPORT_SYMBOL() to lib/math.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to lib/string.c
Juergen Gross [Mon, 27 Nov 2023 10:24:59 +0000 (11:24 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to lib/string.c

Add the needed instances of EXPORT_SYMBOL() to lib/string.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to lib/sys.c
Juergen Gross [Mon, 27 Nov 2023 10:24:58 +0000 (11:24 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to lib/sys.c

Add the needed instances of EXPORT_SYMBOL() to lib/sys.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to mm.c
Juergen Gross [Mon, 27 Nov 2023 10:24:57 +0000 (11:24 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to mm.c

Add the needed instances of EXPORT_SYMBOL() to mm.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to sched.c
Juergen Gross [Mon, 27 Nov 2023 10:24:56 +0000 (11:24 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to sched.c

Add the needed instances of EXPORT_SYMBOL() to sched.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to hypervisor.c
Juergen Gross [Mon, 27 Nov 2023 10:24:55 +0000 (11:24 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to hypervisor.c

Add the needed instances of EXPORT_SYMBOL() to hypervisor.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: add EXPORT_SYMBOL() instances to kernel.c
Juergen Gross [Mon, 27 Nov 2023 10:24:54 +0000 (11:24 +0100)]
Mini-OS: add EXPORT_SYMBOL() instances to kernel.c

Add the needed instances of EXPORT_SYMBOL() to kernel.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: explicitly mark symbols to be visible for apps
Juergen Gross [Mon, 27 Nov 2023 10:24:53 +0000 (11:24 +0100)]
Mini-OS: explicitly mark symbols to be visible for apps

Add an EXPORT_SYMBOL() macro to explicitly mark a symbol to be visible
for an app or library linked with Mini-OS. This prepares hiding all
other symbols from external components, avoiding any problems with
duplicate symbol names.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: link kernel separately
Juergen Gross [Mon, 27 Nov 2023 10:24:52 +0000 (11:24 +0100)]
Mini-OS: link kernel separately

Add an additional link step with linking all Mini-OS kernel binaries
into a single object file.

This is done in preparation of hiding Mini-OS internal symbols before
linking the kernel with libraries and an application.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: fix 9pfs response receiving
Juergen Gross [Tue, 21 Nov 2023 09:49:53 +0000 (10:49 +0100)]
Mini-OS: fix 9pfs response receiving

When copying a 9pfs response chunk from the ring buffer across the
ring end, the local ring pointer and length field are not updated
correctly. Fix that.

Fixes: 0924fec1de58 ("Mini-OS: add 9pfs transport layer")
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: fix 9pfs stat receive format
Juergen Gross [Tue, 21 Nov 2023 09:49:52 +0000 (10:49 +0100)]
Mini-OS: fix 9pfs stat receive format

The format string of the received data for the 9pfs stat command is
missing the initial 2 byte total length specifier. Add it.

Fixes: 2d1dfccd3aa3 ("Mini-OS: add read and write support to 9pfsfront")
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
17 months agoMini-OS: don't crash if no shutdown node is available
Juergen Gross [Tue, 21 Nov 2023 09:49:51 +0000 (10:49 +0100)]
Mini-OS: don't crash if no shutdown node is available

It might be perfectly fine not to have a control/shutdown Xenstore
node. If this is the case, don't crash, but just terminate the
shutdown thread after issuing a message that shutdown isn't available.

In fini_shutdown() clearing the watch can result in an error now, in
case the early exit above was taken. Just ignore this error now.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
17 months agoMini-OS: get own domid
Juergen Gross [Tue, 21 Nov 2023 09:49:50 +0000 (10:49 +0100)]
Mini-OS: get own domid

Get the own domid via creation of a temporary event channel. There is
no "official" way to read the own domid in PV guests, so use the event
channel interface to get it:

- allocate an unbound event channel specifying DOMID_SELF for the
  other end

- read the event channel status which will contain the own domid in
  unbound.dom

- close the event channel

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
17 months agoMini-OS: make xenstore_buf externally visible
Juergen Gross [Tue, 21 Nov 2023 09:49:49 +0000 (10:49 +0100)]
Mini-OS: make xenstore_buf externally visible

For support of the 9pfs frontend in Xenstore-stubdom xenstore_buf
needs to be externally visible.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
18 months agobuild: silence GNU ld 2.39 warning about executable stacks
Jan Beulich [Thu, 2 Nov 2023 07:25:59 +0000 (08:25 +0100)]
build: silence GNU ld 2.39 warning about executable stacks

While for C files the compiler is supposed to arrange for emitting
respective information, for assembly sources we're responsible ourselves.

For the new use of cc-option to work we cannot pass -S to the compiler
anymore. We need the compiler to actually invoke the assembler, so switch
to using -c.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agoMini-OS: add read and write support to 9pfsfront
Juergen Gross [Mon, 13 Feb 2023 08:44:12 +0000 (09:44 +0100)]
Mini-OS: add read and write support to 9pfsfront

Add support to read from and write to a file handled by 9pfsfront.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agoMini-OS: add open and close handling to the 9pfs frontend
Juergen Gross [Mon, 13 Feb 2023 08:44:11 +0000 (09:44 +0100)]
Mini-OS: add open and close handling to the 9pfs frontend

Add the open() and close() support to the 9pfs frontend. This requires
to split the path name and to walk to the desired directory level.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agoMini-OS: add 9pfs transport layer
Juergen Gross [Mon, 13 Feb 2023 08:44:10 +0000 (09:44 +0100)]
Mini-OS: add 9pfs transport layer

Add the transport layer of 9pfs. This is basically the infrastructure
to send requests to the backend and to receive the related answers via
the rings.

As a first example add the version and attach requests of the 9pfs
protocol when mounting a new 9pfs device. For the version use the
"9P2000.u" variant, as it is the smallest subset supported by the qemu
based backend.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agoMini-OS: add 9pfs frontend
Juergen Gross [Mon, 13 Feb 2023 08:44:09 +0000 (09:44 +0100)]
Mini-OS: add 9pfs frontend

Add a frontend for the 9pfs PV device. For now add only the code needed
to connect to the backend and the related disconnect functionality. The
9pfs protocol support will be added later.

Due to its nature (ability to access files) the whole code is guarded
by "#ifdef HAVE_LIBC".

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agoMini-OS: add support for runtime mounts
Juergen Gross [Mon, 13 Feb 2023 08:44:08 +0000 (09:44 +0100)]
Mini-OS: add support for runtime mounts

Add the support to mount a device at runtime. The number of dynamic
mounts is limited by a #define.

For devices supporting multiple files struct file is modified to hold
a pointer to file specific data in contrast to device specific data.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agoMini-OS: add concept of mount points
Juergen Gross [Mon, 13 Feb 2023 08:44:07 +0000 (09:44 +0100)]
Mini-OS: add concept of mount points

Add the concept of mount points to Mini-OS. A mount point is a path
associated with a device pointer and an open() callback. A mount point
can be either a file (e.g. "/dev/mem") or a directory ("/var/log").

This allows to replace the special casing in the generic open()
handling with a generic mount point handling.

Prepare the open() callbacks to support creating new files by adding a
mode parameter.

Additionally add a close() prototype to include/lib.h, as it is missing
today.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agoMini-OS: xenbus: add support for reading node from directory
Juergen Gross [Mon, 13 Feb 2023 08:44:06 +0000 (09:44 +0100)]
Mini-OS: xenbus: add support for reading node from directory

Especially PV device drivers often need to read multiple Xenstore
nodes from a common directory. Add support for reading a string or an
unsigned value by specifying the directory and the node.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agoMini-OS: move xenbus test code into test.c
Juergen Gross [Fri, 27 Jan 2023 07:33:46 +0000 (08:33 +0100)]
Mini-OS: move xenbus test code into test.c

The test code in xenbus.c can easily be moved into test.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agoMini-OS: remove stale subdirs from Makefile
Juergen Gross [Fri, 27 Jan 2023 07:32:44 +0000 (08:32 +0100)]
Mini-OS: remove stale subdirs from Makefile

The SUBDIRS make variable has some stale entries, remove them.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agomini-os: fix bug in ballooning on PVH xen-4.17.0-rc4 xen-4.18.0-rc4 xen-4.18.0-rc5 xen-RELEASE-4.17.0 xen-RELEASE-4.17.1 xen-RELEASE-4.17.3 xen-RELEASE-4.18.0 xen-RELEASE-4.18.1
Juergen Gross [Tue, 21 Jun 2022 07:23:14 +0000 (09:23 +0200)]
mini-os: fix bug in ballooning on PVH

There is a subtle bug in ballooning code for PVH: in case ballooning
extends above a non-RAM area of the memory map, wrong pages will be
used.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agomini-os: fix number of pages for PVH
Juergen Gross [Tue, 21 Jun 2022 07:23:13 +0000 (09:23 +0200)]
mini-os: fix number of pages for PVH

When getting the current allocation from Xen, this value includes the
pages allocated in the MMIO area. Fix the highest available RAM page
by subtracting the size of that area.

This requires to read the E820 map before needing this value. Add two
functions returning the current and the maximum number of RAM pages
taking this correction into account.

At the same time add the LAPIC page to the memory map in order to
avoid reusing that PFN for internal purposes.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agomini-os: prefer memory map via start_info for PVH
Juergen Gross [Tue, 21 Jun 2022 07:23:12 +0000 (09:23 +0200)]
mini-os: prefer memory map via start_info for PVH

Since some time now a guest started in PVH mode will get the memory
map from Xen via the start_info structure.

Modify the PVH initialization to prefer this memory map over the one
obtained via hypercall, as this will allow to add information to the
memory map for a new kernel when supporting kexec.

In case the start_info structure doesn't contain memory map information
fall back to the hypercall.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agomini-os: take newest version of arch-x86/hvm/start_info.h
Juergen Gross [Tue, 21 Jun 2022 07:23:11 +0000 (09:23 +0200)]
mini-os: take newest version of arch-x86/hvm/start_info.h

Update include/xen/arch-x86/hvm/start_info.h to the newest version
from the Xen tree.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agomini-os: add mini-os-debug[.gz] to .gitignore
Juergen Gross [Mon, 20 Jun 2022 07:38:20 +0000 (09:38 +0200)]
mini-os: add mini-os-debug[.gz] to .gitignore

mini-os-debug and mini-os-debug.gz are created when building Mini-OS,
add them to .gitignore.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agomini-os: apply coding style to console.c
Juergen Gross [Mon, 20 Jun 2022 07:38:19 +0000 (09:38 +0200)]
mini-os: apply coding style to console.c

Make console.c coding style compliant.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agomini-os: eliminate console directory
Juergen Gross [Mon, 20 Jun 2022 07:38:18 +0000 (09:38 +0200)]
mini-os: eliminate console directory

Merge the two remaining source files in the console directory into
a single one and move it to the main directory.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agomini-os: apply coding style to consfront.c
Juergen Gross [Mon, 20 Jun 2022 07:38:17 +0000 (09:38 +0200)]
mini-os: apply coding style to consfront.c

Make consfront.c coding style compliant.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agomini-os: rename console/xenbus.c to consfront.c
Juergen Gross [Mon, 20 Jun 2022 07:38:16 +0000 (09:38 +0200)]
mini-os: rename console/xenbus.c to consfront.c

Move console/xenbus.c into the main directory and rename it to
consfront.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agomini-os: eliminate console/console.h
Juergen Gross [Mon, 20 Jun 2022 07:38:15 +0000 (09:38 +0200)]
mini-os: eliminate console/console.h

console/console.h contains only a single prototype. Move that to
include/console.h and remove console/console.h.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agomini-os: apply coding style to xenbus.c
Juergen Gross [Mon, 20 Jun 2022 07:38:14 +0000 (09:38 +0200)]
mini-os: apply coding style to xenbus.c

Make xenbus.c coding style compliant.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2 years agomini-os: drop xenbus directory
Juergen Gross [Mon, 20 Jun 2022 07:38:13 +0000 (09:38 +0200)]
mini-os: drop xenbus directory

The xenbus directory contains only a single source. Move this source
up and remove the xenbus directory.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agofix wrong function declaration
Juergen Gross [Wed, 19 Jan 2022 13:06:00 +0000 (14:06 +0100)]
fix wrong function declaration

Coverity spotted a wrong function declaration, fix it.

Coverity-Id: 1497423
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
3 years agomake files array private to sys.c
Juergen Gross [Sun, 16 Jan 2022 08:33:28 +0000 (09:33 +0100)]
make files array private to sys.c

There is no user of the files[] array outside of lib/sys.c left, so
it can be made static.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agoadd struct file_ops for FTYPE_FILE
Juergen Gross [Sun, 16 Jan 2022 08:33:27 +0000 (09:33 +0100)]
add struct file_ops for FTYPE_FILE

FTYPE_FILE is the last relevant file type without a struct file_ops.
Add it.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agoadd struct file_ops for file type socket
Juergen Gross [Sun, 16 Jan 2022 08:33:26 +0000 (09:33 +0100)]
add struct file_ops for file type socket

Even with some special handling needed in select_poll(), add a struct
file_ops for FTYPE_SOCKET. Due to the need of the special handling it
isn't possible to use a dynamically allocated file type.

Most functions calling the file_ops methods can be simplified a lot now
that no file type specific handling is left. Same applies to the file
type name printing in debug/verbose mode.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agouse file_ops and get_file_from_fd() for console
Juergen Gross [Sun, 16 Jan 2022 08:33:25 +0000 (09:33 +0100)]
use file_ops and get_file_from_fd() for console

Add struct file_ops for the console related file types (FTYPE_CONSOLE
and savefile). FTYPE_CONSOLE remains statically defined, as it is used
to statically init stdin, stdout and stderr.

Instead of directly accessing the files[] array use get_file_from_fd().

With CONSOLE now handled via file_ops the bogus file descriptor case in
select_poll() now needs to be handled more explicit instead of dropping
into console handling, assuming that this case was basically meant to
cover SAVEFILE.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agouse alloc_file_type() and get_file_from_fd() in fbfront
Juergen Gross [Sun, 16 Jan 2022 08:33:24 +0000 (09:33 +0100)]
use alloc_file_type() and get_file_from_fd() in fbfront

Allocate file types dynamically via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agouse alloc_file_type() and get_file_from_fd() in netfront
Juergen Gross [Sun, 16 Jan 2022 08:33:23 +0000 (09:33 +0100)]
use alloc_file_type() and get_file_from_fd() in netfront

Allocate the file type dynamically via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agouse alloc_file_type() and get_file_from_fd() in blkfront
Juergen Gross [Sun, 16 Jan 2022 08:33:22 +0000 (09:33 +0100)]
use alloc_file_type() and get_file_from_fd() in blkfront

Allocate the file type dynamically via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agouse alloc_file_type() and get_file_from_fd() in tpmfront
Juergen Gross [Sun, 16 Jan 2022 08:33:21 +0000 (09:33 +0100)]
use alloc_file_type() and get_file_from_fd() in tpmfront

Allocate a file type dynamically via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agouse alloc_file_type() and get_file_from_fd() in tpm_tis
Juergen Gross [Sun, 16 Jan 2022 08:33:20 +0000 (09:33 +0100)]
use alloc_file_type() and get_file_from_fd() in tpm_tis

Allocate a file type dynamically via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Make some now local functions static and modify their prototypes to
match the file_ops requirements.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agouse alloc_file_type() and get_file_from_fd() in xs
Juergen Gross [Sun, 16 Jan 2022 08:33:19 +0000 (09:33 +0100)]
use alloc_file_type() and get_file_from_fd() in xs

Allocate the needed file type via alloc_file_type().

Instead of directly accessing the files[] array use get_file_from_fd().

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agoremove gnttab specific member from struct file
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>
3 years agoremove event channel specific struct file definitions
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>
3 years agoadd CONFIG_LIBXS item
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>
3 years agouse function vectors instead of switch for file operations
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>
3 years agoremove file type FTYPE_XC
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>
3 years agoreset file type in close() in one place only
Juergen Gross [Sun, 16 Jan 2022 06:45:24 +0000 (07:45 +0100)]
reset file type in close() in one place only

Today the file type in struct file is set to FTYPE_NONE for each
file type individually. Do that at the end of close() handling for
all types.

While at it wipe the complete struct file, too, in order to avoid
old data creeping into a new allocated struct file.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agointroduce get_file_from_fd()
Juergen Gross [Sun, 16 Jan 2022 06:45:23 +0000 (07:45 +0100)]
introduce get_file_from_fd()

Exporting the files[] array especially for components outside the
mini-os source tree is limiting the ability to change any file handling
in mini-os.

Introduce a new function get_file_from_fd() to return the struct file
pointer (or NULL) for a given file descriptor.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agoEliminate xenbus union member in struct file
Juergen Gross [Tue, 11 Jan 2022 14:58:13 +0000 (15:58 +0100)]
Eliminate xenbus union member in struct file

Replace the xenbus specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 years agoEliminate tpmtis union member in struct file
Juergen Gross [Tue, 11 Jan 2022 14:58:12 +0000 (15:58 +0100)]
Eliminate tpmtis union member in struct file

Replace the tpmtis specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>