Revision tags: v6.2.1, v6.2.0, v6.3.0, v6.0.1 |
|
#
b7ad3369 |
| 28-Jul-2021 |
Aaron LI <aly@aaronly.me> |
Revert "WIP"
This reverts commit 5d4c71cc3f59393bac29819031ed5afcedda6359.
Oops, didn't intend to commit this...
|
#
5d4c71cc |
| 28-Jul-2021 |
Aaron LI <aly@aaronly.me> |
WIP
|
#
5d89fb89 |
| 28-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Adjust comments about TSC sync and gd_reqflags check
Replace QEMU with a more generic "emulator", and adjust the comments about TSC sync to be more consistent and concise.
|
#
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 ...
|
#
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 ...
|
#
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 ...
|
#
1467e875 |
| 11-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Various minor style tweaks
|
#
f6c01852 |
| 09-Jul-2021 |
Aaron LI <aly@aaronly.me> |
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 in
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
show more ...
|
#
dd353e30 |
| 06-Jul-2021 |
Matthew Dillon <dillon@apollo.backplane.com> |
nvmm - Fix event commit logic
* Because DragonFly needs to do some tests after hard interrupt disablement, possibly aborting a VM entry before the VM is actually run. Certain assumptions made b
nvmm - Fix event commit logic
* Because DragonFly needs to do some tests after hard interrupt disablement, possibly aborting a VM entry before the VM is actually run. Certain assumptions made by QEMU related to event injection might not hold. Two situations can cause events to be lost.
(1) QEMU overwrites its own event after assuming the event would be injected when it might not be.
(2) Or nvmm overwrites an event for the same reason.
* To fix this we avoid trying to inject the event unless we are absolutely sure that we will issue the VM entry instruction, and we force the system call (the ioctl() actually) to restart with ERESTART to ensure that QEMU doesn't see the ioctl() return until the event is actually injected.
* The tests DragonFly needs to do relate to ASTs and SWIs that might be queued via an IPI prior to VM entry. We absolutely do not want to run the VM if any such flags are pending as it might cause other unrelated interactive processes to stall out for too long a period of time, or allow a signal delivery to the QEMU process to race the VM entry.
show more ...
|
#
42862644 |
| 04-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: More OS independence
* Abstract out various OS-specific defines and functions and organize them in 'nvmm_os.h' and 'nvmm_os.c'. This provides more flexibility for us to port NVMM to Drago
nvmm: More OS independence
* Abstract out various OS-specific defines and functions and organize them in 'nvmm_os.h' and 'nvmm_os.c'. This provides more flexibility for us to port NVMM to DragonFly and other OSes. * Remove 'nvmm_compat.h' and merge the code into the above new files.
Some local changes specific to DragonFly are not abstracted out, and there also exists some NetBSD-specific code. The current version only builds and works on DragonFly.
The OS-dependent code in nvmm_os.* and nvmm_x86.h is a bit messy at the moment. I'll further clean them up later.
show more ...
|
#
bfc69df0 |
| 04-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Various misc cleanups and minor updates
* Rework header inclusions. * Improve the arguments given to uvmspace_alloc(). * Lowercase "NVMM" in printf() logs. * Reorganize a few macros in 'nvmm_x
nvmm: Various misc cleanups and minor updates
* Rework header inclusions. * Improve the arguments given to uvmspace_alloc(). * Lowercase "NVMM" in printf() logs. * Reorganize a few macros in 'nvmm_x86.h' for clarity. * Remove NetBSD VCS markers and update copyright.
show more ...
|
#
412bdc0a |
| 03-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Rename a few things for clarity
|
#
23b2397d |
| 03-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Make FPU state more OS-indenpendent
* Introduce an OS-indenpendent 'nvmm_x64_state_fpu' structure, derived from NetBSD's current FPU implementation. * Also introduce the 'nvmm_x86_xsave' str
nvmm: Make FPU state more OS-indenpendent
* Introduce an OS-indenpendent 'nvmm_x64_state_fpu' structure, derived from NetBSD's current FPU implementation. * Also introduce the 'nvmm_x86_xsave' structure, containing the FPU area and the XSAVE header. * Add the 'nvmm_x86_xsave_size()' that determines the XSAVE area size to simplify the code. * Rename gfpu -> gxsave, for clarity. * Define 'CTASSERT' because 'nvmm.h' and 'nvmm_x86.h' headers will be used by libnvmm(3), but <sys/cdefs.h> only defines 'CTASSERT' for kernel. * Update libnvmm.3 man page accordingly.
show more ...
|
#
88638fc0 |
| 03-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Make svm_vmrun() void
|
#
e157fec4 |
| 03-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Add SVM CET definitions
Not actually used. For completeness.
|
#
c1d369d5 |
| 03-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Redefine CPUID values to be OS-indenpendent
Redefine all CPUID values locally to be OS-indenpendent.
Remove those compat CPUID defines from nvmm_compat.h, no longer needed.
|
#
f8790d01 |
| 03-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Improve CPUID emulation #5: handle Fn0000_0001:EBX[23:16]
Handle CPUID Fn0000_0001:EBX[23:16] to report the logical CPU count.
|
#
a6f61d61 |
| 03-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Improve CPUID emulation #3: handle Fn8000_0008:ECX on AMD
Properly handle Fn8000_0008:ECX on AMD CPUs to report correct CPU count info. Similar to Fn0000_000B:ECX on Intel CPUs.
|
#
1cc8c8a2 |
| 03-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Improve CPUID emulation #2: mask upper bits of guest EAX/ECX
Use uint32_t instead of uint64_t for guest EAX/ECX and mask the upper bits, to prevent wrong results if the upper bits happen to co
nvmm: Improve CPUID emulation #2: mask upper bits of guest EAX/ECX
Use uint32_t instead of uint64_t for guest EAX/ECX and mask the upper bits, to prevent wrong results if the upper bits happen to contain garbage. Not encountered in the wild so far, but could happen.
show more ...
|
#
a5120bfa |
| 03-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Clarify state handling
* Make a clear distinction between global host state and per-cpu host state. The former gets saved in a global structure, while the latter stays in the per-cpu stru
nvmm: Clarify state handling
* Make a clear distinction between global host state and per-cpu host state. The former gets saved in a global structure, while the latter stays in the per-cpu structure.
* Make the host XCR0 part of the global host state, and stop using rdxcr() in each world switch because it's unnecessary.
show more ...
|
#
3402e065 |
| 03-Jul-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Add #CP (control protection exception)
|
#
e809d733 |
| 29-Jun-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Improve FPU support and reduce diff against NetBSD
I was using 'struct savexmm64' to translate NetBSD's 'struct xsave_header'. This works but isn't good enough, because 'savexmm64' can't deal
nvmm: Improve FPU support and reduce diff against NetBSD
I was using 'struct savexmm64' to translate NetBSD's 'struct xsave_header'. This works but isn't good enough, because 'savexmm64' can't deal with xstate, so I disabled the xstate header related code in the old code.
This commit changes to use 'struct saveymm64' instead. It contains the XSAVE header and YMM xstate component, allowing us to enable the originally disabled xstate header code in NVMM.
In addition, define some compat macros to adapt NetBSD's FPU structures to ours, reducing the NVMM code difference against NetBSD.
Will later work on AVX support in guest VM.
show more ...
|
#
c9096cab |
| 24-Jun-2021 |
Matthew Dillon <dillon@apollo.backplane.com> |
nvmm - Fix TSC synchronization issues
* Save the guest TSC offset in cpudata as 'gtsc_offset', replacing the origin absolute TSC value stored as 'gtsc'.
* QEMU and other emulators probably have n
nvmm - Fix TSC synchronization issues
* Save the guest TSC offset in cpudata as 'gtsc_offset', replacing the origin absolute TSC value stored as 'gtsc'.
* QEMU and other emulators probably have no intention of actually forcing the TSC state in the SETSTATE call, so don't act on it if it matches the value we previously returned.
This allows the guest to inherit a completely synchronized TSC from the host. Without it, the TSC's for the VCPUs wind up being badly out of sync.
* Updating MSR_TSC completely blows up TSC mp synchronization. We assume QEMU did not intend to update the TSC if it tries to write 0 or tries to write the value returned in the previous getstate.
* This allows kernels to use the TSC as a clock, which costs nothing, verses the ACPI or HPET which have horrible overhead and a global mutex in QEMU.
show more ...
|
#
9bbbdb7e |
| 27-Jun-2021 |
Aaron LI <aly@aaronly.me> |
nvmm: Revamp host TLB flush mechanism
* Leverage the pmap layer to track guest pmap generation id and the host CPUs that the guest pmap is active on. This avoids the inefficient _tlb_flush() ca
nvmm: Revamp host TLB flush mechanism
* Leverage the pmap layer to track guest pmap generation id and the host CPUs that the guest pmap is active on. This avoids the inefficient _tlb_flush() callbacks from NVMM that invalidate all TLB entries.
* Currently just add all CPUs to the backing pmap for guest physical memory as they are encountered. Do not yet try to remove any CPUs, because multiple vCPUs may wind up (temporarily) scheduled to the same physical CPU. So more sophisticated tracking is needed.
* Fix a bug in SVM's host TLB flush handling where breaking out of the loop and returning, then re-entering the loop on the same cpu, could improperly clear the machine flush request.
Credit to Matt Dillon.
show more ...
|
#
3042e1c3 |
| 29-Jun-2021 |
Matthew Dillon <dillon@apollo.backplane.com> |
nnvm - Move *_fpu_enter/leave inside the cli/sti
* Move the host-to-guest and guest-to-host FP code inside the hard interrupt disablement. The main reason this needs to be done is that DragonFl
nnvm - Move *_fpu_enter/leave inside the cli/sti
* Move the host-to-guest and guest-to-host FP code inside the hard interrupt disablement. The main reason this needs to be done is that DragonFly's normal interrupt mechanism is allowed to use the FP unit (using npxpush/npxpop).
In addition, interrupts will allow the 'interrupt thread' to preempt the current kernel thread outside of a critical section. And inside a critical section the interrupt still fires, but just sets a flag.
* I don't want the host kernel dealing with guest FP state at all, under any circumstances.
show more ...
|