RE: [edk2-devel] [PATCH v5] OvmfPkg/Bhyve: add support for QemuFwCfg

From: Corvin Köhne <C.Koehne_at_beckhoff.com>
Date: Wed, 27 Apr 2022 10:06:26 UTC
Hi,

sry, I'm unfamiliar with the merge process and how to try CI.
I've updated my patch. It should pass CI now.


Thanks
Corvin

Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Beckhoff
Registered office: Verl, Germany | Register court: Guetersloh HRA 7075


-----Original Message-----
From: Rebecca Cran <quic_rcran@quicinc.com>
Sent: Tuesday, April 26, 2022 4:23 PM
To: devel@edk2.groups.io; jiewen.yao@intel.com; Corvin Köhne <C.Koehne@beckhoff.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>; Justen, Jordan L <jordan.l.justen@intel.com>; FreeBSD Virtualization <freebsd-virtualization@freebsd.org>; Gerd Hoffmann <kraxel@redhat.com>; Rebecca Cran <rebecca@bsdio.com>; Peter Grehan <grehan@freebsd.org>
Subject: Re: [edk2-devel] [PATCH v5] OvmfPkg/Bhyve: add support for QemuFwCfg

CAUTION: External Email!!
Specifically:

The commit message format is not valid:

* 'CC' should be 'Cc'
* 'CC' should be 'Cc'
* 'CC' should be 'Cc'





* 'CC' should be 'Cc'












The 'Cc' email address is not valid:
* Email format is invalid: devel@edk2.groups.io
https://github.com/tianocore/tianocore.github.io/wiki/Commit-Message-Format
<https://github.com/tianocore/tianocore.github.io/wiki/Commit-Message-Format>


--
Rebecca Cran

