From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=cFiH5fxz; spf=none, err=permanent DNS error (domain: bombadil.srs.infradead.org, ip: 198.137.202.133, mailfrom: batv+2e1b3bf406a0b60cb2b2+5780+infradead.org+dwmw2@bombadil.srs.infradead.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by groups.io with SMTP; Fri, 21 Jun 2019 15:31:58 -0700 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ndLWymzXw1hP6JIR5o7Pa0am2yt7wqw0ahHsaH9cgIM=; b=cFiH5fxz4otsBX7sYiwJ+mQ+QJ B/d0iMnxJKzPZiXeniCA5yIVDbU93RZcCrXV1CyLPYWWwepf4DfBVpOyfHGFwE/Ab1KQMQvPaoCcb X1I+La8X5+AHHzMe6N9TtH8oeiyb8lxrPmujhCPoQYkDIixmpb79cKG6LHlt43lsJ1Dg2e71dXPvc nAv+8iru0GKTJmfg/McuzxKNQqyt1oZ3ryvvuv8rlI28ExcqY7WtnkvE4FMPint1P2WZW1zxjSiRE mGJzyJVlStU5Jj/Vo736BcmnLtDsHRrHQAGTajMHMipz3DRFybsaQ5xr2RaBxbLK12/sMV18XMkF1 SfuefGKw==; Received: from [2001:8b0:10b:1::425] (helo=i7.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1heS4b-0000KU-TJ; Fri, 21 Jun 2019 22:31:58 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1heS4a-002wVb-L1; Fri, 21 Jun 2019 23:31:56 +0100 From: "David Woodhouse" To: devel@edk2.groups.io Cc: Laszlo Ersek , Ray Ni Subject: [PATCH 6/7] MdeModulePkg/UefiBootManagerLib: describe VirtIO devices correctly Date: Fri, 21 Jun 2019 23:31:55 +0100 Message-Id: <20190621223156.701502-6-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190621223156.701502-1-dwmw2@infradead.org> References: <20190621223156.701502-1-dwmw2@infradead.org> MIME-Version: 1.0 Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Content-Transfer-Encoding: 8bit I know, I said it was Someone Else's Problem. But it annoyed me. My initial thought was to look for VIRTIO_DEVICE_PROTOCOL on the same handle but I don't think I can do that if I can't rely on VirtIO being present in the build. This will do. Signed-off-by: David Woodhouse --- .../UefiBootManagerLib/BmBootDescription.c | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c index dd4d160f31..b7d9e98790 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c @@ -661,6 +661,8 @@ BmGetMiscDescription ( CHAR16 *Description; EFI_BLOCK_IO_PROTOCOL *BlockIo; EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Fs; + EFI_PCI_IO_PROTOCOL *PciIo; + PCI_TYPE00 Pci; switch (BmDevicePathType (DevicePathFromHandle (Handle))) { case BmAcpiFloppyBoot: @@ -698,9 +700,33 @@ BmGetMiscDescription ( Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID **) &Fs); if (!EFI_ERROR (Status)) { Description = L"Non-Block Boot Device"; - } else { - Description = L"Misc Device"; + break; + } + Status = gBS->HandleProtocol (Handle, &gEfiPciIoProtocolGuid, (VOID **) &PciIo); + if (!EFI_ERROR (Status)) { + Status = PciIo->Pci.Read ( + PciIo, // (protocol, device) + // handle + EfiPciIoWidthUint32, // access width & copy + // mode + 0, // Offset + sizeof Pci / sizeof (UINT32), // Count + &Pci // target buffer + ); + // + // If the same node is a Qumranet/Red Hat PCI device, it's VirtIO. + // + if (!EFI_ERROR (Status) && + (Pci.Hdr.VendorId == 0x1AF4) && + (Pci.Hdr.DeviceId >= 0x1000) && + (Pci.Hdr.DeviceId <= 0x103F) && + (Pci.Hdr.RevisionID == 0x00)) { + Description = L"VirtIO Device"; + break; + } } + + Description = L"Misc Device"; break; } -- 2.21.0