Page MenuHomeFreeBSD

bhyve: Advance RIP after userspace instruction decode
ClosedPublic

Authored by adam_fenn.io on Nov 16 2020, 7:33 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 26 2024, 1:21 PM
Unknown Object (File)
Oct 8 2024, 7:18 PM
Unknown Object (File)
Oct 3 2024, 9:52 PM
Unknown Object (File)
Oct 1 2024, 4:11 PM
Unknown Object (File)
Sep 27 2024, 7:42 AM
Unknown Object (File)
Sep 27 2024, 2:09 AM
Unknown Object (File)
Sep 18 2024, 4:18 AM
Unknown Object (File)
Sep 5 2024, 12:24 PM

Details

Summary

Add update to RIP after a userspace instruction decode (as is done for
the in-kernel counterpart of this case).

Test Plan

Found while making use of this facility to prototype some instruction
emulations in userspace. Without this patch, the guest would hang,
endlessly repeating the userspace-prototyped instruction. With this
patch, the guest would continue executing past the userspace-prototyped
instruction as expected.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

adam_fenn.io held this revision as a draft.
markj added a subscriber: markj.
markj added inline comments.
usr.sbin/bhyve/bhyverun.c
771 ↗(On Diff #79623)

Indentation should also be by 4 spaces on this line. It might be a bit clearer if the two conditions were split into separate if-statements.

This revision is now accepted and ready to land.Nov 17 2020, 4:36 PM

Some notes I sent Adam earlier, might be useful for someone in the future:

I think the key is sys/amd64/vmm/vmm.c vm_run(9), where
we set vcpu->nextrip to rip + inst_length on vm exit. Inst_length
will be zero if decoding failed in the kernel. Additionally,
libvmmapi vm_run(3) zeros out the entire passed-in vm_exit context, so
we can't just update vmexit->rip in userspace and expect it to be
passed in during the next vm_run(3) — we need the vm_set_register()
ioctl you've used.

Incorporate review feedback from @markj.

This revision now requires review to proceed.Nov 18 2020, 6:33 PM

Thanks for the review, @markj and @cem! Diff updated with @markj's requested changes.

This revision is now accepted and ready to land.Nov 18 2020, 6:57 PM
This revision was automatically updated to reflect the committed changes.