| 11755db6 | 21-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Fix building nvmm into kernel
* Remove 'DIAGNOSTIC' define from 'nvmm_os.h'. First, 'DIAGNOSTIC' and 'INVARIANTS' are different options. Secondly, 'DIAGNOSTIC' should be defined in kerne
nvmm: Fix building nvmm into kernel
* Remove 'DIAGNOSTIC' define from 'nvmm_os.h'. First, 'DIAGNOSTIC' and 'INVARIANTS' are different options. Secondly, 'DIAGNOSTIC' should be defined in kernel configs, e.g., LINT64 defines it. * Remove 'LOCORE' define from 'nvmm_x86_{svmfunc,vmxfunc}.S'. It's already defined on the command line, when compiling ASM source files with the kernel (i.e., building the module into the kernel). * Manually define 'LOCORE' for 'nvmm_x86_{svmfunc,vmxfunc}.o' compilation in the Makefile, fixing building as a standalone module.
This fixes building nvmm into kernel, like LINT64.
Thanks swildner for reporting the issue and helping with the fix.
show more ...
|
| cca384e4 | 20-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Fix comm page unmapping issue by doing it on userland side
Previously, we're mapping and unmapping the comm page for userland process both on the kernel side. The unmapping was called at the
nvmm: Fix comm page unmapping issue by doing it on userland side
Previously, we're mapping and unmapping the comm page for userland process both on the kernel side. The unmapping was called at the point of closing the fd.
However, the kernel may destroy process' vmspace before or after closing the fd, so there is no guarantee that kernel can get the correct address space to unmap the comm page for the userland process. Therefore, do the comm page unmapping on the userland side in libnvmm to fix the above issue.
In addition, add the 'comm_size' member to 'struct nvmm_capability' to expose the comm page size to userland, which is required for the unmapping operation. This breaks ABI, so bump NVMM_KERN_VERSION. Update nvmmctl(8) accordingly to print the comm page size.
This commit partially reverts: "nvmm: Add missing comm page unmapping"
show more ...
|
| 8a0a54bf | 18-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Add back NetBSD bits
Bring back the NetBSD bits lost during the porting. One minor change is required: MODULE_CLASS_MISC -> MODULE_CLASS_DRIVER. Otherwise, loading nvmm.kmod would fail with
nvmm: Add back NetBSD bits
Bring back the NetBSD bits lost during the porting. One minor change is required: MODULE_CLASS_MISC -> MODULE_CLASS_DRIVER. Otherwise, loading nvmm.kmod would fail with error:
module error: incompatible module class 1 for `nvmm' (wanted 3)
Now the same code builds and works on NetBSD (of course, NetBSD requires a different set of Makefiles).
show more ...
|
| 002185e5 | 18-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Move DragonFly module code in nvmm.c to nvmm_dragonfly.c
Move the OS-specific DragonFly module code in nvmm.c to nvmm_dragonfly.c, making nvmm.c source file more OS-independent. Adjust severa
nvmm: Move DragonFly module code in nvmm.c to nvmm_dragonfly.c
Move the OS-specific DragonFly module code in nvmm.c to nvmm_dragonfly.c, making nvmm.c source file more OS-independent. Adjust several static functions and variables for this purpose.
show more ...
|
| df3af4c9 | 18-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Reorganize OS-specific code in nvmm_os.c
Split the OS-specific code in 'nvmm_os.c' into two separate source files: nvmm_dragonfly.c and nvmm_netbsd.c, one for each supported OS.
Update Makefi
nvmm: Reorganize OS-specific code in nvmm_os.c
Split the OS-specific code in 'nvmm_os.c' into two separate source files: nvmm_dragonfly.c and nvmm_netbsd.c, one for each supported OS.
Update Makefile and sys/conf/files accordingly.
show more ...
|
| b3f7271c | 18-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Optimize DB regs save & restore
Check PCB_DBREGS flag before save/restore DB regs. If the current thread doesn't use DB regs, then no need to save & restore them.
Meanwhile, revert to use x8
nvmm: Optimize DB regs save & restore
Check PCB_DBREGS flag before save/restore DB regs. If the current thread doesn't use DB regs, then no need to save & restore them.
Meanwhile, revert to use x86_dbregs_save() and x86_dbregs_restore() for the NetBSD code.
This is a partial revert of commit: "nvmm: Save host DB regs in per-cpu structure"
show more ...
|
| 665a79c8 | 15-Jul-2021 |
Matthew Dillon <dillon@apollo.backplane.com> |
nvmm - Use a critical section around the vmrun again
* In DragonFly, a thread in kernel mode will not be preemptively migrated to another CPU or preemptively switched to another normal kernel thre
nvmm - Use a critical section around the vmrun again
* In DragonFly, a thread in kernel mode will not be preemptively migrated to another CPU or preemptively switched to another normal kernel thread, but can be preemptively switched to an interrupt thread (which switches back to the kernel thread it preempted the instant it is done or blocks).
However, we still need to use a critical section to prevent this nominal interrupt thread preemption to avoid exposing interrupt threads to guest DB and FP register state. We operate under the assumption that the hard interrupt code won't mess with this state.
show more ...
|
| d8a75061 | 12-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Don't assume comm page size to be PAGE_SIZE
Don't assume the comm page size to be PAGE_SIZE but add the 'NVMM_COMM_PAGE_SIZE' macro to determine the size. So the code is now independent to co
nvmm: Don't assume comm page size to be PAGE_SIZE
Don't assume the comm page size to be PAGE_SIZE but add the 'NVMM_COMM_PAGE_SIZE' macro to determine the size. So the code is now independent to comm page size and thus it can be easily extended in the future.
show more ...
|
| 1759ebc3 | 12-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Add missing comm page unmapping
The comm page mapping has been changed from libnvmm to the kernel side, so I removed the munmap() code from libnvmm, but the kernel wasn't doing the unmapping.
nvmm: Add missing comm page unmapping
The comm page mapping has been changed from libnvmm to the kernel side, so I removed the munmap() code from libnvmm, but the kernel wasn't doing the unmapping. Now add the missing unmapping operation.
show more ...
|
| 3f1b1a2b | 11-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Adjust EPT/NPT transform code for NetBSD
* Rename variable 'pmap_ept_has_ad' to 'vmx_ept_has_ad' to avoid conflict with the global variable in NetBSD. * Set 'pmap_ept_has_ad' global for NetB
nvmm: Adjust EPT/NPT transform code for NetBSD
* Rename variable 'pmap_ept_has_ad' to 'vmx_ept_has_ad' to avoid conflict with the global variable in NetBSD. * Set 'pmap_ept_has_ad' global for NetBSD in vmx_ident(). * Add macro os_vmspace_pmap() to 'nvmm_os.h'. * Add ifdef's in vmx_machine_create() and svm_machine_create() to properly handle EPT/NPT pmap transform on both DragonFly and NetBSD.
show more ...
|
| 7f29793e | 11-Jul-2021 |
Aaron LI <aly@aaronly.me> |
x86_64/cpu.h: Rename nvmm_break_wanted() to hvm_break_wanted()
To avoid confusion with the NVMM code. In addition, this macro checks against RQF_HVM_MASK, so naming it hvm_break_wanted() seems more
x86_64/cpu.h: Rename nvmm_break_wanted() to hvm_break_wanted()
To avoid confusion with the NVMM code. In addition, this macro checks against RQF_HVM_MASK, so naming it hvm_break_wanted() seems more appropriate.
show more ...
|
| ac42d1df | 11-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Revert to use os_curcpu() in vmx_vmcs_enter()
os_curcpu() returns a pointer to the current per-cpu data, which is used in vmx_vmcs_enter() to clear a VMCS from a remote CPU. So it's more effi
nvmm: Revert to use os_curcpu() in vmx_vmcs_enter()
os_curcpu() returns a pointer to the current per-cpu data, which is used in vmx_vmcs_enter() to clear a VMCS from a remote CPU. So it's more efficient and clean than using the os_curcpu_number(), which requires another lookup to obtain the per-cpu data pointer from the CPU id.
This effectively reverts the commit: nvmm: Fix issues of porting 'curcpu()' as 'mycpu'
The "VMX fail valid" panics I had then were actually caused by the missing wait for the asynchronous IPI request to clear VMCS from a remote CPU, which had been fixed in a later commit.
show more ...
|
| 5d445d4c | 11-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Implement os_ipi_broadcast() for _change_cpu()
os_ipi_broadcast() is used in {svm,vmx}_init() and {svm,vmx}_fini() to enable/disable SVM/VMX on all CPUs. The previous implementation used an i
nvmm: Implement os_ipi_broadcast() for _change_cpu()
os_ipi_broadcast() is used in {svm,vmx}_init() and {svm,vmx}_fini() to enable/disable SVM/VMX on all CPUs. The previous implementation used an interlock and made significant changes to the code. Reimplement it in another way (loop on each CPU and execute the task), so it can be easily enclosed in the os_ipi_broadcast() function.
The new implementation referred to our pc64/vmm/vmx.c code.
show more ...
|