linux/arch/x86/mm/mem_encrypt_identity.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * AMD Memory Encryption Support
 *
 * Copyright (C) 2016 Advanced Micro Devices, Inc.
 *
 * Author: Tom Lendacky <[email protected]>
 */

#define DISABLE_BRANCH_PROFILING

/*
 * Since we're dealing with identity mappings, physical and virtual
 * addresses are the same, so override these defines which are ultimately
 * used by the headers in misc.h.
 */
#define __pa(x)
#define __va(x)

/*
 * Special hack: we have to be careful, because no indirections are
 * allowed here, and paravirt_ops is a kind of one. As it will only run in
 * baremetal anyway, we just keep it from happening. (This list needs to
 * be extended when new paravirt and debugging variants are added.)
 */
#undef CONFIG_PARAVIRT
#undef CONFIG_PARAVIRT_XXL
#undef CONFIG_PARAVIRT_SPINLOCKS

/*
 * This code runs before CPU feature bits are set. By default, the
 * pgtable_l5_enabled() function uses bit X86_FEATURE_LA57 to determine if
 * 5-level paging is active, so that won't work here. USE_EARLY_PGTABLE_L5
 * is provided to handle this situation and, instead, use a variable that
 * has been set by the early boot code.
 */
#define USE_EARLY_PGTABLE_L5

#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/mem_encrypt.h>
#include <linux/cc_platform.h>

#include <asm/init.h>
#include <asm/setup.h>
#include <asm/sections.h>
#include <asm/coco.h>
#include <asm/sev.h>

#include "mm_internal.h"

#define PGD_FLAGS
#define P4D_FLAGS
#define PUD_FLAGS
#define PMD_FLAGS

#define PMD_FLAGS_LARGE

#define PMD_FLAGS_DEC
#define PMD_FLAGS_DEC_WP

#define PMD_FLAGS_ENC

#define PTE_FLAGS

#define PTE_FLAGS_DEC
#define PTE_FLAGS_DEC_WP

#define PTE_FLAGS_ENC

struct sme_populate_pgd_data {};

/*
 * This work area lives in the .init.scratch section, which lives outside of
 * the kernel proper. It is sized to hold the intermediate copy buffer and
 * more than enough pagetable pages.
 *
 * By using this section, the kernel can be encrypted in place and it
 * avoids any possibility of boot parameters or initramfs images being
 * placed such that the in-place encryption logic overwrites them.  This
 * section is 2MB aligned to allow for simple pagetable setup using only
 * PMD entries (see vmlinux.lds.S).
 */
static char sme_workarea[2 * PMD_SIZE] __section();

static void __head sme_clear_pgd(struct sme_populate_pgd_data *ppd)
{}

static pud_t __head *sme_prepare_pgd(struct sme_populate_pgd_data *ppd)
{}

static void __head sme_populate_pgd_large(struct sme_populate_pgd_data *ppd)
{}

static void __head sme_populate_pgd(struct sme_populate_pgd_data *ppd)
{}

static void __head __sme_map_range_pmd(struct sme_populate_pgd_data *ppd)
{}

static void __head __sme_map_range_pte(struct sme_populate_pgd_data *ppd)
{}

static void __head __sme_map_range(struct sme_populate_pgd_data *ppd,
				   pmdval_t pmd_flags, pteval_t pte_flags)
{}

static void __head sme_map_range_encrypted(struct sme_populate_pgd_data *ppd)
{}

static void __head sme_map_range_decrypted(struct sme_populate_pgd_data *ppd)
{}

static void __head sme_map_range_decrypted_wp(struct sme_populate_pgd_data *ppd)
{}

static unsigned long __head sme_pgtable_calc(unsigned long len)
{}

void __head sme_encrypt_kernel(struct boot_params *bp)
{}

void __head sme_enable(struct boot_params *bp)
{}