From nobody Tue Nov 15 07:28:08 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 4NBHpJ6vvhz4hBg2; Tue, 15 Nov 2022 07:28:08 +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 4NBHpJ6V5mz3jsB; Tue, 15 Nov 2022 07:28:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668497288; 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=Mw3ahif2pz1voWHNy/AVKXJjUSBYmZmJyPpExj7+V0s=; b=dqggqRjkIpaU93PxxPjaznoVdHdTejHbuvbVjZC2mpwSs7DD+YcC1+HSARo529DmQH1AzR ZBRpodiJlmNQCAHcplFrjhuOfDCm1feQmZ3plzjywUB/7q1L8nQ2iPoujHerkx8F6Oaael aNcypkursr709kKmWMdlzyFgQfClY3SQb1M6pvlDfhxDrD7fylRNvToCz2l4SlABip4dwJ 2I/Epm12lZ1MkhOrZsKchEF4rMmR4QkOD0inhygS+cW0ztjMnlD5f7iqtkYu8Vs+njv2A/ j8XE2dKpbxw6FSSfDcG4Su2kw7MWN9bctB6BuOhuZhW+q5wVwXlNl3Ria0YwXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668497288; 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=Mw3ahif2pz1voWHNy/AVKXJjUSBYmZmJyPpExj7+V0s=; b=TL7dyUm6vvPs7V/pAlBCx7XELtinQHSHkIvBYuLrGPWeEoaj+2Bh6qvmDH0OjwoMFtwBj4 RYYX26exj5pg9BfPx1Poix9WqYla98N+vzbw/4wU7jC45RXBp73+blo2jitp5upGczK0dF K0Zu4Tjeoc/p+RIgE7FEz6Wrs+HlEd1Fe5YqcAHg98UqRDOcbFJjcroK+zwBSezerE9QTv ju4+YTSY+lANVqYQw7wM/JBpb/GSwcKGziNGQS70JUa/XlsGWqr6s5a0Cj4OJcUJUFLCnG qpSbhzoT6aaMmK276QYbdxZlSmyP93B1tSzNM7COAqYyKNOjALdwUTAFA9FpJA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668497288; a=rsa-sha256; cv=none; b=r/QzYWziPBbyrvBBEp/1HDcyMwudCNDiJF9oeK7S/tkA8/w0nVe9Y8kmizcxMkgnIf2LS6 BgsZLDX+EbDYTPi5FdrSNGB57UkkBiHHUoDe6ZUZZGaCwe+mrpEz7C/B1immJT5fjLs+sW fN6UesTXvneouenGmrSpNd0GasufZbGANRyuz0NdBM2IHhFyBriW2e5BstkWueQxrDFrNv NV2WH5pXsuwk98fkbfr0FVQ9JykVCZOC+yEhZFmKlgJKyvCVAHZQN3cJj47Qjsn5RyXGMp 8uSaKH9Mdyfgw3wH9wJTdHwmPW8Mb3SyYcEHxV8+wb/NR5V3AjBMGx+SiQwEZQ== 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 4NBHpJ5Yfsz1Cr5; Tue, 15 Nov 2022 07:28:08 +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 2AF7S8F0046783; Tue, 15 Nov 2022 07:28:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AF7S8eB046782; Tue, 15 Nov 2022 07:28:08 GMT (envelope-from git) Date: Tue, 15 Nov 2022 07:28:08 GMT Message-Id: <202211150728.2AF7S8eB046782@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: 3a766cd0f1fe - main - bhyve: add basl support for length fields 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: 3a766cd0f1fed90df8f3fd010357e36e050bceb2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=3a766cd0f1fed90df8f3fd010357e36e050bceb2 commit 3a766cd0f1fed90df8f3fd010357e36e050bceb2 Author: Corvin Köhne AuthorDate: 2022-04-06 09:10:39 +0000 Commit: Corvin Köhne CommitDate: 2022-11-15 07:27:09 +0000 bhyve: add basl support for length fields ACPI tables have different layouts. So, there's no common position for the length field. When tables are build by basl, the length is unknown at the beginning. It has to be set after building the table. Reviewed by: jhb Approved by: manu (mentor) MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D36989 --- usr.sbin/bhyve/basl.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ usr.sbin/bhyve/basl.h | 1 + 2 files changed, 59 insertions(+) diff --git a/usr.sbin/bhyve/basl.c b/usr.sbin/bhyve/basl.c index 7dfeb8d2acb3..b03c936bd517 100644 --- a/usr.sbin/bhyve/basl.c +++ b/usr.sbin/bhyve/basl.c @@ -21,6 +21,12 @@ #include "basl.h" +struct basl_table_length { + STAILQ_ENTRY(basl_table_length) chain; + uint32_t off; + uint8_t size; +}; + struct basl_table { STAILQ_ENTRY(basl_table) chain; struct vmctx *ctx; @@ -29,6 +35,7 @@ struct basl_table { uint32_t len; uint32_t off; uint32_t alignment; + STAILQ_HEAD(basl_table_length_list, basl_table_length) lengths; }; static STAILQ_HEAD(basl_table_list, basl_table) basl_tables = STAILQ_HEAD_INITIALIZER( basl_tables); @@ -102,6 +109,22 @@ basl_finish_install_guest_tables(struct basl_table *const table) return (0); } +static int +basl_finish_set_length(struct basl_table *const table) +{ + struct basl_table_length *length; + + STAILQ_FOREACH(length, &table->lengths, chain) { + assert(length->off < table->len); + assert(length->off + length->size <= table->len); + + basl_le_enc(table->data + length->off, table->len, + length->size); + } + + return (0); +} + int basl_finish(void) { @@ -113,6 +136,7 @@ basl_finish(void) } STAILQ_FOREACH(table, &basl_tables, chain) { + BASL_EXEC(basl_finish_set_length(table)); BASL_EXEC(basl_finish_install_guest_tables(table)); } @@ -125,6 +149,26 @@ basl_init(void) return (0); } +static int +basl_table_add_length(struct basl_table *const table, const uint32_t off, + const uint8_t size) +{ + struct basl_table_length *length; + + length = calloc(1, sizeof(struct basl_table_length)); + if (length == NULL) { + warnx("%s: failed to allocate length", __func__); + return (ENOMEM); + } + + length->off = off; + length->size = size; + + STAILQ_INSERT_TAIL(&table->lengths, length, chain); + + return (0); +} + int basl_table_append_bytes(struct basl_table *const table, const void *const bytes, const uint32_t len) @@ -184,6 +228,18 @@ basl_table_append_int(struct basl_table *const table, const uint64_t val, return (basl_table_append_bytes(table, buf, size)); } +int +basl_table_append_length(struct basl_table *const table, const uint8_t size) +{ + assert(table != NULL); + assert(size <= sizeof(table->len)); + + BASL_EXEC(basl_table_add_length(table, table->len, size)); + BASL_EXEC(basl_table_append_int(table, 0, size)); + + return (0); +} + int basl_table_create(struct basl_table **const table, struct vmctx *ctx, const uint8_t *const name, const uint32_t alignment, @@ -207,6 +263,8 @@ basl_table_create(struct basl_table **const table, struct vmctx *ctx, new_table->alignment = alignment; new_table->off = off; + STAILQ_INIT(&new_table->lengths); + STAILQ_INSERT_TAIL(&basl_tables, new_table, chain); *table = new_table; diff --git a/usr.sbin/bhyve/basl.h b/usr.sbin/bhyve/basl.h index 95164e98ed7a..95c5fd916761 100644 --- a/usr.sbin/bhyve/basl.h +++ b/usr.sbin/bhyve/basl.h @@ -43,5 +43,6 @@ int basl_table_append_gas(struct basl_table *table, uint8_t space_id, uint8_t bit_width, uint8_t bit_offset, uint8_t access_width, uint64_t address); int basl_table_append_int(struct basl_table *table, uint64_t val, uint8_t size); +int basl_table_append_length(struct basl_table *table, uint8_t size); int basl_table_create(struct basl_table **table, struct vmctx *ctx, const uint8_t *name, uint32_t alignment, uint32_t off);