Commit Graph

220 Commits

Author SHA1 Message Date
Sam Leffler
43d921eb53 ProcessManager: first cut at proper seL4 support
- replace the opaque memory placeholder with MemoryManager integration
  (e.g. ObjDescBundle's and BundleImage's)
- set CNode headroom so there is space to construct a 4MB application
- arrange to get capabilities for an ASIDPool, the global SchedController,
  and the global DomainController for crafting new TCB's
- arrange for copregions (VSpace holes) for working with BundleImage's
  and spilling arguments to the stack of a new TCB
- integrate with the slot allocator
- accept an ObjDescBundle for the pkg_contents of an install request
- add BundleImplInterface traits in suport of mocking/faking the bundle
  implementation (unit tests not included)
- new error codes: ObjCapInvalid, SuspendFailed, ResumeFailed
- integrate with the kernel so TCB construction honors settings like MCS
- track kata_security_* wrapper additions
- add seL4BundleImpl (derived from kata-os-rootserver)

TODO: build+test only on RISCV32
TODO: verify seL4BundleImpl features all build at least
TODO: cleanup VSpace layout (is probably arch specific)
TODO: review+cleanup error handling (esp resources)
TODO: fault endpoints are not conencted
TODO: SDK runtime is not setup
TODO: scheduling is likely not the way we want
TODO: security eview

Change-Id: I025b008eeb8b47af2fe3894149da6576642bb8ed
GitOrigin-RevId: 539bf11739a9e756936168a9cbd3e2e2e4b0ba11
2022-10-06 18:44:45 +00:00
Sam Leffler
e46f247470 StoragManager: track SecurityCoordinator changes
- break dependency loop with kata-security-interface
- use new kata_security_* wrappers

Change-Id: I65b98a406f18c82354e5425b37612789d4ab340d
GitOrigin-RevId: 5744715a439a5305ead57a99eacc1108b5d10750
2022-10-06 18:44:37 +00:00
Sam Leffler
cd6413908a SecurityCoordinator: overhaul server side
This mostly cleans up my bad idea of how to process SecurityRequests.

- accept an ObjDescBundle attached in an InstallRequest
- return a BundleImage in LoadApplication & LoadNModel replies
- integrate with the slot allocator
- integrate with MemoryManager (for the fake)

Change-Id: I695efbecabfa3e71d7d2cfdd013c113a5a915b40
GitOrigin-RevId: 623ffdf19f5550918da530b57a299659061832aa
2022-10-06 18:44:30 +00:00
Sam Leffler
daf232273b SecurityCoordinator: overhaul client api's
- hide marshalling details in kata_security_* wrappers
- replace the placeholder opaque memory representation in rpc's with
  MemoryManager integration
- uses proper struct's for all Request/Response msgs (except for Echo):
  this mostly eases the way for switching away from postcard + CAmkES
  to comething like flatbuffers
- extend SecurityRequest structs with SecurityCapability traits to
  support passing capabilities (specifically CNode's holding dynamically
  allocated objects)
- new error codes: SreDeleteFirst, SreCapAllocFailed, SreCapMoveFailed,
  and SreObjCapInvalid
- shuffle integration with StorageManager to resolve a dependency loop
- redo SecurityCoordinatorInterface to enable server-side changes (in
  a separate cl)
- add headroom to the component CNode for the fake impl to hold package
  contents

Change-Id: Ief6931d451023b511dbe1bdc3ffba4bf18070962
GitOrigin-RevId: 066f6cfa72f47fb8b4f8edc861dd9e3759ec6054
2022-10-06 18:44:22 +00:00
Sam Leffler
426be466ff ProcessManager: add bundle image support for loading apps & models
Add support for BundleImage, a file format for loading applications and
models from a bundle. BundleImage is simple, compact, and streamable,
BundleImage files are constructed with the prepare_bundle_image tool.

TODO: add compression
TODO: check crc32

Change-Id: I0770608a075cac9754a54e0bb244d75673ae1be6
GitOrigin-RevId: 368dabd3a5af19d47fe7f8084b8a0a0b57b8471d
2022-10-06 18:44:15 +00:00
Sam Leffler
4f17bb33b3 MemoryManager: integrate with the slot allocator and many api updates
- track CAmkES well-known name changes (e.g. RECV_CNODE -> MEMORT_RECV_CNODE)
- initialize the slot allocator for the component
- fix size_bytes to use the object count in its calculation
- add can_combine method to help optimize ObjDescBundle construction
- enhance ObjDescBundle:
  - len, count, size_bytes, count_log2, maybe_combine_last
  - move_objects_to_toplevel, move_objects_from_toplevel
  - fmt (show SELF_CNODE & MEMORY_RECV_CNODE symbolically)
