Page MenuHomeFreeBSD

bhyve: dynamically register FwCtl ports
ClosedPublic

Authored by corvink on Dec 16 2021, 8:26 AM.
Tags
Referenced Files
F103041152: D33496.id100123.diff
Wed, Nov 20, 4:14 AM
F103040933: D33496.id100196.diff
Wed, Nov 20, 4:10 AM
F103040712: D33496.id100882.diff
Wed, Nov 20, 4:06 AM
Unknown Object (File)
Sat, Nov 2, 9:54 PM
Unknown Object (File)
Wed, Oct 30, 8:15 PM
Unknown Object (File)
Tue, Oct 22, 12:46 AM
Unknown Object (File)
Oct 3 2024, 10:06 AM
Unknown Object (File)
Oct 3 2024, 8:41 AM

Details

Summary

Qemu's FwCfg uses the same ports as Bhyve's FwCtl. Static allocated
ports wouldn't allow to switch between Qemu's FwCfg and Bhyve's
FwCtl.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Sorry if I missed it, but is there another diff to add alternate handlers for these I/O ports?

usr.sbin/bhyve/bhyverun.c
1541 ↗(On Diff #100123)

Should be errx() instead of perror(), fwctl_init() doesn't set errno.

usr.sbin/bhyve/fwctl.c
555

Can we reasonably assert error == 0, instead of forcing the caller to handle it?

This revision is now accepted and ready to land.Dec 16 2021, 4:17 PM

Sorry if I missed it, but is there another diff to add alternate handlers for these I/O ports?

Sry, I should have linked it. Qemu's FwCfg uses the same I/O ports. I already created a patch to add support for Qemu's FwCfg D31578.

usr.sbin/bhyve/fwctl.c
555

I don't like assert because it could be removed in release builds. If it's removed, fwctl_init will silently fail and users may wonder why it doesn't work.
If you prefer an assert, I'll add it.

In D33496#757273, @c.koehne_beckhoff.com wrote:

Sorry if I missed it, but is there another diff to add alternate handlers for these I/O ports?

Sry, I should have linked it. Qemu's FwCfg uses the same I/O ports. I already created a patch to add support for Qemu's FwCfg D31578.

Thanks.

usr.sbin/bhyve/fwctl.c
555

For better or worse, bhyve(8) already uses assert() all over the place to catch invalid states and fail closed. assert() is enabled even in release builds of FreeBSD (one has to set WITHOUT_ASSERT_DEBUG= in src.conf to turn them off).

I suspect we should switch to some mechanism internal to bhyve that ensures that assertions are never compiled out. It's much better to have bhyve die than to run in an undefined state, in my opinion.

So, I somewhat prefer an assert here just because I think the error should only occur due to a code bug, and because most other register_inout() callers handle it that way, but I don't insist.

corvink marked 3 inline comments as done.
  • use asserts for checking the return code of register_inout
This revision now requires review to proceed.Dec 17 2021, 7:50 AM
usr.sbin/bhyve/fwctl.c
555

Yeah, I know that asserts are used at many places and they aren't removed on release build. Therefore, I'm fine with using an assert.

I totally agree with you that bhyve should die in invalid states. However, asserts could potentially be removed. So, they aren't a safe way to kill bhyve. Adding more of them will make it harder to remove them :) But that might be out of the scope of this review.

This revision was not accepted when it landed; it landed in state Needs Review.Jan 3 2022, 4:03 PM
Closed by commit rG9fe79f2f2b22: bhyve: dynamically register FwCtl ports (authored by corvink, committed by manu). · Explain Why
This revision was automatically updated to reflect the committed changes.