2 * Copyright (c) 2018-2021 Maxime Villard, m00nbsd.net
5 * This code is part of the NVMM hypervisor.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/cdefs.h>
33 #include <sys/types.h>
39 typedef uint64_t gpaddr_t;
40 typedef uint64_t gvaddr_t;
42 typedef uint32_t nvmm_machid_t;
43 typedef uint32_t nvmm_cpuid_t;
46 #define CTASSERT(x) NVMM_CTASSERT(x, __LINE__)
47 #define NVMM_CTASSERT(x, y) NVMM__CTASSERT(x, y)
48 #define NVMM__CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1] __unused
50 #if defined(__x86_64__)
51 #if defined(__NetBSD__)
52 #include <dev/nvmm/x86/nvmm_x86.h>
53 #elif defined(__DragonFly__)
54 #include <dev/virtual/nvmm/x86/nvmm_x86.h>
56 #endif /* __x86_64__ */
58 #define NVMM_KERN_VERSION 3
60 struct nvmm_capability {
64 uint32_t max_machines;
67 struct nvmm_cap_md arch;
70 /* Machine configuration slots. */
71 #define NVMM_MACH_CONF_LIBNVMM_BEGIN 0
72 #define NVMM_MACH_CONF_MI_BEGIN 100
73 #define NVMM_MACH_CONF_MD_BEGIN 200
74 #define NVMM_MACH_CONF_MD(op) (op - NVMM_MACH_CONF_MD_BEGIN)
76 /* VCPU configuration slots. */
77 #define NVMM_VCPU_CONF_LIBNVMM_BEGIN 0
78 #define NVMM_VCPU_CONF_MI_BEGIN 100
79 #define NVMM_VCPU_CONF_MD_BEGIN 200
80 #define NVMM_VCPU_CONF_MD(op) (op - NVMM_VCPU_CONF_MD_BEGIN)
82 struct nvmm_comm_page {
84 uint64_t state_wanted;
85 uint64_t state_cached;
86 uint64_t state_commit;
87 struct nvmm_vcpu_state state;
91 struct nvmm_vcpu_event event;