VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/XenPlatformPei/ClearCache.c@ 107675

最後變更 在這個檔案從107675是 101291,由 vboxsync 提交於 18 月 前

EFI/FirmwareNew: Make edk2-stable202308 build on all supported platforms (using gcc at least, msvc not tested yet), bugref:4643

  • 屬性 svn:eol-style 設為 native
檔案大小: 3.1 KB
 
1/**@file
2 Install a callback to clear cache on all processors.
3 This is for conformance with the TCG "Platform Reset Attack Mitigation
4 Specification". Because clearing the CPU caches at boot doesn't impact
5 performance significantly, do it unconditionally, for simplicity's
6 sake.
7
8 Copyright (C) 2018, Red Hat, Inc.
9 Copyright (c) 2019, Citrix Systems, Inc.
10
11 SPDX-License-Identifier: BSD-2-Clause-Patent
12**/
13
14#include <Library/CacheMaintenanceLib.h>
15#include <Library/DebugLib.h>
16#include <Library/PeiServicesLib.h>
17#include <Ppi/MpServices.h>
18
19#include "Platform.h"
20
21/**
22 Invalidate data & instruction caches.
23 All APs execute this function in parallel. The BSP executes the function
24 separately.
25
26 @param[in,out] WorkSpace Pointer to the input/output argument workspace
27 shared by all processors.
28**/
29STATIC
30VOID
31EFIAPI
32ClearCache (
33 IN OUT VOID *WorkSpace
34 )
35{
36 WriteBackInvalidateDataCache ();
37 InvalidateInstructionCache ();
38}
39
40/**
41 Notification function called when EFI_PEI_MP_SERVICES_PPI becomes available.
42
43 @param[in] PeiServices Indirect reference to the PEI Services Table.
44 @param[in] NotifyDescriptor Address of the notification descriptor data
45 structure.
46 @param[in] Ppi Address of the PPI that was installed.
47
48 @return Status of the notification. The status code returned from this
49 function is ignored.
50**/
51STATIC
52EFI_STATUS
53EFIAPI
54ClearCacheOnMpServicesAvailable (
55 IN EFI_PEI_SERVICES **PeiServices,
56 IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
57 IN VOID *Ppi
58 )
59{
60 EFI_PEI_MP_SERVICES_PPI *MpServices;
61 EFI_STATUS Status;
62
63 DEBUG ((DEBUG_INFO, "%a: %a\n", gEfiCallerBaseName, __func__));
64
65 //
66 // Clear cache on all the APs in parallel.
67 //
68 MpServices = Ppi;
69 Status = MpServices->StartupAllAPs (
70 (CONST EFI_PEI_SERVICES **)PeiServices,
71 MpServices,
72 ClearCache, // Procedure
73 FALSE, // SingleThread
74 0, // TimeoutInMicroSeconds: inf.
75 NULL // ProcedureArgument
76 );
77 if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) {
78 DEBUG ((DEBUG_ERROR, "%a: StartupAllAps(): %r\n", __func__, Status));
79 return Status;
80 }
81
82 //
83 // Now clear cache on the BSP too.
84 //
85 ClearCache (NULL);
86 return EFI_SUCCESS;
87}
88
89//
90// Notification object for registering the callback, for when
91// EFI_PEI_MP_SERVICES_PPI becomes available.
92//
93STATIC CONST EFI_PEI_NOTIFY_DESCRIPTOR mMpServicesNotify = {
94 EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | // Flags
95 EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
96 &gEfiPeiMpServicesPpiGuid, // Guid
97 ClearCacheOnMpServicesAvailable // Notify
98};
99
100VOID
101InstallClearCacheCallback (
102 VOID
103 )
104{
105 EFI_STATUS Status;
106
107 Status = PeiServicesNotifyPpi (&mMpServicesNotify);
108 if (EFI_ERROR (Status)) {
109 DEBUG ((
110 DEBUG_ERROR,
111 "%a: failed to set up MP Services callback: %r\n",
112 __func__,
113 Status
114 ));
115 }
116}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette