nvmm: Fix SVM TSS restore on DragonFly
authorAaron LI <aly@aaronly.me>
Mon, 14 Jun 2021 23:26:03 +0000 (07:26 +0800)
committerAaron LI <aly@aaronly.me>
Tue, 15 Jun 2021 23:22:08 +0000 (07:22 +0800)
commit1f133f0e84bca51fff1ada80a28716d8f4f89bcb
tree277227f297e5f0eb8b1d92fe6ac09f6804c00efb
parent7a66556bd391f15985bf58e5bc34382383de5e13
nvmm: Fix SVM TSS restore on DragonFly

In DragonFly, PCPU(tss_gdt) points directly to the gdt[] entry for the
current CPU's TSS descriptor; while NetBSD's CPUVAR(GDT) points to the
gdtstore[] table.  Fix that 'and' instruction so it works on DragonFly.
(Credit to Matt Dillon for debugging and fixing this.)

The 'and' instruction clears the busy bit (bit 41) so the TSS descriptor
becomes "available" for the reloading, as required by 'ltr' instruction.
(The TSS descriptor was in use prior to launching the guest so it has
been marked busy.)

Credit:
* Illumos: Bug #13029: AMD bhyve should reload TSS ASAP
  https://www.illumos.org/issues/13029
* Illumos: 13029 AMD bhyve should reload TSS ASAP
  https://github.com/illumos/illumos-gate/commit/4d3fdeb14779bb6b0838521971d9ac99d65b0572
sys/dev/virtual/nvmm/x86/nvmm_x86_svmfunc.S