From nobody Mon Jun 12 11:04:45 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 4Qfpjn474gz4cjVH; Mon, 12 Jun 2023 11:04:45 +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 4Qfpjn361vz3Mhc; Mon, 12 Jun 2023 11:04:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686567885; 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=Fw+BzK2QYu16rVEOlSofGPHI8Y6zDlPEn7Zp5n49CE8=; b=N7v9u+BQkMXtgrEUHgbglyYYAhziJmP7Ljbp8FLJ/vkLlYKhzTJ1U7nYBdtx89JEzE2xiM e39/Fk6jQQm54ia70iryarhYfo9u813hoXAHcj1W/L8Bsp8XiAKsirPG6AqxOK2/NUiA3S 9xmEopyyURuA59hoy6OuiOV+kiy4YBkHxO3PO8hLvsWNXftXPODVSrON1IhYKdhbrht4fc HwF9/MMlHQ0MiE/hXoUhpO5CqyjuEbUBof2Q4Th7nbC92FkyRPdxQsCgecnwBZIVz/8XKH FfJr5JFaD/mr6rMaaxHKN0VHO1fKoFKlWPS1dqWVhiUYXclDEarXw6otNiMgIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686567885; 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=Fw+BzK2QYu16rVEOlSofGPHI8Y6zDlPEn7Zp5n49CE8=; b=FZbtMWc5EifiSRpd6/G5d6iii8ZI/gCwD9RNpV9bpPpUX7F0XVMKfhXQZAVFydJl2c1g1q Z1F5i+N5Ep7QX1nIvhyVefjmk5+dbV6u/0m18nLh3LpyJI/wt9tuHMOweTk2YAa+3bHd4P KSfaAPpVU6lJDC/M6TnvWe5IU2nb8VxtWM19bijmjNk/kSl/2bZy6Bp4YMimuH5mc+QU/1 bc4QJTGW1l+YeeVV4artYxzTVPZINp2fanZwF8WKWKZdC1XCe9fcKkvpIZjyfkfj6axvSo bUqPB59BPVHxr5g1XstKo/IAD5Gl0ile3vn9O7MZ5EFawNULlvfBGRQ3xa5+QA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686567885; a=rsa-sha256; cv=none; b=T9lho/mNqeh1BcItlCN1dyP20EFPTVqt1bddYCM9LCPOTc2Ypmja2Ud1MnXEABZnDgncJ5 b4Irv1wLt4V8m3auwq8gAmSJxl61YsEffr9BaTErEY4ENYHmnvKQUoKI5oON+l6dAqgMr0 AGHxXfLtUpZvkr2WgTZSDWoP8XRyMuW4MuAiEnZpvGt3ipkAPCPy1gpjy2j8JfcKY9cVFT 0+fsDDGNnNM5khKA6WHa4E0MvSDYFtzpDl9hZO1BmfB5R3Xcnc9diw8rQMk+BX9rALflB+ Cjc6iWeweXfYYhIEpvYN9wdQ3E43BI5cn85YDWC2wHMmKvVo8gswIAi8iwSTpQ== 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 4Qfpjn1lsrzdFg; Mon, 12 Jun 2023 11:04:45 +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 35CB4jYt017293; Mon, 12 Jun 2023 11:04:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35CB4jF2017292; Mon, 12 Jun 2023 11:04:45 GMT (envelope-from git) Date: Mon, 12 Jun 2023 11:04:45 GMT Message-Id: <202306121104.35CB4jF2017292@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: d5edf13d013f - main - bhyve: add basic TPM device 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: d5edf13d013f3298e7f703c406223feb84810a73 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=d5edf13d013f3298e7f703c406223feb84810a73 commit d5edf13d013f3298e7f703c406223feb84810a73 Author: Corvin Köhne AuthorDate: 2023-05-15 11:00:06 +0000 Commit: Corvin Köhne CommitDate: 2023-06-12 11:04:35 +0000 bhyve: add basic TPM device Add an empty TPM device struct which will be used for TPM emulation in subsequent commits. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D40452 --- usr.sbin/bhyve/Makefile | 1 + usr.sbin/bhyve/tpm_device.c | 68 +++++++++++++++++++++++++++++++++++++++++++++ usr.sbin/bhyve/tpm_device.h | 18 ++++++++++++ 3 files changed, 87 insertions(+) diff --git a/usr.sbin/bhyve/Makefile b/usr.sbin/bhyve/Makefile index 65a32d2fb0b9..ae1e82e7b828 100644 --- a/usr.sbin/bhyve/Makefile +++ b/usr.sbin/bhyve/Makefile @@ -72,6 +72,7 @@ SRCS= \ smbiostbl.c \ sockstream.c \ task_switch.c \ + tpm_device.c \ uart_emul.c \ usb_emul.c \ usb_mouse.c \ diff --git a/usr.sbin/bhyve/tpm_device.c b/usr.sbin/bhyve/tpm_device.c new file mode 100644 index 000000000000..77fd1ccf6a52 --- /dev/null +++ b/usr.sbin/bhyve/tpm_device.c @@ -0,0 +1,68 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 Beckhoff Automation GmbH & Co. KG + * Author: Corvin Köhne + */ + +#include + +#include +#include +#include +#include +#include + +#include "config.h" +#include "tpm_device.h" + +struct tpm_device { + struct vmctx *vm_ctx; +}; + +void +tpm_device_destroy(struct tpm_device *const dev) +{ + if (dev == NULL) + return; + + free(dev); +} + +int +tpm_device_create(struct tpm_device **const new_dev, struct vmctx *const vm_ctx, + nvlist_t *const nvl) +{ + struct tpm_device *dev = NULL; + const char *value; + int error; + + if (new_dev == NULL || vm_ctx == NULL) { + error = EINVAL; + goto err_out; + } + + value = get_config_value_node(nvl, "version"); + if (value == NULL || strcmp(value, "2.0")) { + warnx("%s: unsupported tpm version %s", __func__, value); + error = EINVAL; + goto err_out; + } + + dev = calloc(1, sizeof(*dev)); + if (dev == NULL) { + error = ENOMEM; + goto err_out; + } + + dev->vm_ctx = vm_ctx; + + *new_dev = dev; + + return (0); + +err_out: + tpm_device_destroy(dev); + + return (error); +} diff --git a/usr.sbin/bhyve/tpm_device.h b/usr.sbin/bhyve/tpm_device.h new file mode 100644 index 000000000000..a17c85c2ed47 --- /dev/null +++ b/usr.sbin/bhyve/tpm_device.h @@ -0,0 +1,18 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 Beckhoff Automation GmbH & Co. KG + * Author: Corvin Köhne + */ + +#pragma once + +#include + +#include "config.h" + +struct tpm_device; + +int tpm_device_create(struct tpm_device **new_dev, struct vmctx *vm_ctx, + nvlist_t *nvl); +void tpm_device_destroy(struct tpm_device *dev);