From nobody Tue Feb 28 12:38:36 2023 X-Original-To: dev-commits-src-main@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 4PQxk44Cg6z3vQ2X; Tue, 28 Feb 2023 12:38:36 +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 4PQxk43fp7z43k9; Tue, 28 Feb 2023 12:38:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677587916; 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=yAcy0y/xxsM42PpwjEL22mJ3ddRhLXOoxuOWRo+uptM=; b=ykdHdeXfBJ+PHxS1O+rxVeAu4XCyTaBLuwlVeYCEghC7kukQNb7FhAB3F8vBGk3tSdKIQq q4cTqTXByfNCyHDGx5tIKyZrtqFxNCsEE3clZjfQc2/4ScGti5mCXURpY/Nc7Z/hmWz+PF e87hDLCbH5tlFEJrk3IRtMTzpSeLe8tE61fSjEm8SXmBSjTPwxGc54Z+IVY11eXtyJqKJO B6GV3TMzpCD6OReb8lp6TTQDCO2CndkEocwqZM/8zF5QZcZLbtdxlMidJJfUmIkljAKZ0e 1gMZFWiYPOxRyV8py2ZF1JDcntF3glzS5XkDcNPhCQhqHfP6A8tqbTm30eCFxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677587916; 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=yAcy0y/xxsM42PpwjEL22mJ3ddRhLXOoxuOWRo+uptM=; b=oElXSvZe70SgrUF59DliFRs3oi2Ved6R6rdUFwwx6sbF4Xi524oK3g8smaQgDJZfcC/V/I lzHncF6NDqQswavHviId5bxEIZ90gXDn0PxSPAIhXeP9/J+8rUNvDfdnvSGu8knxPqx9Az 5uCD4h/kWd8AxPoBhAZnpBoGN54JZFklYCMZhV4X7sWs054Vxv4mX/c1xXX/dH1vP9ALxY ZiLoRYdmdSVpsYzkXwabEkNPGcXcdPczGYhx8rzUamwAX8rqCkH+Oo2jw9El6HtLC6W7hn KkGL/5lK40rr1ExV1BMAdr8nqBnC7dyzUaoTKY5w0VB53NIOX0b0Y8HwduDjuQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677587916; a=rsa-sha256; cv=none; b=cliv5BTIwM50A1zR/wtLCe0kpo2OibpoN9SncF+05nMZc0XCylRoaAQl1xkOlNtkf4I3Az N9rOVmSAPA77pTdJam4vLpmQf/19DEIopvbNQp9vBh7DZEoP0RkdtieMN8GdFJnPqa4CmG omoUnO3TOhZC1G0pRn4aiFP/WI4U3E8V6p+12cf6+cXQUHf9SzJpL/GIgz5CTNxBAqVFMa ewp8yx6sMhBl7AbM8SfQzjWyZolR0owZOerwmrKrUdMJmH1Czsg2FkBwLkqHlOwya32KkL Rz2ChBcJudc2dGHjw8R3xeO4v/absBZY3tp+tGjpkseSevep+e4Vc9c86+HCfQ== 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 4PQxk42kl8z16dH; Tue, 28 Feb 2023 12:38:36 +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 31SCcarS043002; Tue, 28 Feb 2023 12:38:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31SCcaI6043001; Tue, 28 Feb 2023 12:38:36 GMT (envelope-from git) Date: Tue, 28 Feb 2023 12:38:36 GMT Message-Id: <202302281238.31SCcaI6043001@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: 3ef46195ac37 - main - bhyve: add helper to add fwcfg items List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 3ef46195ac37111ab247cfabed735d3ee5e7f5b5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=3ef46195ac37111ab247cfabed735d3ee5e7f5b5 commit 3ef46195ac37111ab247cfabed735d3ee5e7f5b5 Author: Corvin Köhne AuthorDate: 2021-08-11 08:01:19 +0000 Commit: Corvin Köhne CommitDate: 2023-02-28 12:37:03 +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 --- 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)