-
Notifications
You must be signed in to change notification settings - Fork 41
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
stage1: Rustify stage1 and update IGVM VTOM on TDP platforms #517
base: main
Are you sure you want to change the base?
Conversation
Remove sections that don't exist in the object files. Signed-off-by: Peter Fang <[email protected]>
stage1/types.h is no longer in use so remove it. Signed-off-by: Peter Fang <[email protected]>
Move stage1/*.S to a Rust crate. This allows for better interfacing with other crates and reduces hard-coding and chances of breakage. Use i686 as the target platform to eliminate the "relocation truncated to fit" error from ld. This ensures the compiler doesn't use relocation types such as R_X86_64_32S and thus avoids truncation entirely. Stage1 is designed to do just enough work in protected mode in order to hand off to Stage2 so it doesn't operate beyond 32-bit mode. Signed-off-by: Peter Fang <[email protected]>
Only turn on zerocopy's alloc feature in kernel/Cargo.toml. This ensures bootlib can be used without requiring a global memory allocator. Signed-off-by: Peter Fang <[email protected]>
Take advantage of asm-const and derive addresses and offsets automatically. Signed-off-by: Peter Fang <[email protected]>
On TDP platforms, VTOM is always set to 0 initially. Its value can be derived during boot time by probing %ebx. This commit updates IgvmParamBlock.vtom in addition to Stage2LaunchInfo.vtom during IGVM boot. It ensures Stage2 & the SVSM kernel can use VTOM as expected. Signed-off-by: Peter Fang <[email protected]>
VTOM shall never be 0 on TDP platforms. Return an error if this is the case. Signed-off-by: Peter Fang <[email protected]>
This fails CI as stage1/stage1.o and stage1/reset.o no longer exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Peter,
I like this change, it will simplify the build process and allows more sharing of constants and code between the different stages.
Can you please adapt the CI files to make it pass with these changes and have a look at using the existing x86-64-unknown-none
target? I tried that already but ran into linker errors due to 32-bit relocations in 64-bit code. But maybe there is a way around that.
ln -sf svsm-kernel.elf bin/kernel.elf | ||
cc -c -DLOAD_STAGE2 -o $@ $< | ||
cargo rustc --target i686-unknown-linux-gnu --manifest-path stage1/Cargo.toml ${CARGO_ARGS} --features load-stage2 --bin stage1 -- -C panic=abort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you see a change of making this work with the x86-64-unknown-none
target? I'd like to avoid pull in another rust target into our build process.
Move stage1/*.S to a Rust crate. This allows for better interfacing with other crates and reduces hard-coding and chances of breakage.
Update IgvmParamBlock.vtom in addition to Stage2LaunchInfo.vtom during IGVM boot. It ensures Stage2 & the SVSM kernel can use VTOM as expected.