History log of /src/lib/libnvmm/libnvmm.3
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base
# 1.29 26-Jul-2025 skrll

Note example code updated to use the new API.

Bump date.


Revision tags: netbsd-10-1-RELEASE perseant-exfatfs-base-20240630 perseant-exfatfs-base netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base
# 1.28 10-Dec-2021 msaitoh

branches: 1.28.4;
s/premissions/permissions/


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.27 05-Sep-2020 maxv

nvmm: update copyright headers


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406
# 1.26 09-Feb-2020 maxv

Reference nvmmctl(8).


Revision tags: phil-wifi-20191119
# 1.25 28-Oct-2019 maxv

should be fork(2), noticed by wiz


# 1.24 28-Oct-2019 wiz

Macro tidyness.


# 1.23 28-Oct-2019 maxv

A few changes:

- Use smaller types in struct nvmm_capability.
- Use smaller type for nvmm_io.port.
- Switch exitstate to a compacted structure.


# 1.22 27-Oct-2019 maxv

Add a new VCPU conf option, that allows userland to request VMEXITs after a
TPR change. This is supported on all Intel CPUs, and not-too-old AMD CPUs.

The reason for wanting this option is that certain OSes (like Win10 64bit)
manage interrupt priority in hardware via CR8 directly, and for these OSes,
the emulator may want to sync its internal TPR state on each change.

Add two new fields in cap.arch, to report the conf capabilities. Report TPR
only on Intel for now, not AMD, because I don't have a recent AMD CPU on
which to test.


# 1.21 27-Oct-2019 maxv

Add the "nvmm" group, and make nvmm_init() public. Sent to tech-kern@ a few
days ago.


# 1.20 25-Oct-2019 maxv

Update the libnvmm man page:

- Sync the naming with reality.

- Replace "relevant" by "desired" and "virtualizer" by "emulator", closer
to what I meant.

- Add a "VCPU Configuration" section.

- Add a "Machine Ownership" section.


Revision tags: netbsd-9-base phil-wifi-20190609
# 1.19 08-Jun-2019 maxv

branches: 1.19.2; 1.19.4;
Change the NVMM API to reduce data movements. Sent to tech-kern@.


# 1.18 11-May-2019 maxv

Replace "VMM" by "emulator", clearer.


# 1.17 11-May-2019 maxv

Sync with reality.


# 1.16 29-Apr-2019 maxv

sync with reality


# 1.15 29-Apr-2019 maxv

Stop taking care of the INT/NMI windows in the kernel, the emulator is
supposed to do that itself.


# 1.14 07-Apr-2019 maxv

Sync, and fix grammar.


# 1.13 04-Apr-2019 maxv

Check the GPA permissions too in the Assists, because it is possible that
the guest traps on a page the virtualizer marked as read-only (even if it
appears as read-write in the HVA).


# 1.12 21-Mar-2019 maxv

Make it possible for an emulator to set the protection of the guest pages.
For some reason I had initially concluded that it wasn't doable; verily it
is, so let's do it.

The reserved 'flags' argument of nvmm_gpa_map() becomes 'prot' and takes
mmap-like protection codes.


# 1.11 05-Feb-2019 wiz

Mark up NULL with Dv. Remove empty line.


# 1.10 05-Feb-2019 maxv

Sync with reality, and improve.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118
# 1.9 07-Jan-2019 wiz

Remove leading zero from date.


# 1.8 07-Jan-2019 maxv

Optimize: on single memory operand instructions, take the GPA directly from
the exit structure provided by the kernel. This saves an MMU translation,
and sometimes complex address computation (eg SIB).

Drop the GVA field, it is not useful to virtualizers.


# 1.7 06-Jan-2019 maxv

Improvements and fixes in NVMM.

Kernel driver:

* Don't take an extra (unneeded) reference to the UAO.

* Provide npc for HLT. I'm not really happy with it right now, will
likely be revisited.

* Add the INT_SHADOW, INT_WINDOW_EXIT and NMI_WINDOW_EXIT states. Provide
them in the exitstate too.

* Don't take the TPR into account when processing INTs. The virtualizer
can do that itself (Qemu already does).

* Provide a hypervisor signature in CPUID, and hide SVM.

* Ignore certain MSRs. One special case is MSR_NB_CFG in which we set
NB_CFG_INITAPICCPUIDLO. Allow reads of MSR_TSC.

* If the LWP has pending signals or softints, leave, rather than waiting
for a rescheduling to happen later. This reduces interrupt processing
time in the guest (Qemu sends a signal to the thread, and now we leave
right away). This could be improved even more by sending an actual IPI
to the CPU, but I'll see later.

Libnvmm:

* Fix the MMU translation of large pages, we need to add the lower bits
too.

* Change the IO and Mem structures to take a pointer rather than a
static array. This provides more flexibility.

* Batch together the str+rep IO transactions. We do one big memory
read/write, and then send the IO commands to the hypervisor all at
once. This considerably increases performance.

* Decode MOVZX.

With these changes in place, Qemu+NVMM works. I can install NetBSD 8.0
in a VM with multiple VCPUs, connect to the network, etc.


# 1.6 27-Dec-2018 maxv

Several improvements and fixes:

* Change the Assist API. Rather than passing callbacks in each call, the
callbacks are now registered beforehand. Then change the I/O Assist to
fetch MMIO data via the Mem callback. This allows a guest to perform an
I/O string operation on a memory that is itself an MMIO.

* Introduce two new functions internal to libnvmm, read_guest_memory and
write_guest_memory. They can handle mapped memory, MMIO memory and
cross-page transactions.

* Allow nvmm_gva_to_gpa and nvmm_gpa_to_hva to take non-page-aligned
addresses. This simplifies a lot of things.

* Support the MOVS instruction, and add a test for it. This instruction
is special, in that it takes two implicit memory operands. In
particular, it means that the two buffers can both be in MMIO memory,
and we handle this case.

* Fix gross copy-pasto in nvmm_hva_unmap. Also fix a few things here and
there.


Revision tags: pgoyette-compat-1226
# 1.5 15-Dec-2018 maxv

Invert the mapping logic.

Until now, the "owner" of the memory was the guest, and by calling
nvmm_gpa_map(), the virtualizer was creating a view towards the guest
memory.

Qemu expects the contrary: it wants the owner to be the virtualizer, and
nvmm_gpa_map should just create a view from the guest towards the
virtualizer's address space. Under this scheme, it is legal to have two
GPAs that point to the same HVA.

Introduce nvmm_hva_map() and nvmm_hva_unmap(), that map/unamp the HVA into
a dedicated UOBJ. Change nvmm_gpa_map() and nvmm_gpa_unmap() to just
perform an enter into the desired UOBJ.

With this change in place, all the mapping-related problems in Qemu+NVMM
are fixed.


# 1.4 12-Dec-2018 wiz

Remove superfluous dot.


# 1.3 12-Dec-2018 maxv

Change the "FILES" section, in the end I don't want to commit toyvirt
and smallkern, there is little interest installing them by default,
rather they can be downloaded from www. It's better this way.

While here add NVMM(4) in "SEE ALSO".


Revision tags: pgoyette-compat-1126
# 1.2 10-Nov-2018 maxv

branches: 1.2.2;
Add copyright and RCSID, from wiz@.


# 1.1 10-Nov-2018 maxv

Add libnvmm, NetBSD's new virtualization API. It provides a way for VMM
software to effortlessly create and manage virtual machines via NVMM.

It is mostly complete, only nvmm_assist_mem needs to be filled -- I have
a draft for that, but it needs some more care. This Mem Assist should
not be needed when emulating a system in x2apic mode, so theoretically
the current form of libnvmm is sufficient to emulate a whole class of
systems.

Generally speaking, there are so many modes in x86 that it is difficult
to handle each corner case without introducing a ton of checks that just
slow down the common-case execution. Currently we check a limited number
of things; we may add more checks in the future if they turn out to be
needed, but that's rather low priority.

Libnvmm is compiled and installed only on amd64. A man page (reviewed by
wiz@) is provided.