Add AMD Secure Nested Paging (SEV-SNP)
Get series with b4
b4 am [email protected]Versions newest first
- v6 Latest49 patches 253 repliesIn review
Changes in v6 from the cover letter
* Rebase to 5.18.0-rc3, these patches are just for review so they are based on 5.18.0-rc3 linux-next release as this included the SNP guest patches which weren't in mainline then.
* Using kvm_write_guest() to sync the GHCB scratch buffer can fail due to host mapping being 2M, but RMP being 4K. The page fault handling in do_user_addr_fault() fails to split the 2M page to handle RMP fault due it being called in a non-preemptible context. Instead, use the already kernel mapped ghcb to sync the scratch buffer when the scratch buffer is contained within the GHCB.
* warn and retry failed rmpupdates.
* Fix for stale per-cpu pointer due to cond_resched due during ghcb mapping.
* Multiple fixes for SEV-SNP AP Creation.
* Remove SRCU to synchronize the PSC and gfn mapping replacing it with a spinlock.
* Remove generic post_{map,unmap}_gfn ops, need to revisit these later with respect to UPM support.
* Fix kvm_mmu_get_tdp_walk() to handle "suspicious RCU usage" warning.
* Fix sev_snp_init() to do WBINVD/DF_FLUSH command after SNP_INIT command has been issued.
* Fix sev_free_vcpu() to flush the VMSA page after it is transitioned back to hypervisor state and restored in the kernel direct map.
Patches in v6 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/49 | x86/cpufeatures: Add SEV-SNP CPU featurearch/ arch/ tools/ | +4 | 1 reply | |
| 2/49 | iommu/amd: Introduce function to check SEV-SNP supportdrivers/ include/ | +39 | 12 replies | |
| 3/49 | x86/sev: Add the host SEV-SNP initialization supportarch/ arch/ arch/ | +157 | 8 replies | |
| 4/49 | x86/sev: set SYSCFG.MFMDarch/ arch/ | +27 | 3 replies | |
| 5/49 | x86/sev: Add RMP entry lookup helpersarch/ arch/ include/ | +100 | 27 replies | |
| 6/49 | x86/sev: Add helper functions for RMPUPDATE and PSMASH instructionarch/ arch/ | +83 | 17 replies | |
| 7/49 | x86/sev: Invalid pages from direct map when adding it to RMP tablearch/ | +60 | 15 replies | |
| 8/49 | x86/traps: Define RMP violation #PF error codearch/ arch/ | +12 | 1 reply | |
| 9/49 | x86/fault: Add support to handle the RMP fault for user addressarch/ include/ include/ +1 more | +84 | 31 replies | |
| 10/49 | x86/fault: Add support to dump RMP entry on faultarch/ arch/ arch/ +1 more | +65 | 4 replies | |
| 11/49 | crypto:ccp: Define the SEV-SNP commandsdrivers/ include/ include/ | +278 | 3 replies | |
| 12/49 | crypto: ccp: Add support to initialize the AMD-SP for SEV-SNPdrivers/ drivers/ include/ | +139 | 8 replies | |
| 13/49 | crypto:ccp: Provide APIs to issue SEV-SNP commandsdrivers/ include/ | +97 | 12 replies | |
| 14/49 | crypto: ccp: Handle the legacy TMR allocation when SNP is enableddrivers/ include/ | +178 | 41 replies | |
| 15/49 | crypto: ccp: Handle the legacy SEV command when SNP is enableddrivers/ drivers/ | +348 | 0 replies | |
| 16/49 | crypto: ccp: Add the SNP_PLATFORM_STATUS commandDocumentation/ drivers/ include/ | +73 | 0 replies | |
| 17/49 | crypto: ccp: Add the SNP_{SET,GET}_EXT_CONFIG commandDocumentation/ drivers/ drivers/ +1 more | +162 | 6 replies | |
| 18/49 | crypto: ccp: Provide APIs to query extended attestation reportdrivers/ include/ | +67 | 2 replies | |
| 19/49 | KVM: SVM: Add support to handle AP reset MSR protocolarch/ arch/ arch/ | +51 | 0 replies | |
| 20/49 | KVM: SVM: Provide the Hypervisor Feature support VMGEXITarch/ arch/ arch/ | +18 | 0 replies | |
| 21/49 | KVM: SVM: Make AVIC backing, VMSA and VMCB memory allocation SNP safearch/ arch/ arch/ +3 more | +57 | 1 reply | |
| 22/49 | KVM: SVM: Add initial SEV-SNP supportarch/ arch/ | +17 | 0 replies | |
| 23/49 | KVM: SVM: Add KVM_SNP_INIT commandDocumentation/ arch/ arch/ +2 more | +87 | 0 replies | |
| 24/49 | KVM: SVM: Add KVM_SEV_SNP_LAUNCH_START commandDocumentation/ arch/ arch/ +1 more | +147 | 3 replies | |
| 25/49 | KVM: SVM: Disallow registering memory range from HugeTLB for SNP guestarch/ | +37 | 1 reply | |
| 26/49 | KVM: SVM: Add KVM_SEV_SNP_LAUNCH_UPDATE commandDocumentation/ arch/ include/ | +235 | 5 replies | |
| 27/49 | KVM: SVM: Mark the private vma unmerable for SEV-SNP guestsarch/ | +32 | 2 replies | |
| 28/49 | KVM: SVM: Add KVM_SEV_SNP_LAUNCH_FINISH commandDocumentation/ arch/ include/ | +155 | 12 replies | |
| 29/49 | KVM: X86: Keep the NPT and RMP page level in syncarch/ arch/ arch/ +3 more | +55 | 1 reply | |
| 30/49 | KVM: x86/mmu: Introduce kvm_mmu_map_tdp_page() for use by TDX and SNParch/ arch/ | +54 | 0 replies | |
| 31/49 | KVM: x86: Introduce kvm_mmu_get_tdp_walk() for SEV-SNP usearch/ arch/ | +35 | 1 reply | |
| 32/49 | KVM: x86: Define RMP page fault error bits for #NPFarch/ | +8 | 0 replies | |
| 33/49 | KVM: x86: Update page-fault trace to log full 64-bit error codearch/ | +3 | 1 reply | |
| 34/49 | KVM: SVM: Do not use long-lived GHCB map while setting scratch areaarch/ arch/ | +36 | 0 replies | |
| 35/49 | KVM: SVM: Remove the long-lived GHCB host maparch/ arch/ arch/ | +111 | 6 replies | |
| 36/49 | KVM: SVM: Add support to handle GHCB GPA register VMGEXITarch/ arch/ arch/ | +42 | 1 reply | |
| 37/49 | KVM: SVM: Add support to handle MSR based Page State Change VMGEXITarch/ arch/ arch/ +1 more | +241 | 9 replies | |
| 38/49 | KVM: SVM: Add support to handle Page State Change VMGEXITarch/ arch/ | +81 | 0 replies | |
| 39/49 | KVM: SVM: Introduce ops for the post gfn map and unmaparch/ arch/ arch/ +2 more | +64 | 4 replies | |
| 40/49 | KVM: x86: Export the kvm_zap_gfn_range() for the SNP usearch/ arch/ arch/ | +3 | 0 replies | |
| 41/49 | KVM: SVM: Add support to handle the RMP nested page faultarch/ arch/ | +86 | 8 replies | |
| 42/49 | KVM: SVM: Provide support for SNP_GUEST_REQUEST NAE eventarch/ arch/ | +192 | 8 replies | |
| 43/49 | KVM: SVM: Use a VMSA physical address variable for populating VMCBarch/ arch/ arch/ | +11 | 0 replies | |
| 44/49 | KVM: SVM: Support SEV-SNP AP Creation NAE eventarch/ arch/ arch/ +4 more | +221 | 0 replies | |
| 45/49 | KVM: SVM: Add module parameter to enable the SEV-SNParch/ arch/ | +5 | 0 replies | |
| 46/49 | ccp: add support to decrypt the pagedrivers/ include/ | +33 | 0 replies | |
| 47/49 | *fix for stale per-cpu pointer due to cond_resched during ghcb mappingarch/ | +5 | 2 replies | |
| 48/49 | *debug: warn and retry failed rmpupdatesarch/ | +15 | 0 replies | |
| 49/49 | KVM: SVM: Sync the GHCB scratch buffer using already mapped ghcbarch/ arch/ | +23 | 0 replies |
Reviews trailers per patch
None of the 49 patches has a Reviewed-by or Acked-by.
| Patch | Borislav Petkov |
|---|---|
| 1/49 | |
| 2/49 | |
| 3/49 | |
| 4/49 | |
| 5/49 | |
| 6/49 | |
| 7/49 | |
| 8/49 | |
| 9/49 | |
| 10/49 | |
| 11/49 | |
| 12/49 | |
| 13/49 | Improvements-by |
| 14/49 | |
| 15/49 | |
| 16/49 | |
| 17/49 | |
| 18/49 | |
| 19/49 | |
| 20/49 | |
| 21/49 | |
| 22/49 | |
| 23/49 | |
| 24/49 | |
| 25/49 | |
| 26/49 | |
| 27/49 | |
| 28/49 | |
| 29/49 | |
| 30/49 | |
| 31/49 | |
| 32/49 | |
| 33/49 | |
| 34/49 | |
| 35/49 | |
| 36/49 | |
| 37/49 | |
| 38/49 | |
| 39/49 | |
| 40/49 | |
| 41/49 | |
| 42/49 | |
| 43/49 | |
| 44/49 | |
| 45/49 | |
| 46/49 | |
| 47/49 | |
| 48/49 | |
| 49/49 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH Part2 v6 00/49] Add AMD Secure Nested Paging (SEV-SNP)
From: Ashish Kalra <[email protected]>
This part of the Secure Encrypted Paging (SEV-SNP) series focuses on the changes required in a host OS for SEV-SNP support. The series builds upon SEV-SNP Guest Support now part of mainline.
This series provides the basic building blocks to support booting the SEV-SNP VMs, it does not cover all the security enhancement introduced by the SEV-SNP such as interrupt protection.
The CCP driver is enhanced to provide new APIs that use the SEV-SNP specific commands defined in the SEV-SNP firmware specification. The KVM driver uses those APIs to create and managed the SEV-SNP guests.
The GHCB specification version 2 introduces new set of NAE's that is used by the SEV-SNP guest to communicate with the hypervisor. The series provides support to handle the following new NAE events:
- Register GHCB GPA
- Page State Change Request
- Hypevisor feature
- Guest message request
The RMP check is enforced as soon as SEV-SNP is enabled. Not every memory access requires an RMP check. In particular, the read accesses from the hypervisor do not require RMP checks because the data confidentiality is already protected via memory encryption. When hardware encounters an RMP checks failure, it raises a page-fault exception. If RMP check failure is due to the page-size mismatch, then split the large page to resolve the fault.
The series does not provide support for the interrupt security and migration and those feature will be added after the base support.
Please note that some areas, such as how private guest pages are managed/pinned/protected, are likely to change once Unmapped Private Memory support is further along in development/design and can be incorporated into this series. We are posting these patches without UPM support for now to hopefully get some review on other aspects of the series in the meantime.
Here is a link to latest UPM v6 patches:
https://lore.kernel.org/linux-mm/[email protected]/
A branch containing these patches is available here:
https://github.com/AMDESE/linux/tree/sev-snp-5.18-rc3-v3
Changes since v5:
* Rebase to 5.18.0-rc3, these patches are just for review so they are based on 5.18.0-rc3 linux-next release as this included the SNP guest patches which weren't in mainline then.
* Using kvm_write_guest() to sync the GHCB scratch buffer can fail due to host mapping being 2M, but RMP being 4K. The page fault handling in do_user_addr_fault() fails to split the 2M page to handle RMP fault due it being called in a non-preemptible context. Instead, use the already kernel mapped ghcb to sync the scratch buffer when the scratch buffer is contained within the GHCB.
* warn and retry failed rmpupdates.
* Fix for stale per-cpu pointer due to cond_resched due during ghcb mapping.
* Multiple fixes for SEV-SNP AP Creation.
* Remove SRCU to synchronize the PSC and gfn mapping replacing it with a spinlock.
* Remove generic post_{map,unmap}_gfn ops, need to revisit these later with respect to UPM support.
* Fix kvm_mmu_get_tdp_walk() to handle "suspicious RCU usage" warning.
* Fix sev_snp_init() to do WBINVD/DF_FLUSH command after SNP_INIT command has been issued.
* Fix sev_free_vcpu() to flush the VMSA page after it is transitioned back to hypervisor state and restored in the kernel direct map.
Changes since v4:
* Move the RMP entry definition to x86 specific header file.
* Move the dump RMP entry function to SEV specific file.
* Use BIT_ULL while defining the #PF bit fields.
* Add helper function to check the IOMMU support for SEV-SNP feature.
* Add helper functions for the page state transition.
* Map and unmap the pages from the direct map after page is added or removed in RMP table.
* Enforce the minimum SEV-SNP firmware version.
* Extend the LAUNCH_UPDATE to accept the base_gfn and remove the logic to calculate the gfn from the hva.
* Add a check in LAUNCH_UPDATE to ensure that all the pages are shared before calling the PSP.
* Mark the memory failure when failing to remove the page from the RMP table or clearing the immutable bit.
* Exclude the encrypted hva range from the KSM.
* Remove the gfn tracking during the kvm_gfn_map() and use SRCU to syncronize the PSC and gfn mapping.
* Allow PSC on the registered hva range only.
* Add support for the Preferred GPA VMGEXIT.
* Simplify the PSC handling routines.
* Use the static_call() for the newly added kvm_x86_ops.
* Remove the long-lived GHCB map.
* Move the snp enable module parameter to the end of the file.
* Remove the kvm_x86_op for the RMP fault handling. Call the fault handler directly from the #NPF interception.
Changes since v3:
* Add support for extended guest message request.
* Add ioctl to query the SNP Platform status.
* Add ioctl to get and set the SNP config.
* Add check to verify that memory reserved for the RMP covers the full system RAM.
* Start the SNP specific commands from 256 instead of 255.
* Multiple cleanup and fixes based on the review feedback.
Changes since v2:
* Add AP creation support.
* Drop the patch to handle the RMP fault for the kernel address.
* Add functions to track the write access from the hypervisor.
* Do not enable the SNP feature when IOMMU is disabled or is in passthrough mode.
* Dump the RMP entry on RMP violation for the debug.
* Shorten the GHCB macro names.
* Start the SNP_INIT command id from 255 to give some gap for the legacy SEV.
* Sync the header with the latest 0.9 SNP spec.
Changes since v1:
* Add AP reset MSR protocol VMGEXIT NAE.
* Add Hypervisor features VMGEXIT NAE.
* Move the RMP table initialization and RMPUPDATE/PSMASH helper in arch/x86/kernel/sev.c.
* Add support to map/unmap SEV legacy command buffer to firmware state when SNP is active.
* Enhance PSP driver to provide helper to allocate/free memory used for the firmware context page.
* Add support to handle RMP fault for the kernel address.
* Add support to handle GUEST_REQUEST NAE event for attestation.
* Rename RMP table lookup helper.
* Drop typedef from rmpentry struct definition.
* Drop SNP static key and use cpu_feature_enabled() to check whether SEV-SNP is active.
* Multiple cleanup/fixes to address Boris review feedback.
Ashish Kalra (1):
KVM: SVM: Sync the GHCB scratch buffer using already mapped ghcb
Brijesh Singh (42):
x86/cpufeatures: Add SEV-SNP CPU feature
iommu/amd: Introduce function to check SEV-SNP support x86/sev: Add the host SEV-SNP initialization support x86/sev: set SYSCFG.MFMD
x86/sev: Add RMP entry lookup helpers
x86/sev: Add helper functions for RMPUPDATE and PSMASH instruction x86/sev: Invalid pages from direct map when adding it to RMP table x86/traps: Define RMP violation #PF error code
x86/fault: Add support to handle the RMP fault for user address x86/fault: Add support to dump RMP entry on fault crypto:ccp: Define the SEV-SNP commands
crypto: ccp: Add support to initialize the AMD-SP for SEV-SNP crypto:ccp: Provide APIs to issue SEV-SNP commands
crypto: ccp: Handle the legacy TMR allocation when SNP is enabled
crypto: ccp: Handle the legacy SEV command when SNP is enabled
crypto: ccp: Add the SNP_PLATFORM_STATUS command
crypto: ccp: Add the SNP_{SET,GET}_EXT_CONFIG command
crypto: ccp: Provide APIs to query extended attestation report
KVM: SVM: Provide the Hypervisor Feature support VMGEXIT
KVM: SVM: Make AVIC backing, VMSA and VMCB memory allocation SNP safe
KVM: SVM: Add initial SEV-SNP support
KVM: SVM: Add KVM_SNP_INIT command
KVM: SVM: Add KVM_SEV_SNP_LAUNCH_START command
KVM: SVM: Disallow registering memory range from HugeTLB for SNP guest
KVM: SVM: Add KVM_SEV_SNP_LAUNCH_UPDATE command
KVM: SVM: Mark the private vma unmerable for SEV-SNP guests
KVM: SVM: Add KVM_SEV_SNP_LAUNCH_FINISH command
KVM: X86: Keep the NPT and RMP page level in sync
KVM: x86: Introduce kvm_mmu_get_tdp_walk() for SEV-SNP use
KVM: x86: Define RMP page fault error bits for #NPF
KVM: x86: Update page-fault trace to log full 64-bit error code
KVM: SVM: Do not use long-lived GHCB map while setting scratch area
KVM: SVM: Remove the long-lived GHCB host map
KVM: SVM: Add support to handle GHCB GPA register VMGEXIT
KVM: SVM: Add support to handle MSR based Page State Change VMGEXIT
KVM: SVM: Add support to handle Page State Change VMGEXIT
KVM: SVM: Introduce ops for the post gfn map and unmap
KVM: x86: Export the kvm_zap_gfn_range() for the SNP use
KVM: SVM: Add support to handle the RMP nested page fault
KVM: SVM: Provide support for SNP_GUEST_REQUEST NAE event
KVM: SVM: Add module parameter to enable the SEV-SNP
ccp: add support to decrypt the page
Michael Roth (2):
*fix for stale per-cpu pointer due to cond_resched during ghcb
mapping
*debug: warn and retry failed rmpupdates
Sean Christopherson (1):
KVM: x86/mmu: Introduce kvm_mmu_map_tdp_page() for use by TDX and SNP
Tom Lendacky (3):
KVM: SVM: Add support to handle AP reset MSR protocol
KVM: SVM: Use a VMSA physical address variable for populating VMCB
KVM: SVM: Support SEV-SNP AP Creation NAE event
Documentation/virt/coco/sevguest.rst | 54 + .../virt/kvm/x86/amd-memory-encryption.rst | 102 + arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/disabled-features.h | 8 +- arch/x86/include/asm/kvm-x86-ops.h | 2 + arch/x86/include/asm/kvm_host.h | 15 + arch/x86/include/asm/msr-index.h | 9 + arch/x86/include/asm/sev-common.h | 28 + arch/x86/include/asm/sev.h | 45 + arch/x86/include/asm/svm.h | 6 + arch/x86/include/asm/trap_pf.h | 18 +- arch/x86/kernel/cpu/amd.c | 3 +- arch/x86/kernel/sev.c | 400 ++++ arch/x86/kvm/lapic.c | 5 +- arch/x86/kvm/mmu.h | 7 +- arch/x86/kvm/mmu/mmu.c | 90 + arch/x86/kvm/svm/sev.c | 1703 ++++++++++++++++- arch/x86/kvm/svm/svm.c | 62 +- arch/x86/kvm/svm/svm.h | 75 +- arch/x86/kvm/trace.h | 40 +- arch/x86/kvm/x86.c | 10 +- arch/x86/mm/fault.c | 84 +- drivers/crypto/ccp/sev-dev.c | 908 ++++++++- drivers/crypto/ccp/sev-dev.h | 17 + drivers/iommu/amd/init.c | 30 + include/linux/iommu.h | 9 + include/linux/mm.h | 3 +- include/linux/mm_types.h | 3 + include/linux/psp-sev.h | 346 ++++ include/linux/sev.h | 32 + include/uapi/linux/kvm.h | 56 + include/uapi/linux/psp-sev.h | 60 + mm/memory.c | 13 + tools/arch/x86/include/asm/cpufeatures.h | 1 + 34 files changed, 4090 insertions(+), 155 deletions(-) create mode 100644 include/linux/sev.h
Signature · 1 line
2.25.1