OvmfPkg/MemEncryptSevLib: clean up MemEncryptSevClearPageEncMask() decl
[mirror_edk2.git] / OvmfPkg / Library / BaseMemEncryptSevLib / X64 / MemEncryptSevLib.c
CommitLineData
a1f22614
BS
1/** @file\r
2\r
3 Secure Encrypted Virtualization (SEV) library helper function\r
4\r
5 Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
6\r
4bd6bf31
LE
7 This program and the accompanying materials are licensed and made available\r
8 under the terms and conditions of the BSD License which accompanies this\r
9 distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
a1f22614
BS
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#include <Library/BaseLib.h>\r
18#include <Library/DebugLib.h>\r
19#include <Register/Cpuid.h>\r
20#include <Register/Amd/Cpuid.h>\r
21#include <Register/Amd/Msr.h>\r
22#include <Library/MemEncryptSevLib.h>\r
23\r
24#include "VirtualMemory.h"\r
25\r
26/**\r
a1f22614 27 This function clears memory encryption bit for the memory region specified by\r
5b5028e6 28 BaseAddress and NumPages from the current page table context.\r
a1f22614 29\r
4bd6bf31
LE
30 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use\r
31 current CR3)\r
32 @param[in] BaseAddress The physical address that is the start\r
33 address of a memory region.\r
5b5028e6 34 @param[in] NumPages The number of pages from start memory\r
4bd6bf31 35 region.\r
a1f22614
BS
36 @param[in] Flush Flush the caches before clearing the bit\r
37 (mostly TRUE except MMIO addresses)\r
38\r
4bd6bf31
LE
39 @retval RETURN_SUCCESS The attributes were cleared for the\r
40 memory region.\r
a1f22614 41 @retval RETURN_INVALID_PARAMETER Number of pages is zero.\r
4bd6bf31
LE
42 @retval RETURN_UNSUPPORTED Clearing the memory encryption attribute\r
43 is not supported\r
5b5028e6 44**/\r
a1f22614
BS
45RETURN_STATUS\r
46EFIAPI\r
47MemEncryptSevClearPageEncMask (\r
48 IN PHYSICAL_ADDRESS Cr3BaseAddress,\r
49 IN PHYSICAL_ADDRESS BaseAddress,\r
50 IN UINTN NumPages,\r
51 IN BOOLEAN Flush\r
52 )\r
53{\r
4bd6bf31
LE
54 return InternalMemEncryptSevSetMemoryDecrypted (\r
55 Cr3BaseAddress,\r
56 BaseAddress,\r
57 EFI_PAGES_TO_SIZE (NumPages),\r
58 Flush\r
59 );\r
a1f22614
BS
60}\r
61\r
62/**\r
63\r
64 This function clears memory encryption bit for the memory region specified by\r
65 BaseAddress and Number of pages from the current page table context.\r
66\r
4bd6bf31
LE
67 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use\r
68 current CR3)\r
69 @param[in] BaseAddress The physical address that is the start\r
70 address of a memory region.\r
71 @param[in] NumberOfPages The number of pages from start memory\r
72 region.\r
a1f22614
BS
73 @param[in] Flush Flush the caches before clearing the bit\r
74 (mostly TRUE except MMIO addresses)\r
75\r
4bd6bf31
LE
76 @retval RETURN_SUCCESS The attributes were cleared for the\r
77 memory region.\r
a1f22614 78 @retval RETURN_INVALID_PARAMETER Number of pages is zero.\r
4bd6bf31
LE
79 @retval RETURN_UNSUPPORTED Clearing the memory encryption attribute\r
80 is not supported\r
a1f22614
BS
81 **/\r
82RETURN_STATUS\r
83EFIAPI\r
84MemEncryptSevSetPageEncMask (\r
85 IN PHYSICAL_ADDRESS Cr3BaseAddress,\r
86 IN PHYSICAL_ADDRESS BaseAddress,\r
87 IN UINTN NumPages,\r
88 IN BOOLEAN Flush\r
89 )\r
90{\r
4bd6bf31
LE
91 return InternalMemEncryptSevSetMemoryEncrypted (\r
92 Cr3BaseAddress,\r
93 BaseAddress,\r
94 EFI_PAGES_TO_SIZE (NumPages),\r
95 Flush\r
96 );\r
a1f22614 97}\r