- add MmeCapAllocFailed
- add kata_object_alloc_in_toplevel & kata_object_free_toplevel
- add kata_object_alloc_in_cnode & kata_object_free_in_cnode
- add kata_frame_alloc_in_cnode
- avoid underflow in stats bookkeeping to not crash until we fix
  the root cause

Change-Id: I826b55f1f0b07bef58a420e32efbc02cd1d6363f
GitOrigin-RevId: 43bd8ae5cf41fd510fae502c7cd8e234c04edb85
2022-10-06 18:44:07 +00:00
Sam Leffler
2251f84c1b TimerService: mark component as part of KataOS
This fixes debug builds which otherwise have an undefined reference
to SELF_CNODE.

Change-Id: I55384cfff19b99cf49b147d396b274c74bdf5db5
GitOrigin-RevId: d055b070ee5a67f1648566d1c1c511446d02b3cc
2022-10-06 18:43:57 +00:00
Sam Leffler
7315d09fb5 Merge "kata-slot-allocator: add a 1-slot RAII helper"
GitOrigin-RevId: 5d339c11e080d99280438552d69147745122780b
2022-10-06 18:43:50 +00:00
Adam Jesionowski
eb46d7c817 Merge "Add test_timer commands."
GitOrigin-RevId: 15cc9f8793813dde2f5272ae99b6ce81a71818ef
2022-10-06 18:43:43 +00:00
Austin Appleby
2378b38d71 Make camkes IRQ numbers match top_matcha.h
Change-Id: I78d4081947cb4ca6509850b91e59e24a4ad8d8aa
GitOrigin-RevId: 8ed42fa6d8ac519e9fecb5b8333cb1523ab88df4
2022-10-06 18:43:35 +00:00
Austin Appleby
6b36b6fd56 Merge "Increase # of SMC PLIC interrupt lines to 32 in Renode and move the SMC software interrupt to #31 until it gets a hardware interrupt # assigned"
GitOrigin-RevId: 85e26fd4c3c4739d2a6ec1c176a226d2fc5c81b7
2022-10-06 18:43:28 +00:00
Sam Leffler
f06f3a51e6 kata-os-common: make CAmkES-specific support controlled by a feature
The slot allocator has CAmkES-specific support that will not build for
a non-CAmkES target. Add a "camkes_support" feature flag that controls
whether the slot allocator is included. This is enabled by default but
allows users like kata-os-rootserver to workaround the problem.

Change-Id: I2decb9fc794c215455e223d17c24c6a19cc52d56
GitOrigin-RevId: d7a3811b4a9a000b0f34fbc2abdfc628250f64d4
2022-10-06 18:43:21 +00:00
Sam Leffler
6eb1d0537f Merge "kata-os-model: make noisy logging feature-dependent"
GitOrigin-RevId: 86cc0e2c482146df56b58ec0a61e54d31c317d71
2022-10-06 18:43:14 +00:00
Sam Leffler
3bf4242a91 Merge "sel4-sys: add some debug helpers"
GitOrigin-RevId: 6d3453d2d46b3af864ea84e8c8d8413acdceb681
2022-10-06 18:43:07 +00:00
Adam Jesionowski
d13355401a Revert "Make camkes IRQ numbers match top_matcha.h"
Revert "Make smc_plic.numberOfSources match top_matcha.h"

Revert submission 21323-top_matcha_irqs

Reason for revert: Breaks TimerService
Reverted Changes:
I40a840585:Make smc_plic.numberOfSources match top_matcha.h
I026a541a6:Move IRQ numbers to config lib and annotate with c...
I2873a0561:Make camkes IRQ numbers match top_matcha.h
Ida9efaf63:Make PLIC_MAX_NUM_INT match top_matcha.h

