File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 44
44
#include " sgx_trts.h"
45
45
#include " trts_inst.h"
46
46
#include " se_cdefs.h"
47
+ #include " sgx_spinlock.h"
47
48
48
49
// add a version to tservice.
49
50
SGX_ACCESS_VERSION (tservice, 1 )
@@ -131,11 +132,18 @@ const sgx_report_t *sgx_self_report(void)
131
132
.key_id = {0 },
132
133
.mac = {0 }
133
134
};
135
+ static sgx_spinlock_t report_lock = SGX_SPINLOCK_INITIALIZER;
134
136
135
- // Below sgx_create_report() will be called only once during the enclave initialization,
136
- // so there is no potential race conditional.
137
137
if (0 == _report.body .attributes .flags )
138
- sgx_create_report (nullptr , nullptr , &_report);
138
+ {
139
+ // sgx_create_report() only needs to be called once to get self report.
140
+ sgx_spin_lock (&report_lock);
141
+ if (0 == _report.body .attributes .flags )
142
+ {
143
+ sgx_create_report (nullptr , nullptr , &_report);
144
+ }
145
+ sgx_spin_unlock (&report_lock);
146
+ }
139
147
140
148
return &_report;
141
149
}
Original file line number Diff line number Diff line change @@ -67,6 +67,8 @@ typedef struct _global_data_sim_t
67
67
uint64_t seed ; /* to initialize the PRNG */
68
68
} global_data_sim_t ;
69
69
70
+ extern global_data_sim_t g_global_data_sim ;
71
+
70
72
#ifdef __cplusplus
71
73
}
72
74
#endif
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ int g_xsave_enabled __attribute__((section(".nipd"))) = 0; // flag to in
58
58
#ifdef SE_SIM
59
59
uint32_t g_xsave_mask_high __attribute__ ((section(" .nipd" ))) = 0xFFFFFFFF;
60
60
uint32_t g_xsave_mask_low __attribute__ ((section(" .nipd" ))) = 0xFFFFFFFF;
61
+ #include " rts_sim.h"
61
62
#endif
62
63
63
64
// EENTER will set xcr0 with secs.attr.xfrm,
@@ -71,10 +72,13 @@ uint32_t g_xsave_mask_low __attribute__((section(".nipd"))) = 0xFFFFFFFF;
71
72
SE_OPTIMIZE_OFF
72
73
uint64_t get_xfeature_state ()
73
74
{
75
+ #ifndef SE_SIM
74
76
auto *report = sgx_self_report ();
75
77
g_xsave_enabled = (report->body .attributes .xfrm == SGX_XFRM_LEGACY) ? 0 : 1 ;
76
78
uint64_t xfrm = report->body .attributes .xfrm ;
77
- #ifdef SE_SIM
79
+ #else
80
+ uint64_t xfrm = g_global_data_sim.secs_ptr ->attributes .xfrm ;
81
+ g_xsave_enabled = (xfrm == SGX_XFRM_LEGACY) ? 0 : 1 ;
78
82
g_xsave_mask_high = (uint32_t )(xfrm >> 32 );
79
83
g_xsave_mask_low = (uint32_t )(xfrm & 0xFFFFFFFF );
80
84
#endif
You can’t perform that action at this time.
0 commit comments