From nobody Tue Nov 29 13:58:03 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 4NM3nl5mSSz4htf0; Tue, 29 Nov 2022 13:58:03 +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 4NM3nl4lWwz4CVP; Tue, 29 Nov 2022 13:58:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669730283; 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=iz6ABcGnKC1Dkj8KwWEljw1piR/Dzo0F3ge2Q18kL2s=; b=h9Ayt60cmlt1xibAIhUhLXwxuzDzOo8BiE1m7rN+mdnikl/+8J34CaEpjKlmUmD+WhaJaF kAIT7wlbooJC7IW7bJn3FcTnhsJC/q2Js/RwYN0xKPKYBMHNcw9It2LynDHAmlU/Ikl3o2 xplom8Ur3Pz6e5x38u/pvZLWX/Ab6d66T1X22G3nwIDb6oK/Z/LxwZDYu4957O3g9qQzA7 EGI1+ztINW3Kt8Cf/ZjhR3JXQS9dpgzM864tBEEy3RQiv9pMEz0HbDlVbb8IQmwp2sJslW f4cb7TC5Qi4FSBTmIOHnMyZAo6dLG0NL4czlzFewDf1fNUi8ezyPFPG7wI+fjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669730283; 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=iz6ABcGnKC1Dkj8KwWEljw1piR/Dzo0F3ge2Q18kL2s=; b=LJuB4vH0ueJxXajRZ45xO4jyscar3ZxKphEA3wNv/q2L+Z0q+41p+w3eX3kDSJDFFSj3j9 T7gazyFzUqf0ON5Dbha2b9a1eB/NHQF6o9dJT2FT93CV6fDohpm6uFgIKcTbEBlrCCBv6D vQBQ3E2mHvfprMAzQxz5y5a/fL8BphkiLNzsBsygN/GoUIINylDzGmXiohz5DSJC02im71 2PJlEoJhQ96WPXQ2Jmhwnve6Lydizu/4t4twSPhn5uBk05AZADr3tYC6vaTyMeEKYCC5yu zPgvzaF8GAfKEWxnpIEGYFhnnwHnT6uI/A2uibUUwip+NVdXUpqcFN1gGV77/A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669730283; a=rsa-sha256; cv=none; b=qaxcWX9HzSdJj5XbOzjAgq95rWyVlgIClU0DKU3LmYVlcIMW1056ZZnRX/9y+HOhn/pnvK lJ2qajb+ydFE49WTL9rbfPlncPlPdu7h72iuzm2gY/wP4mtta7vFm8yAwN7/SHGWvtUUEU omtE3XBY03U/th5cOQf+e5/zDOKKcXLh14tOx8ZumeZ6QkBQd7Rg/FlbkgS8QDPxxYDz52 Xme3NVbduu4sP8HQIRC72cDcjEa2qZPDSbFbOG0ImKmf+NJrQ18ZwZFQWmOfC+oCg4Zp/v gsXmm/nvS1rE3lEYEKEgiLDuKr+692Bucq/dTn5fWUg3OpCNxP0AC3Sk1jnqVQ== 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 4NM3nl3kpnzKdn; Tue, 29 Nov 2022 13:58:03 +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 2ATDw36q029475; Tue, 29 Nov 2022 13:58:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2ATDw3u4029474; Tue, 29 Nov 2022 13:58:03 GMT (envelope-from git) Date: Tue, 29 Nov 2022 13:58:03 GMT Message-Id: <202211291358.2ATDw3u4029474@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: 032165475f5d - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 032165475f5d7357fd68a7db5efb5e0eb103ad4e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=032165475f5d7357fd68a7db5efb5e0eb103ad4e commit 032165475f5d7357fd68a7db5efb5e0eb103ad4e Author: Corvin Köhne AuthorDate: 2022-04-06 09:10:39 +0000 Commit: Corvin Köhne CommitDate: 2022-11-29 13:53:51 +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 (cherry picked from commit 3a766cd0f1fed90df8f3fd010357e36e050bceb2) --- 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);