Page MenuHomeFreeBSD

bhyve: allow reading of fwctl signature multiple times
ClosedPublic

Authored by corvink on Sep 16 2021, 6:49 AM.
Tags
Referenced Files
Unknown Object (File)
Tue, Dec 10, 11:21 AM
Unknown Object (File)
Nov 23 2024, 5:48 PM
Unknown Object (File)
Oct 22 2024, 5:46 PM
Unknown Object (File)
Oct 20 2024, 7:36 AM
Unknown Object (File)
Oct 19 2024, 7:05 AM
Unknown Object (File)
Oct 19 2024, 1:01 AM
Unknown Object (File)
Oct 5 2024, 8:48 PM
Unknown Object (File)
Oct 5 2024, 3:56 PM
Subscribers

Details

Summary

At the moment, you only have one single chance to read the fwctl
signature. At boot bhyve is in the state IDENT_WAIT. It's then
possible to switch to IDENT_SEND. After bhyve sends the signature,
it switches to REQ. From now on it's impossible to switch back to
IDENT_SEND to read the signature. For that reason, only a single
driver can read the signature. A guest can't use two drivers to
identify that fwctl is present. It gets even worse when using
OVMF. OVMF uses a library to access fwctl. Therefore, every single
OVMF driver would try to read the signature. Currently, only a
single OVMF driver accesses the fwctl. So, there's no issue with
it yet. However, no OS driver would have a chance to detect fwctl when
using OVMF because it's signature was already consumed by OVMF.

Signed-off-by: Corvin Köhne <c.koehne@beckhoff.com>

Note: You can have a look at https://github.com/Beckhoff/freebsd-src/commits/phab/corvink/fwctl-signature

Diff Detail

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

Event Timeline

corvink added reviewers: manu, markj.

Is it sufficient to instead set be_state = IDENT_WAIT in fwctl_inl(), or handle be_state == REQ the same as be_state == IDENT_WAIT in fwctl_outw()?

usr.sbin/bhyve/fwctl.c
475–486

Presumably we should still ignore the write if be_state == DORMANT, or perhaps assert that that's not the case.

Is it sufficient to instead set be_state = IDENT_WAIT in fwctl_inl(), or handle be_state == REQ the same as be_state == IDENT_WAIT in fwctl_outw()?

When the guest checks the signature, the current state of fwctl is unknown. Additionally, bhyve's fwctl uses the same ports as qemu's fwcfg. When the guest checks the presence of qemu's fwcfg, he could misconfigure bhyve's fwctl. We should be able to recover from this situation. For that reason, I'd prefer to unconditionally switch to IDENT_SEND on outw.

markj added inline comments.
usr.sbin/bhyve/fwctl.c
479

I think some comment along the lines of, "resets the state machine," would be helpful.

This revision is now accepted and ready to land.Nov 29 2021, 4:36 PM
This revision now requires review to proceed.Nov 30 2021, 7:13 AM
This revision was not accepted when it landed; it landed in state Needs Review.Jan 3 2022, 4:02 PM
This revision was automatically updated to reflect the committed changes.