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=p4SH7m8i; spf=none, err=permanent DNS error (domain: bombadil.srs.infradead.org, ip: 198.137.202.133, mailfrom: batv+7e85d72c84c0ad68b2d1+5784+infradead.org+dwmw2@bombadil.srs.infradead.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by groups.io with SMTP; Tue, 25 Jun 2019 04:49:01 -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=11hUm+JiRctw3y8eY5w7xF7PfHSBtUgrv83eOd1/OUI=; b=p4SH7m8i8fpKHXN9giUNwV/Rpz I8Eh+GYRjRPKvT6aSoluIYy3Ocifqv4djD+uGIQdqlOqpCJLb5WmHJL6UjMrZpWFFzfIve5WsS1Ec O/iqe+reBNDXYEqC5Y28Aopt0b53qEO9yCIQwRDwnAgZewhwlsssuaA0Xs0SvxlVa7ux69qEMxwFo pAgQz6DYFmbhNMu3L1ZsCeqV/+CJLYZmYwXVHQR/vHdHxxU5ipOgRqCrleqym8rBd6Pe1lxEm6c3D Tyr2UR8V4uz9F8q3ilpK2bLGZeCRso2CuPJj8F1Wk8qGCsRHsAyJquLAbhe+qT7iZ4cQ2gSLqRTmE LpN5Unfg==; 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 1hfjwa-0002Pu-Dj; Tue, 25 Jun 2019 11:49:00 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.92 #3 (Red Hat Linux)) id 1hfjwZ-003Kuy-5n; Tue, 25 Jun 2019 12:48:59 +0100 From: "David Woodhouse" To: devel@edk2.groups.io Cc: Laszlo Ersek , Ray Ni Subject: [PATCH v2 6/7] MdeModulePkg/UefiBootManagerLib: describe VirtIO devices correctly Date: Tue, 25 Jun 2019 12:48:58 +0100 Message-Id: <20190625114859.795331-6-dwmw2@infradead.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190625114859.795331-1-dwmw2@infradead.org> References: <20190625114859.795331-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 | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c index 06edba8b4d..95adb9a7d3 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,37 @@ 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)) + // + // Separate checks for legacy/transitional VirtIO vs. Virtio 1.0+ + // + if (((Pci.Hdr.DeviceId >= 0x1000) && (Pci.Hdr.DeviceId <= 0x103F) && + (Pci.Hdr.RevisionID == 0x00)) || + (Pci.Hdr.DeviceId >= 0x1040 && Pci.Hdr.DeviceId <= 0x107F && + Pci.Hdr.RevisionID >= 0x01 && Pci.Device.SubsystemID >= 0x40 && + (Pci.Hdr.Status & EFI_PCI_STATUS_CAPABILITY) != 0)) { + Description = L"VirtIO Device"; + break; + } } + + Description = L"Misc Device"; break; } -- 2.21.0