From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: citrix.com, ip: 216.71.155.144, mailfrom: anthony.perard@citrix.com) Received: from esa4.hc3370-68.iphmx.com (esa4.hc3370-68.iphmx.com [216.71.155.144]) by groups.io with SMTP; Thu, 04 Jul 2019 07:58:39 -0700 Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 4C3oAaBPMzpSpCq59DS3iJHOINMXm6fH+JNG10tetOWQZhlZXBpUDKHYQYIEYvzvg8OMOTMVl9 TqdK2/BalUkD90cz8o06dPDq5sidju7i73Gv56RiUt9KiqP6r5pTxWQy5mOjzAopbUcrHMlCtb awiSTysjpwRYfb/2wW2egMcly5QDZg0ELiffpN9IPDMFL+y3bBUeodihNfiSXbHuZ766r81TDa jIS5Bc3yKTI4gw9oAz1ZTmcwO8Ga5LnYIW+4LUAftQCcsifq4lp+9gKV3tA/oDxFzaqqokEAto z/I= X-SBRS: 2.7 X-MesageID: 2650941 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.63,451,1557201600"; d="scan'208";a="2650941" From: "Anthony PERARD" To: CC: , Ard Biesheuvel , Jordan Justen , Laszlo Ersek , Julien Grall , Anthony PERARD Subject: [PATCH v3 32/35] OvmfPkg/PlatformBootManagerLib: Use a Xen console for ConOut/ConIn Date: Thu, 4 Jul 2019 15:42:30 +0100 Message-ID: <20190704144233.27968-33-anthony.perard@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190704144233.27968-1-anthony.perard@citrix.com> References: <20190704144233.27968-1-anthony.perard@citrix.com> MIME-Version: 1.0 Return-Path: anthony.perard@citrix.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain On a Xen PVH guest, none of the existing serial or console interface works, so we add a new one, based on XenConsoleSerialPortLib, and implemented via SerialDxe. That is a simple console implementation that can works on both PVH guest and HVM guests, even if it rarely going to be use on HVM. Have PlatformBootManagerLib look for the new console, when running as a Xen guest. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1689 Signed-off-by: Anthony PERARD --- Notes: v3: - removed PciSioSerialDxe and IsaSerialDxe from OvmfXen, since they would not be used, maybe, to check. - some coding style fix =20=20=20=20 - not changed: PciSioSerialDxe: even if we add SerialDxe, we still needs PciSioSerialDxe to have OVMF use the emulated serial port on HVM. =20=20=20=20 v2: - Use MdeModulePkg/Universal/SerialDxe instead of something new. - Have PlatformInitializeConsole() look for it by using the known-in-advance device path for the xen console in the PLATFORM_CONSOLE_CONNECT_ENTRY. OvmfPkg/OvmfXen.dsc | 4 ++ OvmfPkg/OvmfXen.fdf | 1 + .../PlatformBootManagerLib.inf | 4 ++ .../PlatformBootManagerLib/BdsPlatform.h | 1 + .../PlatformBootManagerLib/BdsPlatform.c | 3 +- .../PlatformBootManagerLib/PlatformData.c | 59 ++++++++++++++++++- 6 files changed, 69 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc index 1ecae3fb45..487bada64d 100644 --- a/OvmfPkg/OvmfXen.dsc +++ b/OvmfPkg/OvmfXen.dsc @@ -586,6 +586,10 @@ [Components] OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf=0D OvmfPkg/XenBusDxe/XenBusDxe.inf=0D OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf=0D + MdeModulePkg/Universal/SerialDxe/SerialDxe.inf {=0D + =0D + SerialPortLib|OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSeri= alPortLib.inf=0D + }=0D MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf=0D MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntim= eDxe.inf=0D MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf=0D diff --git a/OvmfPkg/OvmfXen.fdf b/OvmfPkg/OvmfXen.fdf index fa0830a324..5c1a925d6a 100644 --- a/OvmfPkg/OvmfXen.fdf +++ b/OvmfPkg/OvmfXen.fdf @@ -312,6 +312,7 @@ [FV.DXEFV] INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf=0D INF OvmfPkg/XenBusDxe/XenBusDxe.inf=0D INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf=0D +INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf=0D =0D INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf=0D INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRun= timeDxe.inf=0D diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.= inf b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf index b2d3b4fb4d..646a1c522c 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf @@ -61,6 +61,10 @@ [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable=0D gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId=0D gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut=0D + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate ## CONSUMES=0D + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits ## CONSUMES=0D + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity ## CONSUMES=0D + gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits ## CONSUMES=0D =0D [Pcd.IA32, Pcd.X64]=0D gEfiMdePkgTokenSpaceGuid.PcdFSBClock=0D diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h b/OvmfPkg= /Library/PlatformBootManagerLib/BdsPlatform.h index 49a072b400..153e215101 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.h @@ -165,6 +165,7 @@ typedef struct { #define CONSOLE_IN BIT1=0D #define STD_ERROR BIT2=0D extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[];=0D +extern PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[];=0D =0D //=0D // Platform BDS Functions=0D diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg= /Library/PlatformBootManagerLib/BdsPlatform.c index 9ae590293a..ee6ee6608f 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c @@ -399,7 +399,8 @@ PlatformBootManagerBeforeConsole ( //=0D EfiBootManagerDispatchDeferredImages ();=0D =0D - PlatformInitializeConsole (gPlatformConsole);=0D + PlatformInitializeConsole (=0D + XenDetected() ? gXenPlatformConsole : gPlatformConsole);=0D PcdStatus =3D PcdSet16S (PcdPlatformBootTimeOut,=0D GetFrontPageTimeoutFromQemu ());=0D ASSERT_RETURN_ERROR (PcdStatus);=0D diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c b/OvmfPk= g/Library/PlatformBootManagerLib/PlatformData.c index 36aab784d7..a9b1fe274a 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c +++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformData.c @@ -9,18 +9,19 @@ =0D #include "BdsPlatform.h"=0D #include =0D +#include =0D =0D //=0D // Debug Agent UART Device Path structure=0D //=0D -#pragma pack(1)=0D +#pragma pack (1)=0D typedef struct {=0D VENDOR_DEVICE_PATH VendorHardware;=0D UART_DEVICE_PATH Uart;=0D VENDOR_DEVICE_PATH TerminalType;=0D EFI_DEVICE_PATH_PROTOCOL End;=0D } VENDOR_UART_DEVICE_PATH;=0D -#pragma pack()=0D +#pragma pack ()=0D =0D //=0D // USB Keyboard Device Path structure=0D @@ -43,6 +44,18 @@ typedef struct { } VENDOR_RAMFB_DEVICE_PATH;=0D #pragma pack ()=0D =0D +//=0D +// Xen Console Device Path structure=0D +//=0D +#pragma pack(1)=0D +typedef struct {=0D + VENDOR_DEVICE_PATH VendorHardware;=0D + UART_DEVICE_PATH Uart;=0D + VENDOR_DEVICE_PATH TerminalType;=0D + EFI_DEVICE_PATH_PROTOCOL End;=0D +} XEN_CONSOLE_DEVICE_PATH;=0D +#pragma pack()=0D +=0D ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode =3D gPnpPs2Keyboard;= =0D ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode =3D gPnp16550ComPort= ;=0D UART_DEVICE_PATH gUartDeviceNode =3D gUart;=0D @@ -141,6 +154,37 @@ STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = =3D { gEndEntire=0D };=0D =0D +STATIC XEN_CONSOLE_DEVICE_PATH gXenConsoleDevicePath =3D {=0D + {=0D + {=0D + HARDWARE_DEVICE_PATH,=0D + HW_VENDOR_DP,=0D + {=0D + (UINT8) (sizeof (VENDOR_DEVICE_PATH)),=0D + (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)=0D + }=0D + },=0D + EDKII_SERIAL_PORT_LIB_VENDOR_GUID=0D + },=0D + {=0D + {=0D + MESSAGING_DEVICE_PATH,=0D + MSG_UART_DP,=0D + {=0D + (UINT8) (sizeof (UART_DEVICE_PATH)),=0D + (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)=0D + }=0D + },=0D + 0,=0D + FixedPcdGet64 (PcdUartDefaultBaudRate),=0D + FixedPcdGet8 (PcdUartDefaultDataBits),=0D + FixedPcdGet8 (PcdUartDefaultParity),=0D + FixedPcdGet8 (PcdUartDefaultStopBits),=0D + },=0D + gPcAnsiTerminal,=0D + gEndEntire=0D +};=0D +=0D //=0D // Predefined platform default console device path=0D //=0D @@ -163,6 +207,17 @@ PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = =3D { }=0D };=0D =0D +PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[] =3D {=0D + {=0D + (EFI_DEVICE_PATH_PROTOCOL *)&gXenConsoleDevicePath,=0D + (CONSOLE_OUT | CONSOLE_IN | STD_ERROR)=0D + },=0D + {=0D + NULL,=0D + 0=0D + }=0D +};=0D +=0D //=0D // Predefined platform connect sequence=0D //=0D --=20 Anthony PERARD