Commit Graph

96 Commits

Author SHA1 Message Date
Adam Jesionowski
39f9eac9c3 Unify DTCM and mem sections.
Move getting the return code and fault registers into Rust and out from
the C driver. This means extending the DTCM to cover memory previously
covered by `mem`.

Change-Id: I9d1ad8e9823445ad7dd476ef05f128a29567999b
GitOrigin-RevId: 21bc1ee544d39d6b4a2ff963aaae7c145fdd7fa9
2022-10-06 18:35:08 +00:00
Adam Jesionowski
3185f9f503 Load ELF in MLCoordinator.
Rather than using the Renode ELF loader, this CL moves that capability
into the ML Coordinator. The ELF is memory mapped in eflash instead. We
create MMIO buffers for the MLCoordinator to access. The ELF information
is gathered from the header. The ITCM and DTCM data is copied over to
the vector core.

Next steps are to integrate the load with the execute and to re-map the
return codes and fault registers into Rust code.

Change-Id: I3fc266feb262966318bb451888df146703a03579
GitOrigin-RevId: 8db55b58f86918b8c37d436f1d9f359afdd2a3ea
2022-10-06 18:35:00 +00:00
Julian Mullings-Black
3bda869f20 Remove symlink to seL4 kernel for sel4-sys build
- delete the symlink called "seL4"
- remove the manually specified SEL4_DIR environment variable from
Cargo.toml and move to .cargo/config.toml

bug: 202428321

Change-Id: I4f54b730e627a8445560e0e5e7bc056ab7e19062
GitOrigin-RevId: 17743c7034a37ac2dc0d036f405096213888f584
2022-10-06 18:34:51 +00:00
Cindy Liu
b620ca4c74 Merge "kata:VectorCoreDriver: Read vector core return code and fault register"
GitOrigin-RevId: 105a1d3296ae2e255326a9370428ace309b331f2
2022-10-06 18:34:38 +00:00
Matt Harvey
05becc9125 Loop in UART driver rx_watermark until rx_empty
If rx_buf filled during the handling of an rx_watermark with the FIFO
nonempty, the rx_watermark would be acknowledged, and there would be no
subsequent interrupt to post to the semaphore blocking the next receive.
(Non-rate-limited ZMODEM uploads easily caused this condition.)

This change ensures each handling of an rx_watermark interrupt
completely empties the FIFO. It is likely stopgap until the simulated
UART can provide an rx_timeout interrupt.

Change-Id: If828bac470ee0e667e0e011b11a7a9aee1d47210
GitOrigin-RevId: 7123bcb0fcca9e39c35f4b67088b581cdf2fb50d
2022-10-06 18:34:30 +00:00
Matt Harvey
6f942b860a Merge "Makes UART driver never read FIFO_STATUS.RXLVL"
GitOrigin-RevId: 3ccf8d334a7e73c5647a9733cde9d2cea94c568a
2022-10-06 18:34:20 +00:00
Matt Harvey
61fbe78415 Merge "Removes extra nesting around LOCK blocks"
GitOrigin-RevId: ced5b4310539398d3425b43fe0b66e35ad5d73b2
2022-10-06 18:34:11 +00:00
Matt Harvey
31946b70ed Ignores __pycache__ files
sel4-sys has been producing __pycache__ files in the source tree, as the
Python interpreter normally locates them next to the corresponding
sources.

This change ignores them, following the precedent set for Rust target/
directories.

Change-Id: Iac2e4c14788f13e1844c1241764918628226aedb
GitOrigin-RevId: 4d4a9f95698d4d5d0fd36996cc154300573adfc8
2022-10-06 18:34:04 +00:00
Matt Harvey
46260515d5 Merge "UART driver additional check for rx_empty"
GitOrigin-RevId: a800f10ebaa2759bcab14ca0a8da49350f54a6f9
2022-10-06 18:33:53 +00:00
Matt Harvey
201f5cf609 Merge "Nits from change 11042"
GitOrigin-RevId: d01d882d7b46ef080e509c153e5f690a9bd68a8b
2022-10-06 18:33:39 +00:00
Matt Harvey
97fccf9c95 Forces logging off during ZMODEM uploads
With logging on, the Rust logger trace messages do indeed cause the
sender to abort near the beginning of the upload.

