Commit Graph

272 Commits

Author SHA1 Message Date
Sam Leffler
3d0a31f7b4 MailboxDriver: fix debug build breakage
Need to disable camkes support in kata-os-common to avoid dragging in refs
to SELF_CNODE_* symbols.

Change-Id: I58fc07e79a7cf438342433ef8a8f99a49561392b
GitOrigin-RevId: 6bc8bdd0332197c5191617c7c67d4a425d4a9844
2022-10-06 19:00:43 +00:00
Sam Leffler
186ad6adc3 MailboxDriver: use consistent build options
Change-Id: I64d553bcb4e2669e7ded9e459faf1fbdee7d9881
GitOrigin-RevId: cc890aeadcd8f236e431c53ea8ab4e9d5686784e
2022-10-06 19:00:36 +00:00
Sam Leffler
601e7f5c78 kata: compile-out debug & trace log calls in release builds
Change-Id: Ibde5a49141daa67c57e24340b73b436d08e68e7a
GitOrigin-RevId: 4a77833a6cd3e16850d2e4d90b7e7ed916770b50
2022-10-06 19:00:28 +00:00
Sam Leffler
b099005951 kata-os-logger: support no logging interface connection out of a component
When a CAmkES component lacks an outbound connection to send log msgs
there will be no logger_log symbol. Use a weak ref here to handle that
without resorting to a feature or similar.

Mark logger connections as "maybe" so they are optional.

Change-Id: I6ecd939014d26a612d115741fd2ac673afa40857
GitOrigin-RevId: 0b1bf2611cbb628500cae37889c6547a996d50e9
2022-10-06 19:00:19 +00:00
Sam Leffler
326ec0d6c9 MemoryManager: sort untyped slabs by available space
Change-Id: I3ee5a717c506f8a969dd7e3465ad612863835b7a
GitOrigin-RevId: 4f75f4a24d6a4a72dd4fcf3879bae342eee0ce7d
2022-10-06 19:00:10 +00:00
Sam Leffler
daa3bb819c kata-security-coordinator::fakeimpl: eliminate deep_copy panics
Bug: 243575548

Change-Id: Ie48e8bb4bfcf2fd2284c5822b12b3ace75018a62
GitOrigin-RevId: 92fa86dc4f528c4046dcf2bb635bf7ad0a50551c
2022-10-06 19:00:02 +00:00
Sam Leffler
9dc07abe53 Merge "kata-shell: remove test_bootinfo"
GitOrigin-RevId: ac301ac9646027657db4bdcd43080c8de171c102
2022-10-06 18:59:54 +00:00
Sam Leffler
fe24490359 kata: add a hello test application wrtten in Rust
This hello app uses the logger crate plumbed to the console. Way
bigger than the C version.

Change-Id: I7bf7e8b559fea8e045123d057412493bf7b71a24
GitOrigin-RevId: 97e12e93cc9ebfb4be021cff506417d7434b27f5
2022-10-06 18:59:46 +00:00
Sam Leffler
e95c0bebeb Merge "hello: use ProcessManager-supplied value to setup __sel4_ipc_buffer"
GitOrigin-RevId: cc80eb54acc4305aa54ce884f25b8577fdae2642
2022-10-06 18:59:38 +00:00
Sam Leffler
831a698120 Merge "sel4bundle: pass ipc buffer address"
GitOrigin-RevId: 8d2799961ded3be2393529253ba5d0b5dfafecfb
2022-10-06 18:59:31 +00:00
Sam Leffler
159d64e4ed README.md: fixups
Change-Id: I9dc18155328360922919224455f83c5762789c6c
GitOrigin-RevId: 3fc7b8106de1eaac2601b1f9903951017dcfd01b
2022-10-06 18:59:23 +00:00
June Tate-Gans
1a068b0143 kata: Prepend the Google copyright and Apache 2.0 license
This includes adding it to TOML files and CAmkES assembly files.

Change-Id: I263e7a566df91fccc04f9b2186edab13331290c5
GitOrigin-RevId: 48a35b06ca868a0a4d379f881068cc4dad491669
2022-10-06 18:59:16 +00:00
June Tate-Gans
c0c03fe731 Merge "SDKRuntime: Introduce skeleton implementation"
GitOrigin-RevId: 4c147d204f782881662e3d30b36f848906ae51d3
2022-10-06 18:59:07 +00:00
June Tate-Gans
02e6caec95 suicide: Introduce the fault handler test app
Change-Id: I3dc62dd7131d8f77ff81b44cbe06c675c8e52f04
GitOrigin-RevId: d9313e605ba3d1a9462117980ae14f408398437f
2022-10-06 18:59:00 +00:00
Sam Leffler
ca6153b68c kata: move test apps into a C hierarchy in prep for adding Rust apps
Note this requires companion changes to the build glue.

Change-Id: I5876d3c8b50f373d21d42cf30dbb7031654fb709
GitOrigin-RevId: 963f05fb3c018ad2d509ef68ef37bf83d924337e
2022-10-06 18:58:52 +00:00
June Tate-Gans
f75b87d6b4 Merge "docs: Add in an overview of component construction."
GitOrigin-RevId: a44fb57b60906de7d2549082e2de980f83fd85bb
2022-10-06 18:58:43 +00:00
Sam Leffler
0b528c2a59 Merge "kata: clang-format C test apps"
GitOrigin-RevId: 88ffd6d1d37febf95c606cf51804069ac5efeb50
2022-10-06 18:58:36 +00:00
June Tate-Gans
a5ca02b0e7 cbindgen: Dynamically generate header files during toplevel build
Change-Id: I9e62df409506f9e9e79c984f966b34cf09c1b95f
GitOrigin-RevId: 319803d00536e972f6aa65eacb5c471db97be9af
2022-10-06 18:58:29 +00:00
Sam Leffler
d890571c5e README.md: fix url
Change-Id: Ic3fb2a4c01007d846d7dae7cb06097cfc4138641
GitOrigin-RevId: 5261616892d6772f27a98d0e745393323e12a973
2022-10-06 18:58:22 +00:00
Sam Leffler
a2d5e3f37b kata: add oss materials
- copyrights in code
- more README (mostly copied from manifest/README)

Change-Id: If7c4293bbd52102a9e8039176be4460206aea12f
GitOrigin-RevId: 5d9c70fa5c357c38ae5f1ef601eb06a8039f6974
2022-10-06 18:58:02 +00:00
Sam Leffler
f61d20ef11 Merge "processmanager: add/tweak OSS materials"
GitOrigin-RevId: 89dcfbb2a0c3d2b69a6c15d88ed51ffa21597bf6
2022-10-06 18:57:54 +00:00
Adam Jesionowski
492a4e725d MlCoordinator: Use return information at model_output
Previously we put the return code and fault PC (if any) at the very end
of the TCM. This was always intended to be temporary. The return
information has instead been placed at the beginning of the model_output
section.

Minor changes:
* Running_model tracks the image_id instead of an index.
* Re-ordered ImageSizes members to match layout in memory.
* Rename unpacked_size to in_memory_size to match rest of MlCoordinator
* Fix fake-vec-core to match kata-vec-core

Change-Id: I33ceb59cb36312b60992a6ada49605ffa3b2fa78
GitOrigin-RevId: 5cf399e2c609e0b4ca83101714881b02eb09b94e
2022-10-06 18:57:47 +00:00
Adam Jesionowski
fd7f31bcb2 kata: Integrate Image Manager and WMMU changes
This CL handles the integration of the Image Manager, which comes
concurrent with the necessary WMMU changes needed by the Image Manager.

The ML Coordinator now calls into Image Manager to make space, commit
images, and set the WMMU.

The MlCoordinator now first verifies that an image is valid by first making a pass through the section headers. It stores the two sizes that we're interested in per image: how big it is packed on flash, and how big it is unpacked in memory.

Known issues:
b/241799340: Refactor BundleImage to support unit testing
The writes to DMEM via the kata-vec-core crate was meant to be in image_manager.rs, but this interfered with the ability to run unit tests. We can refactor BundleImage to make this work.

b/241799866: Improve heap management
Right now I clear all of the "temporary data section" (bss, stack,
heap), but I suspect only the heap needs to be cleared. This needs more effort to check that that's correct, and track those locations.

Minor changes:
ImageId is used instead of (String, String) in the component.

