summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/PvScsiDxe
diff options
context:
space:
mode:
authorLiran Alon <liran.alon@oracle.com>2020-03-28 23:00:59 +0300
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-03-30 16:45:07 +0000
commit7d8a04e9d2fd8a5298636d5a0c702a978b5f22f1 (patch)
tree2e428b2ad021a28bb36c2322acf1be8e5e26a8d8 /OvmfPkg/PvScsiDxe
parentc4c15b870239c2c23442dfc29c4421ac98d00ee0 (diff)
downloadedk2-7d8a04e9d2fd8a5298636d5a0c702a978b5f22f1.tar.gz
edk2-7d8a04e9d2fd8a5298636d5a0c702a978b5f22f1.tar.bz2
edk2-7d8a04e9d2fd8a5298636d5a0c702a978b5f22f1.zip
OvmfPkg/PvScsiDxe: Reset device on ExitBootServices()
This causes the device to forget about the request/completion rings. We allocated said rings in EfiBootServicesData type memory, and code executing after ExitBootServices() is permitted to overwrite it. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2567 Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Liran Alon <liran.alon@oracle.com> Message-Id: <20200328200100.60786-17-liran.alon@oracle.com> Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
Diffstat (limited to 'OvmfPkg/PvScsiDxe')
-rw-r--r--OvmfPkg/PvScsiDxe/PvScsi.c43
-rw-r--r--OvmfPkg/PvScsiDxe/PvScsi.h1
2 files changed, 43 insertions, 1 deletions
diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c
index da3535c752..d7f0d3c879 100644
--- a/OvmfPkg/PvScsiDxe/PvScsi.c
+++ b/OvmfPkg/PvScsiDxe/PvScsi.c
@@ -1221,6 +1221,31 @@ PvScsiUninit (
PvScsiRestorePciAttributes (Dev);
}
+/**
+ Event notification called by ExitBootServices()
+**/
+STATIC
+VOID
+EFIAPI
+PvScsiExitBoot (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ PVSCSI_DEV *Dev;
+
+ Dev = Context;
+ DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __FUNCTION__, Context));
+
+ //
+ // Reset the device to stop device usage of the rings.
+ //
+ // We allocated said rings in EfiBootServicesData type memory, and code
+ // executing after ExitBootServices() is permitted to overwrite it.
+ //
+ PvScsiResetAdapter (Dev);
+}
+
//
// Driver Binding
//
@@ -1314,6 +1339,17 @@ PvScsiDriverBindingStart (
goto ClosePciIo;
}
+ Status = gBS->CreateEvent (
+ EVT_SIGNAL_EXIT_BOOT_SERVICES,
+ TPL_CALLBACK,
+ &PvScsiExitBoot,
+ Dev,
+ &Dev->ExitBoot
+ );
+ if (EFI_ERROR (Status)) {
+ goto UninitDev;
+ }
+
//
// Setup complete, attempt to export the driver instance's PassThru interface
//
@@ -1325,11 +1361,14 @@ PvScsiDriverBindingStart (
&Dev->PassThru
);
if (EFI_ERROR (Status)) {
- goto UninitDev;
+ goto CloseExitBoot;
}
return EFI_SUCCESS;
+CloseExitBoot:
+ gBS->CloseEvent (Dev->ExitBoot);
+
UninitDev:
PvScsiUninit (Dev);
@@ -1384,6 +1423,8 @@ PvScsiDriverBindingStop (
return Status;
}
+ gBS->CloseEvent (Dev->ExitBoot);
+
PvScsiUninit (Dev);
gBS->CloseProtocol (
diff --git a/OvmfPkg/PvScsiDxe/PvScsi.h b/OvmfPkg/PvScsiDxe/PvScsi.h
index 02feac7347..544359ebc0 100644
--- a/OvmfPkg/PvScsiDxe/PvScsi.h
+++ b/OvmfPkg/PvScsiDxe/PvScsi.h
@@ -51,6 +51,7 @@ typedef struct {
typedef struct {
UINT32 Signature;
EFI_PCI_IO_PROTOCOL *PciIo;
+ EFI_EVENT ExitBoot;
UINT64 OriginalPciAttributes;
PVSCSI_RING_DESC RingDesc;
PVSCSI_DMA_BUFFER *DmaBuf;