Ovmf/Xen: move XenBusDxe hypercall code to separate library
This moves all of the Xen hypercall code that was private to XenBusDxe to a new library class XenHypercallLib. This will allow us to reimplement it for ARM, and to export the Xen hypercall functionality to other parts of the code, such as a Xen console SerialPortLib driver. Contributed-under: TianoCore Contribution Agreement 1.0 Reviewed-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@16970 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef __XENBUS_DXE_HYPERCALL_H__
|
#ifndef __XEN_HYPERCALL_LIB_H__
|
||||||
#define __XENBUS_DXE_HYPERCALL_H__
|
#define __XEN_HYPERCALL_LIB_H__
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function will put the two arguments in the right place (registers) and
|
This function will put the two arguments in the right place (registers) and
|
||||||
@ -29,21 +29,9 @@
|
|||||||
INTN
|
INTN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
XenHypercall2 (
|
XenHypercall2 (
|
||||||
IN INTN HypercallID,
|
IN UINTN HypercallID,
|
||||||
IN OUT INTN Arg1,
|
IN OUT INTN Arg1,
|
||||||
IN OUT INTN Arg2
|
IN OUT INTN Arg2
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get the page where all hypercall are from the XenInfo hob.
|
|
||||||
|
|
||||||
@param Dev A XENBUS_DEVICE instance.
|
|
||||||
|
|
||||||
@retval EFI_NOT_FOUND hyperpage could not be found.
|
|
||||||
@retval EFI_SUCCESS Successfully retrieve the hyperpage pointer.
|
|
||||||
**/
|
|
||||||
EFI_STATUS
|
|
||||||
XenHyperpageInit (
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
@ -14,43 +14,12 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
#include <PiDxe.h>
|
#include <PiDxe.h>
|
||||||
#include <Library/HobLib.h>
|
|
||||||
#include <Guid/XenInfo.h>
|
|
||||||
|
|
||||||
#include "XenBusDxe.h"
|
|
||||||
#include "XenHypercall.h"
|
|
||||||
|
|
||||||
#include <IndustryStandard/Xen/hvm/params.h>
|
#include <IndustryStandard/Xen/hvm/params.h>
|
||||||
#include <IndustryStandard/Xen/memory.h>
|
#include <IndustryStandard/Xen/memory.h>
|
||||||
|
|
||||||
STATIC VOID *HyperPage;
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/XenHypercallLib.h>
|
||||||
//
|
|
||||||
// Interface exposed by the ASM implementation of the core hypercall
|
|
||||||
//
|
|
||||||
INTN
|
|
||||||
EFIAPI
|
|
||||||
__XenHypercall2 (
|
|
||||||
IN VOID *HypercallAddr,
|
|
||||||
IN OUT INTN Arg1,
|
|
||||||
IN OUT INTN Arg2
|
|
||||||
);
|
|
||||||
|
|
||||||
EFI_STATUS
|
|
||||||
XenHyperpageInit (
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_HOB_GUID_TYPE *GuidHob;
|
|
||||||
EFI_XEN_INFO *XenInfo;
|
|
||||||
|
|
||||||
GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
|
|
||||||
if (GuidHob == NULL) {
|
|
||||||
return EFI_NOT_FOUND;
|
|
||||||
}
|
|
||||||
XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);
|
|
||||||
HyperPage = XenInfo->HyperPages;
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT64
|
UINT64
|
||||||
XenHypercallHvmGetParam (
|
XenHypercallHvmGetParam (
|
||||||
@ -92,16 +61,3 @@ XenHypercallEventChannelOp (
|
|||||||
return XenHypercall2 (__HYPERVISOR_event_channel_op,
|
return XenHypercall2 (__HYPERVISOR_event_channel_op,
|
||||||
Operation, (INTN) Arguments);
|
Operation, (INTN) Arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
INTN
|
|
||||||
EFIAPI
|
|
||||||
XenHypercall2 (
|
|
||||||
IN UINTN HypercallID,
|
|
||||||
IN OUT INTN Arg1,
|
|
||||||
IN OUT INTN Arg2
|
|
||||||
)
|
|
||||||
{
|
|
||||||
ASSERT (HyperPage != NULL);
|
|
||||||
|
|
||||||
return __XenHypercall2 ((UINT8*)HyperPage + HypercallID * 32, Arg1, Arg2);
|
|
||||||
}
|
|
77
OvmfPkg/Library/XenHypercallLib/XenHypercallIntel.c
Normal file
77
OvmfPkg/Library/XenHypercallLib/XenHypercallIntel.c
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/** @file
|
||||||
|
Xen Hypercall Library implementation for Intel architecture
|
||||||
|
|
||||||
|
Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>
|
||||||
|
This program and the accompanying materials are licensed and made available under
|
||||||
|
the terms and conditions of the BSD License that accompanies this distribution.
|
||||||
|
The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php.
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <PiDxe.h>
|
||||||
|
#include <Library/HobLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Guid/XenInfo.h>
|
||||||
|
|
||||||
|
STATIC VOID *HyperPage;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Interface exposed by the ASM implementation of the core hypercall
|
||||||
|
//
|
||||||
|
INTN
|
||||||
|
EFIAPI
|
||||||
|
__XenHypercall2 (
|
||||||
|
IN VOID *HypercallAddr,
|
||||||
|
IN OUT INTN Arg1,
|
||||||
|
IN OUT INTN Arg2
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Library constructor: retrieves the Hyperpage address
|
||||||
|
from the gEfiXenInfoGuid HOB
|
||||||
|
**/
|
||||||
|
|
||||||
|
RETURN_STATUS
|
||||||
|
EFIAPI
|
||||||
|
XenHypercallLibIntelInit (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_HOB_GUID_TYPE *GuidHob;
|
||||||
|
EFI_XEN_INFO *XenInfo;
|
||||||
|
|
||||||
|
GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
|
||||||
|
if (GuidHob == NULL) {
|
||||||
|
return RETURN_NOT_FOUND;
|
||||||
|
}
|
||||||
|
XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);
|
||||||
|
HyperPage = XenInfo->HyperPages;
|
||||||
|
return RETURN_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function will put the two arguments in the right place (registers) and
|
||||||
|
invoke the hypercall identified by HypercallID.
|
||||||
|
|
||||||
|
@param HypercallID The symbolic ID of the hypercall to be invoked
|
||||||
|
@param Arg1 First argument.
|
||||||
|
@param Arg2 Second argument.
|
||||||
|
|
||||||
|
@return Return 0 if success otherwise it return an errno.
|
||||||
|
**/
|
||||||
|
INTN
|
||||||
|
EFIAPI
|
||||||
|
XenHypercall2 (
|
||||||
|
IN UINTN HypercallID,
|
||||||
|
IN OUT INTN Arg1,
|
||||||
|
IN OUT INTN Arg2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ASSERT (HyperPage != NULL);
|
||||||
|
|
||||||
|
return __XenHypercall2 ((UINT8*)HyperPage + HypercallID * 32, Arg1, Arg2);
|
||||||
|
}
|
52
OvmfPkg/Library/XenHypercallLib/XenHypercallLibIntel.inf
Normal file
52
OvmfPkg/Library/XenHypercallLib/XenHypercallLibIntel.inf
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
## @file
|
||||||
|
# Xen Hypercall abstraction lib for Intel architecture
|
||||||
|
#
|
||||||
|
# Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>
|
||||||
|
# This program and the accompanying materials
|
||||||
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
# which accompanies this distribution. The full text of the license may be found at
|
||||||
|
# http://opensource.org/licenses/bsd-license.php
|
||||||
|
#
|
||||||
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = XenHypercallLibIntel
|
||||||
|
FILE_GUID = B5EE9A32-CA5A-49A8-82E3-ADA4CCB77C7C
|
||||||
|
MODULE_TYPE = BASE
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
LIBRARY_CLASS = XenHypercallLib|DXE_DRIVER UEFI_DRIVER
|
||||||
|
CONSTRUCTOR = XenHypercallLibIntelInit
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
XenHypercallIntel.c
|
||||||
|
|
||||||
|
[Sources.IA32]
|
||||||
|
Ia32/hypercall.nasm
|
||||||
|
|
||||||
|
[Sources.X64]
|
||||||
|
X64/hypercall.nasm
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
XenHypercall.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
OvmfPkg/OvmfPkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseLib
|
||||||
|
HobLib
|
||||||
|
DebugLib
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gEfiXenInfoGuid
|
@ -44,6 +44,10 @@
|
|||||||
#
|
#
|
||||||
SerializeVariablesLib|Include/Library/SerializeVariablesLib.h
|
SerializeVariablesLib|Include/Library/SerializeVariablesLib.h
|
||||||
|
|
||||||
|
## @libraryclass Invoke Xen hypercalls
|
||||||
|
#
|
||||||
|
XenHypercallLib|Include/Library/XenHypercallLib.h
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gUefiOvmfPkgTokenSpaceGuid = {0x93bb96af, 0xb9f2, 0x4eb8, {0x94, 0x62, 0xe0, 0xba, 0x74, 0x56, 0x42, 0x36}}
|
gUefiOvmfPkgTokenSpaceGuid = {0x93bb96af, 0xb9f2, 0x4eb8, {0x94, 0x62, 0xe0, 0xba, 0x74, 0x56, 0x42, 0x36}}
|
||||||
gEfiXenInfoGuid = {0xd3b46f3b, 0xd441, 0x1244, {0x9a, 0x12, 0x0, 0x12, 0x27, 0x3f, 0xc1, 0x4d}}
|
gEfiXenInfoGuid = {0xd3b46f3b, 0xd441, 0x1244, {0x9a, 0x12, 0x0, 0x12, 0x27, 0x3f, 0xc1, 0x4d}}
|
||||||
|
@ -128,6 +128,7 @@
|
|||||||
S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
|
S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
|
||||||
SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
|
SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
|
||||||
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
|
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
|
||||||
|
XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLibIntel.inf
|
||||||
|
|
||||||
[LibraryClasses.common]
|
[LibraryClasses.common]
|
||||||
!if $(SECURE_BOOT_ENABLE) == TRUE
|
!if $(SECURE_BOOT_ENABLE) == TRUE
|
||||||
|
@ -133,6 +133,7 @@
|
|||||||
S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
|
S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
|
||||||
SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
|
SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
|
||||||
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
|
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
|
||||||
|
XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLibIntel.inf
|
||||||
|
|
||||||
[LibraryClasses.common]
|
[LibraryClasses.common]
|
||||||
!if $(SECURE_BOOT_ENABLE) == TRUE
|
!if $(SECURE_BOOT_ENABLE) == TRUE
|
||||||
|
@ -133,6 +133,7 @@
|
|||||||
S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
|
S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
|
||||||
SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
|
SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
|
||||||
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
|
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
|
||||||
|
XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLibIntel.inf
|
||||||
|
|
||||||
[LibraryClasses.common]
|
[LibraryClasses.common]
|
||||||
!if $(SECURE_BOOT_ENABLE) == TRUE
|
!if $(SECURE_BOOT_ENABLE) == TRUE
|
||||||
|
@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
#include "EventChannel.h"
|
#include "EventChannel.h"
|
||||||
#include "XenHypercall.h"
|
|
||||||
|
#include <Library/XenHypercallLib.h>
|
||||||
|
|
||||||
UINT32
|
UINT32
|
||||||
XenEventChannelNotify (
|
XenEventChannelNotify (
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#include <IndustryStandard/Xen/memory.h>
|
#include <IndustryStandard/Xen/memory.h>
|
||||||
|
|
||||||
#include "XenHypercall.h"
|
#include <Library/XenHypercallLib.h>
|
||||||
|
|
||||||
#include "GrantTable.h"
|
#include "GrantTable.h"
|
||||||
#include "InterlockedCompareExchange16.h"
|
#include "InterlockedCompareExchange16.h"
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
#include <IndustryStandard/Pci.h>
|
#include <IndustryStandard/Pci.h>
|
||||||
#include <IndustryStandard/Acpi.h>
|
#include <IndustryStandard/Acpi.h>
|
||||||
#include <Library/DebugLib.h>
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/XenHypercallLib.h>
|
||||||
|
|
||||||
#include "XenBusDxe.h"
|
#include "XenBusDxe.h"
|
||||||
|
|
||||||
#include "XenHypercall.h"
|
|
||||||
#include "GrantTable.h"
|
#include "GrantTable.h"
|
||||||
#include "XenStore.h"
|
#include "XenStore.h"
|
||||||
#include "XenBus.h"
|
#include "XenBus.h"
|
||||||
@ -390,13 +390,6 @@ XenBusDxeDriverBindingStart (
|
|||||||
MmioAddr = BarDesc->AddrRangeMin;
|
MmioAddr = BarDesc->AddrRangeMin;
|
||||||
FreePool (BarDesc);
|
FreePool (BarDesc);
|
||||||
|
|
||||||
Status = XenHyperpageInit ();
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
DEBUG ((EFI_D_ERROR, "XenBus: Unable to retrieve the hyperpage.\n"));
|
|
||||||
Status = EFI_UNSUPPORTED;
|
|
||||||
goto ErrorAllocated;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status = XenGetSharedInfoPage (Dev);
|
Status = XenGetSharedInfoPage (Dev);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((EFI_D_ERROR, "XenBus: Unable to get the shared info page.\n"));
|
DEBUG ((EFI_D_ERROR, "XenBus: Unable to get the shared info page.\n"));
|
||||||
|
@ -34,8 +34,6 @@
|
|||||||
DriverBinding.h
|
DriverBinding.h
|
||||||
ComponentName.c
|
ComponentName.c
|
||||||
ComponentName.h
|
ComponentName.h
|
||||||
XenHypercall.c
|
|
||||||
XenHypercall.h
|
|
||||||
InterlockedCompareExchange16.c
|
InterlockedCompareExchange16.c
|
||||||
InterlockedCompareExchange16.h
|
InterlockedCompareExchange16.h
|
||||||
GrantTable.c
|
GrantTable.c
|
||||||
@ -49,12 +47,10 @@
|
|||||||
Helpers.c
|
Helpers.c
|
||||||
|
|
||||||
[Sources.IA32]
|
[Sources.IA32]
|
||||||
Ia32/hypercall.nasm
|
|
||||||
Ia32/InterlockedCompareExchange16.nasm
|
Ia32/InterlockedCompareExchange16.nasm
|
||||||
Ia32/TestAndClearBit.nasm
|
Ia32/TestAndClearBit.nasm
|
||||||
|
|
||||||
[Sources.X64]
|
[Sources.X64]
|
||||||
X64/hypercall.nasm
|
|
||||||
X64/InterlockedCompareExchange16.nasm
|
X64/InterlockedCompareExchange16.nasm
|
||||||
X64/TestAndClearBit.nasm
|
X64/TestAndClearBit.nasm
|
||||||
|
|
||||||
@ -67,8 +63,7 @@
|
|||||||
UefiLib
|
UefiLib
|
||||||
DevicePathLib
|
DevicePathLib
|
||||||
DebugLib
|
DebugLib
|
||||||
HobLib
|
XenHypercallLib
|
||||||
|
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiDriverBindingProtocolGuid
|
gEfiDriverBindingProtocolGuid
|
||||||
@ -77,7 +72,3 @@
|
|||||||
gEfiComponentNameProtocolGuid
|
gEfiComponentNameProtocolGuid
|
||||||
gXenBusProtocolGuid
|
gXenBusProtocolGuid
|
||||||
|
|
||||||
|
|
||||||
[Guids]
|
|
||||||
gEfiXenInfoGuid
|
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@
|
|||||||
|
|
||||||
#include <IndustryStandard/Xen/hvm/params.h>
|
#include <IndustryStandard/Xen/hvm/params.h>
|
||||||
|
|
||||||
#include "XenHypercall.h"
|
|
||||||
#include "EventChannel.h"
|
#include "EventChannel.h"
|
||||||
|
#include <Library/XenHypercallLib.h>
|
||||||
|
|
||||||
//
|
//
|
||||||
// Private Data Structures
|
// Private Data Structures
|
||||||
|
Reference in New Issue
Block a user