From nobody Mon Jan 17 16:22:15 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 1EA77196D5E6; Mon, 17 Jan 2022 16:22:16 +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 4Jcxxz5lFWz3DQR; Mon, 17 Jan 2022 16:22:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642436535; 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=HvNBwTDQ7APaBViXId5d/xzShEVynPRdn7Chn2VKrTA=; b=mFUu2+RzP1TAdXi+kO2yB4KrX1Ob8Qtg/dtYPFp6bRbHjwWC491+U/NRYj9UlDc7Cu1d83 YCJBSAoBvlPEEUoNzNAKID2OZKfaKRa1uEI4GRCw+3q6Mm0mWi+XKoYeasdsMi1xNQZdtz /drGCf5gnZnO890CYJS849L4hWmm/zNHRCgq9DJbDbipFckBp0WAPb/k+0AAWvTjUZ5KZK jimTeYxQxtGFxPwORyy488hMWZu3JMKu7mq5oNoTtv9rlfkVzwApT+pKa/v4EnWqGrQzqY PCgxWpT3iC6QA/tN99YTBfYu0NPIvVhi+qyIHCUBnGcgHrcW1LIi+CNsxzkfzA== 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 4F38B111BD; Mon, 17 Jan 2022 16:22:15 +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 20HGMFaJ017439; Mon, 17 Jan 2022 16:22:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20HGMFkj017426; Mon, 17 Jan 2022 16:22:15 GMT (envelope-from git) Date: Mon, 17 Jan 2022 16:22:15 GMT Message-Id: <202201171622.20HGMFkj017426@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: e6674c8f7fe7 - stable/13 - bhyve: allow reading of fwctl signature multiple times 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: manu X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e6674c8f7fe765aa72f99bff9bab381737bac896 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642436535; 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=HvNBwTDQ7APaBViXId5d/xzShEVynPRdn7Chn2VKrTA=; b=FOLADbxpVtn/T5oLs5+eeUBZwP15fyPGb6fZDbgC0KNZJFwIYzXV4RmyEyN2zTAE1T1jeG WY+v3XjSEQBfwPjazUeUESA3M8FdbcjxFZpXnZPSJ8WCxwIkDVZDr0X7C1584upmBIAyEs octeeauZ9fS8foWWH4VzZPt/eG3OWyrMYff+X8TEwYhY4WKfVl264INVSRLBjM3h1EcvZc COfnr859pOXt8PZ7QhULyuFfUec110cDmA9IWm5rHoP065W2ZCIGhlBhJDPDc/UQ3HEDn7 UCS3YybW4rZnrMFF/VGeiWXvQArwc/DU31fgr6sj+pqkD47XkOb/v/zCnqUV4w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642436535; a=rsa-sha256; cv=none; b=imfDKX0eDTsEdWbbRBBR92tn0hcTrdjbe+EdzSfa7yUKzVQKzPBHG9b38KlD7+Xo+1WzH9 yWEt0lDFjqkZCxYd4f4ej6KgfP0KeDEju4IgohO0aTWJ+K0WaeIzboWtauhVgEJ8WQym6W q5MGghIgheVpDPTUQggfpbKplD+86pNfgmH68BtLNBZ/+a/L0K6SfgsmMaTug8ln3+9Fg+ pMq1qgKWf4lw8ffbR3uBxpWD98xc1PhGUFHogfzERPLjG8tWkoypf7ByrURiTs+5p4WRcp cs3ioPNJBPiRBsUQlJhunMbt9MGWGfVqythtP9/dDE7P7X4hjgMoHBZhvOjU5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=e6674c8f7fe765aa72f99bff9bab381737bac896 commit e6674c8f7fe765aa72f99bff9bab381737bac896 Author: Corvin Köhne AuthorDate: 2022-01-03 13:18:31 +0000 Commit: Emmanuel Vadot CommitDate: 2022-01-17 12:53:17 +0000 bhyve: allow reading of fwctl signature multiple times At the moment, you only have one single chance to read the fwctl signature. At boot bhyve is in the state IDENT_WAIT. It's then possible to switch to IDENT_SEND. After bhyve sends the signature, it switches to REQ. From now on it's impossible to switch back to IDENT_SEND to read the signature. For that reason, only a single driver can read the signature. A guest can't use two drivers to identify that fwctl is present. It gets even worse when using OVMF. OVMF uses a library to access fwctl. Therefore, every single OVMF driver would try to read the signature. Currently, only a single OVMF driver accesses the fwctl. So, there's no issue with it yet. However, no OS driver would have a chance to detect fwctl when using OVMF because it's signature was already consumed by OVMF. Reviewed by: markj MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D31981 (cherry picked from commit 8ec366ec6c943550a011effe50bc73e3875f8ead) --- usr.sbin/bhyve/fwctl.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/usr.sbin/bhyve/fwctl.c b/usr.sbin/bhyve/fwctl.c index 0640bc28ba2b..abb234fe1de4 100644 --- a/usr.sbin/bhyve/fwctl.c +++ b/usr.sbin/bhyve/fwctl.c @@ -472,16 +472,18 @@ fwctl_inb(void) static void fwctl_outw(uint16_t val) { - switch (be_state) { - case IDENT_WAIT: - if (val == 0) { - be_state = IDENT_SEND; - ident_idx = 0; - } - break; - default: - /* ignore */ - break; + if (be_state == DORMANT) { + return; + } + + if (val == 0) { + /* + * The guest wants to read the signature. It's possible that the + * guest is unaware of the fwctl state at this moment. For that + * reason, reset the state machine unconditionally. + */ + be_state = IDENT_SEND; + ident_idx = 0; } }