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)
Feb 9 2024, 6:15 PM
Unknown Object (File)
Jan 17 2024, 9:00 AM
Unknown Object (File)
Dec 20 2023, 7:33 AM
Unknown Object (File)
Dec 12 2023, 10:12 PM
Unknown Object (File)
Nov 27 2023, 1:27 AM
Unknown Object (File)
Sep 22 2023, 3:45 PM
Unknown Object (File)
Sep 2 2023, 8:04 PM
Unknown Object (File)
Sep 2 2023, 8:03 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

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 34835
Build 31865: arc lint + arc unit

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

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.