]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Tcg/Tcg2Smm/Tcg2TraditionalMm.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / SecurityPkg / Tcg / Tcg2Smm / Tcg2TraditionalMm.c
1 /** @file
2 TCG2 SMM driver that updates TPM2 items in ACPI table and registers
3 SMI2 callback functions for Tcg2 physical presence, ClearMemory, and
4 sample for dTPM StartMethod.
5
6 Caution: This module requires additional review when modified.
7 This driver will have external input - variable and ACPINvs data in SMM mode.
8 This external input must be validated carefully to avoid security issue.
9
10 PhysicalPresenceCallback() and MemoryClearCallback() will receive untrusted input and do some check.
11
12 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
13 Copyright (c) Microsoft Corporation.
14 SPDX-License-Identifier: BSD-2-Clause-Patent
15
16 **/
17
18 #include "Tcg2Smm.h"
19 #include <Library/UefiBootServicesTableLib.h>
20 #include <Library/SmmMemLib.h>
21
22 /**
23 Notify the system that the SMM variable driver is ready.
24 **/
25 VOID
26 Tcg2NotifyMmReady (
27 VOID
28 )
29 {
30 EFI_STATUS Status;
31 EFI_HANDLE Handle;
32
33 Handle = NULL;
34 Status = gBS->InstallProtocolInterface (
35 &Handle,
36 &gTcg2MmSwSmiRegisteredGuid,
37 EFI_NATIVE_INTERFACE,
38 NULL
39 );
40 ASSERT_EFI_ERROR (Status);
41 }
42
43 /**
44 This function is an abstraction layer for implementation specific Mm buffer validation routine.
45
46 @param Buffer The buffer start address to be checked.
47 @param Length The buffer length to be checked.
48
49 @retval TRUE This buffer is valid per processor architecture and not overlap with SMRAM.
50 @retval FALSE This buffer is not valid per processor architecture or overlap with SMRAM.
51 **/
52 BOOLEAN
53 IsBufferOutsideMmValid (
54 IN EFI_PHYSICAL_ADDRESS Buffer,
55 IN UINT64 Length
56 )
57 {
58 return SmmIsBufferOutsideSmmValid (Buffer, Length);
59 }
60
61 /**
62 The driver's entry point.
63
64 It install callbacks for TPM physical presence and MemoryClear, and locate
65 SMM variable to be used in the callback function.
66
67 @param[in] ImageHandle The firmware allocated handle for the EFI image.
68 @param[in] SystemTable A pointer to the EFI System Table.
69
70 @retval EFI_SUCCESS The entry point is executed successfully.
71 @retval Others Some error occurs when executing this entry point.
72
73 **/
74 EFI_STATUS
75 EFIAPI
76 InitializeTcgSmm (
77 IN EFI_HANDLE ImageHandle,
78 IN EFI_SYSTEM_TABLE *SystemTable
79 )
80 {
81 return InitializeTcgCommon ();
82 }