Blame SOURCES/ovmf-OvmfPkg-PlatformBootManagerLib-connect-consoles-unco.patch

6ef48d
From 3e05bfc48cd7b2cf4c1cbfc1d0cd2572338fad1e Mon Sep 17 00:00:00 2001
6ef48d
From: Laszlo Ersek <lersek@redhat.com>
6ef48d
Date: Tue, 15 May 2018 12:40:05 +0200
6ef48d
Subject: [PATCH 1/5] OvmfPkg/PlatformBootManagerLib: connect consoles
6ef48d
 unconditionally
6ef48d
6ef48d
Message-id: <20180515104005.12265-2-lersek@redhat.com>
6ef48d
Patchwork-id: 80268
6ef48d
O-Subject:  [RHEL-7.6 ovmf PATCH 1/1] OvmfPkg/PlatformBootManagerLib: connect
6ef48d
	consoles unconditionally
6ef48d
Bugzilla: 1577546
6ef48d
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
6ef48d
Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
6ef48d
6ef48d
If both ConIn and ConOut exist, but ConIn references none of the PS/2
6ef48d
keyboard, the USB wild-card keyboard, and any serial ports, then
6ef48d
PlatformInitializeConsole() currently allows the boot to proceed without
6ef48d
any input devices at all. This makes for a bad user experience -- the
6ef48d
firmware menu could only be entered through OsIndications, set by a guest
6ef48d
OS.
6ef48d
6ef48d
Do what ArmVirtQemu does already, namely connect the consoles, and add
6ef48d
them to ConIn / ConOut / ErrOut, unconditionally. (The underlying
6ef48d
EfiBootManagerUpdateConsoleVariable() function checks for duplicates.)
6ef48d
6ef48d
The issue used to be masked by the EfiBootManagerConnectAll() call that
6ef48d
got conditionalized in commit 245c643cc8b7.
6ef48d
6ef48d
This patch is best viewed with "git show -b -W".
6ef48d
6ef48d
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
6ef48d
Cc: Jordan Justen <jordan.l.justen@intel.com>
6ef48d
Fixes: 245c643cc8b73240c3b88cb55b2911b285a8c10d
6ef48d
Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1577546
6ef48d
Contributed-under: TianoCore Contribution Agreement 1.1
6ef48d
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
6ef48d
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
6ef48d
(cherry picked from commit f803c03cc2e0b6b0b0bed447a97ea2c61b04ed82)
6ef48d
---
6ef48d
 .../Library/PlatformBootManagerLib/BdsPlatform.c   | 127 +++++++--------------
6ef48d
 1 file changed, 44 insertions(+), 83 deletions(-)
6ef48d
6ef48d
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
6ef48d
index 862fa6e..004b753 100644
6ef48d
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
6ef48d
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
6ef48d
@@ -26,7 +26,6 @@ VOID          *mEfiDevPathNotifyReg;
6ef48d
 EFI_EVENT     mEfiDevPathEvent;
6ef48d
 VOID          *mEmuVariableEventReg;
6ef48d
 EFI_EVENT     mEmuVariableEvent;
6ef48d
-BOOLEAN       mDetectVgaOnly;
6ef48d
 UINT16        mHostBridgeDevId;
6ef48d
 
6ef48d
 //
6ef48d
@@ -830,35 +829,33 @@ DetectAndPreparePlatformPciDevicePath (
6ef48d
     );
6ef48d
   ASSERT_EFI_ERROR (Status);
6ef48d
 
