Commit graph

49 commits

Author SHA1 Message Date
bunnie
d49d46ee0d pre-hash sign the kernel image; normal signing for loader image
The loader image uses the original signing method, because changing
that would require us to modify the gateware ROM, which is a huge
pain in the ass, and doesn't buy us anything.

Thus only the kernel signing uses the pre-hash method.
2024-01-05 16:14:09 +08:00
bunnie
259852c1c6 add a routine to the signer that can do pre-hash images
This requires us to modify our dependencies to have dalek-ed25519
as one of our dependencies.

Which requires another patch in this commit set to implement
sha512 for hosts, since we patch the sha2 crate for all targets
to our local version.
2024-01-05 16:12:55 +08:00
bunnie
069edbc255 support multi-svd file designs
This patch set goes across all the toolchains and brings
in the support for split SVD descriptions of SoCs.

This is helpful for dealing with designs that have multiple
"top" files for the same core IP set. For exmaple, you may have
a SoC that you are developing that targets silicon, but
you have a version that wraps this in additional peripherals
available only in an FPGA emulator that are used for debugging.

In this case, you can have one SVD file be the description of
the SoC itself, and another SVD file describe just the "delta"
introduced by the FPGA wrapper that emulates/controls the SoC.
2023-07-17 16:27:09 +08:00
bunnie
1300771a38 fixes to make PR work 2023-06-16 01:29:55 +08:00
bunnie
7d3f0cd0f8 revert #368
this somehow causes the build to break, and I just checked and
I don't see warnings on our build. There must be some config
differences on hosts, but I'm not sure what it is...
2023-04-21 14:16:28 +08:00
Jean-Pierre De Jesus DIAZ
60a5acbfcf
tools/sign_image: fix warnings
Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
2023-04-20 15:41:15 +02:00
bunnie
3ca8f669a3 breaking change in svd2utra: fix deprecation of quick-xml
quick-xml 0.19.0, a dependency of svd2utra, uses features
that Rust will deprecate.

Unfortunately, the only versions of quick-xml that do not
use the deprecated language features also break a portion
of the API. In particular, quick-xml will no longer take
a `File` as an input: it will only take a `Path`.

This means that the API for svd2utra is also broken, because
originally it was designed to take a `File`

This patch refactors svd2utra to work with the latest quick-xml,
but also breaks any code that calls svd2utra's generate
APIs.

Fortunately this is fairly easy to fix, the calling code
will typically already have the Path somewhere in it, so
instead of opening the Path and passing it into the function,
one may simply pass in the Path.
2023-04-04 02:03:35 +08:00
eupn
8694eaa004
elf.rs: fix alignment edge case (take 2) 2023-03-27 18:41:45 +04:00
eupn
199ab0a73c
elf: fix a section alignment edge case 2023-03-27 16:29:07 +04:00
bunnie
08ae66a264 fix: #320
this commit adds the facilities to extract eh_frame[_header]
sections and pass it to each process.

A bump is required to `std` to extract the passed parameters.
2023-02-15 19:55:08 +08:00
bunnie
43c73c0d6c align sections of the MiniElf
Sections of the MiniElf are now aligned as required by the
source ELF requirements. This is required for direct-mapping
with XIP.

the overhead is just a few bytes every couple of programs, so it's
a small price to pay for XIP.
2023-02-12 01:13:30 +08:00
bunnie
68c9865072 fix the assumption about all alignments being identical
figured out a way to modify the trait so that alignments
are 0 by default, and only set/reported for IniF,
on a per-process basis so if for some reason the alignments
change we should be OK.
2023-02-08 04:57:52 +08:00
bunnie
29f050a8ad fix alignment for IniF region so page mappings are 1:1
Turns out, the pointing end of the stick for ELF sections don't start
at a page boundary. For example:

