nvmm: Save host DB regs in per-cpu structure
authorAaron LI <aly@aaronly.me>
Fri, 9 Jul 2021 04:50:33 +0000 (12:50 +0800)
committerAaron LI <aly@aaronly.me>
Tue, 20 Jul 2021 23:28:26 +0000 (07:28 +0800)
commitf6c0185203d8a0e5955a47e12e0efad053b88532
tree6e4af13d507c109789b686c8c8913b441a6a883b
parentdd353e3086ebbad842607aab7b78ac7f759aa284
nvmm: Save host DB regs in per-cpu structure

* The host DB regs save/restore operations are performed outside the
  hard interrupt disablement.  If the DB regs were saved in curthread's
  PCB, an interrupt thread running just after hard interrupts are
  enabled again could overwrite the DB regs in the PCB with the guest DB
  regs.  Saving the host DB regs in the per-cpu structure avoid such
  issues.

* This change also makes the code a bit more OS-independent.

Credit-to: Matt Dillon
Referred-to: FreeBSD bhyve
sys/dev/virtual/nvmm/x86/nvmm_x86.h
sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c
sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c