Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
inclavare-containers
提交
27627e71
I
inclavare-containers
项目概览
openanolis
/
inclavare-containers
通知
4
Star
7
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
5
列表
看板
标记
里程碑
合并请求
0
分析
仓库
DevOps
项目成员
Pages
I
inclavare-containers
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
5
Issue
5
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
27627e71
编写于
6月 28, 2020
作者:
jia zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rune/libenclave: Implement new ecall get_report() for skeleton
Signed-off-by:
Jia Zhang
<
zhang.jia@linux.alibaba.com
>
上级
484f1580
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
105 addition
and
7 deletion
+105
-7
rune/libenclave/internal/runtime/pal/skeleton/Makefile
rune/libenclave/internal/runtime/pal/skeleton/Makefile
+2
-2
rune/libenclave/internal/runtime/pal/skeleton/arch.h
rune/libenclave/internal/runtime/pal/skeleton/arch.h
+57
-0
rune/libenclave/internal/runtime/pal/skeleton/encl.c
rune/libenclave/internal/runtime/pal/skeleton/encl.c
+25
-1
rune/libenclave/internal/runtime/pal/skeleton/liberpal-skeleton.c
...enclave/internal/runtime/pal/skeleton/liberpal-skeleton.c
+4
-3
rune/libenclave/internal/runtime/pal/skeleton/sgx_call.h
rune/libenclave/internal/runtime/pal/skeleton/sgx_call.h
+17
-1
未找到文件。
rune/libenclave/internal/runtime/pal/skeleton/Makefile
浏览文件 @
27627e71
...
...
@@ -4,9 +4,9 @@ endif
OUTPUT
?=
./
HOST_CFLAGS
:=
-Wall
-Werror
-g
-fPIC
-z
noexecstack
\
-Wno-unused-const-variable
-Wno-unused-const-variable
-std
=
gnu11
ENCL_CFLAGS
:=
-Wall
-Werror
-static
-nostdlib
-nostartfiles
-fPIC
\
-fno-stack-protector
-mrdrnd
-fno-stack-protector
-mrdrnd
-std
=
gnu11
HOST_LDFLAGS
:=
-fPIC
-shared
-Wl
,-Bsymbolic
TEST_CUSTOM_PROGS
:=
$(OUTPUT)
/encl.bin
$(OUTPUT)
/encl.ss
$(OUTPUT)
/liberpal-skeleton.so
$(OUTPUT)
/signing_key.pem
$(OUTPUT)
/encl.token
...
...
rune/libenclave/internal/runtime/pal/skeleton/arch.h
浏览文件 @
27627e71
...
...
@@ -10,6 +10,7 @@
#ifndef _ASM_X86_SGX_ARCH_H
#define _ASM_X86_SGX_ARCH_H
#include <assert.h>
#include <linux/types.h>
#define SGX_CPUID 0x12
...
...
@@ -19,6 +20,8 @@
#define BIT(nr) (1UL << (nr))
#endif
#define EREPORT 0
/**
* enum sgx_return_code - The return code type for ENCLS, ENCLU and ENCLV
* %SGX_NOT_TRACKED: Previous ETRACK's shootdown sequence has not
...
...
@@ -369,4 +372,58 @@ struct sgx_einittoken {
#define SGX_LAUNCH_TOKEN_SIZE 304
#define SGX_TARGET_INFO_SIZE 512
struct
sgx_target_info
{
uint8_t
mrenclave
[
32
];
uint64_t
attributes
;
uint64_t
xfrm
;
uint8_t
cetattributes
;
uint8_t
reserved1
;
uint16_t
config_svn
;
uint32_t
miscselect
;
uint8_t
reserved2
[
8
];
uint32_t
config_id
[
16
];
uint8_t
reserved3
[
384
];
}
__packed
__aligned
(
SGX_TARGET_INFO_SIZE
);
static_assert
(
sizeof
(
struct
sgx_target_info
)
==
SGX_TARGET_INFO_SIZE
,
"incorrect size of sgx_target_info"
);
#define SGX_REPORT_DATA_SIZE 64
struct
sgx_report_data
{
uint8_t
report_data
[
SGX_REPORT_DATA_SIZE
];
}
__packed
__aligned
(
128
);
static_assert
(
sizeof
(
struct
sgx_report_data
)
==
128
,
"incorrect size of sgx_report_data"
);
struct
sgx_report_body
{
uint8_t
cpusvn
[
16
];
uint32_t
miscselect
;
uint8_t
cetattributes
;
uint8_t
reserved1
[
11
];
uint16_t
isv_ext_prod_id
[
8
];
uint64_t
attributes
;
uint64_t
xfrm
;
uint8_t
mrenclave
[
32
];
uint8_t
reserved2
[
32
];
uint8_t
mrsigner
[
32
];
uint8_t
reserved3
[
32
];
uint32_t
config_id
[
16
];
uint16_t
isv_prod_id
;
uint16_t
isv_svn
;
uint16_t
config_svn
;
uint8_t
reserved4
[
42
];
uint8_t
isv_family_id
[
16
];
uint8_t
report_data
[
64
];
}
__packed
;
static_assert
(
sizeof
(
struct
sgx_report_body
)
==
384
,
"incorrect size of sgx_report_body"
);
#define SGX_REPORT_SIZE 432
struct
sgx_report
{
struct
sgx_report_body
body
;
uint8_t
key_id
[
32
];
uint8_t
mac
[
16
];
}
__packed
__aligned
(
512
);
static_assert
(
sizeof
(
struct
sgx_report
)
==
512
,
"incorrect size of sgx_report"
);
#endif
/* _ASM_X86_SGX_ARCH_H */
rune/libenclave/internal/runtime/pal/skeleton/encl.c
浏览文件 @
27627e71
...
...
@@ -25,6 +25,30 @@ static int encl_init(void *dst)
return
0
;
}
static
int
encl_get_report
(
const
struct
sgx_target_info
*
target_info
,
const
uint8_t
*
report_data
,
struct
sgx_report
*
report
)
{
struct
sgx_target_info
ti
;
memcpy
(
&
ti
,
target_info
,
SGX_TARGET_INFO_SIZE
);
struct
sgx_report_data
rd
;
memcpy
(
&
rd
,
report_data
,
SGX_REPORT_DATA_SIZE
);
struct
sgx_report
r
;
asm
volatile
(
ENCLU
"
\n\t
"
::
"a"
(
EREPORT
),
"b"
(
&
ti
),
"c"
(
&
rd
),
"d"
(
&
r
)
:
"memory"
);
memcpy
(
report
,
&
r
,
SGX_REPORT_SIZE
);
return
0
;
}
unsigned
long
enclave_call_table
[
MAX_ECALLS
]
=
{
(
unsigned
long
)
encl_init
,
(
unsigned
long
)
encl_init
,
(
unsigned
long
)
encl_get_report
,
};
rune/libenclave/internal/runtime/pal/skeleton/liberpal-skeleton.c
浏览文件 @
27627e71
...
...
@@ -104,7 +104,8 @@ static bool encl_add_pages(int dev_fd, unsigned long addr, void *data,
}
static
bool
encl_build
(
struct
sgx_secs
*
secs
,
void
*
bin
,
unsigned
long
bin_size
,
struct
sgx_sigstruct
*
sigstruct
,
struct
sgx_einittoken
*
token
)
struct
sgx_sigstruct
*
sigstruct
,
struct
sgx_einittoken
*
token
)
{
struct
sgx_enclave_init
ioc
;
int
dev_fd
;
...
...
@@ -288,7 +289,7 @@ int pal_exec(char *path, char *argv[], const char *envp[],
return
-
1
;
}
fprintf
(
fp
,
"Enclave initialization succeeded
\n
"
);
fprintf
(
fp
,
"Enclave
runtime skeleton
initialization succeeded
\n
"
);
fclose
(
fp
);
*
exit_code
=
0
;
...
...
@@ -299,7 +300,7 @@ int pal_exec(char *path, char *argv[], const char *envp[],
int
pal_destroy
(
void
)
{
if
(
!
initialized
)
{
fprintf
(
stderr
,
"
e
nclave runtime skeleton uninitialized yet!
\n
"
);
fprintf
(
stderr
,
"
E
nclave runtime skeleton uninitialized yet!
\n
"
);
return
-
1
;
}
return
0
;
...
...
rune/libenclave/internal/runtime/pal/skeleton/sgx_call.h
浏览文件 @
27627e71
...
...
@@ -7,7 +7,8 @@
#define SGX_CALL_H
#define ECALL_MAGIC 0
#define MAX_ECALLS 1
#define ECALL_REPORT 1
#define MAX_ECALLS 2
#define EEXIT 4
...
...
@@ -30,6 +31,21 @@
__ret; \
})
#define SGX_ENTER_3_ARGS(ecall_num, tcs, a0, a1, a2) \
({ \
int __ret; \
asm volatile( \
"mov %1, %%r10\n\t" \
"mov %2, %%r11\n\t" \
"call sgx_ecall\n\t" \
: "=a" (__ret) \
: "r" ((uint64_t)ecall_num), "r" (tcs), \
"D" (a0), "S" (a1), "d" (a2) \
: "r10", "r11" \
); \
__ret; \
})
#define ENCLU ".byte 0x0f, 0x01, 0xd7"
#else
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录