From nobody Tue Apr 23 07:23:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+41984+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41984+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1559807006; cv=none; d=zoho.com; s=zohoarc; b=ghiYd9QKvM3aruXHC2llDg0yU4p8i7nLXpep1dNL4O9r8LvoXfmobw8zg1VQaKbpBKOHymyaj0Mt0VcdBL858Ra8I+kO/H00pIO3d6KH5XwldM44dVZ38nUvJzeljSMJOfKyLp2Wol2cvCWj1xhhROUqVUjH6dn9Vb7xPrR1w3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559807006; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=WTUu3U6d2y5Wun/pK6jRLwD/fwirwQ6K2jztdQqkjkU=; b=NqhvOKgol3n9V9BizBKYmDClW5aPkXKO6V08dFyK1rNjp7lbwQgmehalG7uc3fd3n4IvxZXS0XKvxjjYvI8rU9UKl8uM7Q8Af2Dmz5+Yv/gsfXb1RfqCAwvGVULghqmdkHT49zKZ9ZHGtX2bV4FQRTNZAyxzpb0Sdeu8LACGj9U= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41984+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1559807006097708.8329942534938; Thu, 6 Jun 2019 00:43:26 -0700 (PDT) Return-Path: X-Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by groups.io with SMTP; Thu, 06 Jun 2019 00:43:24 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2019 00:43:24 -0700 X-ExtLoop1: 1 X-Received: from chenmarc-mobl.gar.corp.intel.com ([10.5.244.102]) by orsmga006.jf.intel.com with ESMTP; 06 Jun 2019 00:43:21 -0700 From: "Marc W Chen" To: devel@edk2.groups.io Cc: Marc Chen , Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Anthony Perard , Julien Grall , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Berger Subject: [edk2-devel] [PATCH v2] OvmfPkg/QemuVideoDxe: Shouldn't assume system in VGA alias mode. Date: Thu, 6 Jun 2019 15:42:37 +0800 Message-Id: <20190606074237.81492-1-marc.w.chen@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,marc.w.chen@intel.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1559807005; bh=hNrl4Qn5nsT3IkO5/by1iPzMM+iXYzGR5yIQYVxbwrA=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=DiNAnAU3bjFzsniqEn8mWJNeNrMwKR+j0owLjmOKGB0ULO5b4l2iQh52S+8x4xuyAvh Xyz2WZHQpDR0TMo0RINz9zneScdXOZ56SrSpjACGViXbrb4atWK0rn5dXVOHpcZadxgVL SWNLm2GZaOiMZIR51fx/sGn9fj6nLGftqrc= X-ZohoMail-DKIM: pass (identity @groups.io) Query the supported attributes firstly, then bitwise AND (&) both VGA_IO and VGA_IO_16. Since the supported attributes should only have one of VGA_IO or VGA_IO_16 set, the result of bitwise AND (&) is either VGA_IO or IO_16. Then the result can be passed to PciIo->Attributes() to set the attributes. Device driver should consider both since the mReserveVgaAliases in PciBusDxe driver is default FALSE(implies that device driver can only set VGA_IO_16 to PCI_ROOT_BRIDGE), and Platform code may not return EFI_RESERVE_VGA_IO_ALIAS in GetPlatformPolicy of PciPlatformProtocol to make mReserveVgaAliases become TRUE(implies that device driver can only set VGA_IO to PCI_ROOT_BRIDGE), Currently OvmfPkg doesn't have problem due to it has hard code value for PCI_ROOT_BRIDGE's attributes field, so an IO access by PciIoProtocol will be successed due to RootBridgeIoCheckParameter of PciRootBridgeIo.c will always get pass result for legacy IO access. Usually the attributes field of PCI_ROOT_BRIDGE should be 0, in that case it will have issue since the VGA_IO may not be able to be enabled, then IO access by PciIoProtocol will be failed, hence the QemuVideoDxe driver will not work fine. Signed-off-by: Marc Chen Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Cc: Anthony Perard Cc: Julien Grall Cc: Marc-Andr=C3=A9 Lureau Cc: Stefan Berger Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1880 Reviewed-by: Laszlo Ersek --- OvmfPkg/QemuVideoDxe/Driver.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/QemuVideoDxe/Driver.c b/OvmfPkg/QemuVideoDxe/Driver.c index e8a613ef33..522110ef4e 100644 --- a/OvmfPkg/QemuVideoDxe/Driver.c +++ b/OvmfPkg/QemuVideoDxe/Driver.c @@ -201,6 +201,7 @@ QemuVideoControllerDriverStart ( PCI_TYPE00 Pci; QEMU_VIDEO_CARD *Card; EFI_PCI_IO_PROTOCOL *ChildPciIo; + UINT64 SupportedVgaIo; =20 OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); =20 @@ -277,13 +278,32 @@ QemuVideoControllerDriverStart ( goto ClosePciIo; } =20 + // + // Get supported PCI attributes + // + Status =3D Private->PciIo->Attributes ( + Private->PciIo, + EfiPciIoAttributeOperationSupported, + 0, + &SupportedVgaIo + ); + if (EFI_ERROR (Status)) { + goto ClosePciIo; + } + + SupportedVgaIo &=3D (UINT64)(EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_AT= TRIBUTE_VGA_IO_16); + if (SupportedVgaIo =3D=3D 0) { + Status =3D EFI_UNSUPPORTED; + goto ClosePciIo; + } + // // Set new PCI attributes // Status =3D Private->PciIo->Attributes ( Private->PciIo, EfiPciIoAttributeOperationEnable, - EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_V= GA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO, + EFI_PCI_DEVICE_ENABLE | EFI_PCI_IO_ATTRIBUTE_V= GA_MEMORY | SupportedVgaIo, NULL ); if (EFI_ERROR (Status)) { --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#41984): https://edk2.groups.io/g/devel/message/41984 Mute This Topic: https://groups.io/mt/31948697/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-