From nobody Tue Feb 14 07:29:13 2023 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 4PGCWY40Lkz3rLK4; Tue, 14 Feb 2023 07:29:13 +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 4PGCWY36yBz4P0d; Tue, 14 Feb 2023 07:29:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676359753; 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=mAmb7RUF3PhoaaNF6H33XfxjjbRB9gBlTaKZ6asf4UU=; b=W61Np3WMqxaLztf/ElH2/cTz+eD21tfClSZQ4GihYuZQuZKQ077TBmsT/Bh2smFm/hHuw3 /6XQE8Qk2iMH5MpXYkSjxd+yNManUcW3+z/zRG8PpEPb1NDFH/GBHF0HsJCbDOnb73Pyv0 SbOXweWYD81dOpPZAF1S8oPznZvs29bgfIXrDRmuTZDBvcTVUgCyx72MDeBURn4txBUgFM 6WA3PTeRgY03xWcozP8R8kNH9plUBmp+jhGbC67upjhYVzH0AgYRmvz0sCEcToSv4c7wcd GezdE5MEpc6ijSMvDzoXq26Z3OpCpcViSTh3Mbnq0j30sfAK4QZgCvt9cU+RMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676359753; 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=mAmb7RUF3PhoaaNF6H33XfxjjbRB9gBlTaKZ6asf4UU=; b=JZWzWUO/cCiKAcwCYeoCFxwu5gpHN4SdHV3tEbtfJ7HGoIyIj0qbkkFEsGfUN96cwyKOzQ 3l5O8Fseud72nSsqaWGZRBR1PWSMbr3z5cSxSWym8zIfGCE/Wt8oer1FxBQLXcQAmSIJBJ VIKcTKjT5tRTdFcqo9vIgC9kvb10moZ2s9+SwRHkWtBKfSxmwj50oK1PTp8ZvZ5giDinmB wL6+04Jx9bPxbW8A+qv/rDtBPv2dem6d82BVs/Lc2RC0QrsDHB9Mj5gDI5zGkTO25EVXtd dauB/SA8aW+Zhsc+MDfrlTgOIZG0OzPGt4nwyEb+mSRp7euKZ1ScgYNZDycDEw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676359753; a=rsa-sha256; cv=none; b=gQM/632o6Y7a8WRM5Yk7E81EGrlhhKyk7HK11CI41/SlvBVDGW1awsPJ9XVQg4hlbV69+2 7fib/LEdy4CwLIpBuVBLbblLn2WqhLGofnS1Ykt16xfEpeixjFoS0PhiOQtwoe2Aoye/h3 MKkykgPBUsD8oDVmbzQCzP/a5cCuGaGPajrDd+enJWGWJbxLI8ShOHI7C0+zZBBz3mYg6F TnsHHCU46zmy2CGy1bzbML4kiMe5veCRR4Q2Ed0K1dFFv2I+GqJAHvlLXYoU8xm+j+vTj+ KM75vC8/3quI6S9MQZSVtSjY3qz8LhktWMhUR9Da8u2Ld/RiEIfyh4Mc4+Zmhw== 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 4PGCWY299czqnX; Tue, 14 Feb 2023 07:29:13 +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 31E7TDDB044097; Tue, 14 Feb 2023 07:29:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31E7TDtA044096; Tue, 14 Feb 2023 07:29:13 GMT (envelope-from git) Date: Tue, 14 Feb 2023 07:29:13 GMT Message-Id: <202302140729.31E7TDtA044096@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: 151d8131a817 - main - bhyve: add emulation for the qemu fwcfg selector port 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/main X-Git-Reftype: branch X-Git-Commit: 151d8131a817e7a6a629e9bb7fde4d7a158e5211 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=151d8131a817e7a6a629e9bb7fde4d7a158e5211 commit 151d8131a817e7a6a629e9bb7fde4d7a158e5211 Author: Corvin Köhne AuthorDate: 2021-08-11 07:59:16 +0000 Commit: Corvin Köhne CommitDate: 2023-02-14 07:28:43 +0000 bhyve: add emulation for the qemu fwcfg selector port The selector port is used to select the desired fwcfg item. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D38332 --- usr.sbin/bhyve/qemu_fwcfg.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/usr.sbin/bhyve/qemu_fwcfg.c b/usr.sbin/bhyve/qemu_fwcfg.c index 5d3070abf285..dec3fa83c493 100644 --- a/usr.sbin/bhyve/qemu_fwcfg.c +++ b/usr.sbin/bhyve/qemu_fwcfg.c @@ -29,8 +29,33 @@ #define QEMU_FWCFG_DATA_PORT_FLAGS \ IOPORT_F_INOUT /* QEMU v2.4+ ignores writes */ +#define QEMU_FWCFG_ARCHITECTURE_MASK 0x0001 +#define QEMU_FWCFG_INDEX_MASK 0x3FFF + +#define QEMU_FWCFG_SELECT_READ 0 +#define QEMU_FWCFG_SELECT_WRITE 1 + +#define QEMU_FWCFG_ARCHITECTURE_GENERIC 0 +#define QEMU_FWCFG_ARCHITECTURE_SPECIFIC 1 + +#pragma pack(1) + +union qemu_fwcfg_selector { + struct { + uint16_t index : 14; + uint16_t writeable : 1; + uint16_t architecture : 1; + }; + uint16_t bits; +}; + +#pragma pack() + struct qemu_fwcfg_softc { struct acpi_device *acpi_dev; + + uint32_t data_offset; + union qemu_fwcfg_selector selector; }; static struct qemu_fwcfg_softc fwcfg_sc; @@ -40,6 +65,20 @@ qemu_fwcfg_selector_port_handler(struct vmctx *const ctx __unused, const int in, const int port __unused, const int bytes, uint32_t *const eax, void *const arg __unused) { + if (bytes != sizeof(uint16_t)) { + warnx("%s: invalid size (%d) of IO port access", __func__, + bytes); + return (-1); + } + + if (in) { + *eax = htole16(fwcfg_sc.selector.bits); + return (0); + } + + fwcfg_sc.data_offset = 0; + fwcfg_sc.selector.bits = le16toh(*eax); + return (0); }