Page MenuHomeFreeBSD

[PATCH 4/19] bhyve: add basl support for int values
ClosedPublic

Authored by corvink on Oct 14 2022, 9:03 AM.
Tags
Referenced Files
Unknown Object (File)
Sun, Dec 22, 9:58 AM
Unknown Object (File)
Wed, Nov 27, 6:43 AM
Unknown Object (File)
Nov 15 2024, 6:05 PM
Unknown Object (File)
Oct 2 2024, 1:24 AM
Unknown Object (File)
Sep 27 2024, 3:21 PM
Unknown Object (File)
Sep 27 2024, 1:21 PM
Unknown Object (File)
Sep 27 2024, 1:18 PM
Unknown Object (File)
Sep 27 2024, 11:27 AM
Subscribers

Details

Summary

In upcoming commits, bhyve will build some ACPI tables by it's own.
Therefore, it should be capable of appending int values to ACPI tables.

This is the fourth 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-tables part 4] bhyve: add basl support for int values to [PATCH 4/19] bhyve: add basl support for int values.Oct 14 2022, 9:43 AM
usr.sbin/bhyve/basl.c
163

Can this be an assertion instead of a runtime check?

usr.sbin/bhyve/basl.c
163

IMHO, bhyve makes too much use of assertions. You should assume that an assertion won't be compiled for release builds.

In this case, ACPI tables aren't very dynamic yet. So, an assertion could make sense. Nevertheless, ACPI table creation could be more dynamic in the future (e.g. with tpm emulation). So, it's harder to check all code pathes on debug builds.

usr.sbin/bhyve/basl.c
163

bhyve uses assert() too much, yes. In practice it works because assert() is always enabled, in release or debug builds of FreeBSD. I believe it should start using a custom assert() which is guaranteed to be enabled.

So, it's harder to check all code pathes on debug builds.

I don't quite follow what you mean. To me, the reasons assertions are better here are:

  • They document the expectations of the interface. When these are runtime checks, I can't easily tell if they may legitimately arise at runtime.
  • They make debugging easier since bhyve fails closed.
  • We do not need to rely on all callers to correctly check for errors and pass error state up the stack.
  • address feedback of markj
markj added inline comments.
usr.sbin/bhyve/basl.c
163

Thanks, but really the change should be consistent. e.g., basl_table_append_bytes() should use asserts as well. I'm not sure if you applied the change elsewhere or not.

I don't mean to insist on this approach; if you really prefer runtime checks, then please do it your way. Using assert() (or some hypothetical bhyve_assert()) just helps distinguish between true runtime errors and defensive checks, and helps reduce code complexity, so I find it easier to read. Anyway, I will leave it up to you.

This revision is now accepted and ready to land.Nov 4 2022, 2:40 PM
corvink added inline comments.
usr.sbin/bhyve/basl.c
163

I'm going to update all of my patches to use assertions.

usr.sbin/bhyve/basl.c
166

I would perhaps have done this:

char buf[8];

le64enc(buf, val);
return (basl_table_append_bytes(table, buf, size));

I think using a byte buffer explicitly is clearer intent I think.

This revision now requires review to proceed.Nov 11 2022, 8:23 AM
This revision is now accepted and ready to land.Nov 11 2022, 6:29 PM
This revision was automatically updated to reflect the committed changes.