HyperEnclave / hyperenclave

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

How Could I find the trace of the `println!` and other `logging` functions? #7

Closed Unik-lif closed 9 months ago

Unik-lif commented 9 months ago

Hello! It seems that not all of the println! functions show up in dmesg. For example, when the hyperenclave initializes, I can only find message below:

[  240.645555] [0] Activating hypervisor on CPU 0...
[  240.645557] [1] Activating hypervisor on CPU 1...
[  240.645558] [2] Activating hypervisor on CPU 2...
[  240.645559] [3] Activating hypervisor on CPU 3...
[  240.645560] [4] Activating hypervisor on CPU 4...
[  240.645561] [5] Activating hypervisor on CPU 5...
[  240.645561] [6] Activating hypervisor on CPU 6...
[  240.645562] [7] Activating hypervisor on CPU 7...
[  240.645563] [8] Activating hypervisor on CPU 8...
[  240.645564] [9] Activating hypervisor on CPU 9...
[  240.645564] [10] Init HHBox log feature ok
[  240.645565] [10] Init HHBox crash feature ok
[  240.645565] [10] tpm_detect starting....
[  240.645565] [10] fake tpm is detected and initialized
[  240.645566] [10] FAKE TPM: tpm signing key pub x
[  240.645566] [10] C29974C9F1090FA4A10E9990620E91828B593A7211E2468450E3DC96DD5933FB
[  240.645567] [10] size= :0x20
[  240.645567] [10] FAKE TPM: tpm signing key pub y
[  240.645568] [10] 402206ECCC5479289F33668EAAB85527ABBBB9F7B41CEB71551027D57AF28267
[  240.645568] [10] size= :0x20
[  240.645568] [10] FAKE TPM: root secret is generated and sealed
[  240.645569] [10] FAKE TPM: hypervisor AK pub x=
[  240.645569] [10] 3D9BB7BA028C5F97AC5AB1619336D9ED23E86858DDBDC23B510D5F0EBA8FF338
[  240.645569] [10] size= :0x20
[  240.645570] [10] FAKE TPM: hypervisor AK pub y=
[  240.645570] [10] 0B28428BDA30B2800FCB032ABCED81071B5F0DCB1A02B22AFF56B7DD22E52522
[  240.645571] [10] size= :0x20
[  240.645571] [10] FAKE TPM: hash of he_ak_pub extended to PCR 13:
[  240.645571] [10] AAA056CA1F030B7BD6C4089C2AEEC36D01173B46E0FD2B4C1BD2C14649B66539
[  240.645572] [10] size= :0x20
[  240.645572] [10] HyperEnclave: root of trust initialized!
[  240.645572] [10] Activating hypervisor on CPU 10...
[  240.645573] [11] Activating hypervisor on CPU 11...
[  240.645574] [12] Activating hypervisor on CPU 12...
[  240.645575] [13] Activating hypervisor on CPU 13...
[  240.645575] [14] Activating hypervisor on CPU 14...
[  240.645576] [15] Activating hypervisor on CPU 15...

But in main.rs in hyperenclave source code, we got sth like this.

fn main(cpu_id: usize, linux_sp: usize) -> HvResult {
    let cpu_data = PerCpu::from_id_mut(cpu_id);
    let online_cpus = HvHeader::get().online_cpus as usize;
    let is_primary = ENTERED_CPUS.fetch_add(1, Ordering::SeqCst) == 0;
    wait_for_other_completed(&ENTERED_CPUS, online_cpus)?;
    println!(
        "{} CPU {} entered.",
        if is_primary { "Primary" } else { "Secondary" },
        cpu_id
    );

    if is_primary {
        primary_init_early()?;
    } else {
        wait_for_other_completed(&INIT_EARLY_OK, 1)?;
    }

    cpu_data.init(cpu_id, linux_sp, &cell::ROOT_CELL)?;
    println!("CPU {} init OK.", cpu_id);
    INITED_CPUS.fetch_add(1, Ordering::SeqCst);
    wait_for_other_completed(&INITED_CPUS, online_cpus)?;

    if is_primary {
        primary_init_late()?;
    } else {
        wait_for_other_completed(&INIT_LATE_OK, 1)?;
    }

    cpu_data.activate_vmm()
}

Basically the println! function in line 6 and line 19 didn't show up in dmesg log, while in the log the message Activating hypervisor on CPU is printed out with the same function, that's a little strange: In fact, in Rust-Monitor, some of the function println! can show up in dmesg log while others not. So I wonder how can I get the full log of Rust-Monitor?

I've read little code and found the println! is composed by functions concerning serial port, so will using serial port to get the log might be a choice? If so, could you please tell me whether I can get full log of Rust-Monitor via this? It seems that this is not the reason.

Looking forward to your reply~

Unik-lif commented 9 months ago

Got the answer from atomic variable INIT_HHBOX_LOG_OK, close this issue here. Sorry for my careless.