Bug #13338

bhyve should be able to emulate CLTS

Added by Patrick Mooney 5 months ago. Updated about 1 month ago.

Start date:
Due date:
% Done:


Estimated time:
Gerrit CR:


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

Related to illumos gate - Bug #13256: bhyve should shadow %cr0 on AMDClosedPatrick Mooney


Updated by Patrick Mooney 5 months ago

  • Related to Bug #13256: bhyve should shadow %cr0 on AMD added

Updated by Electric Monk 5 months ago

  • Gerrit CR set to 1018

Updated by Patrick Mooney about 1 month 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 about 1 month ago

  • Status changed from In Progress to Closed
  • % Done changed from 0 to 100

git commit 7db0d1931e7f4e135600dcbe0f4c5b10c732181e

commit  7db0d1931e7f4e135600dcbe0f4c5b10c732181e
Author: Patrick Mooney <>
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 <>
    Reviewed by: Joshua M. Clulow <>
    Reviewed by: Andy Fiddaman <>
    Approved by: Richard Lowe <>

Also available in: Atom PDF