x86/kvm: Fix SEV check in sev_map_percpu_data()

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: 4d96f91091 ("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>
This commit is contained in:
Kirill A. Shutemov 2024-01-24 15:03:17 +02:00 committed by Paolo Bonzini
parent d52734d00b
commit a9ef277488

View File

@ -434,7 +434,8 @@ static void __init sev_map_percpu_data(void)
{ {
int cpu; 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; return;
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {