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

platform: fix page validation issues #512

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

msft-jlange
Copy link
Contributor

Validating pages by virtual address may encounter a large span that is backed by 4 KB pages instead of 2 MB pages. If a span is mapped by 4 KB pages, it must always be validated as 4 KB pages regardless of the size and alignment of the virtual address range.

@joergroedel
Copy link
Member

This causes a boot failure for me when launching the guest firmware:

[SVSM] Launching Firmware
[SVSM] Launching request-processing task on CPU 0
[SVSM] Failed to launch /init
KVM: unknown exit reason 24
EAX=00000000 EBX=00000000 ECX=00000000 EDX=00000000
ESI=00000000 EDI=00000000 EBP=00000000 ESP=00000000
EIP=00000000 EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0000 00000000 00000000 00000000
CS =0000 00000000 00000000 00000000
SS =0000 00000000 00000000 00000000
DS =0000 00000000 00000000 00000000
FS =0000 00000000 00000000 00000000
GS =0000 00000000 00000000 00000000
LDT=0000 00000000 00000000 00000000
TR =0000 00000000 00000000 00000000
GDT=     0000000000000000 00000000
IDT=     0000000000000000 00000000
CR0=80000033 CR2=0000000000000000 CR3=0000000000000000 CR4=00000668
DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 DR3=0000000000000000 
DR6=0000000000000000 DR7=0000000000000000
EFER=0000000000000500
Code=<??> ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??

Please let me know if you need help debugging this further.

The function `validate_virtual_page_range` is expected only to validate
those addresses specified.  If the base or end of the address range
happens to fall within the middle of a 2 MB page, then the validation
must be constrained only to those 4 KB pagees that fall within the
requested range and must not include any portion of the 2 MB page that
falls outside of that range.

In addition, page invalidation is not expected to modify page contents.

Signed-off-by: Jon Lange <[email protected]>
The behavior of `pvalidate` on a 2 MB page is undefined if the
underlying virtual address mapping is a 4 KB mapping.  The instruction
requires that the virtual address be appropriately aligned, but if the
virtual address is backed by 4 KB pages, the physical address may not be
aligned, and the resulting behavior is not defined.  To avoid problems,
ensure that pvalidate is only attempted on a 2 MB page if the underlying
mapping is a 2 MB mapping.

Signed-off-by: Jon Lange <[email protected]>
@msft-jlange
Copy link
Contributor Author

This causes a boot failure for me when launching the guest firmware:

I see the problem. The logic was entirely wrong (both for the TDP and SNP fixes) but now both of them should work correctly.

@joergroedel
Copy link
Member

I see the problem. The logic was entirely wrong (both for the TDP and SNP fixes) but now both of them should work correctly.

Tested again and it works now. Thanks for fixing this quickly.

@joergroedel joergroedel merged commit d60a5c5 into coconut-svsm:main Nov 12, 2024
3 checks passed
@msft-jlange msft-jlange deleted the page_validate branch November 12, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants