Commit Graph

62 Commits

Author SHA1 Message Date
Matt Harvey
66c03e7858 Merge "Ports zmodem to no_std and kata_io"
GitOrigin-RevId: 09bc871f7c4fdd64f3b4591a47cf5ba0bffa72c2
2022-10-06 18:12:52 +00:00
Sam Leffler
c0a44de935 Merge "kata-security-coordinator: split impl into fake & sel4"
GitOrigin-RevId: 397cf136e3375588082b8508fd2060116b3101cd
2022-10-06 18:12:44 +00:00
Sam Leffler
0633ce6761 kata-proc-manager: fix unit tests
Change-Id: I7d48e9e31bbc2aae9f899e43bfc3f33331738a42
GitOrigin-RevId: 524e01589e114a541de292e41fa34021e5279703
2022-10-06 18:12:34 +00:00
Sam Leffler
0db63cfb4f Add SecurityCoordinator skeleton.
- add SecurityCoordinator component (needs mailbox support, just
  a fake which should be enabled with a feature flag)
- connect to ProcessManager & MlCoordinator - temproarily connect
  to DebugConsole to enable scecho test command
- expand Bundle to hold application information (may need more elf)
- connect ProcessManager::{install, uninstall} to SecurityCoordinator
  (no application binary yet, needs global page allocator)

Notes:
- SecurityCoordinator depends on camkes for thread synchronization
- private heap is 8KB (and could possible be less; need to tune)
- camkes interface connection uses seL4RPCOverMultiSharedData so ipc
  buffers are 4KB; the request & reply serde buffers are 2KB but could
  be near 4KB since they are used sequentially and the other params
  are a few bytes (but beware of camkes stack allocation)
- the camkes SecurityCoordinator::request rpc is defined so that the
  request param has reasonable handling but the reply param requires
  a full copy (even if only partly used); haven't found a way to
  express the desired handling

Change-Id: I686dc2d501e39bc8c27fe22db40657165a55b472
GitOrigin-RevId: db1536c241e28ddda1dc8f8da341b8c667ed6646
2022-10-06 18:12:24 +00:00
Matt Harvey
4904a61ca0 Merge "Implements some std::io functions in kata_io"
GitOrigin-RevId: b5b1afb7b0528acd100fd35a84a48b984f1b02c1
2022-10-06 18:12:12 +00:00
Cindy Liu
6b25d6fea0 Merge "kata:VectorCoreDriver: Use HW register header."
GitOrigin-RevId: 7b10748eb801311b291aeba25cc0535f4e0b09d4
2022-10-06 18:11:56 +00:00
Matt Harvey
6d41c07085 cargo fmt zmodem
This change does no more than run "cargo fmt" on the sources in the
zmodem directory so that the porting change can be based on formatted
files.

Change-Id: I72789f57bf4d195bdcbd24d04cc08e5d801b6b05
GitOrigin-RevId: 8a27fb27e976c82c10030b6afecfa0fb1980630b
2022-10-06 18:11:46 +00:00
Matt Harvey
6e9addf6bf Forks lexxvir/zmodem
This is commit acdc761522679de2c52e0a7fa2640d48f7bd0ab5 on GitHub.

The project is not actively maintained and requires substantial change
to port to no_std and kata_io traits, making copying more appealing than
tracking upstream.

This change adds the unmodified files as a local diffbase.

Change-Id: I8846f4842d75d01f07b2857998819115a9c449ba
GitOrigin-RevId: 5cb637810ddfa5a35d73d680c16c36855f1b70ef
2022-10-06 18:11:36 +00:00
Matt Harvey
c0df9a3b95 kata-io alias analogous to io::Result
Sometimes it is useful for kata-io to be API-compatible with std::io
(e.g. porting a ZMODEM library). std::io has a similarly defined alias
where E is its own error type.

Change-Id: Idaf88fb1d41bcb984608d82a0ea222290c78f5c4
GitOrigin-RevId: 5738e6ac705b6fe3b48dd64891808cf50b75afb7
2022-10-06 18:11:24 +00:00
Sam Leffler
d4a369a6c3 ProcessManager: switch to serde + postcard
Replace the hand-rolled code to marshal/unmarshal bundle_id's with serde
and postcard. Postcard was selectecd because it works with no_std and has
api's that do not require copying.