Change-Id: I07c06e2f6c43201dc2078745a5146dccab442285
GitOrigin-RevId: 6109d5353bd3a49d827c6c9a1b0b28c8827ffb28
2022-10-06 18:42:59 +00:00
Austin Appleby
3ba2688c2e Make camkes IRQ numbers match top_matcha.h
Change-Id: I2873a0561ef7ff02c0fcc72577a681903f84b562
GitOrigin-RevId: 58149ca60a582af8934e9c6f9c55ebc9ce2fe274
2022-10-06 18:42:52 +00:00
Austin Appleby
10f0ace32e Apparently we still need resolver = 2 for the build to work. :/
Change-Id: I45df25651d19b28ea5335aea8b394ae17394e60f
GitOrigin-RevId: 6eb5747eed94fd2f34686edd46169677f46b644a
2022-10-06 18:42:44 +00:00
Sam Leffler
2924a4c26e kata-logger: fix unit tests after crate rename
Change-Id: Ie9d125f2a8994ae2ebc569ca4c67ee48ec2706ca
GitOrigin-RevId: 9b11c59f20b3ec4310a28657ecc3d193595b8444
2022-10-06 18:42:37 +00:00
June Tate-Gans
57a4ee2f13 cargo: Bump to 2021 edition
Change-Id: Icb2deaff58da7f92970d8f57f7853349769323f5
GitOrigin-RevId: f8303df543a9d84c066b9a4a1bd1c0239eb75857
2022-10-06 18:42:30 +00:00
Sam Leffler
9188a29bd4 Move common crates to kata-os-common and shorten names.
- kata-allocator, kata-kata-logger, kata-panic, and kata-slot-allocator
  are now submodules of kata-os-common
- be more consistent on use stmts (and remove unneeded deps)
- cleanup various deps on kata-panic that no longer seem to be needed
  (likely due to using resolver=2)

Change-Id: I5d3f4b399e3be66c09c2f97c75d5e3053993ebdd
GitOrigin-RevId: 393e28fbb975959cba35388bab749b256cda0095
2022-10-06 18:42:22 +00:00
Sam Leffler
fdc3a88437 Impprove cbindgen integration.
- add Makefile's to re-generate CAmkES interface defs
- move cbindgen.toml files into the interface crate(s)

Note: still need to integrate running make with the build
Change-Id: I16b3e3b831b66ad1c976402e38df6be4a126d923
GitOrigin-RevId: 78b8b9024e4acb89590410a439f121fcb1fdc996
2022-10-06 18:42:15 +00:00
Sam Leffler
3c37de656a Merge "kata-slot-allocator: CSpace slot allocator"
GitOrigin-RevId: 671e23b90d2a182cb66a646b7f22204ede6880db
2022-10-06 18:42:07 +00:00
Adam Jesionowski
9a8254e32a Merge "Remove unused import."
GitOrigin-RevId: ff9426ca8eb891f9cb7f376534feaba6ca23c7f4
2022-10-06 18:42:00 +00:00
Adam Jesionowski
945f519de8 Merge "Kata Timer Service"
GitOrigin-RevId: b0849f9195fc5dcec42d5a3b3ef884837798d824
2022-10-06 18:41:53 +00:00
June Tate-Gans
306d806d4a Merge "handle additional condition syntax in generators"
GitOrigin-RevId: f6b7f62233602191b02becd1d6873a1472b5831a
2022-10-06 18:41:46 +00:00
Sam Leffler
957f429c52 Mark KataOS components for special CAmkES processing.
Mark each component that depends on component.kataos.c features with a
"kataos" attribute.

Change-Id: I7e2e3f9010a7aa717d4fe3dfc2f088cbd1a66488
GitOrigin-RevId: 2967036cf4e70edc3f96d2ead45ecfe9e42fd7fa
2022-10-06 18:41:39 +00:00
Sam Leffler
72faf77df8 DebugConsole: allocate 64 empty CNode slots for test use.
Change-Id: I9bf2053edc81717e42ccbae29c7632225e6985fe
GitOrigin-RevId: 90747a3256ac8e96dabf46548dabf6784a6aba17
2022-10-06 18:41:31 +00:00
Sam Leffler
c0549c75e7 kata-os-model: correct slot calculation for untyped memory handoff
When calculating the landing spot for handing off the UntypedMemory
objects we need to take into account empty slots. Calculate the max
occupied slot # and add one. This works so long as empty slots have
not been allocated (by CAmkES) at the end of the CNode--which should
be safe since we control the MemoryManager CAmkES specification.

Change-Id: I5bfb75bd7134254c4475a91653d54e2aeb126721
GitOrigin-RevId: cf14850894ad21be97ea094f977c3420edf322ab
2022-10-06 18:41:24 +00:00
Sam Leffler
18c7660244 Add MemoryManager service.
The MemoryManager service allocates & frees seL4 objects. Requests can be
batched. Capabilities to dynamically allocated objects are moved in CNode
containers attached to IPC requests.