5    IniF: entrypoint @ 0001e42e, loaded from 000440f4.  Sections:
    Loaded from 000440f4 - Section .rodata        16924 bytes loading into 000100f4..00014310 flags: NONE
    Loaded from 00048310 - Section .eh_frame_hdr   1772 bytes loading into 00014310..000149fc flags: NONE
    Loaded from 000489fc - Section .eh_frame       6004 bytes loading into 000149fc..00016170 flags: NONE
    Loaded from 0004a170 - Section .text          59876 bytes loading into 00017170..00025b54 flags: EXECUTE
    Loaded from 00058b54 - Section .sdata            48 bytes loading into 00026b54..00026b84 flags: WRITE
    Loaded from 00058b84 - Section .sbss             48 bytes loading into 00026b84..00026bb4 flags: WRITE | NOCOPY
    Loaded from 00058bb4 - Section .bss             516 bytes loading into 00026bb8..00026dbc flags: WRITE | NOCOPY

Here you can see, the data is "loading into" 0x100f4, not
0x10000. The original PR would align things to a page, which means
you'd still have an offset mismatch if you tried to map these directly
over.

This patch causes IniF to insert extra padding to target
the offset necessary for the MiniElf to map 1:1.

An important assumption is the offset is constant across all
programs being linked. This seems to be the case, but, if this
assumption breaks, then the padding will also break.
2023-02-08 04:47:29 +08:00
bunnie
9889856ede page-align processes within the kernel image 2023-02-07 21:10:23 +08:00
Sean Cross
f861af7620 tools: elf: fix copy-elf when gcc links program
GCC will set the text size to `0` in a certain case that `rust-lld` did
not. This causes the elf copier to add about 512 MB to the image which
it otherwise shouldn't be doing.

Add a workaround that appears to fix the issue.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-11-04 12:27:13 +08:00
Sean Cross
bad8ba5ea2 tools: sign-image: write remainder of file
During the previous port, we only wrote the first 4096 bytes. Write the
remainder of the file to the destination.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-10-26 23:40:09 +08:00
Sean Cross
22de2bc614 tools: sign_image: fix utterly broken git signing
The previous approach didn't work, for unknown reasons.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-10-26 22:32:24 +08:00
Sean Cross
2cf8ff12a6 tools: add make-renode-boot
This experimental tool can be used to create all-in-one images based
on precomputed file lists. It generates "test images" using just the
bare minimum number of processes.

This program includes all the keys, kernel, and initial images required
to support a simple program.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-10-26 22:22:31 +08:00
Sean Cross
2382d57dd6 tools: add sign_image.rs
Signed-off-by: Sean Cross <sean@xobs.io>
2022-10-26 22:22:18 +08:00
Sean Cross
46cd5e7098 tools: elf: allow loading files from &[u8]
Instead of assuming everything is a file or a path, allow
loading ELF files from u8 slices. This will enable us to create
images with `include_bytes!()`.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-10-26 22:21:24 +08:00
Sean Cross
c50314d4a8 tools: sign-image: break image signing into a library
Move the code used to sign images into its own library file. This will
enable us to use the image signing functions from other code.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-10-26 22:20:33 +08:00
bunnie
86d2437f03 improve formatting so section alignments are easier to debug 2022-10-20 16:14:56 +08:00
Sean Cross
ff3f307a14 tools: read-tags: call output xous_presign.img
The use of the name `args.bin` is now deprecated.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-10-20 14:11:48 +08:00
bunnie
7248f47ca8 fix self-signing to reflect extra data for semvers
the loader is a little funky, and requires some maintainer hand-holding
due to the split of the page ownership between the root-keys
crate and the graphics-server crate.

Improved docs so I don't forget this detail in the future.
2022-07-11 16:11:32 +08:00
bunnie
1256fcb411 add min version requirement and current version to kernel and loader 2022-07-08 18:56:05 +08:00
bunnie
40b16b3cdb inject current semver info into signature appendix on loader and kernel
this allows for a quick readout of the version of each of these
artifacts, inside a signed region, by just inspecting the last
few words of the binary object.
2022-07-08 04:08:37 +08:00
Sean Cross
aa436cbcc7 tools: elf: don't get raw_data for no_copy sections
The `xmas-elf` crate doesn't deal with `raw_data()` of sections that are
`NO_COPY`. These sections may point to data that is outside of the file.

