Skip to content

Commit d389510

Browse files
Remove vestigial OE types (#7122)
Co-authored-by: Amaury Chamayou <[email protected]>
1 parent f0846cb commit d389510

File tree

4 files changed

+13
-91
lines changed

4 files changed

+13
-91
lines changed

include/ccf/pal/mem.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ namespace ccf::pal
2828
size_t peak_allocated_heap_size = 0;
2929
};
3030

31-
#if !defined(INSIDE_ENCLAVE) || defined(VIRTUAL_ENCLAVE)
32-
3331
static inline void* safe_memcpy(void* dest, const void* src, size_t count)
3432
{
3533
return ::memcpy(dest, src, count);
@@ -63,27 +61,4 @@ namespace ccf::pal
6361

6462
return true;
6563
}
66-
67-
#else
68-
69-
static inline void* safe_memcpy(void* dest, const void* src, size_t count)
70-
{
71-
return oe_memcpy_with_barrier(dest, src, count);
72-
}
73-
74-
static bool get_mallinfo(MallocInfo& info)
75-
{
76-
oe_mallinfo_t oe_info;
77-
auto rc = oe_allocator_mallinfo(&oe_info);
78-
if (rc != OE_OK)
79-
{
80-
return false;
81-
}
82-
info.max_total_heap_size = oe_info.max_total_heap_size;
83-
info.current_allocated_heap_size = oe_info.current_allocated_heap_size;
84-
info.peak_allocated_heap_size = oe_info.peak_allocated_heap_size;
85-
return true;
86-
}
87-
88-
#endif
8964
}

src/enclave/virtual_enclave.h

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,11 @@ T get_enclave_exported_function(
2929
return (T)sym;
3030
}
3131