Change-Id: I9ed150db1ad557034d1aefcc99385d771be3edd5
GitOrigin-RevId: 3815d6b21db1dc4978b19fc9b4307007d03e4b12
2022-10-06 18:33:31 +00:00
Matt Harvey
c26d79fff8 Makes ZMODEM crate use BufRead
Using a buffered reader instead of the byte-at-a-time implementation
avoids doing a syscall for each byte.

Change-Id: Ia7bc42e4836593f358ff964962c910f8c94b6f8e
GitOrigin-RevId: e70697d398b07d6de6f03d1d0a4b5204139bc59a
2022-10-06 18:33:20 +00:00
Sam Leffler
a91f8f7916 kata-proc-interface: marshal bundle_id params correctly
Over-optimized the marhaling logic--we Need to convert &str's to CString's
to get the trailing \0 (same lesson learned doing StorageManager).

Change-Id: I97e8d35947dcb32989dc68f11dd422433c00aa02
GitOrigin-RevId: c775bfc3c568ee3dcae32928a422c5178495e77f
2022-10-06 18:33:07 +00:00
Sam Leffler
0e3ca70769 sel4-sys: fix reference to __sel4_ipc_buffer
Change-Id: I6521cfc2693b949ca2f288ac4465bd5032ecaf26
GitOrigin-RevId: bb9bc2359a57d62d75d250861a0c128218c333f5
2022-10-06 18:32:59 +00:00
Sam Leffler
3f4e3fb7f0 Merge changes I3cf10baa,I0062e20b
* changes:
  kata-storage-interface: add back From trait to streamline return processing
  Revert "StorageManager: streamline kata_storage_* routines"

GitOrigin-RevId: 051c4f2b1529e448f70acc4d4e2779f4d9c50e70
2022-10-06 18:32:51 +00:00
Sam Leffler
e23e5907d0 Merge changes Ic0ca4ab4,If1c494aa,I56701b4a,Ia7ff0097,I13812a9f, ...
* changes:
  Replace SeL4Debug with direct syscalls.
  sel4-sys: fix conditional syscall numbering
  sel4-sys: use target_arch &co to select target architecture
  kata-os-common: add sel4-sys support for riscv32
  kata-os-common: cleanup sel4-sys before bringing in local changes
  kata-os-common: pristine import of sel4-sys-0.0.28 (-seL4 submodule)

GitOrigin-RevId: 36ee1d4f9e521b60fdc6b91f2581413b55882fca
2022-10-06 18:32:43 +00:00
Matt Harvey
4faa2e4c82 Implements BufRead in kata_io
Reading one byte at a time in a loop causes excessive syscalls. For
example, ZMODEM needs to do this when finding the end of each frame.
This change copies parts of std::io needed to wrap a Read in a BufReader
so that the read will be done eagerly.

It enables buffered UART reads for the whole DebugConsole at the point
where its single Read object is initialized.

Change-Id: I19935ca02333bc74d9b581d384a1854968ac5329
GitOrigin-RevId: 1aa80e036561a6a18e79dbf28bcab240efe80cd1
2022-10-06 18:32:11 +00:00
Matt Harvey
d70003982c Merge "Aligns UART API with Rust Read and Write"
GitOrigin-RevId: df407ae4bddb75b1bc43c35062947679c2b10c3a
2022-10-06 18:31:59 +00:00
Henry Herman
d6f8c7bced Merge "kata: Update vctop plic assignment"
GitOrigin-RevId: 77d97528f2b1c3ce1c17201ff031169626fe12a6
2022-10-06 18:31:51 +00:00
Cindy Liu
53dc1a2031 kata:MLCoorinator: Retrieve vc_top execution return
Create a new VectorCoreReturnInterface for the connection from the
VectorCoreDriver to MlCoordinator. Retrieve the return code and fault
from the finish IRQ handler back to MlCoordinator. It can be served as
the hook for the continuous run.