Change-Id: I5bec725e42e5f94b4a486669f86e4aeb1322de6c
GitOrigin-RevId: b56e1d39faae0f8705c5d11a62d33db540f2d35c
2022-10-06 18:11:14 +00:00
Sam Leffler
3d2a560986 ProcessManager: correct install api and add cleanups
[NB: this is a step toward adding StorageManager]

- add app_id to Bundle to enable expanding the skeleton framework (for
  now this is filled in with the address of the pkg_buffer arg)
- change install api to follow design doc (bundle id comes from manifest)
- mark start & stop api's as needing a mutable self - hide Bundle
  internals (more): do not export representation, we will use serde to
  pass it through camkes
- remove assumption hashmap of bundles corresponds to StorageManager
  contents - use String instead of BundleId and Vec<String> instead
  of BundleIdArray in public api's (SmallVec & SmallString are impl
  artifacts now pushed down to ProcManager)
- adjust unit tests (ditch kata-proc-manager::tests as it adds nothing)

Change-Id: If3d77b031f43c0c867266dbfa66fa31e4ab67033
GitOrigin-RevId: bbadf0b0b09e7978613d57a816363079642e2a45
2022-10-06 18:04:15 +00:00
Matt Harvey
b0e442a623 LogFibonacci component
This CAmkES component demonstrates concurrent control threads when one
of them never calls seL4_Yield (preemption by timer interrupts). It can
be removed when we are sure this is working well. Until then, the log
messages will be visible after issuing "loglevel trace" at the prompt.

Change-Id: Ice1a3ac2e11dc50f5d9d5f790e2de80b58fe269e
GitOrigin-RevId: d20266a6add4f3d4d673a492a3b0ab70663e0308
2022-10-06 18:04:07 +00:00
Sam Leffler
d97a78316e Misc cleanups.
- change early logging (pre kata-shell prompt) to trace level so by
  default nothing shows up unless kata-debug-console::pre_init sets
  log::set_max_level to Trace (default is Debug)
- log allocator init's in caller so log msgs identify per-component heap
  setups (all the same for now but at some point may diverge)
- shorten kata-shell prompt to "KATA> " - remove unused camkes control's
  and consolidate other early work in pre_init and <component>__init hooks
- cargo fmt components

Change-Id: I010eb5cc5af2e379691cb2e62d82dbab32a06bc3
GitOrigin-RevId: badddf46f5ba50fa60e9cbead9f6d99d5ff3808b
2022-10-06 18:03:53 +00:00
Sam Leffler
a3bd1a6026 Merge "kata-logger: use a larger ipc buffer"
GitOrigin-RevId: 2801cc0bbdf62bd9e468e0e14d04f8bf740e72ee
2022-10-06 18:03:17 +00:00
Matt Harvey
3b609285ad OpenTitanUARTDriver eager TX
With the LogFibonacci component, it became apparent that having
fill_tx_fifo only fill the TX FIFO once would cause only 32 bytes (the
size of the TX FIFO) to be sent out at a time. This was because the
Renode UART is so fast that tx_empty was becoming true again even before
it was cleared from INTR_STATE.

Not clearing INTR_STATE unless rx_buf is empty is enough to fix this by
itself, but to avoid lots of interrupts, we also have fill_tx_fifo loop
until the FIFO is really full.

Change-Id: I4bf2f05770e1a1447b5d79930a446667a268e5dd
GitOrigin-RevId: c61eecb16f6d28c8d9b71605199a62ae01919a41
2022-10-06 18:03:06 +00:00
Matt Harvey
cb57b7bf00 Changes UART base address to 0x40010000
sparrow_all.repl says this address is for "UART1 for SMC Core," but until
this change we have been using "UART3 (Reserved)."

