@@ -187,82 +187,35 @@ static bool bad_spectre_microcode(struct cpuinfo_x86 *c)
187187#define TME_ACTIVATE_LOCKED (x ) (x & 0x1)
188188#define TME_ACTIVATE_ENABLED (x ) (x & 0x2)
189189
190- #define TME_ACTIVATE_POLICY (x ) ((x >> 4) & 0xf) /* Bits 7:4 */
191- #define TME_ACTIVATE_POLICY_AES_XTS_128 0
192-
193190#define TME_ACTIVATE_KEYID_BITS (x ) ((x >> 32) & 0xf) /* Bits 35:32 */
194191
195- #define TME_ACTIVATE_CRYPTO_ALGS (x ) ((x >> 48) & 0xffff) /* Bits 63:48 */
196- #define TME_ACTIVATE_CRYPTO_AES_XTS_128 1
197-
198- /* Values for mktme_status (SW only construct) */
199- #define MKTME_ENABLED 0
200- #define MKTME_DISABLED 1
201- #define MKTME_UNINITIALIZED 2
202- static int mktme_status = MKTME_UNINITIALIZED ;
203-
204192static void detect_tme_early (struct cpuinfo_x86 * c )
205193{
206- u64 tme_activate , tme_policy , tme_crypto_algs ;
207- int keyid_bits = 0 , nr_keyids = 0 ;
208- static u64 tme_activate_cpu0 = 0 ;
194+ u64 tme_activate ;
195+ int keyid_bits ;
209196
210197 rdmsrl (MSR_IA32_TME_ACTIVATE , tme_activate );
211198
212- if (mktme_status != MKTME_UNINITIALIZED ) {
213- if (tme_activate != tme_activate_cpu0 ) {
214- /* Broken BIOS? */
215- pr_err_once ("x86/tme: configuration is inconsistent between CPUs\n" );
216- pr_err_once ("x86/tme: MKTME is not usable\n" );
217- mktme_status = MKTME_DISABLED ;
218-
219- /* Proceed. We may need to exclude bits from x86_phys_bits. */
220- }
221- } else {
222- tme_activate_cpu0 = tme_activate ;
223- }
224-
225199 if (!TME_ACTIVATE_LOCKED (tme_activate ) || !TME_ACTIVATE_ENABLED (tme_activate )) {
226200 pr_info_once ("x86/tme: not enabled by BIOS\n" );
227- mktme_status = MKTME_DISABLED ;
201+ clear_cpu_cap ( c , X86_FEATURE_TME ) ;
228202 return ;
229203 }
230-
231- if (mktme_status != MKTME_UNINITIALIZED )
232- goto detect_keyid_bits ;
233-
234- pr_info ("x86/tme: enabled by BIOS\n" );
235-
236- tme_policy = TME_ACTIVATE_POLICY (tme_activate );
237- if (tme_policy != TME_ACTIVATE_POLICY_AES_XTS_128 )
238- pr_warn ("x86/tme: Unknown policy is active: %#llx\n" , tme_policy );
239-
240- tme_crypto_algs = TME_ACTIVATE_CRYPTO_ALGS (tme_activate );
241- if (!(tme_crypto_algs & TME_ACTIVATE_CRYPTO_AES_XTS_128 )) {
242- pr_err ("x86/mktme: No known encryption algorithm is supported: %#llx\n" ,
243- tme_crypto_algs );
244- mktme_status = MKTME_DISABLED ;
245- }
246- detect_keyid_bits :
204+ pr_info_once ("x86/tme: enabled by BIOS\n" );
247205 keyid_bits = TME_ACTIVATE_KEYID_BITS (tme_activate );
248- nr_keyids = (1UL << keyid_bits ) - 1 ;
249- if (nr_keyids ) {
250- pr_info_once ("x86/mktme: enabled by BIOS\n" );
251- pr_info_once ("x86/mktme: %d KeyIDs available\n" , nr_keyids );
252- } else {
253- pr_info_once ("x86/mktme: disabled by BIOS\n" );
254- }
255-
256- if (mktme_status == MKTME_UNINITIALIZED ) {
257- /* MKTME is usable */
258- mktme_status = MKTME_ENABLED ;
259- }
206+ if (!keyid_bits )
207+ return ;
260208
261209 /*
262- * KeyID bits effectively lower the number of physical address
263- * bits. Update cpuinfo_x86::x86_phys_bits accordingly.
210+ * KeyID bits are set by BIOS and can be present regardless
211+ * of whether the kernel is using them. They effectively lower
212+ * the number of physical address bits.
213+ *
214+ * Update cpuinfo_x86::x86_phys_bits accordingly.
264215 */
265216 c -> x86_phys_bits -= keyid_bits ;
217+ pr_info_once ("x86/mktme: BIOS enabled: x86_phys_bits reduced by %d\n" ,
218+ keyid_bits );
266219}
267220
268221void intel_unlock_cpuid_leafs (struct cpuinfo_x86 * c )
0 commit comments