Change-Id: I6346cca0bc372e5b3a80d70b333d42ba768e822f
GitOrigin-RevId: bae4ab68418ce7ac9d4ac5ebb86bb6e55993b7cd
2022-10-06 18:31:42 +00:00
Sam Leffler
7310343cf9 StorageManager: streamline kata_storage_* routines
- convert &str's directly to C strings (w/o passing through
  CString::new); this eliminates the need for cstr_core::CString
  but potentially permits strings with embedded \0's
- add a From trait to streamline return handling

Change-Id: Ia854aaa297708e47abf310697954c4c18cafc14e
GitOrigin-RevId: b4fd9f6a67f9e460ed46274e18cf506bade818b4
2022-10-06 18:31:34 +00:00
Sam Leffler
6f1ebaeb44 StorageManager: more rust cleanups
- add From traits for mapping return status
- no more need for StorageError::Success w/ switch to Result's
- narrow unsafe blocks where possible

Change-Id: I92e0666e2651eb3647ac4e351d14bf55bc76bbb0
GitOrigin-RevId: 24416448d1c326632f556e224fcca7ac38397dc6
2022-10-06 18:31:23 +00:00
Sam Leffler
5929f8c932 ProcessManager: cleanup interfaces
- kata-proc-common =>'s kata-proc-interface
- use explicit import's
- add kata_proc_* & kata_pkg_* stub wrappers to hide C calls
- hide RAW_BUNDLE_ID_DATA_SIZE, not needed after stub additions
- add From traits to cleanup return handling
- narrow unsafe blocks

Note: removed some less-useful trace calls to enable ?-op usage

Change-Id: Iefe704654f5d286648c94c13a88573baaa434ecb
GitOrigin-RevId: 1639da7ea59653c1d1d22a9c1dab9c05aaf409df
2022-10-06 18:31:11 +00:00
Cindy Liu
cd45ee8c01 Add VectorCoreDriver interrupt handlers
Bug: 199798457
Change-Id: I2899022b9d6d57304d70c50b08e08d225d10c511
GitOrigin-RevId: 22a051696dac158c43df42ccd6a436e314f25f70
2022-10-06 18:30:24 +00:00
Cindy Liu
47efe82e87 Merge "kata:VectorCoreDriver: Fix CSR_OFFSET"
GitOrigin-RevId: b41ddd5227c8413f5c02d7ffd91d9c0d9f0ee08e
2022-10-06 18:29:56 +00:00
Matt Harvey
fc7b9bc232 ZMODEM: sz argument readability rename
Change-Id: I7e49ed8a98f9002177f33d29904fcfe132117401
GitOrigin-RevId: d82cf104363686ba60796e7dfe97ab3d4f7f4618
2022-10-06 18:16:12 +00:00
Matt Harvey
7363bd638c rz shell command
This change adds an "rz" command to the shell that calls a function
rz(). It switches the IO from the shell to a ZMODEM receiver that
produces a Rust upload object that collects the uploaded bytes and
computes a CRC32 checksum on the fly.

In a later change, we will retain the most recent payload in a
shell-owned object until it is consumed by an "install" command.

Limitations:

  * Sender hangup will cause the receiver to block forever and the
    prompt not to come back, since kata-uart-client does reads that
    block forever.
  * Logging must be set to a level higher than debug or messages from
    the zmodem crate itself corrupt the transfer.
  * The sender must rate limit to ~150 bytes/sec to avoid running
    too far ahead of the Renode UART, which drops bytes when the RX
    FIFO is full.
  * Uploading too big a payload will cause a kata_panic! unless the
    heap size is increased in kata-debug-console/src/run.rs

Demo:

KATA> loglevel error
ERROR
KATA> rz
**B0100000023be50
[Ctrl-C]

