]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Include/Library/MemEncryptSevLib.h
OvmfPkg/MemEncryptSevLib: Add an SEV-ES guest indicator function
[mirror_edk2.git] / OvmfPkg / Include / Library / MemEncryptSevLib.h
1 /** @file
2
3 Define Secure Encrypted Virtualization (SEV) base library helper function
4
5 Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
6
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10
11 #ifndef _MEM_ENCRYPT_SEV_LIB_H_
12 #define _MEM_ENCRYPT_SEV_LIB_H_
13
14 #include <Base.h>
15
16 /**
17 Returns a boolean to indicate whether SEV-ES is enabled.
18
19 @retval TRUE SEV-ES is enabled
20 @retval FALSE SEV-ES is not enabled
21 **/
22 BOOLEAN
23 EFIAPI
24 MemEncryptSevEsIsEnabled (
25 VOID
26 );
27
28 /**
29 Returns a boolean to indicate whether SEV is enabled
30
31 @retval TRUE SEV is enabled
32 @retval FALSE SEV is not enabled
33 **/
34 BOOLEAN
35 EFIAPI
36 MemEncryptSevIsEnabled (
37 VOID
38 );
39
40 /**
41 This function clears memory encryption bit for the memory region specified by
42 BaseAddress and NumPages from the current page table context.
43
44 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use
45 current CR3)
46 @param[in] BaseAddress The physical address that is the start
47 address of a memory region.
48 @param[in] NumPages The number of pages from start memory
49 region.
50 @param[in] Flush Flush the caches before clearing the bit
51 (mostly TRUE except MMIO addresses)
52
53 @retval RETURN_SUCCESS The attributes were cleared for the
54 memory region.
55 @retval RETURN_INVALID_PARAMETER Number of pages is zero.
56 @retval RETURN_UNSUPPORTED Clearing the memory encryption attribute
57 is not supported
58 **/
59 RETURN_STATUS
60 EFIAPI
61 MemEncryptSevClearPageEncMask (
62 IN PHYSICAL_ADDRESS Cr3BaseAddress,
63 IN PHYSICAL_ADDRESS BaseAddress,
64 IN UINTN NumPages,
65 IN BOOLEAN Flush
66 );
67
68 /**
69 This function sets memory encryption bit for the memory region specified by
70 BaseAddress and NumPages from the current page table context.
71
72 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use
73 current CR3)
74 @param[in] BaseAddress The physical address that is the start
75 address of a memory region.
76 @param[in] NumPages The number of pages from start memory
77 region.
78 @param[in] Flush Flush the caches before setting the bit
79 (mostly TRUE except MMIO addresses)
80
81 @retval RETURN_SUCCESS The attributes were set for the memory
82 region.
83 @retval RETURN_INVALID_PARAMETER Number of pages is zero.
84 @retval RETURN_UNSUPPORTED Setting the memory encryption attribute
85 is not supported
86 **/
87 RETURN_STATUS
88 EFIAPI
89 MemEncryptSevSetPageEncMask (
90 IN PHYSICAL_ADDRESS Cr3BaseAddress,
91 IN PHYSICAL_ADDRESS BaseAddress,
92 IN UINTN NumPages,
93 IN BOOLEAN Flush
94 );
95
96
97 /**
98 Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM
99 Save State Map.
100
101 @param[out] BaseAddress The base address of the lowest-address page that
102 covers the initial SMRAM Save State Map.
103
104 @param[out] NumberOfPages The number of pages in the page range that covers
105 the initial SMRAM Save State Map.
106
107 @retval RETURN_SUCCESS BaseAddress and NumberOfPages have been set on
108 output.
109
110 @retval RETURN_UNSUPPORTED SMM is unavailable.
111 **/
112 RETURN_STATUS
113 EFIAPI
114 MemEncryptSevLocateInitialSmramSaveStateMapPages (
115 OUT UINTN *BaseAddress,
116 OUT UINTN *NumberOfPages
117 );
118 #endif // _MEM_ENCRYPT_SEV_LIB_H_