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 // OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm
25 // any changes must stay in sync with its usage.
27 typedef struct _SEC_SEV_ES_WORK_AREA
{
33 UINT64 EncryptionMask
;
34 } SEC_SEV_ES_WORK_AREA
;
37 Returns a boolean to indicate whether SEV-ES is enabled.
39 @retval TRUE SEV-ES is enabled
40 @retval FALSE SEV-ES is not enabled
44 MemEncryptSevEsIsEnabled (
49 Returns a boolean to indicate whether SEV is enabled
51 @retval TRUE SEV is enabled
52 @retval FALSE SEV is not enabled
56 MemEncryptSevIsEnabled (
61 This function clears memory encryption bit for the memory region specified by
62 BaseAddress and NumPages from the current page table context.
64 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use
66 @param[in] BaseAddress The physical address that is the start
67 address of a memory region.
68 @param[in] NumPages The number of pages from start memory
70 @param[in] Flush Flush the caches before clearing the bit
71 (mostly TRUE except MMIO addresses)
73 @retval RETURN_SUCCESS The attributes were cleared for the
75 @retval RETURN_INVALID_PARAMETER Number of pages is zero.
76 @retval RETURN_UNSUPPORTED Clearing the memory encryption attribute
81 MemEncryptSevClearPageEncMask (
82 IN PHYSICAL_ADDRESS Cr3BaseAddress
,
83 IN PHYSICAL_ADDRESS BaseAddress
,
89 This function sets memory encryption bit for the memory region specified by
90 BaseAddress and NumPages from the current page table context.
92 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use
94 @param[in] BaseAddress The physical address that is the start
95 address of a memory region.
96 @param[in] NumPages The number of pages from start memory
98 @param[in] Flush Flush the caches before setting the bit
99 (mostly TRUE except MMIO addresses)
101 @retval RETURN_SUCCESS The attributes were set for the memory
103 @retval RETURN_INVALID_PARAMETER Number of pages is zero.
104 @retval RETURN_UNSUPPORTED Setting the memory encryption attribute
109 MemEncryptSevSetPageEncMask (
110 IN PHYSICAL_ADDRESS Cr3BaseAddress
,
111 IN PHYSICAL_ADDRESS BaseAddress
,
118 Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM
121 @param[out] BaseAddress The base address of the lowest-address page that
122 covers the initial SMRAM Save State Map.
124 @param[out] NumberOfPages The number of pages in the page range that covers
125 the initial SMRAM Save State Map.
127 @retval RETURN_SUCCESS BaseAddress and NumberOfPages have been set on
130 @retval RETURN_UNSUPPORTED SMM is unavailable.
134 MemEncryptSevLocateInitialSmramSaveStateMapPages (
135 OUT UINTN
*BaseAddress
,
136 OUT UINTN
*NumberOfPages
138 #endif // _MEM_ENCRYPT_SEV_LIB_H_