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