[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <164940893321.389.1933444875252437895.tip-bot2@tip-bot2>
Date: Fri, 08 Apr 2022 09:08:53 -0000
From: "tip-bot2 for Michael Roth" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Michael Roth <michael.roth@....com>,
Brijesh Singh <brijesh.singh@....com>,
Borislav Petkov <bp@...e.de>,
Venu Busireddy <venu.busireddy@...cle.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: x86/sev] KVM: x86: Move lookup of indexed CPUID leafs to helper
The following commit has been merged into the x86/sev branch of tip:
Commit-ID: b66370db9a90b3fa4c4a1a732af3e7e38d6d4c7c
Gitweb: https://git.kernel.org/tip/b66370db9a90b3fa4c4a1a732af3e7e38d6d4c7c
Author: Michael Roth <michael.roth@....com>
AuthorDate: Thu, 24 Feb 2022 10:56:10 -06:00
Committer: Borislav Petkov <bp@...e.de>
CommitterDate: Thu, 07 Apr 2022 16:47:11 +02:00
KVM: x86: Move lookup of indexed CPUID leafs to helper
Determining which CPUID leafs have significant ECX/index values is
also needed by guest kernel code when doing SEV-SNP-validated CPUID
lookups. Move this to common code to keep future updates in sync.
Signed-off-by: Michael Roth <michael.roth@....com>
Signed-off-by: Brijesh Singh <brijesh.singh@....com>
Signed-off-by: Borislav Petkov <bp@...e.de>
Reviewed-by: Venu Busireddy <venu.busireddy@...cle.com>
Link: https://lore.kernel.org/r/20220307213356.2797205-31-brijesh.singh@amd.com
---
arch/x86/include/asm/cpuid.h | 34 ++++++++++++++++++++++++++++++++++
arch/x86/kvm/cpuid.c | 19 ++-----------------
2 files changed, 36 insertions(+), 17 deletions(-)
create mode 100644 arch/x86/include/asm/cpuid.h
diff --git a/arch/x86/include/asm/cpuid.h b/arch/x86/include/asm/cpuid.h
new file mode 100644
index 0000000..70b2db1
--- /dev/null
+++ b/arch/x86/include/asm/cpuid.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * CPUID-related helpers/definitions
+ *
+ * Derived from arch/x86/kvm/cpuid.c
+ */
+
+#ifndef _ASM_X86_CPUID_H
+#define _ASM_X86_CPUID_H
+
+static __always_inline bool cpuid_function_is_indexed(u32 function)
+{
+ switch (function) {
+ case 4:
+ case 7:
+ case 0xb:
+ case 0xd:
+ case 0xf:
+ case 0x10:
+ case 0x12:
+ case 0x14:
+ case 0x17:
+ case 0x18:
+ case 0x1d:
+ case 0x1e:
+ case 0x1f:
+ case 0x8000001d:
+ return true;
+ }
+
+ return false;
+}
+
+#endif /* _ASM_X86_CPUID_H */
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index b24ca7f..4b62d80 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -19,6 +19,7 @@
#include <asm/user.h>
#include <asm/fpu/xstate.h>
#include <asm/sgx.h>
+#include <asm/cpuid.h>
#include "cpuid.h"
#include "lapic.h"
#include "mmu.h"
@@ -744,24 +745,8 @@ static struct kvm_cpuid_entry2 *do_host_cpuid(struct kvm_cpuid_array *array,
cpuid_count(entry->function, entry->index,
&entry->eax, &entry->ebx, &entry->ecx, &entry->edx);
- switch (function) {
- case 4:
- case 7:
- case 0xb:
- case 0xd:
- case 0xf:
- case 0x10:
- case 0x12:
- case 0x14:
- case 0x17:
- case 0x18:
- case 0x1d:
- case 0x1e:
- case 0x1f:
- case 0x8000001d:
+ if (cpuid_function_is_indexed(function))
entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
- break;
- }
return entry;
}
Powered by blists - more mailing lists