1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#[derive(Default, Debug, Clone)]
#[derive(Deserialize, Serialize)]
#[serde(default)]
pub struct WarningsToSuppress
{
pub suppress_warnings_for_cpu_features: HashSet<String>,
pub suppress_warnings_for_kernel_features: HashSet<String>,
pub suppress_warnings_for_miscellany: HashSet<String>,
}
impl WarningsToSuppress
{
#[inline(always)]
pub(crate) fn cpu_warn<F: FnOnce() -> bool>(&self, name: &str, message: &str, true_if_should_not_warn: F)
{
if true_if_should_not_warn()
{
return
}
if self.suppress_warnings_for_cpu_features.contains(name)
{
return
}
LoggingConfiguration::warn(name, format!("{}", message))
}
#[inline(always)]
pub(crate) fn kernel_warn<F: FnOnce() -> bool>(&self, name: &str, message: &str, true_if_should_not_warn: F)
{
if true_if_should_not_warn()
{
return
}
if self.suppress_warnings_for_kernel_features.contains(name)
{
return
}
LoggingConfiguration::warn(name, format!("{}", message))
}
#[inline(always)]
pub(crate) fn miscellany_warn<F: FnOnce() -> bool>(&self, name: &str, message: &str, true_if_should_not_warn: F)
{
if true_if_should_not_warn()
{
return
}
if self.suppress_warnings_for_miscellany.contains(name)
{
return
}
LoggingConfiguration::warn(name, format!("{}", message))
}
#[inline(always)]
pub(crate) fn kernel_warn_without_check(&self, name: &str, message: &str)
{
if self.suppress_warnings_for_kernel_features.contains(name)
{
return
}
LoggingConfiguration::warn(name, format!("{}", message))
}
#[inline(always)]
pub(crate) fn performance_warnings_it_is_safe_to_assume_for_all_x86_64_cpu_architectures_as_of_q2_2018(&self, feature_information: &FeatureInfo, extended_function_information: &ExtendedFunctionInfo, extended_feature_information: &ExtendedFeatures)
{
self.cpu_warn("has_rep_movsb_stosb", "Your CPU does not support the REP MOVSB and REP STOSB instructions, which are optimal for some memory moves and copies", || extended_feature_information.has_rep_movsb_stosb());
self.cpu_warn("has_prefetchw", "Your CPU does not support the PRETFCHW instruction, which is optimal for some memory moves and copies", || extended_function_information.has_prefetchw());
self.cpu_warn("has_ss", "Your CPU does not support self-snoop of the cache (which nearly all should), which is important for efficient cache management in this application", || feature_information.has_ss());
self.cpu_warn("has_working_xsave", "CPU architecture either lacks XSAVE support or the Linux kernel has disabled XSAVE support", || feature_information.has_xsave() && feature_information.has_oxsave())
}
#[inline(always)]
pub(crate) fn performance_warnings_for_new_features(&self, feature_information: &FeatureInfo, _extended_function_information: &ExtendedFunctionInfo, extended_feature_information: &ExtendedFeatures)
{
self.cpu_warn("has_invpcid", "Your CPU does not support the INVPCID instruction, which is important for efficient mitigation of the Meltdown and Spectre security vulnerabilities", || feature_information.has_xsave() && extended_feature_information.has_invpcid())
}
#[inline(always)]
pub(crate) fn security_warnings_for_new_features(&self, _feature_information: &FeatureInfo, _extended_function_information: &ExtendedFunctionInfo, extended_feature_information: &ExtendedFeatures)
{
self.cpu_warn("has_smap", "Your CPU does not support the Supervisor-Mode Access Prevention (SMAP) instructions CLAC and STAC, which are important for securing modern Linux systems", || extended_feature_information.has_smap())
}
}