Page MenuHomeFreeBSD

bhyve: Do not panic on invalid input in HDA emulation
AcceptedPublic

Authored by christos on Fri, Aug 21, 3:02 PM.
Tags
None
Referenced Files
F167511661: D59082.id184653.diff
Sat, Aug 22, 9:37 AM
F167511401: D59082.diff
Sat, Aug 22, 9:36 AM
F167440765: D59082.diff
Fri, Aug 21, 6:44 PM
F167440759: D59082.diff
Fri, Aug 21, 6:44 PM
F167440751: D59082.diff
Fri, Aug 21, 6:44 PM
F167428051: D59082.diff
Fri, Aug 21, 4:22 PM
F167427038: D59082.id184653.diff
Fri, Aug 21, 4:17 PM

Details

Reviewers
markj
emaste
jhb
bnovkov
Group Reviewers
bhyve
Summary

The emulated HDA controller passed values taken from guest registers and
from guest memory straight into assert(), so a guest could abort bhyve
with values the emulation did not expect. Reject them instead.

In case the guest asked to start something and it failed, clear the
corresponding run/enable bit.

PR: 256379, 256381, 256382, 256383, 256384, 256385, 256386, 256498
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 75946
Build 72829: arc lint + arc unit

Event Timeline

bnovkov added inline comments.
usr.sbin/bhyve/pci_hda.c
812–813

Is it safe to continue executing after this fails?

813
966

There's a bunch of other typos like this.

usr.sbin/bhyve/pci_hda.c
812–813

Is it safe to continue executing after this fails?

Yes. This code path is called before any work is being done, and verb failures are not necessarily fatal errors. In snd_hda(4), hdac_send_command() does something similar for instance.

966

I know. I kept the same mistake for uniformity than cluttering the commit with these fixes.

Thanks for fixing these.

usr.sbin/bhyve/pci_hda.c
646

Maybe fix this to be ((bdle_sz % HDA_DMA_ACCESS_LEN) != 0)? Or alternatively if it isn't too tortured use __is_aligned() from <sys/cdefs.h> (that might be more readable)

This revision is now accepted and ready to land.Fri, Aug 21, 4:19 PM
bnovkov added inline comments.
usr.sbin/bhyve/pci_hda.c
966

got it, thanks.