|
| 1 | +From d7d9055a8cf089f0a93caafa73699a9338b53bfc Mon Sep 17 00:00:00 2001 |
| 2 | +From: Felix Dreissig < [email protected]> |
| 3 | +Date: Fri, 20 Aug 2021 13:24:50 +0000 |
| 4 | +Subject: [PATCH 37/37] Enclavization Pass: Allow nested ECALLs from OCALLs in |
| 5 | + EDL file |
| 6 | + |
| 7 | +--- |
| 8 | + .../llvm/Transforms/Utils/Enclavization/Export.h | 1 + |
| 9 | + llvm/lib/Transforms/Utils/Enclavization/Export.cpp | 12 +++++++++++- |
| 10 | + 2 files changed, 12 insertions(+), 1 deletion(-) |
| 11 | + |
| 12 | +diff --git a/llvm/include/llvm/Transforms/Utils/Enclavization/Export.h b/llvm/include/llvm/Transforms/Utils/Enclavization/Export.h |
| 13 | +index 1c9e92316dfc..2e3f5d4e99f5 100644 |
| 14 | +--- a/llvm/include/llvm/Transforms/Utils/Enclavization/Export.h |
| 15 | ++++ b/llvm/include/llvm/Transforms/Utils/Enclavization/Export.h |
| 16 | +@@ -32,6 +32,7 @@ class EdlFile { |
| 17 | + std::vector<std::string> structs; |
| 18 | + std::unordered_set<unsigned int> wideInts; |
| 19 | + std::vector<std::string> trustedFuncs; |
| 20 | ++ std::vector<std::string> trustedFuncNames; |
| 21 | + std::vector<std::string> untrustedFuncs; |
| 22 | + }; |
| 23 | + |
| 24 | +diff --git a/llvm/lib/Transforms/Utils/Enclavization/Export.cpp b/llvm/lib/Transforms/Utils/Enclavization/Export.cpp |
| 25 | +index 0b103e65b02e..a4996c2da164 100644 |
| 26 | +--- a/llvm/lib/Transforms/Utils/Enclavization/Export.cpp |
| 27 | ++++ b/llvm/lib/Transforms/Utils/Enclavization/Export.cpp |
| 28 | +@@ -51,12 +51,21 @@ void EdlFile::writeFile() { |
| 29 | + for (auto entry : trustedFuncs) { |
| 30 | + fstream << "public "; |
| 31 | + fstream << entry; |
| 32 | ++ fstream << ";\n"; |
| 33 | + } |
| 34 | + fstream << "};\n"; |
| 35 | + |
| 36 | + fstream << "untrusted {\n"; |
| 37 | + for (auto entry : untrustedFuncs) { |
| 38 | + fstream << entry; |
| 39 | ++ fstream << " allow ("; |
| 40 | ++ for (size_t i = 0; i < trustedFuncNames.size(); ++i) { |
| 41 | ++ fstream << trustedFuncNames[i]; |
| 42 | ++ if (i != trustedFuncNames.size() - 1){ |
| 43 | ++ fstream << ", "; |
| 44 | ++ } |
| 45 | ++ } |
| 46 | ++ fstream << ");\n"; |
| 47 | + } |
| 48 | + fstream << "};\n"; |
| 49 | + |
| 50 | +@@ -114,6 +123,7 @@ std::string EdlFile::addWideInt(unsigned int width) { |
| 51 | + |
| 52 | + void EdlFile::addTrustedFunction(Function *postgateFunc) { |
| 53 | + addFunction(postgateFunc, trustedFuncs); |
| 54 | ++ trustedFuncNames.push_back(postgateFunc->getName().str()); |
| 55 | + } |
| 56 | + |
| 57 | + void EdlFile::addUntrustedFunction(Function *func) { |
| 58 | +@@ -146,7 +156,7 @@ void EdlFile::addFunction(llvm::Function *func, std::vector<std::string> &target |
| 59 | + entryStream << edlType << " arg" << i; |
| 60 | + } |
| 61 | + |
| 62 | +- entryStream << ");\n"; |
| 63 | ++ entryStream << ")"; |
| 64 | + |
| 65 | + target.push_back(funcEntry); |
| 66 | + } |
| 67 | +-- |
| 68 | +2.25.1 |
| 69 | + |
0 commit comments