$ sz -O ~/random < /tmp/term | pv -L 150 > /tmp/term
Sending: random
Bytes Sent:  15360/  16384   BPS:26805    ETA 00:00   150 B 0:00:01 [ 146 B/s] [ <=>     Bytes Sent:  16384   BPS:144                                                            ]

Transfer complete
16.6KiB 0:01:53 [ 149 B/s] [               <=>                                          ]

$ stty sane -echo -icanon; socat - /tmp/term 2> /dev/null; stty sane;
size: 16384, crc32: 991b1d60
KATA>
[Ctrl-C]

$ crc32 ~/random
991b1d60

Change-Id: I53252b821a829a667a23a9fd072f71c6955fdc1a
GitOrigin-RevId: c818a35f186dcd8c083891bfaa84ad0a9f9fef7d
2022-10-06 18:14:21 +00:00
Matt Harvey
929966d376 ZMODEM: input/output split in API; over+out
This change makes the ZMODEM API use separate references for the input
and output communications channels, which is better adapted to the
established pattern in kata-shell.

Consuming up to the "OO" (over-and-out) bytes from the sender is also
included as a small throw-in. Preliminary dev runs have revealed that
the sz utility from lrzsz always sends "OO", preceded by 2 bytes of
unclear purpose, even after getting the ZFIN from the receiver.

Change-Id: Ib25261ad4c9054a3403ed5910aeacd62fbd6b93c
GitOrigin-RevId: 452cdaa41f473c0c3781faaf3bd1958b9803bb3a
2022-10-06 18:14:10 +00:00
Matt Harvey
5c3a68f7ac Sets default-features = false for postcard
This fixes a build break that happened without any intervening commit in
our repo. How that could happen is not yet pinpointed, and there has
been no increment in the minor version number of postcard for 2 months.

It appears that postcard was somehow triggering serde to use std, which
is a default feature for serde.

Change-Id: I7ed989976aa1bf75cb440c4070565452571d7306
GitOrigin-RevId: f35b7677e995e5e8245c583ca2c355a04306aea2
2022-10-06 18:13:57 +00:00
Sam Leffler
49c4a251bc SecurityCoordinator: cleanup interface (part 2)
- low serialize of request parameters into kata_security_request
- add InstallRequest that passes the package buffer as an opaque ptr
- add EchoRequest for SecurityRequestEcho
- purge (now) unused SecurityRequestData type alias and hide
  SECURITY_REQUEST_DATA_SIZE (only used in crate)
- use &str instead of String in serialize requests (from mattharvey@)
- add SreSerializeFailed

Change-Id: Iac1930c0b2fead0f96b87da5d116280865031be2
GitOrigin-RevId: 37df6cd1969b3be2628e2e34f3de8fd129fdbc1b
2022-10-06 18:13:49 +00:00
Sam Leffler
02dc75cb43 Merge "SecurityCoordinator: cleanup interface (part 1)"
GitOrigin-RevId: bb5f089cdd9edac2b5d310439adbd9d3948ac858
2022-10-06 18:13:40 +00:00
Matt Harvey
251c907f49 Increases DebugConsole heap to 1MB
There is a temporary desire to keep ZMODEM uploads as state in
DebugConsole. Since realistic package ZIP files might be larger than
16KB, this change increases the heap size to have a lot of excess.

Change-Id: Iabb5014cb77cf828f77d4553b7f304248c085114
GitOrigin-RevId: 2ae49570a887d5bd2d4672fb3e134c8a1394190e
2022-10-06 18:13:32 +00:00
Sam Leffler
36677807e8 Merge "Improve unit test usability."
GitOrigin-RevId: 25772f196da92291383369a233f71f1335cb7cc1
2022-10-06 18:13:21 +00:00
Sam Leffler
bf19c88ccf Merge "Add StorageManager skeleton."
GitOrigin-RevId: e776e3c357ca54ad3b74212176da8a4ebc16b372
2022-10-06 18:13:06 +00:00
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