From nobody Mon Jan 03 16:01:37 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 0CC171926039; Mon, 3 Jan 2022 16:01:38 +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 4JSL8d1zJmz4XJS; Mon, 3 Jan 2022 16:01:37 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 1B7E72797A; Mon, 3 Jan 2022 16:01:37 +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 203G1bIn039359; Mon, 3 Jan 2022 16:01:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 203G1bdv039358; Mon, 3 Jan 2022 16:01:37 GMT (envelope-from git) Date: Mon, 3 Jan 2022 16:01:37 GMT Message-Id: <202201031601.203G1bdv039358@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 8ec366ec6c94 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 8ec366ec6c943550a011effe50bc73e3875f8ead Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641225697; 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=04D6VVhz30mctCe17YphmiYCs0+3UzgVXb0ugvZx7a4=; b=pvgVO/dFzCWMgPXC46uQdJml51kbDlksr9+8vUMbXH0lxc4nV/Opy3cNgKKBcrLi61+ZIP LFrwV4N5iYbV5bAWVVboUs7kdgxPQKO42lZe8wMGHQl8RgpzzQEkSqA4M8WEFy/H/rA9oZ Ru+B/4h2Oh0d9v1ONGjQRlTfCRgBSguKjb1l8Ld1Aopj6D9JSUldnDHVgEs0jbbDGyUlo3 6VRC8T8EnXyVjEFRhQyv9fVi4ldg9gzeQu/ZlyKlW33bItxmAio8tnvuKykddAdkOeYq9c Y2HM5J/8jJo7keQSkVTZs0LkgQITTxceuQngLVtZm6OC3l5T33pHvPjteJACtQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641225697; a=rsa-sha256; cv=none; b=tHyaWGu78mC30J0npSN3lshAEvi51vT6crNLk3Avj9vlwGgOmDLXQ2s3xCqAMDQWQK/N+B SV8hq/KkzdtySHD6eYrOWLhAqvvA40QfFQQZ+J3nR7SYhA/DK4uSiiRnKY+Ojj05DNm8u9 8IitruApV5mggqJXPG1SRVh9rtifO3HmZQctYA8O8dMxGxnk2WpiOCNa6bAFE2aXt9UOJN XJr1Y0CcFxtXeFfBQ9XwqT3FRECiFMhhjvDXfAuzy33BZMWXdf+dsB5bAEDOboweM6gIn1 cR5JM6ieF5S9M6NGDrHFuo2UVetPUPjUK6cVt/qOU+5WWZTCQv2BLbEBT58hrw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=8ec366ec6c943550a011effe50bc73e3875f8ead commit 8ec366ec6c943550a011effe50bc73e3875f8ead Author: Corvin Köhne AuthorDate: 2022-01-03 13:18:31 +0000 Commit: Emmanuel Vadot CommitDate: 2022-01-03 15:32:55 +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 --- 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 a91f3d14fb78..8faae30989e6 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; } }