Change-Id: I149b592f6df484e7bdac4d1bd2a3fc0ab3f813ba
GitOrigin-RevId: 40913f9e26724b6841f4380aa28de1806dcf28e5
2022-10-06 18:02:58 +00:00
Cindy Liu
b926995dbd apps:system:rust: Pin the rust toolchain to a specific release
Change-Id: I14c4ccd44dde92b7d2fce2e5b3779e106b761788
GitOrigin-RevId: 3013c9fc96d26d8f0d8e2c13b57f53d08ac03e98
2022-10-06 18:02:50 +00:00
Matt Harvey
3fe3225b1f Revert "Revert "Enables UART tx_watermark interrupts""
This reverts commit 342e260470ba0c194c7f7a0d1006b2f3a2432236.

Reason for revert: adding to same topic as a sim.mk change that runs the same Renode.exe built by "m renode"

Change-Id: I4ad8715e09ec3c0bf56939706a19db9085f806bb
GitOrigin-RevId: 31b22501c04e525394bc43406affb1c4d4829c1f
2022-10-06 18:02:43 +00:00
Henry Herman
cbfec8e9b7 Revert "Enables UART tx_watermark interrupts"
This reverts commit 010f0d7045d40ea6b0900fc74d79fe92df0fae69.

Reason for revert: kata console fails to come up.

Change-Id: Icab24e9043f967ea76907ce938eef72b2fbf47ac
GitOrigin-RevId: 342e260470ba0c194c7f7a0d1006b2f3a2432236
2022-10-06 18:02:35 +00:00
Matt Harvey
b35f77a2fe Enables UART tx_watermark interrupts
With Renode at HEAD, this causes an infinite loop. It seems like the
Renode OpenTitan UART does not have "edge triggered" behavior.

Change-Id: Ic553ce34cabaf8287c7969904d6336d1acf339a0
GitOrigin-RevId: 010f0d7045d40ea6b0900fc74d79fe92df0fae69
2022-10-06 18:02:28 +00:00
Matt Harvey
b7727a0823 Merge "Makes UART transmit interrupt-driven"
GitOrigin-RevId: 12484d6028b4885eb42e3074c75114454135e270
2022-10-06 18:02:17 +00:00
Matt Harvey
0a506b7c7f Merge "UartDriver receive interrupts, round 2"
GitOrigin-RevId: 26f67f1f11efd4aa664c68f9c638f3fa388b2f81
2022-10-06 18:02:08 +00:00
Matt Harvey
d651e73767 Merge "Makes UART receives interrupt-driven"
GitOrigin-RevId: d8fd1cba1db7257f44e971af457a0fa59b2373ce
2022-10-06 18:01:59 +00:00
Matt Harvey
fe696fc314 Merge "Ports machine_uart to OpenTitan"
GitOrigin-RevId: 5e1d8900f2e7a4ac55804a97767f34ddaff04170
2022-10-06 18:01:50 +00:00
Sam Leffler
69eefbd5c9 Change ProcessManager interfaces to return ProcessManagerError.
Propagate the ProcessManagerError enum through the
PackageManagementInterface and ProcessControlInterface so the client
has more information about why a request failed.

Change-Id: Ic2d8fcf1401edd6faff85fe821443f720d0b00c4
GitOrigin-RevId: 91d668fc56a352776803392d89aacc034cee1f1e
2022-10-06 18:01:42 +00:00
Sam Leffler
cb99661cd0 kata-logger: remove <level> from logged message
Now that logger level is passed with the message it can be added on the
server side if desired. For now just remove it entirely so we have more
space for the actual message.

Change-Id: I7b8dbdb0460cf2bf7b009ddc5d9d70a438f9d803
GitOrigin-RevId: 701ca7a5d32f1ad5c5f583db78b6c5e7625857f4
2022-10-06 18:01:33 +00:00
Sam Leffler
8ace3eb6f2 kata-logger: pass level through LoggerInterface and filter in DebugConsole
Components can reduce the number of rpc's if they set_max_level but by
default pass everything and let the DebugConsole decide what is logged.
With this the shell loglevel command now controls logging from all
components.

Change-Id: I72b77bbf02882ffdba0aaf0b9b88126bfd2e62a1
GitOrigin-RevId: d451e72cf67e41d6ee25ea2995098b5009cf8852
2022-10-06 18:01:22 +00:00
Matt Harvey
4043c8b5b7 Mutex guards kata-uart-client read and write
Change-Id: I5757dcf68f64359b743f458f336a813aeb43c069
GitOrigin-RevId: 1c6c85f95c6509cc915df1b82076942cd540c441
2022-10-06 18:01:13 +00:00
Matt Harvey
7c3cc70ab1 Splits UART tx/rx into separate CAmkES procedures
This ends the behavior where log messages would block on the prompt.

This change does not fix the potential race on dataports if
kata-uart-client read or write has multiple concurrent callers. A later
change will protect those using CAmkES mutexes, although the
alternative of having DebugConsole *own* the UART should also be
considered.

Change-Id: I8d5d8336cd58b9f22cca81ae6aca13b4ed57e7e4
GitOrigin-RevId: e781fd8454d22e0f829d788fe602e431551e259a
2022-10-06 18:01:04 +00:00
Sam Leffler
20c83f6777 Merge "kata-proc-common: improve BundleIdArray marshalling"
GitOrigin-RevId: ec8fb48df635c89eb5ea8b71ecb7bdcfdf111236
2022-10-06 18:00:52 +00:00
Adam Jesionowski
0a952a59f4 kata-ml-coordinator: Fix bit bug
pc_start is a full 16 bits, freeze is 1 bit. Mixed up the bit ands. Need
auto-generation :)

Change-Id: Ib4f701b43e131bfcb448c68b06d2518cf80e8098
GitOrigin-RevId: a7c3c64eb15ffce8e76b28b105832a253a6d580b
2022-10-06 18:00:33 +00:00
Adam Jesionowski
b9cc80a929 kata: MLCoordinator and VectorCoreDriver
Add a VectorCoreDriver component that handles setting vector core CSRs.

Rewrite MLCoordinator to conform to other Kata components. The old code
wasn't useful.

Add `test_mlexecute` command for running ML. Add plumbing from shell to
coordinator.

Change-Id: I3d563f1a343361c95d3ad5b78231fbe9df32b851
GitOrigin-RevId: f3c38839f708743de596339d1b8173315283b772
2022-10-06 18:00:17 +00:00
Sam Leffler
b9e209b008 Overhaul ProcessManager support.
- Split support into three levels:
  o kata_proc_manager::process_manager is a single-threaded implementation
    of ProcessManagerInterface and PackageManagerInterface that uses an
    abstract manager interface to carry out low-level work (used mainly
    to inject fakes for unit testing).
  o kata_proc_manager is a thread-safe wrapper around process_manager that
    has the manager interfaces bound to KataOS; this is the level at which
    we integrate with external components.
  o kata_proc_component is the top-level glue code for the ProcessManager
    camkes component; it has a pre_init function to setup rust support
    (logger, allocator, etc), a run function for the component's control
    block, and wrapper functions for the camkes ProcessControl and
    PackageManagement interfaces.
- Add install, uninstall, start, stop, and bundles shell commands for
  exercising ProcessControlInterface & PackageManagementInterface.

Specifics:
- Bundle id's are now treated internally as SmallString's with &str
  used for passing bundle id's through api's. The BundleId type is
  temporarily used for get_running_bundles() to return information (but
  see below about RawBundleIdData).
- ArrayVec's are replaced with a hashbrown::HashMap
- Bundle objects are Box'd instead of holding refs (now that we have an
  allocator); this eliminates lifetime constraints.
- The manager interface is Box'd to eliminate lifetime constraints.
- Purge ProcessManager::empty(), it's infeasible with the hashmap and
  is not needed with kata_proc_manager support for static decls.
- Add RawBundleIdData support for serialize+deserialize of BundleIdArray;
  no more leaking internal data types to client code.
- Remove bounds check on #bundles recorded; set a nominal capacity
  and fallback to dynamic allocation of the hashmap.
- Manually update ProcessManagerBindings.h (using cbindgen).

Change-Id: I08deaecc997ea96cb794808036540bedd58b3fa4
GitOrigin-RevId: 6e0826940b43b1295d39769b57812a9494b5a4cb
2022-10-06 17:59:52 +00:00
Sam Leffler
1595b3ad6c kata-shell: add loglevel command
Syntax: loglevel [off, info, debug, warn, error, trace]

