[Deepin-Kernel-SIG] [linux 6.6-y] [Upstream] [Intel] Intel: backport KVM Fix for Clearing SGX EDECCSSA to 6.6 #598
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When SGX EDECCSSA support was added to KVM in commit 16a7fe3 ("KVM/VMX: Allow exposing EDECCSSA user leaf function to KVM guest"), it forgot to clear the X86_FEATURE_SGX_EDECCSSA bit in KVM CPU caps when KVM SGX is disabled. Fix it.
Fixes: 16a7fe3 ("KVM/VMX: Allow exposing EDECCSSA user leaf function to KVM guest")
About the patches
The total patch number is 1:
7efb4d8 KVM: VMX: Also clear SGX EDECCSSA in KVM CPU caps when SGX is disabled
Tests
Build successfully for each commit
Kernel selftest - SGX: PASSED
cd tools/testing/selftests/sgx/
make
./test_sgx
Kernel selftest - SGX in VM: PASSED
Function test
Step 1. Original SGX EDECCSSA status in guest
[root@guest ~]# cpuid -1 -l 0x12
CPU:
Software Guard Extensions (SGX) capability (0x12/0):
SGX1 supported = true
SGX2 supported = true
SGX ENCLV E*VIRTCHILD, ESETCONTEXT = false
SGX ENCLS ETRACKC, ERDINFO, ELDBC, ELDUC = false
SGX ENCLU EVERIFYREPORT2 = false
SGX ENCLS EUPDATESVN = false
SGX ENCLU EDECCSSA = true
MISCSELECT.EXINFO supported: #PF & #GP = true
MISCSELECT.CPINFO supported: #CP = false
MaxEnclaveSize_Not64 (log2) = 0x1f (31)
MaxEnclaveSize_64 (log2) = 0x38 (56)
Step 2. Disable SGX in guest
root@KVM-host:
# rmmod kvm_intel# modprobe kvm_intel sgx=0root@KVM-host:
Step 3. The SGX EDECCSSA capability is cleared in KVM, then its status becomes false
[root@guest ~]# cpuid -1 -l 0x12
CPU:
Software Guard Extensions (SGX) capability (0x12/0):
SGX1 supported = false
SGX2 supported = false
SGX ENCLV E*VIRTCHILD, ESETCONTEXT = false
SGX ENCLS ETRACKC, ERDINFO, ELDBC, ELDUC = false
SGX ENCLU EVERIFYREPORT2 = false
SGX ENCLS EUPDATESVN = false
SGX ENCLU EDECCSSA = false
MISCSELECT.EXINFO supported: #PF & #GP = false
MISCSELECT.CPINFO supported: #CP = false
MaxEnclaveSize_Not64 (log2) = 0x0 (0)
MaxEnclaveSize_64 (log2) = 0x0 (0)
[root@TDX-guest ~]#
Known issue:
None
Default config change:
None
Link: https://gitee.com/OpenCloudOS/OpenCloudOS-Kernel/pulls/307
Upstream commit 7efb4d8 Conflict: none
When SGX EDECCSSA support was added to KVM in commit 16a7fe3 ("KVM/VMX: Allow exposing EDECCSSA user leaf function to KVM guest"), it forgot to clear the X86_FEATURE_SGX_EDECCSSA bit in KVM CPU caps when KVM SGX is disabled. Fix it.
Intel-SIG: commit 7efb4d8 KVM: VMX: Also clear SGX EDECCSSA in KVM CPU caps when SGX is disabled
Backport a SGX bug fix from upstream.
Fixes: 16a7fe3 ("KVM/VMX: Allow exposing EDECCSSA user leaf function to KVM guest")
Link: https://lore.kernel.org/r/[email protected]
[ Zhiquan Li: amend commit log ]
Summary by Sourcery
Bug Fixes: