c++ 确定可创建的最大SGX飞地(EPC)

kkih6yb8  于 11个月前  发布在  其他
关注(0)|答案(2)|浏览(111)

我找不到一种方法来确定使用SGX SDK可创建的最大安全区是多少。是否有任何方法可以获取这些功能?这在云环境中特别有用,在这种环境中,您可以使用EPC部分创建虚拟机,但您不知道所配置的EPC的实际可用大小。

6tqwzwtp

6tqwzwtp1#

我发现获取EPC部分值的唯一方法是过滤SGX驱动程序输出的dmesg。

[    2.451815] intel_sgx: EPC section 0x240000000-0x2bfffffff

字符串
如果我们将部分的开始和结束转换为小数,并从开始减去结束,我们得到一个以字节为单位的值,可以转换为gibibytes或mebibytes。
下面是这个例子的计算结果,单位是gibibytes:

python3 -c 'print((0x2bfffffff - 0x240000000) / 1024 ** 3)'
1.9999999990686774

azpvetkf

azpvetkf2#

你可以使用cpuid leaf-0x 12 subleaf 2..直到你遇到一个无效的类型并对大小求和。
使用254 GB EPC的示例:

$ cpuid -1 -l 0x12 -s2 
CPU:
   SGX Enclave Page Cache (EPC) enumeration (0x12/0x2):
      type                     = EPC section
      section physical address = 0x0000002030000000
      section size             = 0x0000001fcf3ff000
      section property         = confidentiality protection only

$ cpuid -1 -l 0x12 -s3
CPU:
   SGX Enclave Page Cache (EPC) enumeration (0x12/0x3):
      type                     = EPC section
      section physical address = 0x0000006030000000
      section size             = 0x0000001fd0000000
      section property         = confidentiality protection only

$ cpuid -1 -l 0x12 -s4
CPU:
   SGX Enclave Page Cache (EPC) enumeration (0x12/0x4):
      type = invalid

$ echo $(((0x0000001fcf3ff000 + 0x0000001fd0000000) / 1024 / 1024 / 1024))
254

$ sudo dmesg|fgrep EPC
[    3.082021] sgx: EPC section 0x2030000000-0x3fff3fefff
[    3.471415] sgx: EPC section 0x6030000000-0x7fffffffff

字符串

相关问题