@@ -194,7 +194,7 @@ void __init sme_early_init(void)
194194 for (i = 0 ; i < ARRAY_SIZE (protection_map ); i ++ )
195195 protection_map [i ] = pgprot_encrypted (protection_map [i ]);
196196
197- if (sev_active ( ))
197+ if (cc_platform_has ( CC_ATTR_GUEST_MEM_ENCRYPT ))
198198 swiotlb_force = SWIOTLB_FORCE ;
199199}
200200
@@ -203,7 +203,7 @@ void __init sev_setup_arch(void)
203203 phys_addr_t total_mem = memblock_phys_mem_size ();
204204 unsigned long size ;
205205
206- if (!sev_active ( ))
206+ if (!cc_platform_has ( CC_ATTR_GUEST_MEM_ENCRYPT ))
207207 return ;
208208
209209 /*
@@ -364,20 +364,15 @@ int __init early_set_memory_encrypted(unsigned long vaddr, unsigned long size)
364364/*
365365 * SME and SEV are very similar but they are not the same, so there are
366366 * times that the kernel will need to distinguish between SME and SEV. The
367- * sme_active () and sev_active() functions are used for this. When a
368- * distinction isn't needed, the mem_encrypt_active() function can be used.
367+ * cc_platform_has () function is used for this. When a distinction isn't
368+ * needed, the CC_ATTR_MEM_ENCRYPT attribute can be used.
369369 *
370370 * The trampoline code is a good example for this requirement. Before
371371 * paging is activated, SME will access all memory as decrypted, but SEV
372372 * will access all memory as encrypted. So, when APs are being brought
373373 * up under SME the trampoline area cannot be encrypted, whereas under SEV
374374 * the trampoline area must be encrypted.
375375 */
376- bool sev_active (void )
377- {
378- return sev_status & MSR_AMD64_SEV_ENABLED ;
379- }
380- EXPORT_SYMBOL_GPL (sev_active );
381376
382377/* Needs to be called from non-instrumentable code */
383378bool noinstr sev_es_active (void )
@@ -391,7 +386,7 @@ bool force_dma_unencrypted(struct device *dev)
391386 /*
392387 * For SEV, all DMA must be to unencrypted addresses.
393388 */
394- if (sev_active ( ))
389+ if (cc_platform_has ( CC_ATTR_GUEST_MEM_ENCRYPT ))
395390 return true;
396391
397392 /*
@@ -450,7 +445,7 @@ static void print_mem_encrypt_feature_info(void)
450445 }
451446
452447 /* Secure Encrypted Virtualization */
453- if (sev_active ( ))
448+ if (cc_platform_has ( CC_ATTR_GUEST_MEM_ENCRYPT ))
454449 pr_cont (" SEV" );
455450
456451 /* Encrypted Register State */
@@ -473,14 +468,14 @@ void __init mem_encrypt_init(void)
473468 * With SEV, we need to unroll the rep string I/O instructions,
474469 * but SEV-ES supports them through the #VC handler.
475470 */
476- if (sev_active ( ) && !sev_es_active ())
471+ if (cc_platform_has ( CC_ATTR_GUEST_MEM_ENCRYPT ) && !sev_es_active ())
477472 static_branch_enable (& sev_enable_key );
478473
479474 print_mem_encrypt_feature_info ();
480475}
481476
482477int arch_has_restricted_virtio_memory_access (void )
483478{
484- return sev_active ( );
479+ return cc_platform_has ( CC_ATTR_GUEST_MEM_ENCRYPT );
485480}
486481EXPORT_SYMBOL_GPL (arch_has_restricted_virtio_memory_access );
0 commit comments