6ef48d
-  if (!mDetectVgaOnly) {
6ef48d
+  //
6ef48d
+  // Here we decide whether it is LPC Bridge
6ef48d
+  //
6ef48d
+  if ((IS_PCI_LPC (Pci)) ||
6ef48d
+      ((IS_PCI_ISA_PDECODE (Pci)) &&
6ef48d
+       (Pci->Hdr.VendorId == 0x8086) &&
6ef48d
+       (Pci->Hdr.DeviceId == 0x7000)
6ef48d
+      )
6ef48d
+     ) {
6ef48d
     //
6ef48d
-    // Here we decide whether it is LPC Bridge
6ef48d
+    // Add IsaKeyboard to ConIn,
6ef48d
+    // add IsaSerial to ConOut, ConIn, ErrOut
6ef48d
     //
6ef48d
-    if ((IS_PCI_LPC (Pci)) ||
6ef48d
-        ((IS_PCI_ISA_PDECODE (Pci)) &&
6ef48d
-         (Pci->Hdr.VendorId == 0x8086) &&
6ef48d
-         (Pci->Hdr.DeviceId == 0x7000)
6ef48d
-        )
6ef48d
-       ) {
6ef48d
-      //
6ef48d
-      // Add IsaKeyboard to ConIn,
6ef48d
-      // add IsaSerial to ConOut, ConIn, ErrOut
6ef48d
-      //
6ef48d
-      DEBUG ((EFI_D_INFO, "Found LPC Bridge device\n"));
6ef48d
-      PrepareLpcBridgeDevicePath (Handle);
6ef48d
-      return EFI_SUCCESS;
6ef48d
-    }
6ef48d
+    DEBUG ((EFI_D_INFO, "Found LPC Bridge device\n"));
6ef48d
+    PrepareLpcBridgeDevicePath (Handle);
6ef48d
+    return EFI_SUCCESS;
6ef48d
+  }
6ef48d
+  //
6ef48d
+  // Here we decide which Serial device to enable in PCI bus
6ef48d
+  //
6ef48d
+  if (IS_PCI_16550SERIAL (Pci)) {
6ef48d
     //
6ef48d
-    // Here we decide which Serial device to enable in PCI bus
6ef48d
+    // Add them to ConOut, ConIn, ErrOut.
6ef48d
     //
6ef48d
-    if (IS_PCI_16550SERIAL (Pci)) {
6ef48d
-      //
6ef48d
-      // Add them to ConOut, ConIn, ErrOut.
6ef48d
-      //
6ef48d
-      DEBUG ((EFI_D_INFO, "Found PCI 16550 SERIAL device\n"));
6ef48d
-      PreparePciSerialDevicePath (Handle);
6ef48d
-      return EFI_SUCCESS;
6ef48d
-    }
6ef48d
+    DEBUG ((EFI_D_INFO, "Found PCI 16550 SERIAL device\n"));
6ef48d
+    PreparePciSerialDevicePath (Handle);
6ef48d
+    return EFI_SUCCESS;
6ef48d
   }
6ef48d
 
6ef48d
   //
6ef48d
@@ -878,26 +875,6 @@ DetectAndPreparePlatformPciDevicePath (
6ef48d
 
6ef48d
 
6ef48d
 /**
6ef48d
-  Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
6ef48d
-
6ef48d
-  @param[in]  DetectVgaOnly - Only detect VGA device if it's TRUE.
6ef48d
-
6ef48d
-  @retval EFI_SUCCESS - PCI Device check and Console variable update
6ef48d
-                        successfully.
6ef48d
-  @retval EFI_STATUS - PCI Device check or Console variable update fail.
6ef48d
-
6ef48d
-**/
6ef48d
-EFI_STATUS
6ef48d
-DetectAndPreparePlatformPciDevicePaths (
6ef48d
-  BOOLEAN DetectVgaOnly
6ef48d
-  )
6ef48d
-{
6ef48d
-  mDetectVgaOnly = DetectVgaOnly;
6ef48d
-  return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
6ef48d
-}
6ef48d
-
6ef48d
-
6ef48d
-/**
6ef48d
   Connect the predefined platform default console device.
6ef48d
 
6ef48d
   Always try to find and enable PCI display devices.
6ef48d
@@ -910,50 +887,34 @@ PlatformInitializeConsole (
6ef48d
   )
6ef48d
 {
6ef48d
   UINTN                              Index;
6ef48d
-  EFI_DEVICE_PATH_PROTOCOL           *VarConout;
6ef48d
-  EFI_DEVICE_PATH_PROTOCOL           *VarConin;
6ef48d
 
6ef48d
   //
6ef48d
-  // Connect RootBridge
6ef48d
+  // Do platform specific PCI Device check and add them to ConOut, ConIn,
6ef48d
+  // ErrOut
6ef48d
   //
6ef48d
-  GetEfiGlobalVariable2 (EFI_CON_OUT_VARIABLE_NAME, (VOID **) &VarConout,
6ef48d
-    NULL);
6ef48d
-  GetEfiGlobalVariable2 (EFI_CON_IN_VARIABLE_NAME, (VOID **) &VarConin, NULL);
6ef48d
-
6ef48d
-  if (VarConout == NULL || VarConin == NULL) {
6ef48d
-    //
6ef48d
-    // Do platform specific PCI Device check and add them to ConOut, ConIn,
6ef48d
-    // ErrOut
6ef48d
-    //
6ef48d
-    DetectAndPreparePlatformPciDevicePaths (FALSE);
6ef48d
+  VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
6ef48d
 
6ef48d
+  //
6ef48d
+  // Have chance to connect the platform default console,
6ef48d
+  // the platform default console is the minimum device group
6ef48d
+  // the platform should support
6ef48d
+  //
6ef48d
+  for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {
6ef48d
     //
6ef48d
-    // Have chance to connect the platform default console,
6ef48d
-    // the platform default console is the minimum device group
6ef48d
-    // the platform should support
6ef48d
+    // Update the console variable with the connect type
6ef48d
     //
6ef48d
-    for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {
6ef48d
-      //
6ef48d
-      // Update the console variable with the connect type
6ef48d
-      //
6ef48d
-      if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
6ef48d
-        EfiBootManagerUpdateConsoleVariable (ConIn,
6ef48d
-          PlatformConsole[Index].DevicePath, NULL);
6ef48d
-      }
6ef48d
-      if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
6ef48d
-        EfiBootManagerUpdateConsoleVariable (ConOut,
6ef48d
-          PlatformConsole[Index].DevicePath, NULL);
6ef48d
-      }
6ef48d
-      if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
6ef48d
-        EfiBootManagerUpdateConsoleVariable (ErrOut,
6ef48d
-          PlatformConsole[Index].DevicePath, NULL);
6ef48d
-      }
6ef48d
+    if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
6ef48d
+      EfiBootManagerUpdateConsoleVariable (ConIn,
6ef48d
+        PlatformConsole[Index].DevicePath, NULL);
6ef48d
+    }
6ef48d
+    if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
6ef48d
+      EfiBootManagerUpdateConsoleVariable (ConOut,
6ef48d
+        PlatformConsole[Index].DevicePath, NULL);
6ef48d
+    }
6ef48d
+    if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
6ef48d
+      EfiBootManagerUpdateConsoleVariable (ErrOut,
6ef48d
+        PlatformConsole[Index].DevicePath, NULL);
6ef48d
     }
6ef48d
-  } else {
6ef48d
-    //
6ef48d
-    // Only detect VGA device and add them to ConOut
6ef48d
-    //
6ef48d
-    DetectAndPreparePlatformPciDevicePaths (TRUE);
6ef48d
   }
6ef48d
 }
6ef48d
 
6ef48d
-- 
6ef48d
1.8.3.1
6ef48d