File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ uint64_t pcpu_active_bitmap = 0UL;
30
30
31
31
/* X2APIC mode is disabled by default. */
32
32
bool x2apic_enabled = false;
33
+ static bool skip_l1dfl_vmentry ;
34
+ static uint64_t x86_arch_capabilities ;
33
35
34
36
/* TODO: add more capability per requirement */
35
37
/* APICv features */
@@ -418,6 +420,18 @@ void bsp_boot_init(void)
418
420
419
421
static bool check_cpu_security_config (void )
420
422
{
423
+ if (cpu_has_cap (X86_FEATURE_ARCH_CAP )) {
424
+ x86_arch_capabilities = msr_read (MSR_IA32_ARCH_CAPABILITIES );
425
+ skip_l1dfl_vmentry = ((x86_arch_capabilities
426
+ & IA32_ARCH_CAP_SKIP_L1DFL_VMENTRY ) != 0UL );
427
+ } else {
428
+ return false;
429
+ }
430
+
431
+ if ((!cpu_has_cap (X86_FEATURE_L1D_FLUSH )) && (!skip_l1dfl_vmentry )) {
432
+ return false;
433
+ }
434
+
421
435
if (!cpu_has_cap (X86_FEATURE_IBRS_IBPB ) &&
422
436
!cpu_has_cap (X86_FEATURE_STIBP )) {
423
437
return false;
Original file line number Diff line number Diff line change 77
77
/* Intel-defined CPU features, CPUID level 0x00000007 (EDX)*/
78
78
#define X86_FEATURE_IBRS_IBPB ((FEAT_7_0_EDX << 5U) + 26U)
79
79
#define X86_FEATURE_STIBP ((FEAT_7_0_EDX << 5U) + 27U)
80
+ #define X86_FEATURE_L1D_FLUSH ((FEAT_7_0_EDX << 5U) + 28U)
81
+ #define X86_FEATURE_ARCH_CAP ((FEAT_7_0_EDX << 5U) + 29U)
80
82
81
83
/* Intel-defined CPU features, CPUID level 0x80000001 (EDX)*/
82
84
#define X86_FEATURE_NX ((FEAT_8000_0001_EDX << 5U) + 20U)
Original file line number Diff line number Diff line change 44
44
#define MSR_IA32_APERF 0x000000E8U
45
45
/* Actual performance clock counter */
46
46
#define MSR_IA32_MTRR_CAP 0x000000FEU /* MTRR capability */
47
+ #define MSR_IA32_ARCH_CAPABILITIES 0x0000010AU
48
+ #define MSR_IA32_FLUSH_CMD 0x0000010BU
47
49
#define MSR_IA32_SYSENTER_CS 0x00000174U /* CS for sysenter */
48
50
#define MSR_IA32_SYSENTER_ESP 0x00000175U /* ESP for sysenter */
49
51
#define MSR_IA32_SYSENTER_EIP 0x00000176U /* EIP for sysenter */
@@ -567,4 +569,14 @@ static inline bool pat_mem_type_invalid(uint64_t x)
567
569
#define SPEC_ENABLE_STIBP (1U<<1U)
568
570
#define PRED_SET_IBPB (1U<<0U)
569
571
572
+ /* IA32 ARCH Capabilities bit */
573
+ #define IA32_ARCH_CAP_RDCL_NO (1U << 0U)
574
+ #define IA32_ARCH_CAP_IBRS_ALL (1U << 1U)
575
+ #define IA32_ARCH_CAP_RSBA (1U << 2U)
576
+ #define IA32_ARCH_CAP_SKIP_L1DFL_VMENTRY (1U << 3U)
577
+ #define IA32_ARCH_CAP_SSB_NO (1U << 4U)
578
+
579
+ /* Flush L1 D-cache */
580
+ #define IA32_L1D_FLUSH (1UL << 0U)
581
+
570
582
#endif /* MSR_H */
You can’t perform that action at this time.
0 commit comments