Skip to content

Commit

Permalink
using native mermaid
Browse files Browse the repository at this point in the history
  • Loading branch information
evan361425 committed Dec 9, 2024
1 parent 4c0784a commit b2dc71f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 30 deletions.
1 change: 0 additions & 1 deletion .github/workflows/github-page.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
mkdocs --version
pip install mkdocs-material
pip install mkdocs-git-revision-date-localized-plugin
pip install mkdocs-mermaid2-plugin
pip install mkdocs-blogging-plugin
pip install mdx_truly_sane_lists
pip install -e lib
Expand Down
19 changes: 2 additions & 17 deletions mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ markdown_extensions:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:mermaid2.fence_mermaid_custom
format: !!python/name:pymdownx.superfences.fence_code_format
# MathJax
- pymdownx.arithmatex:
generic: true
Expand Down Expand Up @@ -208,23 +208,8 @@ plugins:
- javascripts/
- stylesheets/
- feedback/index.md
- feedback/site-reliability-workbook/index.md
- feedback/site-reliability-workbook/nalsd.md
- essay/index.md
- mermaid2:
arguments:
# 這裡會有個問題,當使用者亮暗模式切換時,不會重新 render,一般來說可以使用以下方法解決:
# markdown_extensions:
# - pymdownx.superfences:
# custom_fences:
# - name: mermaid
# class: mermaid
# format: !!python/name:mermaid2.fence_mermaid_custom
# 但是這樣會導致 mermaid2 的設定失效,例如以下的 securityLevel,所以只好用這個方法
# securityLevel: antiscript
# https://mermaid.js.org/config/theming.html#available-themes
# theme: |
# ^(JSON.parse(__md_get("__palette").index == 1)) ? 'dark' : 'default'
- essay/confidential-computing.md
# 用來注入最新的修改
- blogging:
# https://github.com/liang2kl/mkdocs-blogging-plugin
Expand Down
24 changes: 12 additions & 12 deletions src/essay/confidential-computing.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ flowchart LR
v[Data/Code] -.Copy.-> p
end
u[User Space] --"<br>ECREATE<br>EADD<br>EEXTEND"--> e
e --"<br>EINIT"--> p
e --"EINIT"--> p
style v stroke-width:2px,stroke-dasharray: 5 5
```

Expand Down Expand Up @@ -289,6 +289,7 @@ Intel 提供一種機制**為這個應用程式提出證明(attestation)**

```mermaid
sequenceDiagram
autonumber
participant A as Enclave A
participant sgx as Intel SGX
participant B as Enclave B
Expand All @@ -315,6 +316,7 @@ Message Authentication Code (MAC) 來確保其完整性。

```mermaid
sequenceDiagram
autonumber
participant A as Enclave A w/ Report
participant sgx as Intel SGX
participant qe as Quoting Enclave
Expand Down Expand Up @@ -406,7 +408,7 @@ void printf_helloworld(); // (1)!
void printf_helloworld()
{
char buf[30] = {'\0'};
add_prefix(buf, "world\n"); // (1)1
add_prefix(buf, "world\n"); // (1)!

printf("%s", buf);
}
Expand All @@ -423,13 +425,13 @@ void printf_helloworld()

#include "sgx_urts.h"
#include "App.h"
#include "Enclave.h"
#include "Enclave_u.h" // (1)!

sgx_enclave_id_t global_eid = 0;

int initialize_enclave(void)
{
sgx_launch_token_t token = {0}; // (1)!
sgx_launch_token_t token = {0}; // (2)!
int updated = 0; // token 是否有更新

ret = sgx_create_enclave(
Expand Down Expand Up @@ -461,19 +463,17 @@ int SGX_CDECL main(int argc, char *argv[])
return -1;
}

printf_helloworld(global_eid); // (2)!
printf_helloworld(global_eid); // (3)!

sgx_destroy_enclave(global_eid);

return 0;
}
```
1. [Launch Enclave](#系統飛地) 產生的 token
2. `Enclave.h` 提供的函式
??? info "ECALL 和 OCALL"
ECALL 代表服務呼叫飛地裡的函式,而 OCALL 則代表飛地函式呼叫外部函式。
1. 這個是工具產生的程式碼,讓 `App.cpp` 可以透過 `ECALL` 呼叫 `Enclave.cpp`
2. [Launch Enclave](#系統飛地) 產生的 token
3. `Enclave_u.h` 提供的函式
最後就是透過 Intel 提供的設定檔(Enclave Definition Language, EDL),
決定 `Enclave.h` 裡的哪個函式是被放進飛地。
Expand All @@ -494,8 +494,8 @@ enclave {

這時候使用 Intel SGX 工具會編譯出兩組代理程序,分別是 `Enclave_u.cpp``Enclave_t.cpp`

- `Enclave_u.cpp``Enclave.cpp` 看到的 *untrusted* 介面,通常稱為 `OCALL`,代表呼叫飛地「外」的函式
- `Enclave_t.cpp``App.cpp` 看到的 *trusted* 介面,通常稱為 `ECALL`,代表呼叫飛地的函式
- `Enclave_u.cpp``App.cpp` 看到的 *untrusted* 介面,通常稱為 `ECALL`,代表呼叫飛地的函式
- `Enclave_t.cpp``Enclave.cpp` 看到的 *trusted* 介面,通常稱為 `OCALL`,代表呼叫飛地「外」的函式

而這兩個程序讓實際程式碼能夠彼此認知到對方。

Expand Down

0 comments on commit b2dc71f

Please sign in to comment.