Change-Id: I6b480626783cd4bf069a7741d7f4670e96c967b6
GitOrigin-RevId: 527aefa1f2b00d17f7f703d43923463b660caa7e
2022-10-06 17:59:29 +00:00
Sam Leffler
0e740d7282 kata-allocator: remove unneeded RefCell
Mutex<Heap>::lock() gives inner mutability so ditch the RefCell that came
from the original Cortex-M code.

Change-Id: Ib0a29069fd63fd87bd94d68439bfeb433c26db8b
GitOrigin-RevId: bbb505f98c8f1614a81090f58f9445a956697690
2022-10-06 17:59:18 +00:00
Sam Leffler
64da97a4a6 Merge "Add kata-panic support."
GitOrigin-RevId: 86b4cf1b25c2796fff0b2f90da6ef76d773c80a9
2022-10-06 17:59:05 +00:00
Sam Leffler
c5e8722a24 Merge "Add LoggerInterface for logging msgs on the console."
GitOrigin-RevId: 256da9ba28b31f1ac3a87cce0098a52ac918de13
2022-10-06 17:58:54 +00:00
Matt Harvey
3afdc04219 Changes UartDriver implementation to use OpenTitan
The preboot code still sends kernel logging to the 16550. A later change
will also port this to OpenTitan or find another alternative.

Change-Id: Ifbf296e2ba9c6b354dd94d4a0640a2105e177fc9
GitOrigin-RevId: 4226974521b31f8ff8cfa21d8d1fcb19290c8265
2022-10-06 17:58:40 +00:00
Sam Leffler
5cea7522fd Fixup kata RELEASE build handling.
- the RELEASE setting is a boolean, correct cmake check
- explicitly force log-level=0 & debug=true in cargo profile.dev entries

NB: to switch between RELEASE + non-RELEASE builds do "m clean",
  change easy-settings.cmake, then "m kata"
Change-Id: If56cd855a9f30313e264a808c0c12df0532194a0
GitOrigin-RevId: b15be5feba41a19a71ff86f00fee0b7bd0942049
2022-10-06 17:58:31 +00:00
Sam Leffler
3d7923e0a3 UartDriver: yield during tx/rx polling
Sprinkle seL4_Yield's in the tx/rx polling loops so other work in the
DebugConsole component happens. This is a band-aid for the driver not
using interrupts.

Change-Id: I600fdc2b01d60b18bb70e80adbfde9b1c348a194
GitOrigin-RevId: f2e90519f53b78a3ee2b42ca4613b1ea34cd4133
2022-10-06 17:58:20 +00:00
Sam Leffler
94358ffec7 Switch to purpose-built global allocator.
Replace LockedHeap with a purpose-built equivalent. This works around
issues where rust_oom was undefined for certain build configs and
facilitates future sel4 integration (e.g. to use dynamically allocated
memory instead of bss).

Change-Id: I54f779ef794104ad1ae95590812d1cd49b4a3734
GitOrigin-RevId: 83474c02e6b6957946fbca4a9aa090bf3c4dbfdc
2022-10-06 17:58:08 +00:00
Sam Leffler
8d7e4bf44a Add a simple rust global allocator to each component.
- add a linked_list_allocator::LockedHeap instance to each component that
  might want to allocate memory and init the allocator with a fixed-size
  memory block in the component post_init hook
- add an alloc_test shell command that exercises the allocator

This does not dynamically add memory or support sharing memory between
components; this is an intermediate step to simplify bringing in crates
that want to allocate memory (e.g. hashbrown)..

Change-Id: Idaf11fb5d4999218c75bf932133df24de35e3053
GitOrigin-RevId: 7c9b14bf9463239ce030c374b58a140f0835759e
2022-10-06 17:57:56 +00:00
Matt Harvey
e4973577ec Adds kata Makefile step call OpenTitan regtool
To write s3L4 for OpenTitan matcha, we want to depend on generated C
header files for definitions of MMIO sizes, offsets, masks, bit
meanings, etc.

To make these header files available to the seL4 build, this change adds
a make prerequisite for the kata build to run regtool.py with output
going to out/kata/opentitan-gen.

In CAmkES CMake files, the INCLUDE attribute can be used to add to the
include path, and this change also does that for the UartDriver
component. (The implementation will be left for a later change, since an
initial straighforwrd attempt saw writes still going to the 16550.)

