Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for running native builds on qemu #614

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kraxel
Copy link

@kraxel kraxel commented Feb 12, 2025

No description provided.

@joergroedel joergroedel added the in-review PR is under active review and not yet approved label Feb 14, 2025
@msft-jlange msft-jlange added ready-to-merge PR is ready for merging into main branch and removed in-review PR is under active review and not yet approved labels Feb 18, 2025
Copy link
Member

@joergroedel joergroedel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kraxel , this PR is pretty amazing! Together with the QEMU PR I can boot a non-cc VM. Just a question, the last messages I see from SVSM are:

[SVSM] Invalidating boot region [0x0000000000000000-0x00000000000a0000]
[SVSM] Invalidating boot region [0x0000000000800000-0x00000000008c2000]
[SVSM] Invalidating boot region [0x00000000008c2000-0x0000000000b6a000]
[SVSM] Invalidating boot region [0x0000000000b6a000-0x0000000000b71000]
[SVSM] Invalidating boot region [0x0000000000b71000-0x0000000000b74000]
[SVSM] Size of OBJECT = 2104
[SVSM] Size of components in TPMT_SENSITIVE = 1384
[SVSM]     TPMI_ALG_PUBLIC                 2
[SVSM]     TPM2B_AUTH                      50
[SVSM]     TPM2B_DIGEST                    50
[SVSM]     TPMU_SENSITIVE_COMPOSITE        1282
[SVSM] VTPM: TPM 2.0 Reference Implementation initialized
[SVSM] [CPU 0] Virtual memory pages used: 0 * 4K, 0 * 2M

Is that expected?

Comment on lines 1 to 35
{
"igvm": {
"qemu": {
"output": "coconut-qemu.igvm",
"platforms": [
"snp",
"native"
],
"policy": "0x30000",
"measure": "print",
"check-kvm": true
}
},
"kernel": {
"svsm": {
"features": "nosmep,nosmap",
"binary": true
},
"stage2": {
"manifest": "kernel/Cargo.toml",
"binary": true,
"objcopy": "binary"
}
},
"firmware": {
"env": "FW_FILE"
},
"fs": {
"modules": {
"userinit": {
"path": "/init"
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for a separate target definition. Just add native as a platform to qemu-target.json.

Copy link
Author

@kraxel kraxel Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for a separate target definition. Just add native as a platform to qemu-target.json.

I also need "features": "nosmep,nosmap",, otherwise svsm goes panic on my intel box.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, okay, then a separate target definition makes sense. But can you name it around the feature difference and add all three targets (snp,tdp, native) to the existing qemu target and the one you add?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I only need to turn those features on the qemu cmd line to get things going without separate config.

@kraxel
Copy link
Author

kraxel commented Feb 20, 2025

[SVSM] VTPM: TPM 2.0 Reference Implementation initialized
[SVSM] [CPU 0] Virtual memory pages used: 0 * 4K, 0 * 2M


Is that expected?

Dunno, I'm new to svsm ...

For me it looks like this (without vtpm included, have some autoconf problems building it which I didn't investigate yet):

[SVSM] Invalidating boot region [0x00000000009fe000-0x0000000000a01000]
[SVSM] [CPU 0] Virtual memory pages used: 0 * 4K, 0 * 2M
[init] COCONUT-SVSM init process starting
[SVSM] Terminating current task, exit_code 0

What exactly you are concerned about? The zero virtual memory pages reported? Or init not printing something?

@joergroedel
Copy link
Member

[SVSM] Invalidating boot region [0x00000000009fe000-0x0000000000a01000]
[SVSM] [CPU 0] Virtual memory pages used: 0 * 4K, 0 * 2M
[init] COCONUT-SVSM init process starting
[SVSM] Terminating current task, exit_code 0

What exactly you are concerned about? The zero virtual memory pages reported? Or init not printing something?

Okay, for me it is not booting to user-space yet, but that is probably a problem with my configuration or an unrelated bug in the SVSM code-base. No reason to block this PR on it.

@kraxel
Copy link
Author

kraxel commented Feb 20, 2025

What exactly you are concerned about? The zero virtual memory pages reported? Or init not printing something?

Okay, for me it is not booting to user-space yet, but that is probably a problem with my configuration or an unrelated bug in the SVSM code-base. No reason to block this PR on it.

A possibly unrelated issue I see here is that it works for me only with tcg. With kvm it fails (stage2 pagefaults when loading the kernel elf binary to 0xffff000000000000) for some reason I've not tracked down yet.

igvm builder does not add pre-built page tables to native platform builds,
so when starting the cpu with paging enabled it triple-fails right away.

Fix that by including page tables for both VSM and NATIVE platforms.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Add 'native' to the list of platforms in configs/qemu-target.json

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge PR is ready for merging into main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants