summaryrefslogtreecommitdiff
path: root/arch/x86/include/asm/cpuid.h
diff options
context:
space:
mode:
authorMichael Roth <michael.roth@amd.com>2022-02-24 19:56:10 +0300
committerBorislav Petkov <bp@suse.de>2022-04-07 17:47:11 +0300
commitb66370db9a90b3fa4c4a1a732af3e7e38d6d4c7c (patch)
treeb520b988f3441a2bb3822bcd61c5ce2d334c06ed /arch/x86/include/asm/cpuid.h
parent5ea98e01ab524cbc53dad8aebd27b434ebe5d074 (diff)
downloadlinux-b66370db9a90b3fa4c4a1a732af3e7e38d6d4c7c.tar.xz
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@amd.com> Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Venu Busireddy <venu.busireddy@oracle.com> Link: https://lore.kernel.org/r/20220307213356.2797205-31-brijesh.singh@amd.com
Diffstat (limited to 'arch/x86/include/asm/cpuid.h')
-rw-r--r--arch/x86/include/asm/cpuid.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/arch/x86/include/asm/cpuid.h b/arch/x86/include/asm/cpuid.h
new file mode 100644
index 000000000000..70b2db18165e
--- /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 */