From nobody Fri Mar 17 10:29:21 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 4PdL353KC2z3yBWR; Fri, 17 Mar 2023 10:29:21 +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 4PdL352jz7z3GNh; Fri, 17 Mar 2023 10:29:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679048961; 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=gV+PZn63sFKmOsawt90BW25MHPLIRIkr3Lmk1FmJK5Y=; b=o+3QbXg8HoH7Pg+nh0JCXBSMsImIkxJxCjcmdDcIXLcq0zHHC5pMQft0bN/jpi3fIl0rWQ 2CGH3lRljqWAd1i2AWfgxA6X4nJHZMOJdlPz3Qbwgn5HfjqvuWs9OjVMY3pNJHFHMiQPZR wIyhPPEhW4q2godc/df4CqCqZSjgAeA1ZGkyByTg89a0oMson4AasTP06spF0dcgI4iSET EJfhaeu7k0kxieDeXxb1bjSX8Dsk1COYoMey4lXEIaPkhLwSGD7IcLGyC/Hfjn0wr+uv0H XMF+WFR5RYPcqgaQGPnffzo7X5936QxfuIbpNdr1WJ9gMc6cwas8BxJAOcdMVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679048961; 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=gV+PZn63sFKmOsawt90BW25MHPLIRIkr3Lmk1FmJK5Y=; b=RSroO8WY4C2WAHaK0kuwhvH78NZ81f5Y2IdwlrVxcg/vZz8g/UePGquwivRvYqF36NKePz se04E6L5Bf7K3hyRmzUZ4CFXrsAueePwk14WJirADwSx9l7kK4FT0p4JXAN+S/2o82bAFs Wei6nVdcQQfXV04VpbtTDPTQEpii5k2ObT7GwMtsqYfbwGMTe+HP1mgxwXFPz8ur55D/x/ 4KsRq3R0Soj45SJi7dNiwFcavQFNGjeao9E8bXcGn6XwnCZ8dMgqVLrWiPXVrdxaqHBznS sezrrtVjleUEM4FmhEXr6QByirkDOd6n8l4klPLTaIl8bmZzPREej2/xYg34pQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679048961; a=rsa-sha256; cv=none; b=w6aFQOg6tBcJWjDuiXBThSmWyhbUAOLjNrZ9jT4XQ/g8MkGw3BnQXHlEhVjC5854KrO7dE GjyQEJB9JcaiWr8KFrTL3q/4iwqZ0jqgIhhHO5sCCJS5No3C3MERpm13Vf1d1YXErO0SWU AC8A0Z1vegzyBtGRRAcdSN6I7J3nqzaX9byToLJOcMqPToEUn3irQm2QWUiqQ60eowczI1 pkmqIybG9XWfKf9Ws8i//l9CKnStrcEGL/4cWXF0TR7kugxO8jNp/6msgg/3L8iYg9zQKA bZ8x3xZNFbKLQXH9IdKF7PPY4ZtMTqucgSmZQJlkyNoTSn2eUWQk58K75qfTPA== 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 4PdL351mLHzMpW; Fri, 17 Mar 2023 10:29:21 +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 32HATLte067252; Fri, 17 Mar 2023 10:29:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32HATLHE067251; Fri, 17 Mar 2023 10:29:21 GMT (envelope-from git) Date: Fri, 17 Mar 2023 10:29:21 GMT Message-Id: <202303171029.32HATLHE067251@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: 1adfb2e834c5 - stable/13 - bhyve: add helper to add fwcfg items 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: 1adfb2e834c57b319d3f0eee1b80e2d7b1a3d421 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=1adfb2e834c57b319d3f0eee1b80e2d7b1a3d421 commit 1adfb2e834c57b319d3f0eee1b80e2d7b1a3d421 Author: Corvin Köhne AuthorDate: 2021-08-11 08:01:19 +0000 Commit: Corvin Köhne CommitDate: 2023-03-17 10:26:32 +0000 bhyve: add helper to add fwcfg items This helper makes it easier to add multiple fwcfg items. You can pass an index and some data to the helper. The helper adds these information to the fwcfg emulation so that the guest reads the given data on the specified index. Reviewed by: MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D38334 (cherry picked from commit 3ef46195ac37111ab247cfabed735d3ee5e7f5b5) --- usr.sbin/bhyve/qemu_fwcfg.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/usr.sbin/bhyve/qemu_fwcfg.c b/usr.sbin/bhyve/qemu_fwcfg.c index 13e21daca7ff..8cb71b819956 100644 --- a/usr.sbin/bhyve/qemu_fwcfg.c +++ b/usr.sbin/bhyve/qemu_fwcfg.c @@ -130,6 +130,31 @@ qemu_fwcfg_data_port_handler(struct vmctx *const ctx __unused, const int in, return (0); } +static int +qemu_fwcfg_add_item(const uint16_t architecture, const uint16_t index, + const uint32_t size, void *const data) +{ + /* truncate architecture and index to their desired size */ + const uint16_t arch = architecture & QEMU_FWCFG_ARCHITECTURE_MASK; + const uint16_t idx = index & QEMU_FWCFG_INDEX_MASK; + + /* get pointer to item specified by selector */ + struct qemu_fwcfg_item *const fwcfg_item = &fwcfg_sc.items[arch][idx]; + + /* check if item is already used */ + if (fwcfg_item->data != NULL) { + warnx("%s: qemu fwcfg item exists (architecture %s index 0x%x)", + __func__, arch ? "specific" : "generic", idx); + return (-1); + } + + /* save data of the item */ + fwcfg_item->size = size; + fwcfg_item->data = data; + + return (0); +} + static int qemu_fwcfg_register_port(const char *const name, const int port, const int size, const int flags, const inout_func_t handler)