Change-Id: If7e7e206ddcf625b8f5a45dc6486693cab7c51e2
GitOrigin-RevId: 018b9ddf9cde2389fb9f39553095d955705cb7a0
2022-10-06 17:57:47 +00:00
June Tate-Gans
a01ee363ea rust: Remove a rogue duplicate rust.cmake file
This only serves to confuse the cmake build tools into using the wrong
definitions, instead of the ones used in apps/system/rust.cmake.

Change-Id: Iaed204a8f8a9ae5fc2233dc4f9147ba6cf6a9a25
GitOrigin-RevId: 290682ee7b8eb7ad00a52f72c0f6e3be08e88673
2022-10-06 17:57:38 +00:00
Austin Appleby
622727086d Disable BBL in easy-settings
Change-Id: I1c2524968246bae00009092a5cedcedd962e66c9
GitOrigin-RevId: d4f6df0a8405a61251a93781d0fc4e67934f8920
2022-10-06 17:57:24 +00:00
Austin Appleby
ff08436a47 Add .gitignore to kata/projects/processmanager
Change-Id: I472245c8dc984f6db18fe24e662fcd08af4cc11d
GitOrigin-RevId: 53774f360e4b450f9544f2561a2047ba64345f01
2022-10-06 17:57:06 +00:00
June Tate-Gans
af63371fd9 Merge "rust-toolchain: Use riscv32imac and better handle build tweaks"
GitOrigin-RevId: 50e4058c935cf522124ce2983d36ca4013ce1940
2022-10-06 17:56:54 +00:00
June Tate-Gans
83d2875eb2 rust: Add in link-time optimization by default
This turns on "fat" LTO for builds even in dev mode so that we can keep our
binaries size down. It's not a total solution, but eliminates the "kitchen sink"
effect that building Rust static libs has, allowing us to keep our dependencies
down a bit.

Change-Id: I5fb071d7cdb7b9964b2af25d8137944593bd065c
GitOrigin-RevId: fe7f105307e042c211be5d031870d6161d71e27c
2022-10-06 17:56:41 +00:00
Sam Leffler
e35c69ae4c Add initial ProcessMaanger interfaces.
- new ProcessManager component (aka kata-process-manager)

NB: interfaces/ProcessManagerBindings.h is manually generated by cbindgen
for the moment; e.g.
  cargo install cbindgen;
  cd components/ProcessManager; cbindgen -c cbindgen.toml \
      -o ../../interfaces/ProcessManagerBindings.h kata-proc-common

Change-Id: I153c6b193c6ba8e376b87a2563dc8543753f0b42
GitOrigin-RevId: 18c354f14cbec6ce01c020136fe9aefd88248ee9
2022-10-06 17:56:26 +00:00
Sam Leffler
c61d7890a7 Add SeL4Debug component to expose sel4 debug syscalls.
- add a SeL4Debug component that wraps seL4DebugPutString and seL4DumpScheduler
  system calls that are marked static inline (so not callable from rust)
- connect seL4Debug to the DebugConsole and add a "ps" command to the shell
  that uses sel4DumpScheduler to print the tcb's on the console; e.g.

KATA_PROMPT> ps
Dumping all tcbs!
Name                                            State           IP                       Prio    Core
--------------------------------------------------------------------------------------
                     sel4debug:sel4debug                running 0x1017e                  254    0
                 sel4debug:fault_handler        blocked on recv 0x1046e                  255    0
                       sel4debug:control        blocked on recv 0x1046e                  254    0
                                drv:uart        blocked on recv 0x11dc4                  254    0
                       drv:fault_handler        blocked on recv 0x105d4                  255    0
                             drv:control        blocked on recv 0x105d4                  254    0
             debug_console:fault_handler        blocked on recv 0x10840                  255    0
                   debug_console:control        blocked on reply        0x12808                  254    0
                             idle_thread                   idle 0                          0    0
                              rootserver               inactive 0x10558                  255    0

Change-Id: I48496ec0002e3307aaeb5c779319d4beb87ae56b
GitOrigin-RevId: 8665f609bdb7efd3b814b4f40abf08c5dd1e863d
2022-10-06 17:56:12 +00:00