]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - OvmfPkg/Library/BaseMemEncryptSevLib/X64/MemEncryptSevLib.c
OvmfPkg/MemEncryptSevLib: clean up MemEncryptSevSetPageEncMask() decl
[mirror_edk2.git] / OvmfPkg / Library / BaseMemEncryptSevLib / X64 / MemEncryptSevLib.c
... / ...
CommitLineData
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
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
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
27 This function clears memory encryption bit for the memory region specified by\r
28 BaseAddress and NumPages from the current page table context.\r
29\r
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
34 @param[in] NumPages The number of pages from start memory\r
35 region.\r
36 @param[in] Flush Flush the caches before clearing the bit\r
37 (mostly TRUE except MMIO addresses)\r
38\r
39 @retval RETURN_SUCCESS The attributes were cleared for the\r
40 memory region.\r
41 @retval RETURN_INVALID_PARAMETER Number of pages is zero.\r
42 @retval RETURN_UNSUPPORTED Clearing the memory encryption attribute\r
43 is not supported\r
44**/\r
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
54 return InternalMemEncryptSevSetMemoryDecrypted (\r
55 Cr3BaseAddress,\r
56 BaseAddress,\r
57 EFI_PAGES_TO_SIZE (NumPages),\r
58 Flush\r
59 );\r
60}\r
61\r
62/**\r
63 This function sets memory encryption bit for the memory region specified by\r
64 BaseAddress and NumPages from the current page table context.\r
65\r
66 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use\r
67 current CR3)\r
68 @param[in] BaseAddress The physical address that is the start\r
69 address of a memory region.\r
70 @param[in] NumPages The number of pages from start memory\r
71 region.\r
72 @param[in] Flush Flush the caches before setting the bit\r
73 (mostly TRUE except MMIO addresses)\r
74\r
75 @retval RETURN_SUCCESS The attributes were set for the memory\r
76 region.\r
77 @retval RETURN_INVALID_PARAMETER Number of pages is zero.\r
78 @retval RETURN_UNSUPPORTED Setting the memory encryption attribute\r
79 is not supported\r
80**/\r
81RETURN_STATUS\r
82EFIAPI\r
83MemEncryptSevSetPageEncMask (\r
84 IN PHYSICAL_ADDRESS Cr3BaseAddress,\r
85 IN PHYSICAL_ADDRESS BaseAddress,\r
86 IN UINTN NumPages,\r
87 IN BOOLEAN Flush\r
88 )\r
89{\r
90 return InternalMemEncryptSevSetMemoryEncrypted (\r
91 Cr3BaseAddress,\r
92 BaseAddress,\r
93 EFI_PAGES_TO_SIZE (NumPages),\r
94 Flush\r
95 );\r
96}\r