]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Include/Library/MemEncryptSevLib.h
OvmfPkg: Replace BSD License with BSD+Patent License
[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 is enabled
18
19 @retval TRUE SEV is enabled
20 @retval FALSE SEV is not enabled
21 **/
22 BOOLEAN
23 EFIAPI
24 MemEncryptSevIsEnabled (
25 VOID
26 );
27
28 /**
29 This function clears memory encryption bit for the memory region specified by
30 BaseAddress and NumPages from the current page table context.
31
32 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use
33 current CR3)
34 @param[in] BaseAddress The physical address that is the start
35 address of a memory region.
36 @param[in] NumPages The number of pages from start memory
37 region.
38 @param[in] Flush Flush the caches before clearing the bit
39 (mostly TRUE except MMIO addresses)
40
41 @retval RETURN_SUCCESS The attributes were cleared for the
42 memory region.
43 @retval RETURN_INVALID_PARAMETER Number of pages is zero.
44 @retval RETURN_UNSUPPORTED Clearing the memory encryption attribute
45 is not supported
46 **/
47 RETURN_STATUS
48 EFIAPI
49 MemEncryptSevClearPageEncMask (
50 IN PHYSICAL_ADDRESS Cr3BaseAddress,
51 IN PHYSICAL_ADDRESS BaseAddress,
52 IN UINTN NumPages,
53 IN BOOLEAN Flush
54 );
55
56 /**
57 This function sets memory encryption bit for the memory region specified by
58 BaseAddress and NumPages from the current page table context.
59
60 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use
61 current CR3)
62 @param[in] BaseAddress The physical address that is the start
63 address of a memory region.
64 @param[in] NumPages The number of pages from start memory
65 region.
66 @param[in] Flush Flush the caches before setting the bit
67 (mostly TRUE except MMIO addresses)
68
69 @retval RETURN_SUCCESS The attributes were set for the memory
70 region.
71 @retval RETURN_INVALID_PARAMETER Number of pages is zero.
72 @retval RETURN_UNSUPPORTED Setting the memory encryption attribute
73 is not supported
74 **/
75 RETURN_STATUS
76 EFIAPI
77 MemEncryptSevSetPageEncMask (
78 IN PHYSICAL_ADDRESS Cr3BaseAddress,
79 IN PHYSICAL_ADDRESS BaseAddress,
80 IN UINTN NumPages,
81 IN BOOLEAN Flush
82 );
83
84
85 /**
86 Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM
87 Save State Map.
88
89 @param[out] BaseAddress The base address of the lowest-address page that
90 covers the initial SMRAM Save State Map.
91
92 @param[out] NumberOfPages The number of pages in the page range that covers
93 the initial SMRAM Save State Map.
94
95 @retval RETURN_SUCCESS BaseAddress and NumberOfPages have been set on
96 output.
97
98 @retval RETURN_UNSUPPORTED SMM is unavailable.
99 **/
100 RETURN_STATUS
101 EFIAPI
102 MemEncryptSevLocateInitialSmramSaveStateMapPages (
103 OUT UINTN *BaseAddress,
104 OUT UINTN *NumberOfPages
105 );
106 #endif // _MEM_ENCRYPT_SEV_LIB_H_