Page MenuHomeFreeBSD

[PATCH 6/19] bhyve: add basl support for length fields
ClosedPublic

Authored by corvink on Oct 14 2022, 9:07 AM.
Tags
Referenced Files
Unknown Object (File)
Sat, Oct 26, 8:01 PM
Unknown Object (File)
Oct 4 2024, 6:38 PM
Unknown Object (File)
Sep 27 2024, 1:24 PM
Unknown Object (File)
Sep 27 2024, 11:28 AM
Unknown Object (File)
Sep 20 2024, 12:54 AM
Unknown Object (File)
Sep 19 2024, 4:35 PM
Unknown Object (File)
Sep 18 2024, 10:05 AM
Unknown Object (File)
Aug 21 2024, 12:21 PM
Subscribers

Details

Summary

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.

This is the 6. patch required to merge D36983

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

corvink retitled this revision from [acpi-table part 6] bhyve: add basl support for length fields to [PATCH 6/19] bhyve: add basl support for length fields.Oct 14 2022, 9:43 AM
usr.sbin/bhyve/basl.c
49

Looks like this can be static.

113

I think _set_lengths() would be a bit better as a name.

116
121

Shouldn't you assert that the offset is within the bounds of the table?

236

Similarly I think these should simply be assertions, since this check can only fail due to a programming error.

  • make use of assertions as suggested by reviewers
  • turn basl_lengths into a member variable of basl_table to avoid global variables and backpointer
usr.sbin/bhyve/basl.c
120

I wonder if what you kind of want actually is a helper function that writes an integer in little endian format to a buffer but takes a size, something like:

static __inline void
basl_store_int(void *pp, uint64_t val, size_t len)
{
    char buf[8];

    le64enc(buf, val);
    memcpy(pp, buf, len);
}

You could use this in the earlier commit that appends an integer to a table, and you could use it here as:

basl_store_int(table->data + length->off, table->len, length->size);
  • make use of basl_le_enc helper
This revision is now accepted and ready to land.Nov 11 2022, 6:28 PM
This revision was automatically updated to reflect the committed changes.