Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Salus-TSM stub #129

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

atulkharerivos
Copy link
Contributor

@atulkharerivos atulkharerivos commented Oct 7, 2022

This adds a new binary target for the Salus-TSM. The Salus-TSM binary will be loaded early by the platform-FW, and is intended for use with a HS-mode VMM.

At present, the binary is a stub intended for use prototyping purposes, and will evolve to provide the complete range of functionality.

  1. The first commit adds a feature flag
  2. . The second commit refactors the existing Salus code, and moves most of the host_vm functionality into a separate module. The common functionality is in the new tsm_core module/.
  3. The third commit adds the Salus-TSM module
  4. The fourth commit adds the build targets.

Note that we can have the a single main.rs, and have two different [[bin]] targets with the feature flag, but cargo emits a warning about it (which will likely cause the CI to fail).

@dgreid
Copy link
Collaborator

dgreid commented Oct 7, 2022

Looks like a squashing error on commits 3 and 4?

Also can we have a slack discussion about splitting in to two vs adding an optional mode to the existing binary?

This adds a feature flag that can be conditionally used to compile code
specific to Salus-TSM (or alternatively exclude code that's not needed
for the functionality). The Salus-TSM binary will be loaded early by
the platform-FW, and is intended for use with a HS-mode VMM.
This refactors the host_vm functionality and moves most of it into a
seperate module. It also introduces a tsm_core module to contain
functionality that will be shared by the Salus version that supports
VS-mode guests, and the Salus-TSM version that will support HS-mode
VMMs.
This adds a module for the Salus TSM binary. At present, the it's a
stub intended for use prototyping purposes, and will evolve to
provide the complete range of functionality.
This makes the changes to Cargo.toml and the Makefile to build binaries
for the original Salus, and the new Salus-TSM.
Copy link
Collaborator

@abrestic-rivos abrestic-rivos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I'm not sure separate binary targets + feature flag is the way to go, unless the binary targets can implicitly select the correct value of the feature flag.

I'm not a huge fan of the "Salus" vs "Salus-TSM" naming as they're both TSMs, but the former has the ability to load & run the host in VS while the latter is just a TSM that expects the host to be load & run independently. It would be better to name them after the deployment models they are to be used in (host-in-VS vs host-in-non-TEE-HS), but I don't have a good suggestion at the moment :)

@@ -0,0 +1,526 @@
// Copyright (c) 2021 by Rivos Inc.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(general comment on this file)

There's quite a lot here that isn't really about the "host VM" or even the "host-in-VS" deployment model, for example: setting up CSRs, building a memory map, setting up a heap, setting up paging(*). It feels like much of this can remain in main or tsm_core. Anything that's related to the loading and running of the host VM could be placed in host_vm_loader.

*both will need paging, but obviously there will be differences in how it's set up.

Comment on lines +18 to +23
path = "src/salus_tsm.rs"
required-features = ["salustsm"]

[[bin]]
name = "salus"
path = "src/main.rs"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of main.rs and salus_tsm.rs, can we put main in both names so that it's obvious that they're both the "main" modules of their respective binaries?

Comment on lines +149 to +153
run_salus_tsm: salus_tsm
$(QEMU_BIN) \
$(MACH_ARGS) \
-kernel $(RELEASE_BINS)salus-tsm \
$(EXTRA_QEMU_ARGS)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably have an internal discussion about how this Makefile target is expected to be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure..will add this and the below to the thread.

@@ -10,6 +10,9 @@ strip = "debuginfo"
codegen-units = 1
panic = "abort"

[features]
salustsm = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are separate binary targets, do we still need a feature flag? If we want a feature flag + separate binary targets, is there a way to automatically set the feature based on which binary we're building?

Also some bikeshedding: I feel like "tsm_only" is a better name than "salustsm", as it's more obvious what the flag is doing (stripping out the non-TSM components).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature flags can be enabled by default, but it does require the flag to be defined AFAIK. The nomenclature was arbitrary, so perhaps, we can just see what feels best in the channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants