3 Define Secure Encrypted Virtualization (SEV) base library helper function
5 Copyright (c) 2017 - 2020, AMD Incorporated. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #ifndef _MEM_ENCRYPT_SEV_LIB_H_
12 #define _MEM_ENCRYPT_SEV_LIB_H_
17 // Internal structure for holding SEV-ES information needed during SEC phase
18 // and valid only during SEC phase and early PEI during platform
21 // This structure is also used by assembler files:
22 // OvmfPkg/ResetVector/ResetVector.nasmb
23 // OvmfPkg/ResetVector/Ia32/PageTables64.asm
24 // any changes must stay in sync with its usage.
26 typedef struct _SEC_SEV_ES_WORK_AREA
{
28 } SEC_SEV_ES_WORK_AREA
;
31 Returns a boolean to indicate whether SEV-ES is enabled.
33 @retval TRUE SEV-ES is enabled
34 @retval FALSE SEV-ES is not enabled
38 MemEncryptSevEsIsEnabled (
43 Returns a boolean to indicate whether SEV is enabled
45 @retval TRUE SEV is enabled
46 @retval FALSE SEV is not enabled
50 MemEncryptSevIsEnabled (
55 This function clears memory encryption bit for the memory region specified by
56 BaseAddress and NumPages from the current page table context.
58 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use
60 @param[in] BaseAddress The physical address that is the start
61 address of a memory region.
62 @param[in] NumPages The number of pages from start memory
64 @param[in] Flush Flush the caches before clearing the bit
65 (mostly TRUE except MMIO addresses)
67 @retval RETURN_SUCCESS The attributes were cleared for the
69 @retval RETURN_INVALID_PARAMETER Number of pages is zero.
70 @retval RETURN_UNSUPPORTED Clearing the memory encryption attribute
75 MemEncryptSevClearPageEncMask (
76 IN PHYSICAL_ADDRESS Cr3BaseAddress
,
77 IN PHYSICAL_ADDRESS BaseAddress
,
83 This function sets memory encryption bit for the memory region specified by
84 BaseAddress and NumPages from the current page table context.
86 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use
88 @param[in] BaseAddress The physical address that is the start
89 address of a memory region.
90 @param[in] NumPages The number of pages from start memory
92 @param[in] Flush Flush the caches before setting the bit
93 (mostly TRUE except MMIO addresses)
95 @retval RETURN_SUCCESS The attributes were set for the memory
97 @retval RETURN_INVALID_PARAMETER Number of pages is zero.
98 @retval RETURN_UNSUPPORTED Setting the memory encryption attribute
103 MemEncryptSevSetPageEncMask (
104 IN PHYSICAL_ADDRESS Cr3BaseAddress
,
105 IN PHYSICAL_ADDRESS BaseAddress
,
112 Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM
115 @param[out] BaseAddress The base address of the lowest-address page that
116 covers the initial SMRAM Save State Map.
118 @param[out] NumberOfPages The number of pages in the page range that covers
119 the initial SMRAM Save State Map.
121 @retval RETURN_SUCCESS BaseAddress and NumberOfPages have been set on
124 @retval RETURN_UNSUPPORTED SMM is unavailable.
128 MemEncryptSevLocateInitialSmramSaveStateMapPages (
129 OUT UINTN
*BaseAddress
,
130 OUT UINTN
*NumberOfPages
132 #endif // _MEM_ENCRYPT_SEV_LIB_H_