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