Change-Id: I1505c6474fc60205323ce3bb13610fdac3702b89
GitOrigin-RevId: 5df9938a6cbd7ca5510ce8fcb500ce471f42b2cb
2022-10-06 18:57:39 +00:00
Cindy Liu
50cd809320 Merge changes If949288d,I9849065a,I121edee2
* changes:
  kata: LSC: rustfmt with global rustfmt.toml
  kata: update global rustfmt flags
  kata: Promote rustfmt.toml to all kata crates

GitOrigin-RevId: 452e66fa7231f39cff81dc2fbe37ad1a1fc62fb9
2022-10-06 18:57:32 +00:00
Sam Leffler
f33b5b4a9e rust.cmake: add comment pointing to CAmkES setting of --tls-model
Change-Id: I5b2674ef86b9a5c35f441666a9d3ec55cd591f7e
GitOrigin-RevId: 32312f93e053ea0579cb6d98e9fc991ba325ddb2
2022-10-06 18:57:25 +00:00
June Tate-Gans
c8e27dab0a domains: Remove TPA sandbox domain for now
At the moment, the scheduler is wasting 50% of its time in an idle thread for
the application sandbox domain. Until we can figure out how to use these domains
more effectively, we'll reduce to a single domain.

Bug: 238811077
Change-Id: If40d01d5c94e31cc8d522dd5f906f857e363cc42
GitOrigin-RevId: 911f6fe046c61b8ce7e9ba00f8de0ec872997ec3
2022-10-06 18:57:17 +00:00
Sam Leffler
1b0f694aaf Merge "capdl: add CDL_ObjID_Invalid"
GitOrigin-RevId: 57f22db2fddaa9c3d8fd8024cf3ea6411b81daef
2022-10-06 18:57:08 +00:00
Sam Leffler
846993767c Merge "kata-os-model: reclaim rootserver resources"
GitOrigin-RevId: d4cefc38720351494ff4c96848112c11ce36c2a6
2022-10-06 18:57:00 +00:00
Sam Leffler
0fdb94a938 Merge changes from topic "kata-os-bootinfo"
* changes:
  MemoryManager: add kernel reserved memory to startup logging
  sel4-sys: add kernel reserved memory size to BootInfo

GitOrigin-RevId: f5a2227c1b4c919db4658e361c8c0479c67f313d
2022-10-06 18:56:53 +00:00
Sam Leffler
b9b0120953 kata-os-model: portability fix
Change-Id: Ib89769b0471480cec6acf9e181076860fc875d8c
GitOrigin-RevId: 8fcffbe853b6d615fb9593a0d9163da25d8b07ce
2022-10-06 18:56:45 +00:00
Sam Leffler
9e5f1dd2ad kata-os-model: additional rustfmt (missed --all the first time)
Change-Id: Ie11db517980aec543e6ee1b7704d26b4474d9292
GitOrigin-RevId: 4ee016d85e949ddeec6a4016cd6a788e2ef9defb
2022-10-06 18:56:37 +00:00
Sam Leffler
13c433c647 Merge "MemoryManager: log system-wide memory stats at boot"
GitOrigin-RevId: f62d293c8b6ac0f11a8ee163b4bbb8b19b7030fc
2022-10-06 18:56:30 +00:00
June Tate-Gans
be8c32c874 scheduling: Create a secondary sandbox scheduling domain
This updates the kernel configs to setup two domains instead of one,
and also defines a bare-bones domain scheduler that simply round-
robins through the domains.

Bug: 238811077
Change-Id: Ibb49f10265c38dc26235fc246f6147b306055bcb
GitOrigin-RevId: 6b17211d8866bec9207f78dc61c4840c6da9537d
2022-10-06 18:56:23 +00:00
Sam Leffler
ce1543c466 kata: rustfmt
Change-Id: I1edc1d0aa241983fb9336d9bd7e42f2dfa362a15
GitOrigin-RevId: 1a10df3451ce2dfb7d54c6553cfa5d237bf96431
2022-10-06 18:56:15 +00:00
Sam Leffler
05233af12c Add capscan suport.
Add support to output the contents of the top-level CNode of a CAmkES
service or KataOS application to the serial console. This is dependent
on kernel support that is enabled with CONFIG_PRINTING. Applications
must be running; otherwise there is no CSpace to dump.

