From nobody Tue Dec 13 12:45:07 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NWdW775YFz4l045; Tue, 13 Dec 2022 12:45:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NWdW76YxSz3NwJ; Tue, 13 Dec 2022 12:45:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670935507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7gLaKATYdzflm5VHjMD00Xy4udrszG0ty4PEorknIY0=; b=Y8xwdbyzn6Xn9rIOOBDJrqY5SOWFOA44p7Qs3E6AvVfKx+GCBLViN2KUUqPZDwNzgO2tHL w5o7nbbYtVsgfQGJbQ5mcRCABuwv7F9OYLFkxLqphkHTpzj7pCd7mEJRbn7TpMQTNYnpIn 4SX1h2hmQdO1WUu5fzWsSEFDMDgO7ATAh2dgE2UI3Rs2VDLm0xieETxnIgrAWJr++TS5IJ vTbdpAp3bWYmA0b6FgUJDFKMFsoEJRhJwYml/Uu/Wzy+UbKkvoMY/Oh3gRiVUXYZsgb8jP KSbX6HY4TtVO7qmI1H8LB4y9dXYecpilshssBe+kwqGuWpgnKDNhn5IMRKiOvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670935507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7gLaKATYdzflm5VHjMD00Xy4udrszG0ty4PEorknIY0=; b=BJWi1hCSJe+eWm4L2rTu3OjNV9T9prXOSYVGiM2zLZFnASsiC5KWz4z9WD8O76c6I/ZVqI HU2eBL/cG/dzQiNgOVkXKYQGZigNU7pW1UhpyEpM9yi6iF3hdNu87S2tBzJPqR3HH9BJtM zOW1kG5FNDBoqflDDexUQIw/9p3ZipCOtJjGqLo/JHXU1hjFSseS+l2OJSaHSO6Px0rBUa 7ODN4kyrKLXdBRv2mp3Hs7bXvzJ9NAYx/oliNxrgazIIO5fQk2Y3BEvFekCxvh+Vi2IFtG uG/w+7sMt4cx+BNnlGKNXaS9xi4VGATvJlXOf3pRqjkqMgmIbz6jUY/UywSIVA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670935507; a=rsa-sha256; cv=none; b=LfyTviqKYpVUcNF6vlwV+duVHYL4JJbXKbiOhbkLToQZyv3LAkPCf5dtmDiVOiRLmXepb2 1Iey+jOjavz75f4u9h70Th/82HnSy8xEWyNTO+HbQY+8Wq1DZ7zIPc8ZSEyOCd45wsMpYY rfn3sBDtHb02Qh3D0t9RxPUKYQa5AA5WK77WKHtNQvXaizNk8A3BXBo/rRvFqKISmOW2om Dr0BFc2cyq6UtMneVPQ1HVbdgCfA5Y0NGVGAkdBWaIHjFJH5Le2l/tAC0cg4xKjCB3CDJ6 JFXzaCkP5K294Rcrq+eIXwWvEpw8sry39p2zjFAc9+lFa1uHqe+zB1ro7YyvwQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NWdW75dGzzFKc; Tue, 13 Dec 2022 12:45:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2BDCj7nv075262; Tue, 13 Dec 2022 12:45:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BDCj7sV075261; Tue, 13 Dec 2022 12:45:07 GMT (envelope-from git) Date: Tue, 13 Dec 2022 12:45:07 GMT Message-Id: <202212131245.2BDCj7sV075261@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: c479b7736cff - stable/13 - bhyve: build SPCR ACPI table List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: corvink X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c479b7736cff170494b9411146c35bd35147e79e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=c479b7736cff170494b9411146c35bd35147e79e commit c479b7736cff170494b9411146c35bd35147e79e Author: Corvin Köhne AuthorDate: 2022-11-30 14:46:19 +0000 Commit: Corvin Köhne CommitDate: 2022-12-13 12:39:42 +0000 bhyve: build SPCR ACPI table OVMF ships some static ACPI tables. This worked in the past but won't work in the future when we support devices like tpms. They require a TPM ACPI table. So, we have to dynamically create ACPI tables depending on the bhyve configuration. Bhyve has much more information about the system than OVMF. Therefore, it's easier for bhyve to build up some ACPI tables. For that reason, it would be much better to use the ACPI tables provided by bhyve instead of building some tables by OVMF. At the moment, OVMF always creates a SPCR table. Maybe someone depends on it. So, we have to build it by bhyve too before we can patch OVMF to install the tables provided by bhyve. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D37591 (cherry picked from commit b972e7cbb4f9f44ab77be24857c674c0733785cf) --- usr.sbin/bhyve/acpi.c | 32 ++++++++++++++++++++++++++++++++ usr.sbin/bhyve/basl.h | 23 +++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c index 30b0a814c9d5..6cfd4462526a 100644 --- a/usr.sbin/bhyve/acpi.c +++ b/usr.sbin/bhyve/acpi.c @@ -692,6 +692,37 @@ build_rsdt(struct vmctx *const ctx) return (0); } +static int +build_spcr(struct vmctx *const ctx) +{ + ACPI_TABLE_SPCR spcr; + struct basl_table *table; + + BASL_EXEC(basl_table_create(&table, ctx, ACPI_SIG_SPCR, + BASL_TABLE_ALIGNMENT)); + + memset(&spcr, 0, sizeof(spcr)); + BASL_EXEC(basl_table_append_header(table, ACPI_SIG_SPCR, 1, 1)); + spcr.InterfaceType = ACPI_DBG2_16550_COMPATIBLE; + basl_fill_gas(&spcr.SerialPort, ACPI_ADR_SPACE_SYSTEM_IO, 8, 0, + ACPI_GAS_ACCESS_WIDTH_LEGACY, 0x3F8); + spcr.InterruptType = ACPI_SPCR_INTERRUPT_TYPE_8259; + spcr.PcInterrupt = 4; + spcr.BaudRate = ACPI_SPCR_BAUD_RATE_115200; + spcr.Parity = ACPI_SPCR_PARITY_NO_PARITY; + spcr.StopBits = ACPI_SPCR_STOP_BITS_1; + spcr.FlowControl = 3; /* RTS/CTS | DCD */ + spcr.TerminalType = ACPI_SPCR_TERMINAL_TYPE_VT_UTF8; + BASL_EXEC(basl_table_append_content(table, &spcr, sizeof(spcr))); + + BASL_EXEC(basl_table_append_pointer(rsdt, ACPI_SIG_SPCR, + ACPI_RSDT_ENTRY_SIZE)); + BASL_EXEC(basl_table_append_pointer(xsdt, ACPI_SIG_SPCR, + ACPI_XSDT_ENTRY_SIZE)); + + return (0); +} + static int build_xsdt(struct vmctx *const ctx) { @@ -749,6 +780,7 @@ acpi_build(struct vmctx *ctx, int ncpu) BASL_EXEC(build_hpet(ctx)); BASL_EXEC(build_mcfg(ctx)); BASL_EXEC(build_facs(ctx)); + BASL_EXEC(build_spcr(ctx)); BASL_EXEC(build_dsdt(ctx)); BASL_EXEC(basl_finish()); diff --git a/usr.sbin/bhyve/basl.h b/usr.sbin/bhyve/basl.h index fba921a46882..c4d0d9d26c0d 100644 --- a/usr.sbin/bhyve/basl.h +++ b/usr.sbin/bhyve/basl.h @@ -15,6 +15,29 @@ #define ACPI_GAS_ACCESS_WIDTH_DWORD 3 #define ACPI_GAS_ACCESS_WIDTH_QWORD 4 +#define ACPI_SPCR_INTERRUPT_TYPE_8259 0x1 +#define ACPI_SPCR_INTERRUPT_TYPE_APIC 0x2 +#define ACPI_SPCR_INTERRUPT_TYPE_SAPIC 0x4 +#define ACPI_SPCR_INTERRUPT_TYPE_GIC 0x8 + +#define ACPI_SPCR_BAUD_RATE_9600 3 +#define ACPI_SPCR_BAUD_RATE_19200 4 +#define ACPI_SPCR_BAUD_RATE_57600 6 +#define ACPI_SPCR_BAUD_RATE_115200 7 + +#define ACPI_SPCR_PARITY_NO_PARITY 0 + +#define ACPI_SPCR_STOP_BITS_1 1 + +#define ACPI_SPCR_FLOW_CONTROL_DCD 0x1 +#define ACPI_SPCR_FLOW_CONTROL_RTS_CTS 0x2 +#define ACPI_SPCR_FLOW_CONTROL_XON_XOFF 0x4 + +#define ACPI_SPCR_TERMINAL_TYPE_VT100 0 +#define ACPI_SPCR_TERMINAL_TYPE_VT100_PLUS 1 +#define ACPI_SPCR_TERMINAL_TYPE_VT_UTF8 2 +#define ACPI_SPCR_TERMINAL_TYPE_ANSI 3 + #define BHYVE_ACPI_BASE 0xf2400 #define BASL_TABLE_ALIGNMENT 0x10