void __init mem_encrypt_init(void);
 
 void __init sev_es_init_vc_handling(void);
-bool sev_active(void);
 bool sev_es_active(void);
 
 #define __bss_decrypted __section(".bss..decrypted")
 static inline void __init sme_enable(struct boot_params *bp) { }
 
 static inline void sev_es_init_vc_handling(void) { }
-static inline bool sev_active(void) { return false; }
 static inline bool sev_es_active(void) { return false; }
 
 static inline int __init
 
 #include <linux/crash_dump.h>
 #include <linux/uaccess.h>
 #include <linux/io.h>
+#include <linux/cc_platform.h>
 
 static ssize_t __copy_oldmem_page(unsigned long pfn, char *buf, size_t csize,
                                  unsigned long offset, int userbuf,
 
 ssize_t elfcorehdr_read(char *buf, size_t count, u64 *ppos)
 {
-       return read_from_oldmem(buf, count, ppos, 0, sev_active());
+       return read_from_oldmem(buf, count, ppos, 0,
+                               cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT));
 }
 
 #include <linux/nmi.h>
 #include <linux/swait.h>
 #include <linux/syscore_ops.h>
+#include <linux/cc_platform.h>
 #include <asm/timer.h>
 #include <asm/cpu.h>
 #include <asm/traps.h>
 {
        int cpu;
 
-       if (!sev_active())
+       if (!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
                return;
 
        for_each_possible_cpu(cpu) {
 
 #include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/set_memory.h>
+#include <linux/cc_platform.h>
 
 #include <asm/hypervisor.h>
-#include <asm/mem_encrypt.h>
 #include <asm/x86_init.h>
 #include <asm/kvmclock.h>
 
         * hvclock is shared between the guest and the hypervisor, must
         * be mapped decrypted.
         */
-       if (sev_active()) {
+       if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) {
                r = set_memory_decrypted((unsigned long) hvclock_mem,
                                         1UL << order);
                if (r) {
 
        }
        pte = pte_offset_kernel(pmd, vaddr);
 
-       if (sev_active())
+       if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
                prot = PAGE_KERNEL_EXEC;
 
        set_pte(pte, pfn_pte(paddr >> PAGE_SHIFT, prot));
        level4p = (pgd_t *)__va(start_pgtable);
        clear_page(level4p);
 
-       if (sev_active()) {
+       if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) {
                info.page_flag   |= _PAGE_ENC;
                info.kernpg_flag |= _PAGE_ENC;
        }
 
 #include <linux/pagemap.h>
 #include <linux/swap.h>
 #include <linux/rwsem.h>
+#include <linux/cc_platform.h>
 
 #include <asm/apic.h>
 #include <asm/perf_event.h>
                return 0;
        }
 
-       if (sev_active()) {
+       if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)) {
                pr_info("KVM is unsupported when running as an SEV guest\n");
                return 0;
        }
 
  */
 static unsigned int __ioremap_check_encrypted(struct resource *res)
 {
-       if (!sev_active())
+       if (!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
                return 0;
 
        switch (res->desc) {
  */
 static void __ioremap_check_other(resource_size_t addr, struct ioremap_desc *desc)
 {
-       if (!sev_active())
+       if (!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
                return;
 
        if (!IS_ENABLED(CONFIG_EFI))
        case E820_TYPE_NVS:
        case E820_TYPE_UNUSABLE:
                /* For SEV, these areas are encrypted */
-               if (sev_active())
+               if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
                        break;
                fallthrough;
 
 
        for (i = 0; i < ARRAY_SIZE(protection_map); i++)
                protection_map[i] = pgprot_encrypted(protection_map[i]);
 
-       if (sev_active())
+       if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
                swiotlb_force = SWIOTLB_FORCE;
 }
 
        phys_addr_t total_mem = memblock_phys_mem_size();
        unsigned long size;
 
-       if (!sev_active())
+       if (!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
                return;
 
        /*
 /*
  * SME and SEV are very similar but they are not the same, so there are
  * times that the kernel will need to distinguish between SME and SEV. The
- * sme_active() and sev_active() functions are used for this.  When a
- * distinction isn't needed, the mem_encrypt_active() function can be used.
+ * cc_platform_has() function is used for this.  When a distinction isn't
+ * needed, the CC_ATTR_MEM_ENCRYPT attribute can be used.
  *
  * The trampoline code is a good example for this requirement.  Before
  * paging is activated, SME will access all memory as decrypted, but SEV
  * up under SME the trampoline area cannot be encrypted, whereas under SEV
  * the trampoline area must be encrypted.
  */
-bool sev_active(void)
-{
-       return sev_status & MSR_AMD64_SEV_ENABLED;
-}
-EXPORT_SYMBOL_GPL(sev_active);
 
 /* Needs to be called from non-instrumentable code */
 bool noinstr sev_es_active(void)
        /*
         * For SEV, all DMA must be to unencrypted addresses.
         */
-       if (sev_active())
+       if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
                return true;
 
        /*
        }
 
        /* Secure Encrypted Virtualization */
-       if (sev_active())
+       if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
                pr_cont(" SEV");
 
        /* Encrypted Register State */
         * With SEV, we need to unroll the rep string I/O instructions,
         * but SEV-ES supports them through the #VC handler.
         */
-       if (sev_active() && !sev_es_active())
+       if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT) && !sev_es_active())
                static_branch_enable(&sev_enable_key);
 
        print_mem_encrypt_feature_info();
 
 int arch_has_restricted_virtio_memory_access(void)
 {
-       return sev_active();
+       return cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT);
 }
 EXPORT_SYMBOL_GPL(arch_has_restricted_virtio_memory_access);
 
 #include <linux/reboot.h>
 #include <linux/slab.h>
 #include <linux/ucs2_string.h>
-#include <linux/mem_encrypt.h>
+#include <linux/cc_platform.h>
 #include <linux/sched/task.h>
 
 #include <asm/setup.h>
        if (!(md->attribute & EFI_MEMORY_WB))
                flags |= _PAGE_PCD;
 
-       if (sev_active() && md->type != EFI_MEMORY_MAPPED_IO)
+       if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT) &&
+           md->type != EFI_MEMORY_MAPPED_IO)
                flags |= _PAGE_ENC;
 
        pfn = md->phys_addr >> PAGE_SHIFT;
        if (!(md->attribute & EFI_MEMORY_RO))
                pf |= _PAGE_RW;
 
-       if (sev_active())
+       if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
                pf |= _PAGE_ENC;
 
        return efi_update_mappings(md, pf);
                        (md->type != EFI_RUNTIME_SERVICES_CODE))
                        pf |= _PAGE_RW;
 
-               if (sev_active())
+               if (cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
                        pf |= _PAGE_ENC;
 
                efi_update_mappings(md, pf);