Commit Graph

238 Commits

Author SHA1 Message Date
Adam Jesionowski
1662e80ef1 MlCoord: Execution queue
This CL enables multiple outstanding periodic executions. To do so the
MlCoordinator now includes an array of started models and a queue of
models that are ready to be executed immediately. Additionally, each
periodic model has an associated timer. When that timer fires the model
is added to the execution queue. When a model finishes executing, the
next model is popped off the queue and executed. If a model becomes
ready when there's already an execution for it queued, that execution
is dropped and a warning printed. A cancel command is added to remove
periodic or outstanding executions.

A state debug command was also added.

Currently we can only load a single model due to limitations with the
StorageManager, but we can do so multiple times.

Tests:
Single shot: https://paste.googleplex.com/6704629669691392
Two periodic execs: https://paste.googleplex.com/5288292800004096
Overloaded warning: https://paste.googleplex.com/4549962219126784

Debug State:
KATA> state_mlcoord
kata_ml_coordinator::Running model: fubar:mobilenet_v1_emitc_static.model
kata_ml_coordinator::Loaded model: fubar:mobilenet_v1_emitc_static.model
kata_ml_coordinator::Loadable Models:
kata_ml_coordinator::  LoadableModel { bundle_id: "fubar", model_id: "mobilenet_v1_emitc_static.model", rate_in_ms: Some(2000) }
kata_ml_coordinator::  LoadableModel { bundle_id: "fubar", model_id: "mobilenet_v1_emitc_static.model", rate_in_ms: Some(6000) }
kata_ml_coordinator::Execution Queue:
kata_ml_coordinator::  fubar:mobilenet_v1_emitc_static.model
kata_ml_coordinator::Statistics: Statistics { load_failures: 0, already_queued: 0 }

Change-Id: I7637c9c390eb6ffd9ae22088f37b98c056a441c2
GitOrigin-RevId: 18c0d3fe740a37381f7f1eddee8f2224f679fd61
2022-10-06 18:47:28 +00:00
Adam Jesionowski
20f1d1aa9d Merge "Enable WMMU."
GitOrigin-RevId: 634f6371e1b965d782534705c0c975abcdf94510
2022-10-06 18:47:20 +00:00
Sam Leffler
b8dfe92451 DebugConsole: clippy findings
Change-Id: I8e93e5441e5762171b4e32baa253ceba6d96855b
GitOrigin-RevId: 90106f4f236c27f88a59ea6286612bb6db378cfc
2022-10-06 18:47:07 +00:00
Sam Leffler
c4563fabfb TimerService: clippy findings
Change-Id: I024582343a38760d4c83b9b78c783ea170dff1b4
GitOrigin-RevId: 24315ccd139f19ced79aaf6703530f6e56437c3c
2022-10-06 18:46:50 +00:00
Sam Leffler
588fb66af6 StorageManager: clippy findings
Change-Id: If4b16efb9c333f82631f9b1a13be3890d1560e39
GitOrigin-RevId: c4eba8d744f0cf29e0cac6ce697e49ee3e29a577
2022-10-06 18:46:39 +00:00
Sam Leffler
558a199151 SecurityCoordinator: clippy findings
Change-Id: Ie5bf4e61cc86f2bdb40077280c9e332858642a56
GitOrigin-RevId: 8e58df9034fe0a6c21b0e78b0f500361d59c10fb
2022-10-06 18:46:30 +00:00
Sam Leffler
17b9878ecc MlCoordinator: clippy findings
Change-Id: I1d7f8f0d3de71cafb3712e755f3fff4ef03cbc4f
GitOrigin-RevId: b8108ae5232d3455be36668a8e5d09bb0dfec809
2022-10-06 18:46:22 +00:00
Sam Leffler
34b8067a2d ProcessManager:: clippy findings
Change-Id: I9cc9044399cc8c74803484100743f156cfacf4d3
GitOrigin-RevId: e4a95dde642e5ea2660d2eb8f1a6fd8a18bcc443
2022-10-06 18:46:15 +00:00
Sam Leffler
e2ec09e001 MemoryManager: clippy findings
Change-Id: I9a82a9cd7628c7a770752baccf382a7c4e7b625c
GitOrigin-RevId: 7cf81bf93076305d733ea658fae08e58c3e6f7f1
2022-10-06 18:46:07 +00:00
Sam Leffler
06d636f27f kata-os-common: move CSpaceSlot into it's own crate
Having CSpaceSlot be a submodule of kata-slot-allocator caused an sel-4sys
dependency that broke unit tests. Split it out to it's own crate.

Change-Id: Iea531e36284b58e932eb0cbd84f90abc81823fe3
GitOrigin-RevId: 39abb4510f66cfe026b12fcacf78b429ddd8f0b5
2022-10-06 18:46:00 +00:00
Sam Leffler
ea5b34e20b MemoryManager: workaround release build problem
Running test_obj_alloc and similar (e.g. install+start+stop+uninstall)
on a  release build yields kernel complaints about using a null
capability. Traced this down to delete_caps for ObjDesc's with count >
1. Checking the result from the syscall resolves things. Seems like an
optimizer bug.

Change-Id: Ib09095ac4255261b1ef67fec68ef3267d6be4883
GitOrigin-RevId: 7149d33b88d2b383d4ab65903c62c478e1659d1d
2022-10-06 18:45:52 +00:00
Sam Leffler
0286d516ce Regenerate C interface bindings.
Change-Id: I298dd002508da5c94e81c64634ae6d97194d8cd5
GitOrigin-RevId: ff1cc5fa27f6e194f5244d6e49df800ac64fecc7
2022-10-06 18:45:44 +00:00
Sam Leffler
746616b6d6 DebugConsole: add cpio archive of builtin bundle objects
- replace the memory-mapped elf file by a cpio archive of bundle
  objects (BundleImages until we fill in what a bundle is)
- add a new "builtins" command to list the contents of the cpio
  archive (similar to cpio -t)
- extend the "install" command to load from the builtins archive
- switch the connection to ProcessManager to support the larger
  ObjDescBundle's coming from the cpio archive

Change-Id: I5d7c195b58937df3921f925de3637f325f53fa2f
GitOrigin-RevId: 410813e62ae8f38685a1b32deb2e80de538085a4
2022-10-06 18:45:35 +00:00
Sam Leffler
6b1fff796b DebugConsole: add kata_object_alloc_in_cnode test to test_obj_alloc
Change-Id: Iaf53ab57720c65f7545211fecab43211bf7513bf
GitOrigin-RevId: 63114c23e82cdab2a2deddb55b00441ed3de33db
2022-10-06 18:45:27 +00:00
Sam Leffler
876c7148e7 DebugConsole: update test_mlexecute for kata-ml-coordinator changes
Change-Id: I02dbbe01b623d39b5e49bee15e620efebfea5fe1
GitOrigin-RevId: df14aecfcde1e0ed0fda7a615e670f8777873c5e
2022-10-06 18:45:18 +00:00
Sam Leffler
6729689f1b DebugConsole: update scecho for kata-security-interface changes
Change-Id: I3fa7ef4b8ea8eaeafa832308f50ac28670de4672
GitOrigin-RevId: 6cb70aa9abab17ddba4852fe7cfd60d4f68a4eff
2022-10-06 18:45:11 +00:00
Sam Leffler
0a51bd8b59 DebugConsole: hookup zmodem to MemoryManager
- change zmodem uploads to get memory from the MemoryManager
- add a "-z" option to the "install" command to start a zmodem upload
  to generate the package contents to send to ProcessManager
- increase CNode headroom for loading package contents

Change-Id: I5f329cdd044368e5568ad891245d67a4a13f8468
GitOrigin-RevId: 2853cde48cb8232f3ba75fe7e8efdbd3032bcb66
2022-10-06 18:44:59 +00:00
Sam Leffler
09ed791c1e MlCoordinator: get models in BundleImage format from SecurityCoordinator
- remove vestiges of mapped ELF file; models now come from
  SecurityCoordinator using a LoadModel request in the form of a BundleImage
- change execute api to take a bundle_id & model_id
- track loded bundle_id & model_id to handle switching between models
- load_elf -> load_image (which loads a BundleImage)
- add a client-side wrapper to hide marshalling details
- add a copyregion (VSpace hole) for processing BundleImages
- integrate with slot allocator
- setup the heap (needed for various things)

Change-Id: I50f3526bddefcdb67b742d42ca396bfefc10801f
GitOrigin-RevId: 80aa0da34b057b334b7d76932c7ad25146364569
2022-10-06 18:44:52 +00:00
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