Specific changes:
- Add new CAmkES MemoryManager component.
- Add api's for allocating & freeing singleton objects (e.g.
  kata_cnode_alloc) and batches of objects (kata_object_alloc &
  kata_object_free).
- Add support to kata-os-rootserver to hand-off UntypedMemory objects
  just before terminating. The objects are placed directly in the
  MemoryManager's top-level CNode and a BootInfo frame is constructed
  that describes where the objects are.
- Switch the rootserver to kata-os-rootserver as the C version lacks
  the UntypedMemory hand-off.
- Add test_bootinfo kata-shell command to dump the MemoryManager BootInfo
  frame contents (broken for now because it directlry references the
  shared page).
- Add test_obj_alloc kata-shell command that exercises the MemoryManager
  singleton and batch api's

While here, did some cleanup of arg handling in kata-shell.

TODO: top-level object allocations use a simplistic capability allocator
TODO: move test_bootinfo to the MemoryManager and add an interface rpc

Change-Id: I778b2d5fe7f2f9b65ee642ff905cf56d4b2b02fd
GitOrigin-RevId: 7fc72d1927bba165234955e68f8b9ad1b556f6fb
2022-10-06 18:41:15 +00:00
Sam Leffler
4e5b8a4423 Merge "sel4-sys: rename arch/riscv.rs in preparation for 64-bit support"
GitOrigin-RevId: cc502e8cbae75e7825050ec37bd585f4d082f9dc
2022-10-06 18:41:08 +00:00
Sam Leffler
3e37996648 Merge "sel4-sys: make seL4_GetCapReceivePath more Rust-friendly"
GitOrigin-RevId: 8a14f93d1f13718784e8377056d50377187f2343
2022-10-06 18:41:01 +00:00
Sam Leffler
c24f1fc9d7 Merge "sel4-sys: add BootInfo serde support"
GitOrigin-RevId: a6191ecf1b2bddbe8c92dbe7d2e5ba0a65824117
2022-10-06 18:40:53 +00:00
Sam Leffler
a4a1ca9556 Merge "sel4-sys: add ObjectType sizing"
GitOrigin-RevId: 6484fdbf5e7fe9c004ed436debffa97bcc84c971
2022-10-06 18:40:46 +00:00
Sam Leffler
0088925a43 Merge "sel4-sys: remove unused files"
GitOrigin-RevId: b335379fb7efe392e1d7f7fbfa6816d8772e73f3
2022-10-06 18:40:38 +00:00
Adam Jesionowski
6ff6c95b3c Use local copies of cpio and xmas-elf crates.
Change-Id: I41ea714291d15caa2187315766322c41ead72e24
GitOrigin-RevId: c7ea56a9216972f51a21a2f59c7ee0987ee7b72d
2022-10-06 18:40:31 +00:00
Sam Leffler
0211cf3a9c Disable LTO for profile.dev when building CAmkES components.
This is a workaround for gdb complaints of the form:

Dwarf Error: Cannot find DIE at 0x5136b referenced from DIE at 0x57eed

Release builds continue to enable LTO.

BUG: 223253186

Change-Id: I137456045e842b2b93b32e0edd348ff916925c97
GitOrigin-RevId: 8ab2ab4fac615eb2a1a259a5a18aa410a4aae5fb
2022-10-06 18:40:25 +00:00
Cindy Liu
f47d252904 kata: vec_core: Update ITCM memory address
To match HW def in
3d05e14abb/hw/top_matcha/data/top_matcha.hjson (749)

Change-Id: I933db00d1e6702fb38544b6641dabcb0d6b6e390
GitOrigin-RevId: 31de9893d54e43db60d000f03561f22d59482ad4
2022-10-06 18:40:16 +00:00
Sam Leffler
4fe71acb97 rust.cmake: fix RELEASE handling
Cmake's list operator operates on the current scope so we were not
setting --release on the cargo cmd line.

Change-Id: I91aa8489869c3190d60c3f2dee374b3d9388ebda
GitOrigin-RevId: 36fa241862c1cb94b736be89d09e8127fefdfc4d
2022-10-06 18:40:08 +00:00
Adam Jesionowski
2749156acf Use read_volatile for reading from vc control
Without read_volatile the compiler may try to optimize reads, which
causes issues with renode simulation.

