diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2015-02-28 20:32:27 +0000 |
---|---|---|
committer | lersek <lersek@Edk2> | 2015-02-28 20:32:27 +0000 |
commit | bbc3758ab5bc0e526994a63d739d445416ff0c07 (patch) | |
tree | f55eaa48c03a5442fb83891d1207e853de731ec2 /OvmfPkg/XenBusDxe/XenBusDxe.c | |
parent | d6970b9b4155db6835629ec938f86490b3ae5091 (diff) | |
download | edk2-platforms-bbc3758ab5bc0e526994a63d739d445416ff0c07.tar.xz |
Ovmf/Xen: refactor XenBusDxe hypercall implementation
This refactors the Xen hypercall implementation that is part of the
XenBusDxe driver, in preparation of splitting it off entirely into
a XenHypercallLib library. This involves:
- removing the dependency on XENBUS_DEVICE* pointers in the XenHypercall()
prototypes
- moving the discovered hyperpage address to a global variable
- moving XenGetSharedInfoPage() to its only user XenBusDxe.c (the shared info
page is not strictly part of the Xen hypercall interface, and is not used
by other expected users of XenHypercallLib such as the Xen console version
of SerialPortLib
- reimplement XenHypercall2() in C and move the indexing of the hyperpage
there; the existing asm implementations are renamed to __XenHypercall2() and
invoked from the new C implementation.
Contributed-under: TianoCore Contribution Agreement 1.0
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16969 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OvmfPkg/XenBusDxe/XenBusDxe.c')
-rw-r--r-- | OvmfPkg/XenBusDxe/XenBusDxe.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.c b/OvmfPkg/XenBusDxe/XenBusDxe.c index 7a7fd82d55..d333b331b6 100644 --- a/OvmfPkg/XenBusDxe/XenBusDxe.c +++ b/OvmfPkg/XenBusDxe/XenBusDxe.c @@ -34,6 +34,8 @@ #include "XenStore.h"
#include "XenBus.h"
+#include <IndustryStandard/Xen/hvm/params.h>
+#include <IndustryStandard/Xen/memory.h>
///
/// Driver Binding Protocol instance
@@ -52,6 +54,46 @@ STATIC EFI_LOCK mMyDeviceLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_CALLBACK STATIC XENBUS_DEVICE *mMyDevice = NULL;
/**
+ Map the shared_info_t page into memory.
+
+ @param Dev A XENBUS_DEVICE instance.
+
+ @retval EFI_SUCCESS Dev->SharedInfo whill contain a pointer to
+ the shared info page
+ @retval EFI_LOAD_ERROR The shared info page could not be mapped. The
+ hypercall returned an error.
+**/
+STATIC
+EFI_STATUS
+XenGetSharedInfoPage (
+ IN OUT XENBUS_DEVICE *Dev
+ )
+{
+ xen_add_to_physmap_t Parameter;
+
+ ASSERT (Dev->SharedInfo == NULL);
+
+ Parameter.domid = DOMID_SELF;
+ Parameter.space = XENMAPSPACE_shared_info;
+ Parameter.idx = 0;
+
+ //
+ // using reserved page because the page is not released when Linux is
+ // starting because of the add_to_physmap. QEMU might try to access the
+ // page, and fail because it have no right to do so (segv).
+ //
+ Dev->SharedInfo = AllocateReservedPages (1);
+ Parameter.gpfn = (UINTN) Dev->SharedInfo >> EFI_PAGE_SHIFT;
+ if (XenHypercallMemoryOp (XENMEM_add_to_physmap, &Parameter) != 0) {
+ FreePages (Dev->SharedInfo, 1);
+ Dev->SharedInfo = NULL;
+ return EFI_LOAD_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
Unloads an image.
@param ImageHandle Handle that identifies the image to be unloaded.
@@ -348,7 +390,7 @@ XenBusDxeDriverBindingStart ( MmioAddr = BarDesc->AddrRangeMin;
FreePool (BarDesc);
- Status = XenHyperpageInit (Dev);
+ Status = XenHyperpageInit ();
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "XenBus: Unable to retrieve the hyperpage.\n"));
Status = EFI_UNSUPPORTED;
|