VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.c

Last change on this file was 108794, checked in by vboxsync, 5 weeks ago

Devices/EFI/FirmwareNew: Merge edk2-stable202502 from the vendor branch and make it build for the important platforms, bugref:4643

  • Property svn:eol-style set to native
File size: 4.5 KB
Line 
1/** @file
2SMM CPU Platform Hook library instance for QEMU.
3
4Copyright (c) 2020, Red Hat, Inc.
5Copyright (c) 2006 - 2024, Intel Corporation. All rights reserved.<BR>
6SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9#include <Library/BaseLib.h> // AsmReadMsr64()
10#include <PiSmm.h>
11#include <Register/Intel/ArchitecturalMsr.h> // MSR_IA32_APIC_BASE_REGISTER
12
13#include <Library/SmmCpuPlatformHookLib.h>
14
15/**
16 Checks if platform produces a valid SMI.
17
18 This function checks if platform produces a valid SMI. This function is
19 called at SMM entry to detect if this is a spurious SMI. This function
20 must be implemented in an MP safe way because it is called by multiple CPU
21 threads.
22
23 @retval TRUE There is a valid SMI
24 @retval FALSE There is no valid SMI
25
26**/
27BOOLEAN
28EFIAPI
29PlatformValidSmi (
30 VOID
31 )
32{
33 return TRUE;
34}
35
36/**
37 Clears platform top level SMI status bit.
38
39 This function clears platform top level SMI status bit.
40
41 @retval TRUE The platform top level SMI status is cleared.
42 @retval FALSE The platform top level SMI status cannot be
43 cleared.
44
45**/
46BOOLEAN
47EFIAPI
48ClearTopLevelSmiStatus (
49 VOID
50 )
51{
52 return TRUE;
53}
54
55/**
56 Performs platform specific way of SMM BSP election.
57
58 This function performs platform specific way of SMM BSP election.
59
60 @param IsBsp Output parameter. TRUE: the CPU this function
61 executes on is elected to be the SMM BSP. FALSE:
62 the CPU this function executes on is to be SMM AP.
63
64 @retval EFI_SUCCESS The function executes successfully.
65 @retval EFI_NOT_READY The function does not determine whether this CPU
66 should be BSP or AP. This may occur if hardware
67 init sequence to enable the determination is yet to
68 be done, or the function chooses not to do BSP
69 election and will let SMM CPU driver to use its
70 default BSP election process.
71 @retval EFI_DEVICE_ERROR The function cannot determine whether this CPU
72 should be BSP or AP due to hardware error.
73
74**/
75EFI_STATUS
76EFIAPI
77PlatformSmmBspElection (
78 OUT BOOLEAN *IsBsp
79 )
80{
81 MSR_IA32_APIC_BASE_REGISTER ApicBaseMsr;
82
83 ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE);
84 *IsBsp = (BOOLEAN)(ApicBaseMsr.Bits.BSP == 1);
85 return EFI_SUCCESS;
86}
87
88/**
89 Get platform page table attribute.
90
91 This function gets page table attribute of platform.
92
93 @param Address Input parameter. Obtain the page table entries
94 attribute on this address.
95 @param PageSize Output parameter. The size of the page.
96 @param NumOfPages Output parameter. Number of page.
97 @param PageAttribute Output parameter. Paging Attributes (WB, UC, etc).
98
99 @retval EFI_SUCCESS The platform page table attribute from the address
100 is determined.
101 @retval EFI_UNSUPPORTED The platform does not support getting page table
102 attribute for the address.
103
104**/
105EFI_STATUS
106EFIAPI
107GetPlatformPageTableAttribute (
108 IN UINT64 Address,
109 IN OUT SMM_PAGE_SIZE_TYPE *PageSize,
110 IN OUT UINTN *NumOfPages,
111 IN OUT UINTN *PageAttribute
112 )
113{
114 return EFI_UNSUPPORTED;
115}
116
117/**
118 SMM CPU Platform Hook before executing MMI Handler.
119
120 This function can be used to perform the platform specific items before executing MMI Handler.
121
122 @retval EFI_SUCCESS The smm cpu platform hook before executing MMI Handler is executed successfully.
123 @retval EFI_UNSUPPORTED The smm cpu platform hook before executing MMI Handler is unsupported.
124
125**/
126EFI_STATUS
127EFIAPI
128SmmCpuPlatformHookBeforeMmiHandler (
129 VOID
130 )
131{
132 return EFI_UNSUPPORTED;
133}
134
135/**
136 This function determines whether the first CPU Synchronization should be executed unconditionally
137 when a SMI occurs.
138
139 If the function returns true, it indicates that there is no need to check the system configuration
140 and status, and the first CPU Synchronization should be executed unconditionally.
141
142 If the function returns false, it indicates that the first CPU Synchronization is not executed
143 unconditionally, and the decision to synchronize should be based on the system configuration and status.
144
145 @retval TRUE The first CPU Synchronization is executed unconditionally.
146 @retval FALSE The first CPU Synchronization is not executed unconditionally.
147
148**/
149BOOLEAN
150EFIAPI
151IsCpuSyncAlwaysNeeded (
152 VOID
153 )
154{
155 return FALSE;
156}
Note: See TracBrowser for help on using the repository browser.

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