]>
Commit | Line | Data |
---|---|---|
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 | |
7 | This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD\r | |
9 | License which accompanies this distribution. The full text of the license may\r | |
10 | be found at 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 | /**\r | |
25 | This function clears memory encryption bit for the memory region specified\r | |
26 | by BaseAddress and Number of pages from the current page table context.\r | |
27 | \r | |
28 | @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use current CR3)\r | |
29 | @param[in] BaseAddress The physical address that is the start address\r | |
30 | of a memory region.\r | |
31 | @param[in] NumberOfPages The number of pages from start memory region.\r | |
32 | @param[in] Flush Flush the caches before clearing the bit\r | |
33 | (mostly TRUE except MMIO addresses)\r | |
34 | \r | |
35 | @retval RETURN_SUCCESS The attributes were cleared for the memory region.\r | |
36 | @retval RETURN_INVALID_PARAMETER Number of pages is zero.\r | |
37 | @retval RETURN_UNSUPPORTED Clearing memory encryption attribute is not\r | |
38 | supported\r | |
39 | **/\r | |
40 | RETURN_STATUS\r | |
41 | EFIAPI\r | |
42 | MemEncryptSevClearPageEncMask (\r | |
43 | IN PHYSICAL_ADDRESS Cr3BaseAddress,\r | |
44 | IN PHYSICAL_ADDRESS BaseAddress,\r | |
45 | IN UINTN NumberOfPages,\r | |
46 | IN BOOLEAN Flush\r | |
47 | )\r | |
48 | {\r | |
49 | //\r | |
50 | // Memory encryption bit is not accessible in 32-bit mode\r | |
51 | //\r | |
52 | return RETURN_UNSUPPORTED;\r | |
53 | }\r | |
54 | \r | |
55 | /**\r | |
56 | This function sets memory encryption bit for the memory region specified by\r | |
57 | BaseAddress and Number of pages from the current page table context.\r | |
58 | \r | |
59 | @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use current CR3)\r | |
60 | @param[in] BaseAddress The physical address that is the start address\r | |
61 | of a memory region.\r | |
62 | @param[in] NumberOfPages The number of pages from start memory region.\r | |
63 | @param[in] Flush Flush the caches before clearing the bit\r | |
64 | (mostly TRUE except MMIO addresses)\r | |
65 | \r | |
66 | @retval RETURN_SUCCESS The attributes were set for the memory region.\r | |
67 | @retval RETURN_INVALID_PARAMETER Number of pages is zero.\r | |
68 | @retval RETURN_UNSUPPORTED Clearing memory encryption attribute is not\r | |
69 | supported\r | |
70 | **/\r | |
71 | RETURN_STATUS\r | |
72 | EFIAPI\r | |
73 | MemEncryptSevSetPageEncMask (\r | |
74 | IN PHYSICAL_ADDRESS Cr3BaseAddress,\r | |
75 | IN PHYSICAL_ADDRESS BaseAddress,\r | |
76 | IN UINTN NumberOfPages,\r | |
77 | IN BOOLEAN Flush\r | |
78 | )\r | |
79 | {\r | |
80 | //\r | |
81 | // Memory encryption bit is not accessible in 32-bit mode\r | |
82 | //\r | |
83 | return RETURN_UNSUPPORTED;\r | |
84 | }\r |