In order to avoid hitting this assert, don't call `raw_data()` on
sections that are marked `NO_COPY`.

Signed-off-by: Sean Cross <sean@xobs.io>
2022-06-10 16:52:57 +08:00
bunnie
421a3814d8 clean up some warnings before moving on to further integration 2022-01-02 15:07:48 +08:00
bunnie
8b59bcdf61 add indices to create_image output
makes it easier to figure out what IniE section corresponds
with which PID.
2021-11-06 21:03:28 +08:00
bunnie
c87acaeddc clarify a bit of rounding code in the create-image routine 2021-11-06 20:30:01 +08:00
bunnie
825322c730 add explicit .iter() for arrays so we still work with Rust 1.51 2021-07-18 16:04:22 +08:00
Sean Cross
aaa4407e21 sign-image: enable kernel image signing
Previously we only supported signing the loader. This also adds the
kernel as a thing that can be signed.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-07-15 16:39:35 +08:00
Sean Cross
31551a6227 tools: add sign-image
Add a Rust implementation of `sign-image`. This enables us to sign the
binary on any platform that can compile Rust.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-07-11 16:34:23 +08:00
Sean Cross
f7ae13da44 tools: run cargo fmt on pnam
Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-19 14:20:22 +08:00
Sean Cross
2e4fb672ab arguments: document and add pnam tag
The `PNam` tag stores information in the kernel about process names.
This can be used at runtime to discover what process maps to what
program name.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-05-10 14:37:33 +08:00
Sean Cross
7b50d00eb8 repo: run cargo fmt
This reformats line endings to be consistent, and reinforces the
contents of `.gitattributes`.

Signed-off-by: Sean Cross <sean@xobs.io>
2021-01-03 18:31:51 +08:00
Sean Cross
96df91f53b create-image: support generating an image from an svd
Now that we can parse svd files, support creating an image using an svd
instead of a csv file.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-10-05 11:37:44 +08:00
Sean
ba320184b0 tools: create-image: print out error when csr.csv can't be opened
Signed-off-by: Sean <xobs@ci.betrusted.io>
2020-10-03 20:32:31 +08:00
Sean Cross
10ecacd136 kernel: native: create process for initial processes
These all need to bootstrap themselves.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-08-09 23:08:54 +08:00
Sean Cross
09be029ad0 tools: refactor to make clippy happy
This fixes a lot of small clippy warnings.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-07-29 20:02:58 +08:00
Sean Cross
14bb1ac1e5 kernel: working on getting process termination functioning
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-22 17:42:24 +08:00
Sean Cross
973945fce2 tools: read-tags: fix bad pointer arithmetic
This removes raw pointer usage that could cause unaligned accesses.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-15 12:30:21 +08:00
Sean Cross
7da67f050a tools: fix most clippy warnings
Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-15 12:04:23 +08:00
Sean Cross
5aa3358bc0 tools: generate byte addresses for mini elf files
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-12 15:29:26 +08:00
Sean Cross
4645816674 tools: elf: add comment and dead code for alignment fixing
This issue was spotted when the kernel address was wrong.  This fixed
the test, but was indicative of something else being wrong.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-10 14:43:15 +08:00
Sean Cross
edf723e107 create-image: verify the kernel image address is sane
Rust inconsistently applies linker scripts.  Verify the image being
added has a script that makes sense.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-10 14:42:01 +08:00
Sean Cross
36dbc97a61 tools: pad inie and xkrn tags to 4-bytes
This fixes an issue where images were not word-aligned.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-10 13:12:27 +08:00
Sean Cross
6959b4ef77 tools: rename from xous-tools
Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-10 12:46:20 +08:00
Sean Cross
f50ec67553 initial commit
This pulls together many disparate repositories into one xous-core
repository.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-10 12:13:05 +08:00