]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/BaseMemEncryptSevLib/X64/SecVirtualMemory.c
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / Library / BaseMemEncryptSevLib / X64 / SecVirtualMemory.c
CommitLineData
a746ca5b
TL
1/** @file\r
2\r
3 Virtual Memory Management Services to set or clear the memory encryption bit\r
4\r
5 Copyright (c) 2020, AMD Incorporated. All rights reserved.<BR>\r
6\r
7 SPDX-License-Identifier: BSD-2-Clause-Patent\r
8\r
9**/\r
10\r
11#include <Library/CpuLib.h>\r
12#include <Library/MemEncryptSevLib.h>\r
13\r
14#include "VirtualMemory.h"\r
15\r
c330af02
TL
16/**\r
17 Return the pagetable memory encryption mask.\r
18\r
19 @return The pagetable memory encryption mask.\r
20\r
21**/\r
22UINT64\r
23EFIAPI\r
24InternalGetMemEncryptionAddressMask (\r
25 VOID\r
26 )\r
27{\r
ac0a286f 28 UINT64 EncryptionMask;\r
c330af02 29\r
ac0a286f 30 EncryptionMask = MemEncryptSevGetEncryptionMask ();\r
c330af02
TL
31 EncryptionMask &= PAGING_1G_ADDRESS_MASK_64;\r
32\r
33 return EncryptionMask;\r
34}\r
35\r
a746ca5b
TL
36/**\r
37 This function clears memory encryption bit for the memory region specified by\r
38 PhysicalAddress and Length from the current page table context.\r
39\r
40 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use\r
41 current CR3)\r
42 @param[in] PhysicalAddress The physical address that is the start\r
43 address of a memory region.\r
44 @param[in] Length The length of memory region\r
a746ca5b
TL
45\r
46 @retval RETURN_SUCCESS The attributes were cleared for the\r
47 memory region.\r
48 @retval RETURN_INVALID_PARAMETER Number of pages is zero.\r
49 @retval RETURN_UNSUPPORTED Clearing the memory encyrption attribute\r
50 is not supported\r
51**/\r
52RETURN_STATUS\r
53EFIAPI\r
54InternalMemEncryptSevSetMemoryDecrypted (\r
ac0a286f
MK
55 IN PHYSICAL_ADDRESS Cr3BaseAddress,\r
56 IN PHYSICAL_ADDRESS PhysicalAddress,\r
57 IN UINTN Length\r
a746ca5b
TL
58 )\r
59{\r
60 //\r
61 // This function is not available during SEC.\r
62 //\r
63 return RETURN_UNSUPPORTED;\r
64}\r
65\r
66/**\r
67 This function sets memory encryption bit for the memory region specified by\r
68 PhysicalAddress and Length from the current page table context.\r
69\r
70 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use\r
71 current CR3)\r
72 @param[in] PhysicalAddress The physical address that is the start\r
73 address of a memory region.\r
74 @param[in] Length The length of memory region\r
75 @param[in] Flush Flush the caches before applying the\r
76 encryption mask\r
77\r
78 @retval RETURN_SUCCESS The attributes were set for the memory\r
79 region.\r
80 @retval RETURN_INVALID_PARAMETER Number of pages is zero.\r
81 @retval RETURN_UNSUPPORTED Setting the memory encyrption attribute\r
82 is not supported\r
83**/\r
84RETURN_STATUS\r
85EFIAPI\r
86InternalMemEncryptSevSetMemoryEncrypted (\r
ac0a286f
MK
87 IN PHYSICAL_ADDRESS Cr3BaseAddress,\r
88 IN PHYSICAL_ADDRESS PhysicalAddress,\r
89 IN UINTN Length\r
a746ca5b
TL
90 )\r
91{\r
92 //\r
93 // This function is not available during SEC.\r
94 //\r
95 return RETURN_UNSUPPORTED;\r
96}\r
901a9bfc
BS
97\r
98/**\r
99 This function clears memory encryption bit for the MMIO region specified by\r
100 PhysicalAddress and Length.\r
101\r
102 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use\r
103 current CR3)\r
104 @param[in] PhysicalAddress The physical address that is the start\r
105 address of a MMIO region.\r
106 @param[in] Length The length of memory region\r
107\r
108 @retval RETURN_SUCCESS The attributes were cleared for the\r
109 memory region.\r
110 @retval RETURN_INVALID_PARAMETER Length is zero.\r
111 @retval RETURN_UNSUPPORTED Clearing the memory encyrption attribute\r
112 is not supported\r
113**/\r
114RETURN_STATUS\r
115EFIAPI\r
116InternalMemEncryptSevClearMmioPageEncMask (\r
ac0a286f
MK
117 IN PHYSICAL_ADDRESS Cr3BaseAddress,\r
118 IN PHYSICAL_ADDRESS PhysicalAddress,\r
119 IN UINTN Length\r
901a9bfc
BS
120 )\r
121{\r
122 //\r
123 // This function is not available during SEC.\r
124 //\r
125 return RETURN_UNSUPPORTED;\r
126}\r