]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
x86/cpu, kvm: Add support for CPUID_80000021_EAX
authorKim Phillips <kim.phillips@amd.com>
Tue, 10 Jan 2023 22:46:37 +0000 (16:46 -0600)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 4 Sep 2023 09:19:31 +0000 (11:19 +0200)
Add support for CPUID leaf 80000021, EAX. The majority of the features will be
used in the kernel and thus a separate leaf is appropriate.

Include KVM's reverse_cpuid entry because features are used by VM guests, too.

  [ bp: Massage commit message. ]

Signed-off-by: Kim Phillips <kim.phillips@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20230124163319.2277355-2-kim.phillips@amd.com
CVE-2023-20569
(backported from commit 8415a74852d7c24795007ee9862d25feb519007c)
[cascardo: conflicts with NBUGINTS 2]
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Acked-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/x86/include/asm/cpufeature.h
arch/x86/include/asm/cpufeatures.h
arch/x86/include/asm/disabled-features.h
arch/x86/include/asm/required-features.h
arch/x86/kernel/cpu/common.c
arch/x86/kvm/reverse_cpuid.h

index 1a85e1fb09226653bbf78fb82e3dbb4bfe2a7eb3..ce0c8f7d32186f32893bfdf4555246c856febc61 100644 (file)
@@ -32,6 +32,7 @@ enum cpuid_leafs
        CPUID_8000_0007_EBX,
        CPUID_7_EDX,
        CPUID_8000_001F_EAX,
+       CPUID_8000_0021_EAX,
 };
 
 #define X86_CAP_FMT_NUM "%d:%d"
@@ -94,8 +95,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
           CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 17, feature_bit) ||    \
           CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 18, feature_bit) ||    \
           CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 19, feature_bit) ||    \
+          CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 20, feature_bit) ||    \
           REQUIRED_MASK_CHECK                                    ||    \
-          BUILD_BUG_ON_ZERO(NCAPINTS != 20))
+          BUILD_BUG_ON_ZERO(NCAPINTS != 21))
 
 #define DISABLED_MASK_BIT_SET(feature_bit)                             \
         ( CHECK_BIT_IN_MASK_WORD(DISABLED_MASK,  0, feature_bit) ||    \
@@ -118,8 +120,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
           CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 17, feature_bit) ||    \
           CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 18, feature_bit) ||    \
           CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 19, feature_bit) ||    \
+          CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 20, feature_bit) ||    \
           DISABLED_MASK_CHECK                                    ||    \
-          BUILD_BUG_ON_ZERO(NCAPINTS != 20))
+          BUILD_BUG_ON_ZERO(NCAPINTS != 21))
 
 #define cpu_has(c, bit)                                                        \
        (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 :  \
index 50990749abdc07c04dd61bd9cfcd199e3387f9bd..ed2cd68ff0c89478be37af85ed4b48a66e6eae86 100644 (file)
@@ -13,7 +13,7 @@
 /*
  * Defines x86 CPU feature bits
  */
-#define NCAPINTS                       20         /* N 32-bit words worth of info */
+#define NCAPINTS                       21         /* N 32-bit words worth of info */
 #define NBUGINTS                       2          /* N 32-bit bug flags */
 
 /*
index c44b56f7ffba0d0e4bf881c035a3a3668be9929e..5dfa4fb76f4b2ba025b4c4e45b9e4846b75128c6 100644 (file)
 #define DISABLED_MASK17        0
 #define DISABLED_MASK18        0
 #define DISABLED_MASK19        0
-#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20)
+#define DISABLED_MASK20        0
+#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21)
 
 #endif /* _ASM_X86_DISABLED_FEATURES_H */
index aff774775c678434e2b20218d0873676f5b4a39b..7ba1726b71c7b8bfc95888dc78508998bba263fe 100644 (file)
@@ -98,6 +98,7 @@
 #define REQUIRED_MASK17        0
 #define REQUIRED_MASK18        0
 #define REQUIRED_MASK19        0
-#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20)
+#define REQUIRED_MASK20        0
+#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21)
 
 #endif /* _ASM_X86_REQUIRED_FEATURES_H */
index d950fb5ac0b4f7d13eb6f7cb2b6cb99a377de805..becea4fcd0ac0fe353a2ded6173baf90c2800d26 100644 (file)
@@ -1097,6 +1097,9 @@ void get_cpu_cap(struct cpuinfo_x86 *c)
        if (c->extended_cpuid_level >= 0x8000001f)
                c->x86_capability[CPUID_8000_001F_EAX] = cpuid_eax(0x8000001f);
 
+       if (c->extended_cpuid_level >= 0x80000021)
+               c->x86_capability[CPUID_8000_0021_EAX] = cpuid_eax(0x80000021);
+
        init_scattered_cpuid_features(c);
        init_speculation_control(c);
 
index 042d0aca3c92b238602d93d0158e043bcd2b4447..81f4e9ce0c77079860a3391338b419bdcb956f93 100644 (file)
@@ -68,6 +68,7 @@ static const struct cpuid_reg reverse_cpuid[] = {
        [CPUID_12_EAX]        = {0x00000012, 0, CPUID_EAX},
        [CPUID_8000_001F_EAX] = {0x8000001f, 0, CPUID_EAX},
        [CPUID_7_1_EDX]       = {         7, 1, CPUID_EDX},
+       [CPUID_8000_0021_EAX] = {0x80000021, 0, CPUID_EAX},
 };
 
 /*