Specific changes:
- add a "capscan" shell command
- add capscan method to each CAmkES interface
- add capscan_bundle method to the ProcessControlInterface
- add Camkes::capscan() to dump the top-level CNode
- add ProcessManager support to dump the CNode for a bundle

TODO: fix syscall wrapper error return

Change-Id: If6ca222decdb4c40a1d3a63e69792eb3feb30f6a
GitOrigin-RevId: 504c0182ccccf287b5d58cd8e33981c11d7539d7
2022-10-06 18:56:08 +00:00
Sam Leffler
c2accc33b0 MemoryManager: correct initial memory use and add mdebug command
- Use seL4_Untyped_Describe to get an accurate view of each
  UntypedMemory slab being managed; this makes mstats reflect
  rootserver allocations.
- Track memory allocated before we run as "overhead" (was meant to
  track fragmentation but was always zero).
- Add an "mdebug" command to describe each managed memory slab;
  this is useful to see whether the kernel's view of memory use is
  consistent with MemoryManager.

Change-Id: I53b2738c430ad3356ecd16a1cad29ca92dc74beb
GitOrigin-RevId: 2ad43f9b7760c722a6590ea049a3814c8dcccba7
2022-10-06 18:56:00 +00:00
Sam Leffler
a28057ea73 kata-os-model: misc fixups
Fallout from rootserver memory reclamation work:
- add CDL_Object::next_free_slot
- add CONFIG_NOISY_UNTYPEDS feature for spammy debug msgs
- add CONFIG_NOISY_CREATE_OBJECT msgs
- assert if bootinfo/untyped_cnode setup is wrong instead of
  logging msgs and then failing later
- bury ugly BIT usage in is_obj_inside_untyped
- revise handoff_cap api for future use in memory reclamation
- remove some unneeded type coercions
- streamline printing seL4_CPath's
- simplify get_object & get_asid

Change-Id: Ib2c3d717dd41b307cb7afd4821dee4b6be173d57
GitOrigin-RevId: 99f4b79e1df257d373accf96190a77a65ba3305f
2022-10-06 18:55:53 +00:00
Marcin Witkowski
0539aae221 sel4-sys: add isTainted member to UntypedDesc
Change-Id: Id69616f01a6f546e1d4db712092497c5a0367596
GitOrigin-RevId: 11c131a1af0fe1d8b4831a91a3ff5adc757461a1
2022-10-06 18:55:46 +00:00
Sam Leffler
772bd6040a kata-os-model: stop dup'ing TCB's and CNode's
capdl-loader-app duplicated the TCB & CNode caps.  The only possible
reason to do this is if a cap is Move'd (e.g. when constructing the
CSpace for each component) and then later referenced.  But this does
not appear to happen so remove in prep for memory reclamation changes.

Change-Id: I8c9bd1f4f2fa1535da330f782ba978b460b0cf00
GitOrigin-RevId: 7d950dee814705b13b95831b39b7626d4210599b
2022-10-06 18:55:39 +00:00
Sam Leffler
70b4072428 kata-memory-manager: add CONFIG_NOISY_UNTYPEDS feature
Enabling CONFIG_NOISY_UNTYPEDS causes the UntypedMemory slabs received
at boot to be logged to the console.

Change-Id: Ieceedbe17b09c4bb72a2e40e44daa041990019af
GitOrigin-RevId: b5f598cac4302e24b501a8df0c6e0c194b27b991
2022-10-06 18:55:32 +00:00
Sam Leffler
bb7e82468f Merge "Fix CONFIG_PRINTING handling by test applications."
GitOrigin-RevId: 1ea1b3b4e0c7a4d1d817ac1e2ef3939d2b2200b3
2022-10-06 18:55:24 +00:00
Adam Jesionowski
92dc1019be Complete image_manager.
The ML Coordinator will validate the cpio model and collect the fsize
and msizes for each section. It will then pass that information along
with a Boxed version of the bundle_image, which implements the
kata_io::Read trait.

This CL adds the lower level (vec-core) function that writes to the TCM and
calls these functions from the image_manager.

Complete integration of the image_manager is pending splitting the ELF
image into all 6 sections.