On 4/26/22 08:07, Yao, Jiewen wrote:
> Hi
> CI failed -https://github.com/tianocore/edk2/pull/2829
>
> Would you please try CI by yourself before you submit next patch?
> It is mandatory process.
>
> Thank you
> Yao Jiewen
>
>> -----Original Message-----
>> From: Corvin Köhne<c.koehne@beckhoff.com>
>> Sent: Tuesday, April 26, 2022 9:08 PM
>> Cc: Köhne, Corvin<c.koehne@beckhoff.com>; Ard Biesheuvel
>> <ardb+tianocore@kernel.org>; Justen, Jordan L<jordan.l.justen@intel.com>;
>> devel@edk2.groups.io; FreeBSD Virtualization <freebsd-
>> virtualization@freebsd.org>; Yao, Jiewen <jiewen.yao@intel.com>; Gerd
>> Hoffmann<kraxel@redhat.com>; Rebecca Cran<rebecca@bsdio.com>; Peter
>> Grehan<grehan@freebsd.org>
>> Subject: [PATCH v5] OvmfPkg/Bhyve: add support for QemuFwCfg
>>
>> QemuFwCfg is much more powerful than BhyveFwCtl. Sadly, BhyveFwCtl
>> decided to use the same IO ports as QemuFwCfg. It's not possible to use
>> both interfaces simultaneously. So, prefer QemuFwCfg over BhyveFwCtl.
>>
>> Signed-off-by: Corvin Köhne<c.koehne@beckhoff.com>
>> Reviewed-by: Rebecca Cran<rebecca@bsdio.com>
>> Acked-by: Gerd Hoffmann<kraxel@redhat.com>
>> Acked-by: Peter Grehan<grehan@freebsd.org>
>> Acked-by: Jiewen Yao<jiewen.yao@intel.com>
>> CC: Ard Biesheuvel<ardb+tianocore@kernel.org>
>> CC: Jordan Justen<jordan.l.justen@intel.com>
>> CC:devel@edk2.groups.io
>> CC: FreeBSD Virtualization<freebsd-virtualization@freebsd.org>
>> ---
>>   OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf |  1 +
>>   OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c             | 41 ++++++++++++++++++++-
>> --
>>   OvmfPkg/Bhyve/BhyveX64.dsc                        |  4 +--
>>   3 files changed, 40 insertions(+), 6 deletions(-)
>>
>> diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
>> b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
>> index 595fd055f9..94c65f32dc 100644
>> --- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
>> +++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
>> @@ -43,6 +43,7 @@
>>     MemoryAllocationLib
>>     OrderedCollectionLib
>>     PcdLib
>> +  QemuFwCfgLib
>>     UefiBootServicesTableLib
>>     UefiDriverEntryPoint
>>     UefiLib
>> diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
>> b/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
>> index 8e80aa33e1..e216a21bfa 100644
>> --- a/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
>> +++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
>> @@ -11,6 +11,41 @@
>>   #include <Library/BaseMemoryLib.h>
>>   #include <Library/BhyveFwCtlLib.h>
>>   #include <Library/MemoryAllocationLib.h>
>> +#include <Library/QemuFwCfgLib.h>             // QemuFwCfgFindFile()
>> +
>> +STATIC
>> +EFI_STATUS
>> +EFIAPI
>> +BhyveGetCpuCount (
>> +  OUT UINT32  *CpuCount
>> +  )
>> +{
>> +  FIRMWARE_CONFIG_ITEM  Item;
>> +  UINTN                 Size;
>> +
>> +  if (QemuFwCfgIsAvailable ()) {
>> +    if (EFI_ERROR (QemuFwCfgFindFile ("opt/bhyve/hw.ncpu", &Item, &Size))) {
>> +      return EFI_NOT_FOUND;
>> +    } else if (Size != sizeof (*CpuCount)) {
>> +      return EFI_BAD_BUFFER_SIZE;
>> +    }
>> +
>> +    QemuFwCfgSelectItem (Item);
>> +    QemuFwCfgReadBytes (Size, CpuCount);
>> +
>> +    return EFI_SUCCESS;
>> +  }
>> +
>> +  //
>> +  // QemuFwCfg not available, try BhyveFwCtl.
>> +  //
>> +  Size = sizeof (*CpuCount);
>> +  if (BhyveFwCtlGet ("hw.ncpu", CpuCount, &Size) == RETURN_SUCCESS) {
>> +    return EFI_SUCCESS;
>> +  }
>> +
>> +  return EFI_UNSUPPORTED;
>> +}
>>
>>   STATIC
>>   EFI_STATUS
>> @@ -23,7 +58,6 @@ BhyveInstallAcpiMadtTable (
>>     )
>>   {
>>     UINT32                                               CpuCount;
>> -  UINTN                                                cSize;
>>     UINTN                                                NewBufferSize;
>>     EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER  *Madt;
>>     EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE          *LocalApic;
>> @@ -36,9 +70,8 @@ BhyveInstallAcpiMadtTable (
>>     ASSERT (AcpiTableBufferSize >= sizeof (EFI_ACPI_DESCRIPTION_HEADER));
>>
>>     // Query the host for the number of vCPUs
>> -  CpuCount = 0;
>> -  cSize    = sizeof (CpuCount);
>> -  if (BhyveFwCtlGet ("hw.ncpu", &CpuCount, &cSize) == RETURN_SUCCESS) {
>> +  Status = BhyveGetCpuCount (&CpuCount);
>> +  if (!EFI_ERROR (Status)) {
>>       DEBUG ((DEBUG_INFO, "Retrieved CpuCount %d\n", CpuCount));
>>       ASSERT (CpuCount >= 1);
>>     } else {
>> diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
>> index 5fa08bebd7..14070fd6dd 100644
>> --- a/OvmfPkg/Bhyve/BhyveX64.dsc
>> +++ b/OvmfPkg/Bhyve/BhyveX64.dsc
>> @@ -163,8 +163,7 @@
>>
>> SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/D
>> xeSecurityManagementLib.inf
>>     UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
>>
>> SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLi
>> b.inf
>> -  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibNull.inf
>> -
>> QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNu
>> ll.inf
>> +  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxeLib.inf
>>     BhyveFwCtlLib|OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.inf
>>     VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
>>
>> MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptS
>> evLib.inf
>> @@ -355,6 +354,7 @@
>>   !endif
>>     PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
>>     MpInitLib|UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf
>> +
>> QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwC
>> fg.inf
>>
>>   [LibraryClasses.common.UEFI_APPLICATION]
>>     PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
>> --
>> 2.11.0
>>
>> Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans
>> Beckhoff
>> Registered office: Verl, Germany | Register court: Guetersloh HRA 7075
>>
>>
> -=-=-=-=-=-=-=-=-=-=-=-
> https://nospamproxywebp.beckhoff.com/enqsig/link?id=BCAAAABGd7m3lfMOLOIhx3uNR_1Qav4Ffx8-jQB0torD82ts_GgAAADzBJywd7ugwiARO0cBT_iv7_bIiRgHlWMUL6WkcMFGQ9VLPohc0UD2LiaXfUpLeW19CgOAXJPAtMpSqj7nfPYBImxx09yz3fZUafLgui-cstrFlDBTvw98ozA39bvzvVI4-zmW3OwHtg2  Links: You receive all messages sent to this group.
> View/Reply Online (#89331):https://nospamproxywebp.beckhoff.com/enqsig/link?id=BCAAAABGd7m3lfMOLOIhx3uNR_1Qav4Ffx8-jQB0torD82ts_IMAAACwj7h8eIdbgbi7KKCg2bDOH3zvyFM5WYVipKJIUoKv-wdsnOsQQFTsJQgh-KJ4aXv4yu0daeFj_X1HpFeZOVPJSiE8W93nHboWRHKgnPeGFmOi24T58hh9T2FTZDP2z4W0pbrZ_1TT6btKKlO6iIg-fVHmbySsxIpdq7v0xu3C5MehIQ2
> Mute This Topic:https://nospamproxywebp.beckhoff.com/enqsig/link?id=BCAAAABGd7m3lfMOLOIhx3uNR_1Qav4Ffx8-jQB0torD82ts_HwAAABkxIOSqXAdbmB7SQnV3wWfL8SD9x8PwoQVR6IP8RhCShnhIj-As4WiSVzVxTkByo7H76dV1wLOApA-cwg0okzOLoutfRDbENkY_fryX4FJX6AggzUjE-9XrM9QHBYd_zc8NuZlsNyoLhOxODK9REZIilVlxQjqUP9IJG8w0
> Group Owner:devel+owner@edk2.groups.io
> Unsubscribe:https://nospamproxywebp.beckhoff.com/enqsig/link?id=BCAAAABGd7m3lfMOLOIhx3uNR_1Qav4Ffx8-jQB0torD82ts_HsAAACyVZgi54sI8jJY8gTpJ7a52PTprtgQ3WXotwkTfdqWEkfMmm2Z5fYca7-S-WRQfc7zcI33DiQbL9_oZ9CRL-KwB-NO76lPizpV3gzInQ_qMxqqCCapJNghVrDfqby2AVlMKmfDe49wk4-9ZiEnjn3D3Hgkg5IlQsqmIQs1   [quic_rcran@quicinc.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>