32-
// If this build does not also include OE definitions, then recreate them here.
33-
// It should not matter if these do not match precisely OE's, so long as they
34-
// can be used consistently by the virtual build.
35-
using oe_result_t = int;
36-
constexpr oe_result_t OE_OK = 0;
37-
constexpr oe_result_t OE_FAILURE = 1;
38-
39-
using oe_enclave_t = void;
40-
using oe_log_level_t = size_t;
41-
42-
enum oe_enclave_type_t
43-
{
44-
OE_ENCLAVE_TYPE_SGX = 2,
45-
};
46-
47-
#define oe_result_str(x) x
48-
4932
#ifdef __cplusplus
5033
extern "C"
5134
{
5235
#endif
5336

54-
typedef void (*oe_ocall_func_t)(
55-
const uint8_t* input_buffer,
56-
size_t input_buffer_size,
57-
uint8_t* output_buffer,
58-
size_t output_buffer_size,
59-
size_t* output_bytes_written);
60-
61-
/*ocall function table*/
62-
static oe_ocall_func_t __ccf_ocall_function_table[] = {nullptr};
63-
6437
inline void* load_virtual_enclave(const char* path)
6538
{
6639
auto virtual_enclave_handle = dlopen(
@@ -91,9 +64,8 @@ extern "C"
9164
}
9265
}
9366

94-
inline oe_result_t virtual_create_node(
67+
inline CreateNodeStatus virtual_create_node(
9568
void* virtual_enclave_handle,
96-
CreateNodeStatus* status,
9769
void* enclave_config,
9870
uint8_t* ccf_config,
9971
size_t ccf_config_size,
@@ -139,7 +111,7 @@ extern "C"
139111
get_enclave_exported_function<create_node_func_t>(
140112
virtual_enclave_handle, "enclave_create_node");
141113

142-
*status = create_node_func(
114+
CreateNodeStatus status = create_node_func(
143115
enclave_config,
144116
ccf_config,
145117
ccf_config_size,
@@ -160,26 +132,18 @@ extern "C"
160132
time_location,
161133
work_beacon);
162134

163-
// Only return OE_OK when the error isn't OE related
164-
switch (*status)
165-
{
166-
case CreateNodeStatus::EnclaveInitFailed:
167-
case CreateNodeStatus::MemoryNotOutsideEnclave:
168-
return OE_FAILURE;
169-
default:
170-
return OE_OK;
171-
}
135+
return status;
172136
}
173137

174-
inline oe_result_t virtual_run(void* virtual_enclave_handle, bool* _retval)
138+
inline bool virtual_run(void* virtual_enclave_handle)
175139
{
176140
using run_func_t = bool (*)();
177141

178142
static run_func_t run_func = get_enclave_exported_function<run_func_t>(
179143
virtual_enclave_handle, "enclave_run");
180144

181-
*_retval = run_func();
182-
return *_retval ? OE_OK : OE_FAILURE;
145+
bool retval = run_func();
146+
return retval;
183147
}
184148

185149
#ifdef __cplusplus

src/host/enclave.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,21 @@ namespace host
124124
auto config_s = nlohmann::json(ccf_config).dump();
125125

126126
#define CREATE_NODE_ARGS \
127-
&status, (void*)&enclave_config, (uint8_t*)config_s.data(), config_s.size(), \
127+
(void*)&enclave_config, (uint8_t*)config_s.data(), config_s.size(), \
128128
startup_snapshot.data(), startup_snapshot.size(), node_cert.data(), \
129129
node_cert.size(), &node_cert_len, service_cert.data(), \
130130
service_cert.size(), &service_cert_len, enclave_version_buf.data(), \
131131
enclave_version_buf.size(), &enclave_version_len, start_type, log_level, \
132132
num_worker_thread, time_location, work_beacon
133133

134-
oe_result_t err = OE_FAILURE;
135-
136134
// Assume that constructor correctly set the appropriate field, and call
137135
// appropriate function
138136
if (virtual_handle != nullptr)
139137
{
140-
err = virtual_create_node(virtual_handle, CREATE_NODE_ARGS);
138+
status = virtual_create_node(virtual_handle, CREATE_NODE_ARGS);
141139
}
142140

143-
if (err != OE_OK || status != CreateNodeStatus::OK)
141+
if (status != CreateNodeStatus::OK)
144142
{
145143
// Logs have described the errors already, we just need to allow the
146144
// host to read them (via read_all()).
@@ -171,18 +169,16 @@ namespace host
171169
// from a thread
172170
bool run()
173171
{
174-
bool ret = true;
175-
oe_result_t err = OE_FAILURE;
172+
bool ret = false;
176173

177174
if (virtual_handle != nullptr)
178175
{
179-
err = virtual_run(virtual_handle, &ret);
176+
ret = virtual_run(virtual_handle);
180177
}
181178

182-
if (err != OE_OK)
179+
if (!ret)
183180
{
184-
throw std::logic_error(
185-
fmt::format("Failed to call in enclave_run: {}", oe_result_str(err)));
181+
throw std::logic_error(fmt::format("Failure in virtual_run"));
186182
}
187183

188184
return ret;

tests/infra/remote.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,6 @@ def get_result(self, line_count):
264264
return self._get_perf(result)
265265

266266

267-
CCF_TO_OE_LOG_LEVEL = {
268-
"trace": "VERBOSE",
269-
"debug": "INFO",
270-
"info": "WARNING",
271-
"fail": "ERROR",
272-
"fatal": "FATAL",
273-
}
274-
275-
276267
class CCFRemote(object):
277268
BIN = "cchost"
278269
TEMPLATE_CONFIGURATION_FILE = "config.jinja"
@@ -361,10 +352,6 @@ def __init__(
361352
snp_uvm_security_context_dir
362353
)
363354

364-
oe_log_level = CCF_TO_OE_LOG_LEVEL.get(kwargs.get("log_level"))
365-
if oe_log_level:
366-
env["OE_LOG_LEVEL"] = oe_log_level
367-
368355
self.name = f"{label}_{local_node_id}"
369356
self.start_type = start_type
370357
self.local_node_id = local_node_id

0 commit comments

Comments
 (0)