summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/SmmControl2Dxe/SmiFeatures.h
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2016-11-30 20:06:34 +0100
committerLaszlo Ersek <lersek@redhat.com>2017-02-07 12:27:19 +0100
commita316d7ac91d302085b5c35d76db703f2208ec026 (patch)
tree51c4b0a0f2198179aabd5c83977b4c2e0e04c7c3 /OvmfPkg/SmmControl2Dxe/SmiFeatures.h
parent22d7be69c45ecc7ce2b21252710c37be7122c1bd (diff)
downloadedk2-a316d7ac91d302085b5c35d76db703f2208ec026.tar.gz
edk2-a316d7ac91d302085b5c35d76db703f2208ec026.tar.bz2
edk2-a316d7ac91d302085b5c35d76db703f2208ec026.zip
OvmfPkg/SmmControl2Dxe: select broadcast SMI if available
When writing to IO port 0xB2 (ICH9_APM_CNT), QEMU by default injects an SMI only on the VCPU that is writing the port. This has exposed corner cases and strange behavior with edk2 code, which generally expects a software SMI to affect all CPUs at once. We've experienced instability despite the fact that OVMF sets PcdCpuSmmApSyncTimeout and PcdCpuSmmSyncMode differently from the UefiCpuPkg defaults, such that they match QEMU's unicast SMIs better. (Refer to edk2 commits 9b1e378811ff and bb0f18b0bce6.) Using the new fw_cfg-based SMI feature negotiation in QEMU (see commits 50de920b372b "hw/isa/lpc_ich9: add SMI feature negotiation via fw_cfg" and 5ce45c7a2b15 "hw/isa/lpc_ich9: add broadcast SMI feature"), we can ask QEMU to broadcast SMIs. Extensive testing from earlier proves that broadcast SMIs are only reliable if we use the UefiCpuPkg defaults for the above PCDs. With those settings however, the broadcast is very reliable -- the most reliable configuration encountered thus far. Therefore negotiate broadcast SMIs with QEMU, and if the negotiation is successful, dynamically revert the PCDs to the UefiCpuPkg defaults. Setting the PCDs in this module is safe: - only PiSmmCpuDxeSmm consumes them, - PiSmmCpuDxeSmm is a DXE_SMM_DRIVER, launched by the SMM_CORE (MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf), - the SMM_CORE is launched by the SMM IPL runtime DXE driver (MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf), - the SMM IPL has a DEPEX on EFI_SMM_CONTROL2_PROTOCOL, - OvmfPkg/SmmControl2Dxe produces that protocol. The end result is that PiSmmCpuDxeSmm cannot be dispatched before SmmControl2Dxe installs EFI_SMM_CONTROL2_PROTOCOL and returns from its entry point. Hence we can set the PCD's consumed by PiSmmCpuDxeSmm in SmmControl2Dxe. Cc: Jordan Justen <jordan.l.justen@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=230 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Diffstat (limited to 'OvmfPkg/SmmControl2Dxe/SmiFeatures.h')
-rw-r--r--OvmfPkg/SmmControl2Dxe/SmiFeatures.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/OvmfPkg/SmmControl2Dxe/SmiFeatures.h b/OvmfPkg/SmmControl2Dxe/SmiFeatures.h
new file mode 100644
index 0000000000..9d5f1dbcb5
--- /dev/null
+++ b/OvmfPkg/SmmControl2Dxe/SmiFeatures.h
@@ -0,0 +1,49 @@
+/**@file
+ Negotiate SMI features with QEMU, and configure UefiCpuPkg/PiSmmCpuDxeSmm
+ accordingly.
+
+ Copyright (C) 2016-2017, Red Hat, Inc.
+
+ This program and the accompanying materials are licensed and made available
+ under the terms and conditions of the BSD License which accompanies this
+ distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
+ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+**/
+
+#ifndef __SMI_FEATURES_H__
+#define __SMI_FEATURES_H__
+
+#include <Protocol/S3SaveState.h>
+
+/**
+ Negotiate SMI features with QEMU.
+
+ @retval FALSE If SMI feature negotiation is not supported by QEMU. This is
+ not an error, it just means that SaveSmiFeatures() should not
+ be called.
+
+ @retval TRUE SMI feature negotiation is supported, and it has completed
+ successfully as well. (Failure to negotiate is a fatal error
+ and the function never returns in that case.)
+**/
+BOOLEAN
+NegotiateSmiFeatures (
+ VOID
+ );
+
+/**
+ Append a boot script fragment that will re-select the previously negotiated
+ SMI features during S3 resume.
+
+ @param[in] S3SaveState The EFI_S3_SAVE_STATE_PROTOCOL instance to append to
+ the S3 boot script with.
+**/
+VOID
+SaveSmiFeatures (
+ IN EFI_S3_SAVE_STATE_PROTOCOL *S3SaveState
+ );
+
+#endif