From: "Anthony PERARD" <anthony.perard@citrix.com>
To: <devel@edk2.groups.io>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Julien Grall <julien.grall@arm.com>,
Jordan Justen <jordan.l.justen@intel.com>,
<xen-devel@lists.xenproject.org>,
Anthony Perard <anthony.perard@citrix.com>,
Laszlo Ersek <lersek@redhat.com>
Subject: [PATCH 10/11] OvmfPkg/XenPvBlkDxe: Use XenBusIo->RegisterExitCallback
Date: Fri, 13 Sep 2019 15:50:59 +0100 [thread overview]
Message-ID: <20190913145100.303433-11-anthony.perard@citrix.com> (raw)
In-Reply-To: <20190913145100.303433-1-anthony.perard@citrix.com>
In order to be able to reset the backend before handing it to the next
operating system, it should be reset properly. This patch register a
callback function to be called by XenBusDxe during the
ExitBootServices event.
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2190
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
OvmfPkg/XenPvBlkDxe/BlockFront.c | 37 ++++++++++++++++++++++++++++---
OvmfPkg/XenPvBlkDxe/BlockFront.h | 12 +++++++++-
OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.c | 4 ++--
3 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/OvmfPkg/XenPvBlkDxe/BlockFront.c b/OvmfPkg/XenPvBlkDxe/BlockFront.c
index 25a398ccc4..7c166888bd 100644
--- a/OvmfPkg/XenPvBlkDxe/BlockFront.c
+++ b/OvmfPkg/XenPvBlkDxe/BlockFront.c
@@ -309,6 +309,8 @@ XenPvBlockFrontInitialization (
Dev->MediaInfo.Sectors, Dev->MediaInfo.SectorSize));
*DevPtr = Dev;
+
+ XenBusIo->RegisterExitCallback (XenBusIo, XenPvBlockFrontReset, Dev);
return EFI_SUCCESS;
Error2:
@@ -326,13 +328,16 @@ XenPvBlockFrontInitialization (
VOID
XenPvBlockFrontShutdown (
- IN XEN_BLOCK_FRONT_DEVICE *Dev
+ IN XEN_BLOCK_FRONT_DEVICE *Dev,
+ IN BOOLEAN ResetOnly
)
{
XENBUS_PROTOCOL *XenBusIo = Dev->XenBusIo;
XENSTORE_STATUS Status;
UINT64 Value;
+ XenBusIo->RegisterExitCallback (XenBusIo, NULL, NULL);
+
XenPvBlockSync (Dev);
Status = XenBusIo->SetState (XenBusIo, XST_NIL, XenbusStateClosing);
@@ -393,12 +398,38 @@ XenPvBlockFrontShutdown (
}
Close:
- XenBusIo->UnregisterWatch (XenBusIo, Dev->StateWatchToken);
+ if (!ResetOnly) {
+ XenBusIo->UnregisterWatch (XenBusIo, Dev->StateWatchToken);
+ }
XenBusIo->XsRemove (XenBusIo, XST_NIL, "ring-ref");
XenBusIo->XsRemove (XenBusIo, XST_NIL, "event-channel");
XenBusIo->XsRemove (XenBusIo, XST_NIL, "protocol");
- XenPvBlockFree (Dev);
+ if (ResetOnly) {
+ XenBusIo->GrantEndAccess (XenBusIo, Dev->RingRef);
+ XenBusIo->EventChannelClose (XenBusIo, Dev->EventChannel);
+ } else {
+ XenPvBlockFree (Dev);
+ }
+}
+
+/**
+ To be called when ExitBootServices has been called.
+
+ This should reset the PV backend without using memory allocation
+ services.
+**/
+VOID
+EFIAPI
+XenPvBlockFrontReset (
+ IN VOID *Context
+ )
+{
+ XEN_BLOCK_FRONT_DEVICE *Dev;
+
+ Dev = Context;
+
+ XenPvBlockFrontShutdown (Dev, TRUE);
}
STATIC
diff --git a/OvmfPkg/XenPvBlkDxe/BlockFront.h b/OvmfPkg/XenPvBlkDxe/BlockFront.h
index 7c2d7f2c9e..ebce4fe434 100644
--- a/OvmfPkg/XenPvBlkDxe/BlockFront.h
+++ b/OvmfPkg/XenPvBlkDxe/BlockFront.h
@@ -67,9 +67,19 @@ XenPvBlockFrontInitialization (
OUT XEN_BLOCK_FRONT_DEVICE **DevPtr
);
+/**
+ @param ResetOnly Set to TRUE when called during the ExitBootServices.
+**/
VOID
XenPvBlockFrontShutdown (
- IN XEN_BLOCK_FRONT_DEVICE *Dev
+ IN XEN_BLOCK_FRONT_DEVICE *Dev,
+ IN BOOLEAN ResetOnly
+ );
+
+VOID
+EFIAPI
+XenPvBlockFrontReset (
+ IN VOID *Context
);
VOID
diff --git a/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.c b/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.c
index bfe7b1a754..3031406980 100644
--- a/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.c
+++ b/OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.c
@@ -312,7 +312,7 @@ XenPvBlkDxeDriverBindingStart (
UninitBlockFront:
FreePool (Media);
- XenPvBlockFrontShutdown (Dev);
+ XenPvBlockFrontShutdown (Dev, FALSE);
CloseProtocol:
gBS->CloseProtocol (ControllerHandle, &gXenBusProtocolGuid,
This->DriverBindingHandle, ControllerHandle);
@@ -377,7 +377,7 @@ XenPvBlkDxeDriverBindingStop (
Media = BlockIo->Media;
Dev = XEN_BLOCK_FRONT_FROM_BLOCK_IO (BlockIo);
- XenPvBlockFrontShutdown (Dev);
+ XenPvBlockFrontShutdown (Dev, FALSE);
FreePool (Media);
--
Anthony PERARD
next prev parent reply other threads:[~2019-09-13 15:10 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-13 14:50 [PATCH 00/11] OvmfPkg/XenBusDxe: Fix ExitBootServices handler to avoid allocation Anthony PERARD
2019-09-13 14:50 ` [PATCH 01/11] OvmfPkg/XenBusDxe: Fix missing \n in DEBUG messages Anthony PERARD
2019-09-16 14:24 ` [edk2-devel] " Laszlo Ersek
2019-09-13 14:50 ` [PATCH 02/11] OvmfPkg/XenBusDxe: Have XenStoreFindWatch take a pointer Anthony PERARD
2019-09-16 14:38 ` [edk2-devel] " Laszlo Ersek
2019-09-13 14:50 ` [PATCH 03/11] OvmfPkg/XenBusDxe: Rework watch events reception Anthony PERARD
2019-09-16 14:39 ` [edk2-devel] " Laszlo Ersek
2019-09-13 14:50 ` [PATCH 04/11] OvmfPkg/XenBusDxe: Avoid Allocate in XenStoreVSPrint Anthony PERARD
2019-09-16 14:45 ` [edk2-devel] " Laszlo Ersek
2019-09-13 14:50 ` [PATCH 05/11] OvmfPkg/XenBusDxe: Construct paths without allocation Anthony PERARD
2019-09-16 15:39 ` [edk2-devel] " Laszlo Ersek
2019-09-16 15:43 ` Laszlo Ersek
2019-09-13 14:50 ` [PATCH 06/11] OvmfPkg/XenBusDxe: Rework XenStoreProcessMessage to avoid allocating memory Anthony PERARD
2019-09-16 15:41 ` [edk2-devel] " Laszlo Ersek
2019-09-13 14:50 ` [PATCH 07/11] OvmfPkg/XenBusDxe: Use on stack buffer in internal functions Anthony PERARD
2019-09-16 16:11 ` [edk2-devel] " Laszlo Ersek
2019-09-13 14:50 ` [PATCH 08/11] OvmfPkg/XenBus: Change XENBUS_PROTOCOL to not return allocated memory Anthony PERARD
2019-09-16 16:16 ` [edk2-devel] " Laszlo Ersek
2019-09-13 14:50 ` [PATCH 09/11] OvmfPkg/XenBusDxe: Fix NotifyExitBoot to avoid Memory Allocation Services Anthony PERARD
2019-09-16 17:36 ` [edk2-devel] " Laszlo Ersek
2019-09-16 18:36 ` Andrew Fish
2019-09-16 19:31 ` Laszlo Ersek
2019-09-16 20:50 ` Andrew Fish
2019-09-13 14:50 ` Anthony PERARD [this message]
2019-09-13 14:51 ` [PATCH 11/11] OvmfPkg/XenBusDxe: Fix XenStoreWaitForEvent use during EBS Anthony PERARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190913145100.303433-11-anthony.perard@citrix.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox