From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx2.freebsd.org (mx2.freebsd.org [96.47.72.81]) by mx.groups.io with SMTP id smtpd.web10.10844.1683703450198412653 for ; Wed, 10 May 2023 00:24:10 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@freebsd.org header.s=dkim header.b=DhIFvs0v; spf=pass (domain: freebsd.org, ip: 96.47.72.81, mailfrom: corvink@freebsd.org) Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4QGRNT48m4z3wNN; Wed, 10 May 2023 07:24:09 +0000 (UTC) (envelope-from corvink@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QGRNT375Nz4KQT; Wed, 10 May 2023 07:24:09 +0000 (UTC) (envelope-from corvink@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683703449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=39JXpL4hDylo9emp8VRKkIyyJfllZCeP0m9P1wSCaZ0=; b=DhIFvs0v+HqHbhkUb1O/hHl89k9kDFvSc1jxRYd5pxRQ2A+ITsTDT9Ktj3RVSL8Wrf2Lwe AUVLUsNBqf4usQq8+NVZxFOxXqD5S6TkU8rNN1LXHv2hhpBuJzxkfxtAbbZQ4dfeouY3Y4 mP6qPZZgCu0Jla6rgo+cqAWJUGbMqsdEORUMMEoq7MbTU77uw66CGJ4rid0aq5+tZU35Gz 8dpyEO5usJQ4qe33b1g5a/M9aXHNcbqUUy+iJt0Z1qJfryCDTg7MUbIM/ENSb1kufx6jpr oecCHccQxiIlCUzcY+mbjOEZkjgYqmnNIP1aP7wAp2lFJ7pZMjGBseQx4BNkuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683703449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=39JXpL4hDylo9emp8VRKkIyyJfllZCeP0m9P1wSCaZ0=; b=tMA62RNyYThLt0+3ITMgRapKk0SdZEiTL/3ggObH2q5lnZsTDMFC9VizixP5xdrGUDms/9 2hH1ZkFnL2NwYvTNnMfuC3V4U/SbFxMEbaFkG2aCl1mVpfllcR1oq7CiDn2ZjNyk7DPC9H UTJ2FjzqS7Ch+1e6ubma6unBU6z0CZkOuMkqcmcoCuy7CfqTpHcAIkIB+qoZyo23a10M/b M32RvYqHPRUEdT19jHs38QAA2eDscJu/3+MBFQNd4px3nyOYFkweuuXW5oKUMKU6ExcXx2 9NYUQH7q1KD4z8WNqyDN2ZE0XnfZm03fSMbQivpWOOihIoLBts2exnkAWnKocQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683703449; a=rsa-sha256; cv=none; b=S2HpKD1hJUU1I49kCEpkZCpalNXyuzjOIpvRTVWSeGwDmINMiebVGed6EGwBPyGhYZr9M/ SxeImaQRh662kJYFPBtcuCUIefcWd9+8MkVeKQlq2FbeTNdUzL9zOCRRRVdvOog1WhXF1Q Tz21gJDcnV4qUrwsgG8ZU3ZTZWHOhFn73m47JchbqGmuxtdIp63JitcBEmY/ohIwMtyOIO NBPfuhfK0tZtqontiCyyzOIcFk+W/Jd2LBUYKapIIEnurQkCq7LYZ97VAuUP417sjCQRGL wd7q6kc2touDEvfx3DzPUAZ5mbqNy6bXbYbWN9feaTZbjnBehQUbSs6+hx3z9Q== Received: from corvink-nb.beckhoff.com (unknown [IPv6:2001:9e8:da4f:c300:5a72:6c71:9bf9:8839]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: corvink) by smtp.freebsd.org (Postfix) with ESMTPSA id 4QGRNS28k6zh4s; Wed, 10 May 2023 07:24:08 +0000 (UTC) (envelope-from corvink@FreeBSD.org) From: =?UTF-8?B?Q29ydmluIEvDtmhuZQ==?= To: devel@edk2.groups.io Cc: =?UTF-8?q?Corvin=20K=C3=B6hne?= , Gerd Hoffmann , Ard Biesheuvel , Jiewen Yao , Jordan Justen , Rebecca Cran , Peter Grehan Subject: [PATCH v4 3/3] OvmfPkg/Bhyve: install ACPI tables from memory Date: Wed, 10 May 2023 09:23:26 +0200 Message-Id: <20230510072326.309805-3-corvink@FreeBSD.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230510072326.309805-1-corvink@FreeBSD.org> References: <20230510072326.309805-1-corvink@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable It's much easier to create configuration dependend ACPI tables for bhyve than for OVMF. For this reason, don't use the statically created ACPI tables provided by OVMF. Instead prefer the dynamically created ACPI tables of bhyve. If bhyve provides no ACPI tables or we are unable to detect those, fall back to OVMF tables. Ideally, we use the qemu fwcfg interface to pass the ACPI tables from bhyve to OVMF. bhyve will support this in the future. However, current bhyve executables don't support passing ACPI tables by the qemu fwcfg interface. They just copy the ACPI into main memory. For that reason, pick up the ACPI tables from main memory. Signed-off-by: Corvin K=C3=B6hne Acked-by: Gerd Hoffmann Cc: Ard Biesheuvel Cc: Jiewen Yao Cc: Jordan Justen Cc: Rebecca Cran Cc: Peter Grehan --- OvmfPkg/Bhyve/BhyveX64.dsc | 1 + .../Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf | 1 + OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c | 37 ++++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc index d0d2712c5662..465b81ffcd51 100644 --- a/OvmfPkg/Bhyve/BhyveX64.dsc +++ b/OvmfPkg/Bhyve/BhyveX64.dsc @@ -341,6 +341,7 @@ [LibraryClasses.common.UEFI_DRIVER] PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf =20 [LibraryClasses.common.DXE_DRIVER] + AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryA= llocationLib.inf diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf b/OvmfPkg/= Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf index 94c65f32dcab..75ed8e4a7deb 100644 --- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf +++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf @@ -35,6 +35,7 @@ [Packages] UefiCpuPkg/UefiCpuPkg.dec =20 [LibraryClasses] + AcpiPlatformLib BaseLib BaseMemoryLib BhyveFwCtlLib diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c b/OvmfPkg/Bhyve= /AcpiPlatformDxe/AcpiPlatform.c index 999e9f151ebb..1e1c90614ea1 100644 --- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c +++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c @@ -10,6 +10,11 @@ =20 #include "AcpiPlatform.h" =20 +#include // InstallAcpiTablesFromMemory() + +#define BHYVE_ACPI_PHYSICAL_ADDRESS ((UINTN)0x000F2400) +#define BHYVE_BIOS_PHYSICAL_END ((UINTN)0x00100000) + EFI_STATUS EFIAPI InstallAcpiTable ( @@ -241,7 +246,37 @@ InstallAcpiTables ( IN EFI_ACPI_TABLE_PROTOCOL *AcpiTable ) { - EFI_STATUS Status; + EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp; + EFI_STATUS Status; + + Status =3D GetAcpiRsdpFromMemory ( + BHYVE_ACPI_PHYSICAL_ADDRESS, + BHYVE_BIOS_PHYSICAL_END, + &Rsdp + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D InstallAcpiTablesFromRsdp ( + AcpiTable, + Rsdp + ); + if (!EFI_ERROR (Status)) { + return EFI_SUCCESS; + } + + if (Status !=3D EFI_NOT_FOUND) { + DEBUG ( + ( + DEBUG_WARN, + "%a: unable to install bhyve's ACPI tables (%r)\n", + __func__, + Status + ) + ); + return Status; + } =20 Status =3D InstallOvmfFvTables (AcpiTable); =20 --=20 2.40.1