HyperEnclave / hyperenclave

An Open and Cross-platform Trusted Execution Environment.
Apache License 2.0
138 stars 18 forks source link

Stuck while running the occlum demo hello_c on Intel CPU with fake TPM #19

Closed bronzeMe closed 3 months ago

bronzeMe commented 3 months ago

basic information

Memory block size: 128M Total online memory: 11.9G Total offline memory: 0B

* cmdline
```bash
cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-5.4.0-88-generic root=UUID=80266541-2151-4cde-87c2-6aed3ef445c7 ro memmap=4G$0x100000000 intel_iommu=off intremap=off no5lvl quiet splash vt.handoff=7
  1. install enable_rdfsbase following enable_rdfsbase

    dmesg|grep -i enable_rd
    [  547.012158] enable_rdfsbase: loading out-of-tree module taints kernel.
    [  547.012184] enable_rdfsbase: module verification failed: signature and/or required key missing - tainting kernel
    [  547.012316] enable_rdfsbase: Loaded
    [  547.012324] Modules linked in: enable_rdfsbase(OE+) xt_conntrack xt_MASQUERADE nf_conntrack_netlink nfnetlink xfrm_user xfrm_algo ip6table_nat ip6table_filter ip6_tables iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c xt_addrtype iptable_filter bpfilter br_netfilter bridge stp llc aufs overlay nls_iso8859_1 binfmt_misc kvm_intel kvm crct10dif_pclmul crc32_pclmul ghash_clmulni_intel input_leds aesni_intel ipmi_ssif crypto_simd cryptd glue_helper ipmi_si video ipmi_devintf ipmi_msghandler acpi_pad sch_fq_codel msr parport_pc ppdev lp parport drm efi_pstore ip_tables x_tables autofs4 hid_generic usbhid hid tg3 ahci libahci
    [  547.012350]  set_cr4_fsgsbase+0x3f/0x50 [enable_rdfsbase]
    [  547.012375] enable_rdfsbase: RDFSBASE and its friends are now enabled on CPU 0
    [  547.012377] enable_rdfsbase: RDFSBASE and its friends are now enabled on CPU 1
    [  547.012377] enable_rdfsbase: RDFSBASE and its friends are now enabled on CPU 2
    [  547.012379] enable_rdfsbase: RDFSBASE and its friends are now enabled on CPU 3
    tee@tee:/data/enable_rdfsbase$ lsmod |grep enable
    enable_rdfsbase        16384  0
    • ./start_hyperenclave.sh
      /data/hyperenclave/scripts$ ./start_hyperenclave.sh
    • dmesg
      [  547.012374] ---[ end trace 4175d4fa27f271d1 ]---
      [  547.012375] enable_rdfsbase: RDFSBASE and its friends are now enabled on CPU 0
      [  547.012377] enable_rdfsbase: RDFSBASE and its friends are now enabled on CPU 1
      [  547.012377] enable_rdfsbase: RDFSBASE and its friends are now enabled on CPU 2
      [  547.012379] enable_rdfsbase: RDFSBASE and its friends are now enabled on CPU 3
      [  607.358689] HE: cpu_vendor_detect: 39. Vendor ID: GenuineIntel
      [  607.366435] HE: get_convertible_memory: 136. BIOS E820 table from firmware: [0x0000000000000000 -> 0x00000000000a0000], type: System RAM
      [  607.366436] HE: get_convertible_memory: 136. BIOS E820 table from firmware: [0x00000000000a0000 -> 0x0000000000100000], type: Reserved
      [  607.366436] HE: get_convertible_memory: 136. BIOS E820 table from firmware: [0x0000000000100000 -> 0x0000000064600000], type: System RAM
      [  607.366437] HE: get_convertible_memory: 136. BIOS E820 table from firmware: [0x0000000064600000 -> 0x0000000068600000], type: Reserved
      [  607.366437] HE: get_convertible_memory: 136. BIOS E820 table from firmware: [0x0000000068600000 -> 0x000000006e6ff000], type: System RAM
      [  607.366438] HE: get_convertible_memory: 136. BIOS E820 table from firmware: [0x000000006e6ff000 -> 0x000000006fbff000], type: Reserved
      [  607.366438] HE: get_convertible_memory: 136. BIOS E820 table from firmware: [0x000000006fbff000 -> 0x000000006fcff000], type: ACPI Non-volatile Storage
      [  607.366439] HE: get_convertible_memory: 136. BIOS E820 table from firmware: [0x000000006fcff000 -> 0x000000006feff000], type: ACPI Tables
      [  607.366439] HE: get_convertible_memory: 136. BIOS E820 table from firmware: [0x000000006feff000 -> 0x000000006ff00000], type: System RAM
      [  607.366440] HE: get_convertible_memory: 136. BIOS E820 table from firmware: [0x000000006ff00000 -> 0x000000007c000000], type: Reserved
      [  607.366440] HE: get_convertible_memory: 136. BIOS E820 table from firmware: [0x0000000080000000 -> 0x0000000090000000], type: Reserved
      [  607.366441] HE: get_convertible_memory: 136. BIOS E820 table from firmware: [0x00000000fe010000 -> 0x00000000fe011000], type: Reserved
      [  607.366441] HE: get_convertible_memory: 136. BIOS E820 table from firmware: [0x00000000fed20000 -> 0x00000000fed80000], type: Reserved
      [  607.366441] HE: get_convertible_memory: 136. BIOS E820 table from firmware: [0x0000000100000000 -> 0x0000000484000000], type: System RAM
      [  607.366442] HE: get_convertible_memory: 213. Convertible Memory[ 0]: 0x0000000000000000 -> 0x00000000000a0000
      [  607.366443] HE: get_convertible_memory: 213. Convertible Memory[ 1]: 0x0000000000100000 -> 0x0000000064600000
      [  607.366443] HE: get_convertible_memory: 213. Convertible Memory[ 2]: 0x0000000068600000 -> 0x000000006e6ff000
      [  607.366444] HE: get_convertible_memory: 213. Convertible Memory[ 3]: 0x000000006feff000 -> 0x000000006ff00000
      [  607.366444] HE: get_convertible_memory: 213. Convertible Memory[ 4]: 0x0000000100000000 -> 0x0000000484000000
      [  607.366445] HE: get_convertible_memory: 218. Convertible Memory size: 0x3ee6a0000
      [  607.366445] HE: get_valid_rsrv_mem: 285. Reserved Memory[ 0]: 0x100000000 -> 0x200000000
      [  607.366446] HE: get_valid_rsrv_mem: 290. Reserved Memory size: 0x100000000
      [  607.366450] HE: mem_test: 48. Memory[0x100000000 - 0x200000000] test begin
      [  608.061435] HE: mem_test: 78. Memory[0x100000000 - 0x200000000] test pass
      [  610.143925] HE: get_hv_heap_size: 375. Hypervisor heap size: 0x43800000
      [  610.143926] HE: get_hv_cmrm_size: 387. Hypervisor cmrm size: 0x6c60000
      [  610.143926] HE: get_hv_frame_size: 400. Hypervisor frame size: 0x1c00000
      [  610.143926] HE: get_hypervisor_size: 413. Hv_core_and_percpu_size: 0x815000, Hypervisor size: 0x80000000
      [  610.143927] HE: he_cmd_enable: 302. hypervisor size: 0x80000000
      [  610.210058] HE: he_cmd_enable: 352. config_size: 1508
      [  610.226679] HE: add_epc_pages: 43. total_epc_pages: 0x80000, free_epc_pages: 0x80000
      [  610.226680] HE: init_enclave_page: 317. epc ranges: [0x180000000-0x200000000], 0x80000000
      [  610.226681] HE: init_enclave_page: 333. Initialized EPC ranges size: 0x80000000
      [  610.226682] HE: he_cmd_enable: 383. config_header load_addr: 0xffffff0000815000
      [  610.226703] HE: he_cmd_enable: 404. mem_region load_addr: 0xffffff0000815124
      [  610.226704] HE: inspect_tpm: 206. using fake tpm
      [  610.226704] HE: he_cmd_enable: 411. tpm mmio type=8,size=0 pa=ffffffff
      [  610.516066] HE: init_cmrm: 448. Initialize [0x0 -> 0x484000000]'s CMRM
      [  610.516194] HE: he_cmd_enable: 483. The hyperenclave is opening.
      [  620.549690] [0] Activating hypervisor on CPU 0...
      [  620.549690] [1] Init HHBox log feature ok
      [  620.549691] [1] Init HHBox crash feature ok
      [  620.549691] [1] tpm_detect starting....
      [  620.549691] [1] fake tpm is detected and initialized
      [  620.549691] [1] FAKE TPM: tpm signing key pub x
      [  620.549691] [1] C29974C9F1090FA4A10E9990620E91828B593A7211E2468450E3DC96DD5933FB
      [  620.549691] [1] size= :0x20
      [  620.549692] [1] FAKE TPM: tpm signing key pub y
      [  620.549692] [1] 402206ECCC5479289F33668EAAB85527ABBBB9F7B41CEB71551027D57AF28267
      [  620.549692] [1] size= :0x20
      [  620.549692] [1] FAKE TPM: root secret is generated and sealed
      [  620.549692] [1] FAKE TPM: hypervisor AK pub x=
      [  620.549692] [1] 3D9BB7BA028C5F97AC5AB1619336D9ED23E86858DDBDC23B510D5F0EBA8FF338
      [  620.549693] [1] size= :0x20
      [  620.549693] [1] FAKE TPM: hypervisor AK pub y=
      [  620.549693] [1] 0B28428BDA30B2800FCB032ABCED81071B5F0DCB1A02B22AFF56B7DD22E52522
      [  620.549693] [1] size= :0x20
      [  620.549693] [1] FAKE TPM: hash of he_ak_pub extended to PCR 13:
      [  620.549694] [1] AAA056CA1F030B7BD6C4089C2AEEC36D01173B46E0FD2B4C1BD2C14649B66539
      [  620.549694] [1] size= :0x20
      [  620.549694] [1] HyperEnclave: root of trust initialized!
      [  620.549694] [1] Activating hypervisor on CPU 1...
      [  620.549694] [2] Activating hypervisor on CPU 2...
      [  620.549695] [3] Activating hypervisor on CPU 3...
    • run the hello_c
      root@tee:~/occlum/demos/hello_c/occlum_instance# occlum run /bin/hello_world
    • Then it got stuck image
    
    OCCLUM_LOG_LEVEL=trace occlum run /bin/hello_world
    [2024-07-24T02:45:44.572Z][DEBUG][T0][#0] lookup_inode: cwd: "/", path: "/etc/resolv.conf"
    [2024-07-24T02:45:44.573Z][DEBUG][T0][#0] convert_to_abs_path: cwd: "/", path: "/etc/resolv.conf"
    [2024-07-24T02:45:44.573Z][DEBUG][T0][#0] lookup_inode: cwd: "/", path: "/etc/hostname"
    [2024-07-24T02:45:44.573Z][DEBUG][T0][#0] convert_to_abs_path: cwd: "/", path: "/etc/hostname"
    [2024-07-24T02:45:44.573Z][DEBUG][T0][#0] lookup_inode: cwd: "/", path: "/etc/hosts"
    [2024-07-24T02:45:44.573Z][DEBUG][T0][#0] convert_to_abs_path: cwd: "/", path: "/etc/hosts"
    [2024-07-24T02:45:44.573Z][TRACE][T0][#0] env_checked from env untrusted: []
    [2024-07-24T02:45:44.573Z][TRACE][T0][#0] env_merged = ["OCCLUM=yes"]  (default env and untrusted env)
    [2024-07-24T02:45:44.573Z][DEBUG][T0][#0] lookup_inode: cwd: "/", path: "/bin/init"
    [2024-07-24T02:45:44.573Z][DEBUG][T0][#0] convert_to_abs_path: cwd: "/", path: "/bin/init"
    [2024-07-24T02:45:44.574Z][TRACE][T0][#0] PT_INTERP offset = 568, count = 25
    [2024-07-24T02:45:44.574Z][TRACE][T0][#0] interpreter = Some("/lib/ld-musl-x86_64.so.1")
    [2024-07-24T02:45:44.574Z][TRACE][T0][#0] ldso_path = "/lib/ld-musl-x86_64.so.1"
    [2024-07-24T02:45:44.574Z][DEBUG][T0][#0] lookup_inode: cwd: "/", path: "/lib/ld-musl-x86_64.so.1"
    [2024-07-24T02:45:44.574Z][DEBUG][T0][#0] convert_to_abs_path: cwd: "/", path: "/lib/ld-musl-x86_64.so.1"
    [2024-07-24T02:45:44.574Z][TRACE][T0][#0] interpreter = None
    [2024-07-24T02:45:44.574Z][DEBUG][T0][#0] allocated rsrv addr is 0x7f87063ad000, len is 0x12c00000
    [2024-07-24T02:45:44.574Z][TRACE][T0][#0] find free range, free list = [VMRange { start: 0x7f87063ad000, end: 0x7f8718fad000, size: 0x12c00000 }]
    [2024-07-24T02:45:44.574Z][TRACE][T0][#0] after find free range, free list = [VMRange { start: 0x7f87063ad000, end: 0x7f8706400000, size: 0x53000 }, VMRange { start: 0x7f8706800000, end: 0x7f8718fad000, size: 0x127ad000 }]
    [2024-07-24T02:45:44.574Z][TRACE][T0][#0] allocate a new single vma chunk: range = VMRange { start: 0x7f8706400000, end: 0x7f8706800000, size: 0x400000 }, Single VMA chunk: SgxMutex { data: VMArea { range: VMRange { start: 0x7f8706400000, end: 0x7f8706800000, size: 0x400000 }, perms: READ | WRITE | EXEC | DEFAULT | ALL, file_backed: Some(FileBacked { file: INodeFile { inode: ???, abs_path: /bin/init, pos: 0, access_mode: O_RDONLY, status_flags: 0o0 }, offset: 0, write_back: false }), pid: 0 }, poisoned: false, .. }
    [2024-07-24T02:45:44.576Z][TRACE][T0][#0] elf range = VMRange { start: 0x7f8706400000, end: 0x7f8706800000, size: 0x400000 }
    [2024-07-24T02:45:44.576Z][TRACE][T0][#0] find free range, free list = [VMRange { start: 0x7f87063ad000, end: 0x7f8706400000, size: 0x53000 }, VMRange { start: 0x7f8706800000, end: 0x7f8718fad000, size: 0x127ad000 }]
    [2024-07-24T02:45:44.576Z][TRACE][T0][#0] after find free range, free list = [VMRange { start: 0x7f87063ad000, end: 0x7f8706400000, size: 0x53000 }, VMRange { start: 0x7f8706c00000, end: 0x7f8718fad000, size: 0x123ad000 }]
    [2024-07-24T02:45:44.576Z][TRACE][T0][#0] allocate a new single vma chunk: range = VMRange { start: 0x7f8706800000, end: 0x7f8706c00000, size: 0x400000 }, Single VMA chunk: SgxMutex { data: VMArea { range: VMRange { start: 0x7f8706800000, end: 0x7f8706c00000, size: 0x400000 }, perms: READ | WRITE | EXEC | DEFAULT | ALL, file_backed: Some(FileBacked { file: INodeFile { inode: ???, abs_path: /lib/ld-musl-x86_64.so.1, pos: 0, access_mode: O_RDONLY, status_flags: 0o0 }, offset: 0, write_back: false }), pid: 0 }, poisoned: false, .. }
    [2024-07-24T02:45:44.578Z][TRACE][T0][#0] elf range = VMRange { start: 0x7f8706800000, end: 0x7f8706c00000, size: 0x400000 }
    [2024-07-24T02:45:44.578Z][TRACE][T0][#0] find free range, free list = [VMRange { start: 0x7f87063ad000, end: 0x7f8706400000, size: 0x53000 }, VMRange { start: 0x7f8706c00000, end: 0x7f8718fad000, size: 0x123ad000 }]
    [2024-07-24T02:45:44.578Z][TRACE][T0][#0] after find free range, free list = [VMRange { start: 0x7f87063ad000, end: 0x7f8706400000, size: 0x53000 }, VMRange { start: 0x7f8708c00000, end: 0x7f8718fad000, size: 0x103ad000 }]
    [2024-07-24T02:45:44.578Z][TRACE][T0][#0] allocate a new single vma chunk: range = VMRange { start: 0x7f8706c00000, end: 0x7f8708c00000, size: 0x2000000 }, Single VMA chunk: SgxMutex { data: VMArea { range: VMRange { start: 0x7f8706c00000, end: 0x7f8708c00000, size: 0x2000000 }, perms: READ | WRITE | DEFAULT, file_backed: None, pid: 0 }, poisoned: false, .. }
    [2024-07-24T02:45:44.578Z][TRACE][T0][#0] heap range = VMRange { start: 0x7f8706c00000, end: 0x7f8708c00000, size: 0x2000000 }
    [2024-07-24T02:45:44.578Z][TRACE][T0][#0] find free range, free list = [VMRange { start: 0x7f87063ad000, end: 0x7f8706400000, size: 0x53000 }, VMRange { start: 0x7f8708c00000, end: 0x7f8718fad000, size: 0x103ad000 }]
    [2024-07-24T02:45:44.578Z][TRACE][T0][#0] after find free range, free list = [VMRange { start: 0x7f87063ad000, end: 0x7f8706400000, size: 0x53000 }, VMRange { start: 0x7f8709000000, end: 0x7f8718fad000, size: 0xffad000 }]
    [2024-07-24T02:45:44.578Z][TRACE][T0][#0] allocate a new single vma chunk: range = VMRange { start: 0x7f8708c00000, end: 0x7f8709000000, size: 0x400000 }, Single VMA chunk: SgxMutex { data: VMArea { range: VMRange { start: 0x7f8708c00000, end: 0x7f8709000000, size: 0x400000 }, perms: READ | WRITE | DEFAULT, file_backed: None, pid: 0 }, poisoned: false, .. }
    [2024-07-24T02:45:44.578Z][TRACE][T0][#0] stack range = VMRange { start: 0x7f8708c00000, end: 0x7f8709000000, size: 0x400000 }
    [2024-07-24T02:45:44.578Z][TRACE][T0][#0] new process sigmask = SigSet { [] }
    [2024-07-24T02:45:44.578Z][TRACE][T0][#0] new process sig_dispositions = SigDispositions (only none-default is shown) {}
    [2024-07-24T02:45:44.578Z][DEBUG][T0][#0] process group:ProcessGrp { inner: RwLock { inner: RwLockInner { status: AtomicRwLockStatus(0), rw_waiters: 0 }, data: PgrpInner { pgid: 1, process_group: {1: Process { pid: 1, exec_path: "/bin/init", ppid: Some(0), pgid: 1, inner: ProcessInner::Live { status: Running, child_pids: [], thread_tids: [1] } }}, leader_process: Some(Process { pid: 1, exec_path: "/bin/init", ppid: Some(0), pgid: 1, inner: ProcessInner::Live { status: Running, child_pids: [], thread_tids: [1] } }) } } }
    [2024-07-24T02:45:44.578Z][DEBUG][T0][#0] non idle process all pgrp: [ProcessGrp { inner: RwLock { inner: RwLockInner { status: AtomicRwLockStatus(0), rw_waiters: 0 }, data: PgrpInner { pgid: 0, process_group: {}, leader_process: Some(Process { pid: 0, exec_path: "", ppid: None, pgid: 0, inner: ProcessInner::Live { status: Running, child_pids: [1], thread_tids: [0] } }) } } }, ProcessGrp { inner: RwLock { inner: RwLockInner { status: AtomicRwLockStatus(0), rw_waiters: 0 }, data: PgrpInner { pgid: 1, process_group: {1: Process { pid: 1, exec_path: "/bin/init", ppid: Some(0), pgid: 1, inner: ProcessInner::Live { status: Running, child_pids: [], thread_tids: [1] } }}, leader_process: Some(Process { pid: 1, exec_path: "/bin/init", ppid: Some(0), pgid: 1, inner: ProcessInner::Live { status: Running, child_pids: [], thread_tids: [1] } }) } } }]
    [2024-07-24T02:45:44.578Z][ INFO][T0][#0] Process created: elf = /bin/init, pid = 1
bronzeMe commented 3 months ago
Bonjourz commented 3 months ago

@bronzeMe Cool! It seems that Occlum needs some modifications to clearly show the error message. We will fix it in the future.

Bonjourz commented 3 months ago

Close it since it is solved.