Change-Id: I7a5706c588867b4aee04109e2a9edeca071d2ca8
GitOrigin-RevId: 89df1c81bade3ec4508f643a8ba83cae6a3e1f60
2022-10-06 18:55:17 +00:00
Adam Jesionowski
cbe333e2e3 kata/processmanager: Merge ITCM and DTCM into TCM.
For now we treat the image as one big block. A follow up CL will break
it into individual sections like text, model_output, etc.

Change-Id: I86006fc18c940f04f4d15ec032f9196c01255170
GitOrigin-RevId: 7f36043202bca8994f62ced3338b4ba4b1ef922a
2022-10-06 18:55:10 +00:00
Adam Jesionowski
d90b2c173e Partial implementation of Image Manager.
kata-os-common prevents unit testing, so we need to split up
functionality so that other logic can be unit tested. To this end this
CL adds:
kata-ml-shared: structs used in other crates that don't require
kata-os-common
kata-ml-support: logic like image manager that is unit testable

Image Manager is responsible for managing the images loaded onto the
VC's TCM. It tracks pointers into the TCM, which image is loaded where,
and unloads images when space needs to be made.

Change-Id: Icdda9a284b4de7448e8661bb8647e9e6d39e652e
GitOrigin-RevId: cfb65a1dd29d1279aa8ab6c9bf41d5f20206ef68
2022-10-06 18:55:03 +00:00
Sam Leffler
0d82a88f84 MailboxDriver: clippy findings
Change-Id: I116cce53a531915916d0a3509f3324e9694b1293
GitOrigin-RevId: a816c6ea0d3ca42cfc75d5b88cf7795fb99b63f6
2022-10-06 18:54:55 +00:00
Sam Leffler
c70ed4f3e3 MailboxDriver: purge unused stuff
Looks like stuff from when the mailbox test code was in the driver got
left behind; remove it.

Change-Id: I379a58e1fd46895436ed49f780e643efbed81aea
GitOrigin-RevId: 1783642a34ed4f23e7d6703e5e6d041785c1ee4a
2022-10-06 18:54:48 +00:00
Sam Leffler
7bef3289dd Reduce CAmkES per-component heap allocation.
Set the per-component static heap size to 8KB. The heap is only used by
CAmkES RPC for marhsaling dynamic array & string parameters. We mostly
use the former and no more than 4KB at a time so 8KB should be fine until
we can redirect C use to the Rust heap allocator (or replace the C code).

BUG=224069025

Change-Id: I600854c5cb41ed268087f4b2294b70c3384973c2
GitOrigin-RevId: 177a353e6873f2c048cf4b446114534d9dcffc94
2022-10-06 18:54:41 +00:00
Sam Leffler
c4c0e01765 kata-slot-allocator: update bitvec dep to v1.0
With the newer rustc we can switch to the stable version of bitvec;
this includes some api changes.

Change-Id: I9a7af5c2699f9bdebedc06ee68f5e3b7b71b9d75
GitOrigin-RevId: 44d44f930e8b35830d819949b6203c584fea2be3
2022-10-06 18:54:33 +00:00
Sam Leffler
02e1b40885 OpenTitanUARTDriver: fix missing unlock
Bug: 233102476

Writing >CIRCULAR_BUFFER_CAPACITY bytes to the uart will hang because
of a missing unlock of the tx_mutex.

While here add a shell test command that was used to debug the issue
(but don't enable it by default).

Change-Id: I3e35001a653fe2659fb1534e4100727b69f662a1
GitOrigin-RevId: 550b35c88328dcbd1f87dd8e0209b1faabf7f931
2022-10-06 18:54:26 +00:00
Sam Leffler
4ca13e9088 DebugConsole: add features to set initial logging level
Add features to control the log level used before reaching the shell
prompt (where the "loglevel" command can be used to control log
filtering).  The default log level is Info. LOG_DEBUG forces it to
Debug. LOG_TRACE forces it to Trace (max).

Change-Id: Ic55eaf3cd08fc101c53319b5a45a2c7de6f94a66
GitOrigin-RevId: 5500ac5d65186773d5304a75d03295e09b2e9a63
2022-10-06 18:54:19 +00:00