NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-amd64/59860: nvmm: support AVX2, AVX512, &c.



>Number:         59860
>Category:       port-amd64
>Synopsis:       nvmm: support AVX2, AVX512, &c.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-amd64-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 24 16:05:00 +0000 2025
>Originator:     Taylor R Campbell
>Release:        current, 11, 10, 9, ...
>Organization:
The Nvmm Vectorization
>Environment:
>Description:
Of the extended CPU state registers, nvmm only supports x87 and SSE.

It should also support AVX2, AVX512, &c., depending on host support and software configuration.

Requires extending nvmm_x86_vmx.c and nvmm_x86_svm.c with:

- extra bits in vmx_xcr0_mask / svm_xcr0_mask (possibly on a per-VM basis with nvmm_machine_configure or nvmm_vcpu_configure)
- logic to negotiate those bits in vmx_exit_xsetbv / svm_exit_xsetbv
- logic to allocate states larger than struct fxsave in struct vmx_cpudata / struct svm_cpudata
- logic in vmx_inkernel_handle_cpuid / svm_inkernel_handle_cpuid to handle CPUID[EAX=0x0d,ECX=0] (extended state sizes) and CPUID[EAX=0x0d,ECX=1] (extended state feature bits) for the extensions
- logic in vmx_vcpu_getstate / svm_vcpu_getstate to copy the whole extended state when NVMM_X64_STATE_FPU is set, which may have variable size like x86_fpu_save_size (but may be smaller if guest has negotiated fewer feature bits)

Saving and restoring should be handled by fpu_area_save/restore already.

Of course, this must all be limited by the host's supported features.  See also: https://nxr.netbsd.org/xref/src/sys/arch/x86/x86/identcpu.c?r=1.139#808

XCR0/XGETBV/XSETBV references: https://nxr.netbsd.org/xref/src/sys/arch/x86/include/specialreg.h?r=1.220#124

(AVX512 registers zmm0..15 are XCR0_ZMM_Hi256 (high 256-bit halves of the ymm0..15 registers); AVX512 registers zmm16..zmm31 are XCR0_Hi16_ZMM (high 16 registers).)
>How-To-Repeat:
try to run code with AVX2/AVX512/AVM/... in a guest under nvmm
>Fix:
Yes, please!



Home | Main Index | Thread Index | Old Index