From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by mx.groups.io with SMTP id smtpd.web09.1597.1650940716306170227 for ; Mon, 25 Apr 2022 19:38:36 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@bsdio.com header.s=fm2 header.b=JQuQABJs; spf=pass (domain: bsdio.com, ip: 64.147.123.24, mailfrom: rebecca@bsdio.com) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id A77E43200956; Mon, 25 Apr 2022 22:38:34 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 25 Apr 2022 22:38:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdio.com; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1650940714; x= 1651027114; bh=yDspjCedUaP/+AfKCoWepeUj/zplD1cyA6tEHyjk7jk=; b=J QuQABJscvV1hjJngl72DDeQFgaQykP007KoSYNDGIYSe/SbzcnjEf2bCSCJcgDtJ yTRjjDPRHk6huRZtTF/ol7bVA+3TwoL7h85B5Omgpxjs9hmnqBbgG+Umcg4GfCXV LP/sF3MKFAJw59qNgyP/V6Wyx8HGOrKkzfCbhSgJQMMMXMAgFXKlQISd1HdwKLht XaKSyQMNpDC1zMJ64SgwvJCnIRux6uwjI+tGBaey8t8bDSGBAXwmmL72XJDmikTC mY8Q7dZKtv3au7WWmb4knPRPesDoS/U5Il5/9TO6XH+pnLE44NH+a6gf8Rk0C9Od cIrmHHfgGBAeQf214uYNg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1650940714; x=1651027114; bh=yDspjCedUaP/+ AfKCoWepeUj/zplD1cyA6tEHyjk7jk=; b=Shg91OA7Ir1TYL1EkVYnCf8XIHi+9 GT6/QtZmmdvQlsyIJkQH3nnvyuO8GLU7IsOddSGlMm56SuyxXEtHG9u+noXe3GwA qiyO74ovVZBTI4PtHzV/YdoKAVzygENGQNo3qNCsEYMy5xtq7FxVfr2aUZEmvctV 9ko4Jhm5zcMey4zohLe1LDjNEbgZH9m3scqXt6/P84beZj5yNAO0sVPUPo4pI8mE 0866R2OC+I5qjg47tZJT2a2q+NMr0wXD+zHG9S+B82jAlFIVR/zSqgrMMgmNLzyv EeXaXZuCSn4r218gIgBYgW8es/n5mAoYzIH9GWTTRFOVaerZG1W+Ruw7Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedruddvgdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthekredttdefjeenucfhrhhomheptfgvsggv tggtrgcuvehrrghnuceorhgvsggvtggtrgessghsughiohdrtghomheqnecuggftrfgrth htvghrnhepgeefgeevudehjefgudfffefhheelheeigffhtedvjedvlefhueekhffhvdeg heevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprh gvsggvtggtrgessghsughiohdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 25 Apr 2022 22:38:32 -0400 (EDT) Message-ID: Date: Mon, 25 Apr 2022 20:38:31 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v4] OvmfPkg/BhyveBhfPkg: add support for QemuFwCfg To: =?UTF-8?Q?Corvin_K=c3=b6hne?= Cc: =?UTF-8?Q?Corvin_K=c3=b6hne?= , Ard Biesheuvel , Jordan Justen , devel@edk2.groups.io, FreeBSD Virtualization , Jiewen Yao , Gerd Hoffmann , Peter Grehan References: <20220408081515.191-1-c.koehne@beckhoff.com> From: "Rebecca Cran" In-Reply-To: <20220408081515.191-1-c.koehne@beckhoff.com> Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Reviewed-by: Rebecca Cran Maybe I'm misunderstanding, but the commit message looks wrong: there's no OvmfPkg/BhyveBhfPkg - it's OvmfPkg/Bhyve . -- Rebecca Cran On 4/8/22 02:15, Corvin Köhne wrote: > From: Corvin Köhne > > 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 > Acked-by: Gerd Hoffmann > Acked-by: Rebecca Cran > Acked-by: Peter Grehan > Acked-by: Jiewen Yao > CC: Ard Biesheuvel > CC: Jordan Justen > CC: devel@edk2.groups.io > CC: FreeBSD Virtualization > --- > 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 > #include > #include > +#include // 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/DxeSecurityManagementLib.inf > UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf > SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf > - QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibNull.inf > - QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf > + QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxeLib.inf > BhyveFwCtlLib|OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.inf > VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf > MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf > @@ -355,6 +354,7 @@ > !endif > PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf > MpInitLib|UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf > + QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf > > [LibraryClasses.common.UEFI_APPLICATION] > PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf