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

Enclave connections and enclave coordination in the C++ target #1665

Merged
merged 45 commits into from
May 16, 2023

Conversation

cmnrd
Copy link
Collaborator

@cmnrd cmnrd commented Mar 18, 2023

This PR extends the C++ target with support for connections between enclave. Most of the functionality is added in lf-lang/reactor-cpp#44 which most importantly introduces three new connection types: EnclaveConnection, DelayedEnclaveConnection, and PhysicalEnclaveConnection. This PR mostly updates the code generator such that the corresponding enclave connection type is inserted into the generated code if an enclave is involved in the connection. This PR also pulls in lf-lang/reactor-cpp#45 which prevents a race condition between staring enclaves.

There remain open issues which will be covered in feature PRs:

  • Zero delay loops between enclaves are not supported. This itself is not much of an issue, as the sequential execution implied by a zero delay loop cancels the benefits we hope to get from using enclaves in the first place. Consequently, a program that requires a zero delay loop should not use enclaves in this loop. However, the actual problem is, that there is currently no detection mechanism for zero delay loops implemented and no warning or error is printed. An application with a zero delay loop between enclaves silently deadlocks. We should add a detection mechanism to the validator to the extend possible and also produce warnings at runtime (for corner cases that are not statically detectable).
  • Cyclic dependencies with a small delay are inefficient. Currently, loops are not detected (neither statically nor dynamically). A loop between enclaves will create a chain of acquire requests. This chain might get very long if the time decrements (given by the delay on the loop) are small.

@cmnrd cmnrd added cpp Related to C++ target feature New feature labels Mar 18, 2023
@cmnrd cmnrd requested a review from tanneberger March 18, 2023 11:22
@cmnrd cmnrd marked this pull request as draft March 18, 2023 11:23
Base automatically changed from clem.new-equals-initializers to master March 27, 2023 17:55
Copy link
Member

@tanneberger tanneberger left a comment

Choose a reason for hiding this comment

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

Looks good so far just left a couple of questions

@cmnrd cmnrd changed the title Implement enclave connections and enclave coordination Enclave connections and enclave coordination in the C++ target May 10, 2023
@cmnrd cmnrd added this to the 0.5.0 milestone May 10, 2023
@cmnrd cmnrd force-pushed the enclave-connections branch from a25e609 to f2d73f1 Compare May 10, 2023 13:07
@cmnrd cmnrd marked this pull request as ready for review May 10, 2023 13:08
@cmnrd cmnrd force-pushed the enclave-connections branch from f2d73f1 to 1e0dd75 Compare May 10, 2023 13:23
@cmnrd cmnrd force-pushed the enclave-connections branch from 1e0dd75 to aae5cae Compare May 11, 2023 07:57
| std::unique_ptr<$reactorType> __lf_instance{nullptr};
|
| $enclaveWrapperClassName(const std::string& name, reactor::Reactor* container, $reactorType::Parameters&& params) {
| if (__lf_env == nullptr) {
Copy link
Member

Choose a reason for hiding this comment

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

general question the code generator generates c++ code in a totally different style like what is currently standard in reactor-cpp. __lf_env compared it would be probably be named lf_env_ in the style of reactor-cpp.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We use the __lf_ prefix for some variables to avoid name clashes. It is unlikely, but if someone would name their state variable or some other reactor component lf_env_, we would see compile errors. __ is kind of a protected namespace in C/C++ that is not supposed to be used by users.

reaction(in) {=
received = true;
auto value = *in.get();
reactor::log::Info() << "Received " << value;
Copy link
Member

Choose a reason for hiding this comment

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

I like this that we now have native logging. Maybe we just need some alias for more handier use.

@cmnrd cmnrd force-pushed the enclave-connections branch from 9ff7169 to 48898a2 Compare May 13, 2023 07:43
@cmnrd cmnrd merged commit 4d23747 into master May 16, 2023
@cmnrd cmnrd deleted the enclave-connections branch May 16, 2023 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp Related to C++ target feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants