Closed msft-jlange closed 1 month ago
@peterfang This should resolve the challenges you had in implementing validation for the TDP platform.
@peterfang This should resolve the challenges you had in implementing validation for the TDP platform.
Thanks! Will update my stage2 PR after this is merged.
These changes break boot for me, I need to investigate before this can be merged.
This breaks the boot for me too. I'll help investigate.
I've started on this as well. AFAICT the self-map isn't set up properly for some (or all?) page tables, so the lookups fail. AFAICT the self-map sometimes points to random garbage, I'm not yet sure why.
I've fixed the PR. There were two problems: neither the self-map PML4E nor the level 1/2/3 page table hierarchy logic would set the C-bit in any of those entries. With a self-map, every intermediate entry can be treated like a PTE, so all of them need to set the C-bit. The Hyper-V and TDX environments both use vTOM (or a vTOM equivalent) which is why no problem was observed in either environment. I've updated the PR to set the C-bit correctly in non-vTOM environments and everything appears to work now.
BTW, the reason the failures appeared to be so random is that with the C-bit clear, accesses through the self-map would result in reading ciphertext, which is random.
I've fixed the PR.
I've tested this new version and it works in my environment.
SNP validates pages by virtual address while TDX validates pages by physical address. This PR makes it possible for code to request validation changes based on either. This ensures that virtual mappings are not created unnecessarily on platforms that do not require them, and ensures that it can be possible to correctly obtain the physical address for validation in those cases where the caller has only a virtual address.