Bug #13338
closedbhyve should be able to emulate CLTS
100%
Description
When shadowing %cr0
, it becomes necessary to do instruction emulation for certain %cr0
accesses. SVM has decoding assists for mov-to-cr and mov-from-cr, but CLTS is not covered by it. Unlike SMSW and LMSW, which do not appear to see much modern use, CLTS is often used for FPU-related handling in modern OSes. In order for Bug #13256: bhyve should shadow %cr0 on AMD to be feasible, the instruction emulation in bhyve must be capable of handling CLTS.
Related issues
Updated by Patrick Mooney over 1 year ago
- Related to Bug #13256: bhyve should shadow %cr0 on AMD added
Updated by Patrick Mooney over 1 year ago
Finding a good test case for this can be a bit of a challenge. With well-behaving bootroms and guests, the bits in cr0
which require shadowing (and therefore CLTS emulation) are disabled well before any CLTS activity is going on. One way around this is to simply set one of those shadowed bits (in my case, CR0_CD
) manually with bhyvectl. The guest OS is typically none the wiser, but it forces the vmm to handle CLTS
emulation, since cr0
reads and writes are now intercepted to maintain the fiction of CR0_CD
being set. I checked this on an AMD machine (and an omnios guest) to verify that's the case:
12 64611 vie_emulate_clts:entry 12 65022 svm_set_cr0:entry rip:fffffffffb87dda6 old:c005003b new:c0050033
We can see the CLTS
emulation triggered, and clearing CR0_TS
as expected.
Updated by Electric Monk over 1 year ago
- Status changed from In Progress to Closed
- % Done changed from 0 to 100
git commit 7db0d1931e7f4e135600dcbe0f4c5b10c732181e
commit 7db0d1931e7f4e135600dcbe0f4c5b10c732181e Author: Patrick Mooney <pmooney@pfmooney.com> Date: 2021-03-04T21:54:38.000Z 13256 bhyve should shadow %cr0 on AMD 13338 bhyve should be able to emulate CLTS Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Joshua M. Clulow <josh@sysmgr.org> Reviewed by: Andy Fiddaman <andy@omniosce.org> Approved by: Richard Lowe <richlowe@richlowe.net>