Change-Id: I8877798420cdecc2dece97d168db753adfe89163
GitOrigin-RevId: c7b3e2ee5500c993b48d9793f575758cb0c3a0ac
2022-10-06 18:40:00 +00:00
Sam Leffler
b584015157 Merge "kata-os-model: fix release build"
GitOrigin-RevId: 4ae1ca568f1cf3c6aac5c7ba975f0ae4d68798be
2022-10-06 18:39:52 +00:00
Marcin Witkowski
18474970dc processmanager: use rx_fifo_level in OpenTitanUARTDriver
Use RX_FIFO_LEVEL additionally to RX_EMPTY. This improves
performance a bit, as RX_EMPTY register and circular buffer
status don't have to be read for every byte.

Change-Id: Ib56b4c6a0dc5689b63941b449f476f3555421abb
GitOrigin-RevId: f7a46154afaf5be28feab173687cebd8b584e8f4
2022-10-06 18:39:45 +00:00
Sam Leffler
8961c75d25 Merge changes from topic "kata-os-rootserver"
* changes:
  capdl: calculate space used by a specification
  kata-os-model: fix MCS support
  kata-os-model: mark RISC-V non-executable pages with the NX bit
  kata-os-model: simplify & shrink page frame fills
  kata-os-model: merge vspace root collection into object creation
  kata-os-model: rust version of capdl-loader-app internals

GitOrigin-RevId: 44208d281ea021a671c90dc650389029baf9243e
2022-10-06 18:39:37 +00:00
Adam Jesionowski
3f121414ea Fix seL4 slowdown by increasing ELF space.
In order to allocate a frame for the ELF, the seL4 object creation
routine scans through addresses, allocating frame by frame. This is very
slow if the ELF MMIO is sized 0x300000 as it requires a smaller seL4 object
(12 bits). Thus it allocates a 0x1000 frame over and over through the
space from 0x3c40_0000 to 0x4600_0000. Paradoxically if we instead
allocate 0x1000_0000 for the ELF, this scans the address range faster as
it needs a seL4 object of 22 bit size, so it scans the address space by
0x040_0000 increments instead.

Change-Id: Ic989e15eb0b2d65e26b141c7975d28cd611b5f79
GitOrigin-RevId: f1b27cc5b452247f8c15f4cb252a7a49fdcf12b9
2022-10-06 18:39:30 +00:00
Marcin Witkowski
b4e76a37b6 processmanager: update OpenTitanUARTDriver
Change-Id: I3fc395213fc0b254c87e9afefea61ad678fe578b
GitOrigin-RevId: 5d7c76ef1aeb552d0b6e270688e29cdf8114a9f8
2022-10-06 18:39:22 +00:00
Sam Leffler
2f4d3c8e35 Merge "processmanger: fix release builds"
GitOrigin-RevId: 18bd5b9b85ab3b264c5816327d34b0ba3d645204
2022-10-06 18:39:14 +00:00
Adam Jesionowski
336808a812 Update camkes to 1M ITCM
Change-Id: I6d265220843bd0e4b0251c42150b221af4b269b0
GitOrigin-RevId: 7bb11dd5f4898bef716118f545c557f3da1d20da
2022-10-06 18:39:06 +00:00
Adam Jesionowski
eae7aa7ab1 Update memory map.
Control block moved due to Secure Core PLIC moving.

Change-Id: If3dee2559503ad97e2f9917f416dd6abc9765732
GitOrigin-RevId: 16b0878c8b09c9610dfe0b50264b59d4aec5a2ae
2022-10-06 18:38:49 +00:00
Adam Jesionowski
d803859470 Merge "Re-map SMC UART and PLIC."
GitOrigin-RevId: 04a0dadc27218e9dfba4440c42630a5b34ab0c56
2022-10-06 18:38:42 +00:00
Lun Dong
0d610d1ca6 MLCoordinator: Increase ITCM size to 1M
Increase ITCM size to 1M.

BUG: 214092253
Change-Id: I6762b5b12ea268c43f558a31d8fce3725cb2bf22
GitOrigin-RevId: 6b520a0c77d33c38bf774b127a1cc76d5f7165fd
2022-10-06 18:38:35 +00:00
Adam Jesionowski
4ed5fc91fd Use CSR initialization for clearing ITCM.
Clears the ITCM in one go before loading an ELF file using the
hardware initialization CSRs.
DTCM is not cleared as it's temporarily larger than the CSRs can fit.

Tested manually.

Change-Id: Ie4620508404cebc8724771eb579c873fcc0cf0ee
GitOrigin-RevId: ef5de7003c22a1871ab0f74a23fce34593b73fe1
2022-10-06 18:38:28 +00:00