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
{
32 } SEC_SEV_ES_WORK_AREA
;
35 Returns a boolean to indicate whether SEV-ES is enabled.
37 @retval TRUE SEV-ES is enabled
38 @retval FALSE SEV-ES is not enabled
42 MemEncryptSevEsIsEnabled (
47 Returns a boolean to indicate whether SEV is enabled
49 @retval TRUE SEV is enabled
50 @retval FALSE SEV is not enabled
54 MemEncryptSevIsEnabled (
59 This function clears memory encryption bit for the memory region specified by
60 BaseAddress and NumPages from the current page table context.
62 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use
64 @param[in] BaseAddress The physical address that is the start
65 address of a memory region.
66 @param[in] NumPages The number of pages from start memory
68 @param[in] Flush Flush the caches before clearing the bit
69 (mostly TRUE except MMIO addresses)
71 @retval RETURN_SUCCESS The attributes were cleared for the
73 @retval RETURN_INVALID_PARAMETER Number of pages is zero.
74 @retval RETURN_UNSUPPORTED Clearing the memory encryption attribute
79 MemEncryptSevClearPageEncMask (
80 IN PHYSICAL_ADDRESS Cr3BaseAddress
,
81 IN PHYSICAL_ADDRESS BaseAddress
,
87 This function sets memory encryption bit for the memory region specified by
88 BaseAddress and NumPages from the current page table context.
90 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use
92 @param[in] BaseAddress The physical address that is the start
93 address of a memory region.
94 @param[in] NumPages The number of pages from start memory
96 @param[in] Flush Flush the caches before setting the bit
97 (mostly TRUE except MMIO addresses)
99 @retval RETURN_SUCCESS The attributes were set for the memory
101 @retval RETURN_INVALID_PARAMETER Number of pages is zero.
102 @retval RETURN_UNSUPPORTED Setting the memory encryption attribute
107 MemEncryptSevSetPageEncMask (
108 IN PHYSICAL_ADDRESS Cr3BaseAddress
,
109 IN PHYSICAL_ADDRESS BaseAddress
,
116 Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM
119 @param[out] BaseAddress The base address of the lowest-address page that
120 covers the initial SMRAM Save State Map.
122 @param[out] NumberOfPages The number of pages in the page range that covers
123 the initial SMRAM Save State Map.
125 @retval RETURN_SUCCESS BaseAddress and NumberOfPages have been set on
128 @retval RETURN_UNSUPPORTED SMM is unavailable.
132 MemEncryptSevLocateInitialSmramSaveStateMapPages (
133 OUT UINTN
*BaseAddress
,
134 OUT UINTN
*NumberOfPages
136 #endif // _MEM_ENCRYPT_SEV_LIB_H_