Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KVM, x86/mmu: Support TDX private mapping for TDP MMU
Frame in TDX private mapping support to support running TD with TDP MMU. Similar to legacy MMU, use private mapping related kvm_x86_ops hooks in __handle_changed_spte()/handle_removed_tdp_mmu_page() to support creating/removing private mapping. And support temporarily blocking private mapping upon receiving MMU notifier and later on unblocking it upon EPT violation, rather than completely removing the private page, because currently page migration for the private page is not supported, therefore the page cannot be removed from TD upon MMU notifier. Similar to legacy MMU, zap aliasing mapping (truly remove the page) upon EPT violation. And only the leaf page is zapped, but not intermediate page tables. Support 4K page only at this stage. 2M page support can be done in future patches. A key change to TDP MMU to support the TDX guest is, the read_lock() is changed to write_lock() for page fault on private GPA in direct_page_fault(), while for fault on shared GPA, read_lock() is still used. This is because for TD guest, at a given time for given GFN, only one type of mapping (either private, or shared) can be valid, but not both, otherwise it may cause machine check and data loss. As a result, aliasing mapping is zapped in TDP MMU fault handler. In this case, running multiple fault threads with both private and shared addresses concurrently may end up with having both private and shared mapping for given GPN. Consider the below case: vcpu 0 is accessing using private GPA, and vcpu 1 is accessing the shared GPA (i.e. right after MAP_GPA). vcpu 0 vcpu 1 (fault with private GPA) (fault with shared GPA) zap shared mapping zap private mapping setup shared mapping setup private mapping This may end up with having both private and shared mappings. Perhaps it is arguable whether the above case is valid, but for security, just don't allow running multiple fault threads concurrently. Signed-off-by: Kai Huang <kai.huang@intel.com> Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
- Loading branch information
Showing
5 changed files
with
569 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.