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