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

stage1: Rustify stage1 and update IGVM VTOM on TDP platforms #517

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

Conversation

peterfang
Copy link
Contributor

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.

@peterfang
Copy link
Contributor Author

This fails CI as stage1/stage1.o and stage1/reset.o no longer exist.

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.

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.

Makefile Outdated Show resolved Hide resolved
@joergroedel joergroedel added the in-review PR is under active review and not yet approved label Nov 15, 2024
@peterfang
Copy link
Contributor Author

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.

Hi Joerg, I sidestepped the ld issue on the CI system using --emit=obj -C linker=/usr/bin/true. It should work as expected now.

@peterfang peterfang force-pushed the stage1-vtom branch 3 times, most recently from 87814a6 to bcf1823 Compare November 22, 2024 10:20
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]>
Run make with "RELEASE=1" when building a release image.

Signed-off-by: Peter Fang <[email protected]>
Move stage1/*.S to a Rust crate. This allows for better interfacing with
other crates and reduces the amount of hard-coding and chances of
breakage.

Replace label-based relative addressing with raw pointer arithmetics to
avoid the "relocation truncated to fit" errors caused by the use of
relocation type R_X86_64_32S in 32-bit code.

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]>
Turn numerous stage2 parameters into constants and use them in
igvmbuilder/stage1/stage2 code. This allows for better stage2
configuration and creates necessary dependencies among these components
to reduce the possibility of breakage when there's a change in stage2.

Signed-off-by: Peter Fang <[email protected]>
Stage2 has gotten larger in size so increase the size of the stage2 area
to 800K (0x808000 - 0x8D0000).

Also, do sanity check in stage1 to make sure the stage2 image size
doesn't exceed 800K when loading stage2.

The memory regions are still hard-coded in gen_meta.c. This can be
tackled in the future if we decide to export these Rust constants.

Signed-off-by: Peter Fang <[email protected]>
When loading stage2 in stage1, make sure the amount of data pushed down
the stage2 stack matches the size of Stage2LaunchInfo.

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. Crash the system if this is the
case.

Signed-off-by: Peter Fang <[email protected]>
stage1/*.S no longer exists. Update CI to build the object files for
svsm.bin & stage1-trampoline.bin instead.

Add a new clippy job for stage1 as well.

Signed-off-by: Peter Fang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-review PR is under active review and not yet approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants