On 10/16/12 16:58, Jeff VanDellen wrote:
> I've attached the the output of the serial console while attempting to
> boot off the iso. Hopefully this information would be helpful.
>From the end of the attachment:
Loading driver at 0x00010000000 EntryPoint=0x00010001000 bootmgfw.efi
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF
C058FF18
ASSERT /usr/local/src/edk2/OvmfPkg/VirtioBlkDxe/VirtioBlk.c(950):
CR has Bad Signature
What a facepalm. I messed up VirtioBlkDriverBindingStop()!
EFI_STATUS
EFIAPI
VirtioBlkDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE DeviceHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
)
{
VBLK_DEV *Dev;
EFI_STATUS Status;
Dev = VIRTIO_BLK_FROM_BLOCK_IO (This);
"This" is not a pointer to EFI_BLOCK_IO_PROTOCOL, it is a pointer to
EFI_DRIVER_BINDING_PROTOCOL. My only excuse is that I must have been
using "OvmfPkg/BlockMmioToBlockIoDxe/BlockIo.c", function
BlockIoDriverBindingStop() as an example :)
The right way to do it is documented in the Driver Writer’s Guide for
UEFI 2.3.1, 8.4 Freeing private context data structures, and in the spec
(2.3.1+errC), 6.3 Protocol Handler Services, OpenProtocol().
The EFI_OPEN_PROTOCOL_GET_PROTOCOL attribute is key: with that the
function basically performs a lookup (just returns the BlockIo protocol
interface *we* have installed on the handle), and doesn't seem to
increment reference counters.
Does the attached patch work for you? (If it does, then I'll have to fix
VirtioScsi as well.)
Thanks & sorry!
Laszlo
From d44a787eb7fa1b3134aa4df14096639eb7efaec3 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <ler...@redhat.com>
Date: Tue, 16 Oct 2012 21:10:39 +0200
Subject: [PATCH] OvmfPkg: VirtioBlkDriverBindingStop: fix incorrect use of UEFI
driver model
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
index 1ac36cd..e8b1cf0 100644
--- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
+++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c
@@ -943,18 +943,32 @@ VirtioBlkDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer
)
{
- VBLK_DEV *Dev;
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ EFI_BLOCK_IO_PROTOCOL *BlockIo;
+ VBLK_DEV *Dev;
- Dev = VIRTIO_BLK_FROM_BLOCK_IO (This);
+ Status = gBS->OpenProtocol (
+ DeviceHandle, // candidate device
+ &gEfiBlockIoProtocolGuid, // retrieve the BlockIo iface
+ (VOID **)&BlockIo, // target pointer
+ This->DriverBindingHandle, // requestor driver identity
+ DeviceHandle, // requesting lookup for dev.
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL // lookup only, no ref. added
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Dev = VIRTIO_BLK_FROM_BLOCK_IO (BlockIo);
//
- // If DriverBindingStop() is called with the driver instance still in use,
- // or any of the parameters are invalid, we've caught a bug.
+ // Handle Stop() requests for in-use driver instances gracefully.
//
Status = gBS->UninstallProtocolInterface (DeviceHandle,
&gEfiBlockIoProtocolGuid, &Dev->BlockIo);
- ASSERT (Status == EFI_SUCCESS);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
VirtioBlkUninit (Dev);
--
1.7.1
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel