Skip to content

Commit

Permalink
x86/kvm: Fix SEV check in sev_map_percpu_data()
Browse files Browse the repository at this point in the history
The function sev_map_percpu_data() checks if it is running on an SEV
platform by checking the CC_ATTR_GUEST_MEM_ENCRYPT attribute. However,
this attribute is also defined for TDX.

To avoid false positives, add a cc_vendor check.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Fixes: 4d96f91 ("x86/sev: Replace occurrences of sev_active() with cc_platform_has()")
Suggested-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: David Rientjes <rientjes@google.com>
Message-Id: <20240124130317.495519-1-kirill.shutemov@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Kirill A. Shutemov authored and Paolo Bonzini committed Jan 31, 2024
1 parent d52734d commit a9ef277
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/x86/kernel/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ static void __init sev_map_percpu_data(void)
{
int cpu;

if (!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
if (cc_vendor != CC_VENDOR_AMD ||
!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
return;

for_each_possible_cpu(cpu) {
Expand Down

0 comments on commit a9ef277

Please sign in to comment.