Commit Graph

747 Commits

Author SHA1 Message Date
June Andronick 366cc9088f fix broken internal links
Signed-off-by: June Andronick <june.andronick@proofcraft.systems>
2025-07-10 08:53:02 +10:00
Gerwin Klein 9cdaf8b3e1
api docs: fix links (#135)
The anchors are called #interface-*, not #module-*. Not sure which one
changed from the generated version, but since we are maintaining the
result manually, apply the fix to the links directly.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-07-09 16:01:17 +02:00
Gerwin Klein 46f6dc9c0c remove obsolete LICENSE_* files
These are already covered by the LICENSES/ directory and SPDX
identifiers.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-05-26 09:59:17 +02:00
Kent McLeod 06f372ce29 vmmplatsupport: Fix issue with unaligned writes
strncpy was generating unaligned writes if the str length was not
alligned. Because the source memory passed into the function's length
isn't known, we copy via an alligned stack buffer to avoid an unaligned
write to uncached memory.

Signed-off-by: Kent McLeod <kent@kry10.com>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-05-26 09:59:17 +02:00
Gerwin Klein 2c95034d43 github: use central CI workflows
Use GitHub workflow_call feature to reduce workflow duplication.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2025-03-17 11:37:11 +11:00
Kent McLeod 0c75408d9a sel4vmmplatsupport: Rename PAGE_SIZE constant
PAGE_SIZE_4K is a constant declared by one of our libraries, while
PAGE_SIZE was previously provided by an older fork of the C library.

Signed-off-by: Kent McLeod <kent@kry10.com>
2025-02-28 12:07:39 +11:00
Robbie VanVossen bca46738da libsel4vm: Proper error for map_vm_memory_res
Currently, if the map_iterator function fails to find a frame for a
given address, then it breaks from the loop, but it does not return an
error and marks the reservation as mapped. Since it skipped some number
of reservations, that is not true and an error should be returned
instead.

Signed-off-by: Robbie VanVossen <robert.vanvossen@dornerworks.com>
2025-02-22 10:57:42 +11:00
kenaml 8ac68eeb4b vm_syscall_handler error
Signed-off-by: kenaml <kenaml@qq.com>
2025-02-22 10:56:37 +11:00
Kent McLeod 97360824ee libsel4vm: Remove SMP config guard on vmpidr reg
seL4_ARM_VCPU objects now allow single core configurations to access the
VMPIDR register, thus this config guard is no longer needed.

Signed-off-by: Kent McLeod <kent@kry10.com>
2024-03-15 09:25:27 +11:00
Christopher Guikema 4662171c60
vmmplatsupport: support hpet emulation (#117)
Real-time Linux kernels often don't work when using the PIT. This commit
adds support for emulating the HPET by adding an HPET entry to the ACPI
tables.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2024-01-28 10:41:04 +11:00
Chris Guikema 0d46afe203 x86, decode: fix 4-level page table walk
This commit fixes the page table walk when using 4-level mappings. Linux
can use 64-bit memory to store tables, and masking off the upper 32-bits
prevents the walk from functioning properly. Additionally, the physical
instruction calculation was using the incorrect logical address bits for
each level. Finally, the last PTE doesn't have the 7th bit flag a valid
page, we just check the first bit to ensure the entry is present, and
calculate the PTE address.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2023-11-09 15:14:10 +11:00
Chris Guikema 7d8f309a9b trivial, decode: fix zf_log statements
This commit removes the newlines, as ZF_LOG adds a newline. It also
fixes a DPRINTF level holdover, which causes a data fault when logging
is enabled.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2023-11-08 21:41:47 +00:00
Chris Guikema 8d71a8afc3 vmmplatsupport, vesa: fix vesa mapping
The previous behavior would only attempt to map the vesa framebuffer and
set the screen info struct if the vbe protection mode interface was
successfully mapped in. This removes the dependency on the vbe protected
mode interface. It is not clear that it is needed as vesa framebuffer
passthrough works without it.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2023-11-03 13:55:39 +11:00
Chris Guikema e219913b3f vmmplatsupport, x86: remove e820 entry
This commit removes an e820 entry for 64-bit guests. This was a
reserved memory region from the end of guest memory to the beginning of
high memory. When 64-bit guests have access to 64-bit memory, this
subtraction would place a bogus region in the e820 map that could
confuse the guest.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2023-10-27 17:57:41 +01:00
Chris Guikema e26333184e sel4vm, guest_ram: fix compare function
The compare function is used with qsort to sort the guest ram regions.
However, the compare function was returning an int, when the region
checked is a uintptr_t. Subtracting these values and returning an int
can cause undefined behavior. This commit fixes the compare function
such that the return is compatible with qsort.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2023-10-27 09:51:05 +01:00
Chris Guikema 3365675cbb sel4vm, guest_ram: add 32-bit check
64-bit x86 VMs can have RAM in 64-bit memory, which cannot be used to
store the kernel and initrd images, as those must be in 32-bit memory.
This commit adds a check when 64-bit guests are enabled to ensure the
returned region is in 32-bit space.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2023-10-27 09:51:05 +01:00
Chris Guikema b82f9f455b vmmplatsupport, pci: fix offset bug
The offset is applied twice, which can prevent PCI passthrough from
functioning properly when the offset is not zero. This commit removes
the second offset addition.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2023-10-27 08:47:49 +11:00
Chris Guikema bfe54e3a7b sel4vm, lapic: fix apic mmio access
The subtraction is backwards, so lapic access will never work.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2023-10-26 14:05:08 +11:00
Alex Pavey eb42051d12 smc_cap: Allow a custom smc handler
This required a new callback to be added to the vm_arch struct for
ARM. The old handle_smc function gets registered as the smc handler by
default. The callback allows a user to register a custom smc handler
instead.

This is especially useful to allow SMC forwarding in the user's custom
handler.

Signed-off-by: Robbie VanVossen <robert.vanvossen@dornerworks.com>
2023-09-05 14:08:22 +01:00
Jingyao Zhou 82e0e3f85e 64-bit-vms: small code refactoring
switch from CONFIG_ARCH_X86_64 to CONFIG_X86_64_VTX_64BIT_GUESTS to
allow 32 bit guests on 64 bit hosts.

Signed-off-by: Jingyao Zhou <jingyao.zhou@unsw.edu.au>
2023-06-15 17:22:53 +10:00
Hannu Lyytinen 6cc80a3245 Remove duplicate code
The convenience function is moved to util_libs/libfdt, with
naming and argument order changed to conform the style used
in libfdt.

Signed-off-by: Hannu Lyytinen <hannux@ssrc.tii.ae>
2023-06-15 09:40:27 +10:00
Jingyao Zhou d96def8545 trivial: remove unused variable for acpi.c
Signed-off-by: Jingyao Zhou <jingyao.zhou@unsw.edu.au>
2023-06-07 12:00:10 +10:00
Jingyao Zhou d062d869ff 64-bit-vms: code refactoring
switch from CONFIG_ARCH_X86_64 to CONFIG_X86_64_VTX_64BIT_GUESTS to
allow 32 bit guests on 64 bit hosts; fix print format for seL4_Word;
misc improvement.

Signed-off-by: Jingyao Zhou <jingyao.zhou@unsw.edu.au>
2023-06-07 12:00:10 +10:00
Chris Guikema d25cd0cf57 acpi: track vaddr of ACPI tables
Previously, the physical address of the ACPI tables were being
tracked. This caused a Linux error while parsing the ACPI tables. Since
Linux does not have access to those memory regions, they would appear
empty, causing an Invalid Table Length bug print. By tracking the
virtual address that Linux expects and placing the vaddr into the ACPI
tables, Linux can parse the tables properly.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2023-06-07 12:00:10 +10:00
Damon Lee 4358724eef libsel4vm: Force optimisation level for release
As the comment in the file explains, optimisation level -O3 on gcc 8.4
is too aggressive and causes issues for the guest VM. The problem isn't
limited to a single function or group of functions but rather the entire
file for some reason that requires extra investigation (but is not worth
the time to do so).

Signed-off-by: Damon Lee <Damon.Lee@data61.csiro.au>
2023-06-07 12:00:10 +10:00
Damon Lee 982f5356e1 trivial: Fix compiler warnings
Signed-off-by: Damon Lee <Damon.Lee@data61.csiro.au>
2023-06-07 12:00:10 +10:00
Damon Lee 0994ab7b17 64-bit-vms: Add 64-bit VM support to VMM
This large commit combines a number of smaller commits in order to add
64-bit VM support to the VMM. The commits do the following:

    * Load elfs of the same architecture size
    * Support reading 64-bit vaddrs from elf files
    * Create initial address space based on guest architecture
    * Allow instruction decoding of 4-level paging scheme
    * Do not exit VMX state based on CR3 load/store in 64-bit mode
    * Use seL4_Word for vmcs and user context fields
    * Handle additional general purpose registers
    * Handle 64-bit MSRs
    * Configure 64-bit guests to boot in long mode
    * Let guest know about 64-bit hardware features in 64-bit mode
    * Add FADT and DSDT tables
    * Track guest state for additional 64-bit registers
    * Add new function to print 64-bit guest context
    * Properly emulate 64-bit trampoline code
    * Define access rights macros for vmcs initialization
    * Hardcode FADT table information
    * Set an initial stack pointer before running guest
    * Handle fetching cross-page instructions
    * Add additional x86 instruction prefixes

CCDC-GVSC DISTRIBUTION A.  Approved for public release; distribution
unlimited. OPSEC#4481.

Co-authored-by: Chris Guikema <chris.guikema@dornerworks.com>
Signed-off-by: Damon Lee <Damon.Lee@data61.csiro.au>
2023-06-07 12:00:10 +10:00
Axel Heider 59570c811a libsel4vmmplatsupport: make functions static
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-05-30 09:21:34 +10:00
Axel Heider 790ac4bc4c trivial: address style warnings
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-05-30 09:21:34 +10:00
Hannu Lyytinen d7401438fe cross_vm_connectors: Derive size properly
After all the size is derived from the number of frames and their
size, not the other way around.

Signed-off-by: Hannu Lyytinen <hannux@ssrc.tii.ae>
2023-05-25 19:18:54 +10:00
Markku Ahvenjärvi 7e46cbb8eb libsel4vm: use compile_time_assert
static_assert was standardized in C11 as a macro prior C23. While
_Static_assert was introduced to C11 standard too, it's been part of
GNU extensions and it is available for gnu99. Use compile_time_assert()
which handles this for us.

Fixes compilation errors when standard is set to versions prior C11.

Signed-off-by: Markku Ahvenjärvi <markkux@ssrc.tii.ae>
2023-05-25 17:21:28 +10:00
Axel Heider 4a3c271a0e libsel4vmmplatsupport: remove escape char
There is no need to escape singe quotes

Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-05-25 17:09:50 +10:00
Axel Heider a755faf4d9 libsel4vmmplatsupport: remove linux references
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-05-25 17:09:50 +10:00
Felix Schladt 8d5e6f4482 libsel4vmmplatsupport: reduce log level
Turn log level for io access to debug as this gets quite annoying when
using the vm.

Signed-off-by: Felix Schladt <felix.schladt@hensoldt.net>
2023-05-25 17:09:00 +10:00
Hannu Lyytinen fb383966ee cross_vm_connectors: Use proper frame size
CAmkES selects the biggest possible page size supported by MMU and
generates frames with the same size. For example, on aarch64 dataports
equal to or larger than 2 MB were broken, as only the first 4 kB were
mapped to guest's vspace.

Also use vm_map_reservation_frames() to unclutter code here.

Signed-off-by: Hannu Lyytinen <hannux@ssrc.tii.ae>
2023-05-25 17:06:59 +10:00
Hannu Lyytinen a4bdc51a3e libsel4vm: Map reservation from array of frames
Signed-off-by: Hannu Lyytinen <hannux@ssrc.tii.ae>
2023-05-25 17:06:59 +10:00
Hannu Lyytinen fba3613235 trivial: Make local variables static
Signed-off-by: Hannu Lyytinen <hannux@ssrc.tii.ae>
2023-05-25 17:06:59 +10:00
Hannu Lyytinen b494fffb2b trivial: Remove unused code
Signed-off-by: Hannu Lyytinen <hannux@ssrc.tii.ae>
2023-05-25 17:06:59 +10:00
Hannu Lyytinen 4184716605 trivial: Add error check
Signed-off-by: Hannu Lyytinen <hannux@ssrc.tii.ae>
2023-05-25 17:06:59 +10:00
Joonas Onatsu e7b8a34f71 trivial: Fix hardcoded page sizes
Signed-off-by: Joonas Onatsu <joonasx@ssrc.tii.ae>
2023-05-25 17:06:59 +10:00
Axel Heider 275223b526 libsel4vmmplatsupport: remove newline
Remove newline, ZF_LOGx() already prints it.

Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-05-09 07:33:40 +10:00
Axel Heider da0e9ac068 libsel4vmmplatsupport: remove unused variable
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-05-09 07:33:03 +10:00
Axel Heider e13b3fa2fc libsel4vmmplatsupport: use uintptr_t
- This is no pointer that can be dereferenced.
- uintptr_t is used in other places already, so casting can be avoided.

Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-04-21 07:59:36 +10:00
Axel Heider e919ff931b libsel4vmmplatsupport: remove unrechable return
The last return statement is never reached.

Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-03-21 12:21:57 +11:00
Axel Heider 7fb3ad8da8 libsel4vmmplatsupport: make functions static
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-03-21 12:21:52 +11:00
Axel Heider 721bab5ef0 libsel4vmmplatsupport: remove unused variable
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
2023-03-21 12:16:33 +11:00
Chris Guikema 58dc2820a9 libsel4vm: add entries to vm structure
This commit adds three entries to the vm structure. The first is the
entry address of the loaded kernel. The second is a flag to determine
whether the cache should be cleaned when loading images to the guest's
address space. The third flag is whether the VM should map memory 1:1.

These flags are necessary to differentiate VMs in a multiple VM setup.
For example, if two VMs have kernels with different entry points, only
one VM would run, and the other would fault.

Signed-off-by: Chris Guikema <chris.guikema@dornerworks.com>
2023-03-07 17:04:51 +11:00
Jingyao Zhou f376e0b907 virtio: Small refactor for virtio vsock
refactor the interfaces between different virtio vsock
layers for a better OO design.

Signed-off-by: Jingyao Zhou <jingyao.zhou@unsw.edu.au>
2023-01-16 11:07:25 +11:00
Jingyao Zhou 813be718c9 virtio: Small refactor for virtio con
refactor the interfaces between different virtio console
layers for a better OO design.

Signed-off-by: Jingyao Zhou <jingyao.zhou@unsw.edu.au>
2023-01-16 11:07:25 +11:00
Jingyao Zhou 1bfd64cd48 virtio: modify virtio con to deal with ring bufs
make emul_con_rx_complete deal with ring buffers to avoid an extra
copy of the buffer from the virtio console backend to the virtio console
emul layer.

Signed-off-by: Jingyao Zhou <jingyao.zhou@unsw.edu.au>
2023-01-16 11:07:25 +11:00