Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F134889114
D53586.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
12 KB
Referenced Files
None
Subscribers
None
D53586.id.diff
View Options
diff --git a/sys/amd64/include/vmm.h b/sys/amd64/include/vmm.h
--- a/sys/amd64/include/vmm.h
+++ b/sys/amd64/include/vmm.h
@@ -160,17 +160,12 @@
struct vioapic;
struct vlapic;
struct vmspace;
+struct vm_eventinfo;
struct vm_object;
struct vm_guest_paging;
struct pmap;
enum snapshot_req;
-struct vm_eventinfo {
- cpuset_t *rptr; /* rendezvous cookie */
- int *sptr; /* suspend cookie */
- int *iptr; /* reqidle cookie */
-};
-
#define DECLARE_VMMOPS_FUNC(ret_type, opname, args) \
typedef ret_type (*vmmops_##opname##_t) args; \
ret_type vmmops_##opname args
@@ -233,8 +228,6 @@
extern const struct vmm_ops vmm_ops_intel;
extern const struct vmm_ops vmm_ops_amd;
-const char *vm_name(struct vm *vm);
-
int vm_map_mmio(struct vm *vm, vm_paddr_t gpa, size_t len, vm_paddr_t hpa);
int vm_unmap_mmio(struct vm *vm, vm_paddr_t gpa, size_t len);
int vm_assign_pptdev(struct vm *vm, int bus, int slot, int func);
@@ -253,9 +246,6 @@
int vm_inject_extint(struct vcpu *vcpu);
int vm_extint_pending(struct vcpu *vcpu);
void vm_extint_clear(struct vcpu *vcpu);
-int vcpu_vcpuid(struct vcpu *vcpu);
-struct vm *vcpu_vm(struct vcpu *vcpu);
-struct vcpu *vm_vcpu(struct vm *vm, int cpu);
struct vlapic *vm_lapic(struct vcpu *vcpu);
struct vioapic *vm_ioapic(struct vm *vm);
struct vhpet *vm_hpet(struct vm *vm);
@@ -280,33 +270,6 @@
void vm_await_start(struct vm *vm, const cpuset_t *waiting);
#endif /* _SYS__CPUSET_H_ */
-static __inline int
-vcpu_rendezvous_pending(struct vcpu *vcpu, struct vm_eventinfo *info)
-{
- /*
- * This check isn't done with atomic operations or under a lock because
- * there's no need to. If the vcpuid bit is set, the vcpu is part of a
- * rendezvous and the bit won't be cleared until the vcpu enters the
- * rendezvous. On rendezvous exit, the cpuset is cleared and the vcpu
- * will see an empty cpuset. So, the races are harmless.
- */
- return (CPU_ISSET(vcpu_vcpuid(vcpu), info->rptr));
-}
-
-static __inline int
-vcpu_suspended(struct vm_eventinfo *info)
-{
-
- return (*info->sptr);
-}
-
-static __inline int
-vcpu_reqidle(struct vm_eventinfo *info)
-{
-
- return (*info->iptr);
-}
-
/*
* Return true if device indicated by bus/slot/func is supposed to be a
* pci passthrough device.
@@ -317,9 +280,7 @@
void *vm_iommu_domain(struct vm *vm);
-void *vcpu_stats(struct vcpu *vcpu);
void vcpu_notify_lapic(struct vcpu *vcpu);
-struct vm_mem *vm_mem(struct vm *vm);
struct vatpic *vm_atpic(struct vm *vm);
struct vatpit *vm_atpit(struct vm *vm);
struct vpmtmr *vm_pmtmr(struct vm *vm);
diff --git a/sys/amd64/vmm/io/vhpet.c b/sys/amd64/vmm/io/vhpet.c
--- a/sys/amd64/vmm/io/vhpet.c
+++ b/sys/amd64/vmm/io/vhpet.c
@@ -44,6 +44,7 @@
#include <dev/vmm/vmm_dev.h>
#include <dev/vmm/vmm_ktr.h>
+#include <dev/vmm/vmm_vm.h>
#include "vmm_lapic.h"
#include "vatpic.h"
diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c
--- a/sys/amd64/vmm/vmm.c
+++ b/sys/amd64/vmm/vmm.c
@@ -470,12 +470,6 @@
vm_init(vm, false);
}
-const char *
-vm_name(struct vm *vm)
-{
- return (vm->name);
-}
-
int
vm_map_mmio(struct vm *vm, vm_paddr_t gpa, size_t len, vm_paddr_t hpa)
{
@@ -1621,24 +1615,6 @@
return (vmmops_setcap(vcpu->cookie, type, val));
}
-struct vm *
-vcpu_vm(struct vcpu *vcpu)
-{
- return (vcpu->vm);
-}
-
-int
-vcpu_vcpuid(struct vcpu *vcpu)
-{
- return (vcpu->vcpuid);
-}
-
-struct vcpu *
-vm_vcpu(struct vm *vm, int vcpuid)
-{
- return (vm->vcpu[vcpuid]);
-}
-
struct vlapic *
vm_lapic(struct vcpu *vcpu)
{
@@ -1732,13 +1708,6 @@
mtx_unlock(&vm->rendezvous_mtx);
}
-void *
-vcpu_stats(struct vcpu *vcpu)
-{
-
- return (vcpu->stats);
-}
-
int
vm_get_x2apic_state(struct vcpu *vcpu, enum x2apic_state *state)
{
@@ -1771,12 +1740,6 @@
vcpu_unlock(vcpu);
}
-struct vm_mem *
-vm_mem(struct vm *vm)
-{
- return (&vm->mem);
-}
-
int
vm_apicid2vcpuid(struct vm *vm, int apicid)
{
diff --git a/sys/amd64/vmm/vmm_ioport.c b/sys/amd64/vmm/vmm_ioport.c
--- a/sys/amd64/vmm/vmm_ioport.c
+++ b/sys/amd64/vmm/vmm_ioport.c
@@ -33,6 +33,7 @@
#include <machine/vmm_instruction_emul.h>
#include <dev/vmm/vmm_ktr.h>
+#include <dev/vmm/vmm_vm.h>
#include "vatpic.h"
#include "vatpit.h"
diff --git a/sys/arm64/include/vmm.h b/sys/arm64/include/vmm.h
--- a/sys/arm64/include/vmm.h
+++ b/sys/arm64/include/vmm.h
@@ -135,16 +135,11 @@
};
#define VM_MAX_SPECIAL_REGS 16
-struct vm_eventinfo {
- void *rptr; /* rendezvous cookie */
- int *sptr; /* suspend cookie */
- int *iptr; /* reqidle cookie */
-};
-
#define DECLARE_VMMOPS_FUNC(ret_type, opname, args) \
ret_type vmmops_##opname args
struct vm;
+struct vm_eventinfo;
struct vm_exception;
struct vm_exit;
struct vm_run;
@@ -181,16 +176,11 @@
#endif
#endif
-const char *vm_name(struct vm *vm);
-
int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval);
int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val);
int vm_run(struct vcpu *vcpu);
void* vm_get_cookie(struct vm *vm);
-int vcpu_vcpuid(struct vcpu *vcpu);
void *vcpu_get_cookie(struct vcpu *vcpu);
-struct vm *vcpu_vm(struct vcpu *vcpu);
-struct vcpu *vm_vcpu(struct vm *vm, int cpu);
int vm_get_capability(struct vcpu *vcpu, int type, int *val);
int vm_set_capability(struct vcpu *vcpu, int type, int val);
int vm_inject_exception(struct vcpu *vcpu, uint64_t esr, uint64_t far);
@@ -204,23 +194,6 @@
void vm_exit_debug(struct vcpu *vcpu, uint64_t pc);
void vm_exit_astpending(struct vcpu *vcpu, uint64_t pc);
-static __inline int
-vcpu_rendezvous_pending(struct vm_eventinfo *info)
-{
-
- return (*((uintptr_t *)(info->rptr)) != 0);
-}
-
-static __inline int
-vcpu_suspended(struct vm_eventinfo *info)
-{
-
- return (*info->sptr);
-}
-
-void *vcpu_stats(struct vcpu *vcpu);
-struct vm_mem *vm_mem(struct vm *vm);
-
struct vm_copyinfo {
uint64_t gpa;
size_t len;
diff --git a/sys/arm64/vmm/io/vtimer.c b/sys/arm64/vmm/io/vtimer.c
--- a/sys/arm64/vmm/io/vtimer.c
+++ b/sys/arm64/vmm/io/vtimer.c
@@ -47,6 +47,8 @@
#include <arm64/vmm/arm64.h>
+#include <dev/vmm/vmm_vm.h>
+
#include "vgic.h"
#include "vtimer.h"
diff --git a/sys/arm64/vmm/vmm.c b/sys/arm64/vmm/vmm.c
--- a/sys/arm64/vmm/vmm.c
+++ b/sys/arm64/vmm/vmm.c
@@ -399,12 +399,6 @@
vm_init(vm, false);
}
-const char *
-vm_name(struct vm *vm)
-{
- return (vm->name);
-}
-
int
vm_gla2gpa_nofault(struct vcpu *vcpu, struct vm_guest_paging *paging,
uint64_t gla, int prot, uint64_t *gpa, int *is_fault)
@@ -720,19 +714,6 @@
vmexit->exitcode = VM_EXITCODE_DEBUG;
}
-void *
-vcpu_stats(struct vcpu *vcpu)
-{
-
- return (vcpu->stats);
-}
-
-struct vm_mem *
-vm_mem(struct vm *vm)
-{
- return (&vm->mem);
-}
-
static void
restore_guest_fpustate(struct vcpu *vcpu)
{
@@ -805,30 +786,12 @@
return (vmmops_setcap(vcpu->cookie, type, val));
}
-struct vm *
-vcpu_vm(struct vcpu *vcpu)
-{
- return (vcpu->vm);
-}
-
-int
-vcpu_vcpuid(struct vcpu *vcpu)
-{
- return (vcpu->vcpuid);
-}
-
void *
vcpu_get_cookie(struct vcpu *vcpu)
{
return (vcpu->cookie);
}
-struct vcpu *
-vm_vcpu(struct vm *vm, int vcpuid)
-{
- return (vm->vcpu[vcpuid]);
-}
-
int
vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval)
{
diff --git a/sys/arm64/vmm/vmm_reset.c b/sys/arm64/vmm/vmm_reset.c
--- a/sys/arm64/vmm/vmm_reset.c
+++ b/sys/arm64/vmm/vmm_reset.c
@@ -34,6 +34,8 @@
#include <machine/cpu.h>
#include <machine/hypervisor.h>
+#include <dev/vmm/vmm_vm.h>
+
#include "arm64.h"
#include "reset.h"
diff --git a/sys/dev/vmm/vmm_stat.h b/sys/dev/vmm/vmm_stat.h
--- a/sys/dev/vmm/vmm_stat.h
+++ b/sys/dev/vmm/vmm_stat.h
@@ -32,6 +32,8 @@
#ifndef _DEV_VMM_STAT_H_
#define _DEV_VMM_STAT_H_
+#include <dev/vmm/vmm_vm.h>
+
struct vm;
#define MAX_VMM_STAT_ELEMS 64 /* arbitrary */
diff --git a/sys/dev/vmm/vmm_vm.h b/sys/dev/vmm/vmm_vm.h
--- a/sys/dev/vmm/vmm_vm.h
+++ b/sys/dev/vmm/vmm_vm.h
@@ -62,6 +62,24 @@
void vcpu_notify_event_locked(struct vcpu *vcpu);
int vcpu_debugged(struct vcpu *vcpu);
+static inline void *
+vcpu_stats(struct vcpu *vcpu)
+{
+ return (vcpu->stats);
+}
+
+static inline struct vm *
+vcpu_vm(struct vcpu *vcpu)
+{
+ return (vcpu->vm);
+}
+
+static inline int
+vcpu_vcpuid(struct vcpu *vcpu)
+{
+ return (vcpu->vcpuid);
+}
+
static int __inline
vcpu_is_running(struct vcpu *vcpu, int *hostcpu)
{
@@ -161,6 +179,55 @@
uint16_t *threads, uint16_t *maxcpus);
int vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores,
uint16_t threads, uint16_t maxcpus);
+
+static inline const char *
+vm_name(struct vm *vm)
+{
+ return (vm->name);
+}
+
+static inline struct vm_mem *
+vm_mem(struct vm *vm)
+{
+ return (&vm->mem);
+}
+
+static inline struct vcpu *
+vm_vcpu(struct vm *vm, int vcpuid)
+{
+ return (vm->vcpu[vcpuid]);
+}
+
+struct vm_eventinfo {
+ cpuset_t *rptr; /* rendezvous cookie */
+ int *sptr; /* suspend cookie */
+ int *iptr; /* reqidle cookie */
+};
+
+static inline int
+vcpu_rendezvous_pending(struct vcpu *vcpu, struct vm_eventinfo *info)
+{
+ /*
+ * This check isn't done with atomic operations or under a lock because
+ * there's no need to. If the vcpuid bit is set, the vcpu is part of a
+ * rendezvous and the bit won't be cleared until the vcpu enters the
+ * rendezvous. On rendezvous exit, the cpuset is cleared and the vcpu
+ * will see an empty cpuset. So, the races are harmless.
+ */
+ return (CPU_ISSET(vcpu_vcpuid(vcpu), info->rptr));
+}
+
+static inline int
+vcpu_suspended(struct vm_eventinfo *info)
+{
+ return (*info->sptr);
+}
+
+static inline int
+vcpu_reqidle(struct vm_eventinfo *info)
+{
+ return (*info->iptr);
+}
#endif /* _KERNEL */
#endif /* !_DEV_VMM_VM_H_ */
diff --git a/sys/riscv/include/vmm.h b/sys/riscv/include/vmm.h
--- a/sys/riscv/include/vmm.h
+++ b/sys/riscv/include/vmm.h
@@ -115,6 +115,7 @@
struct vmm_mmio_region mmio_region[VM_MAX_MMIO_REGIONS]
struct vm;
+struct vm_eventinfo;
struct vm_exception;
struct vm_exit;
struct vm_run;
@@ -131,12 +132,6 @@
};
#define VM_MAX_MMIO_REGIONS 4
-struct vm_eventinfo {
- void *rptr; /* rendezvous cookie */
- int *sptr; /* suspend cookie */
- int *iptr; /* reqidle cookie */
-};
-
#define DECLARE_VMMOPS_FUNC(ret_type, opname, args) \
ret_type vmmops_##opname args
@@ -160,16 +155,11 @@
vm_offset_t max));
DECLARE_VMMOPS_FUNC(void, vmspace_free, (struct vmspace *vmspace));
-const char *vm_name(struct vm *vm);
-
int vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval);
int vm_set_register(struct vcpu *vcpu, int reg, uint64_t val);
int vm_run(struct vcpu *vcpu);
void *vm_get_cookie(struct vm *vm);
-int vcpu_vcpuid(struct vcpu *vcpu);
void *vcpu_get_cookie(struct vcpu *vcpu);
-struct vm *vcpu_vm(struct vcpu *vcpu);
-struct vcpu *vm_vcpu(struct vm *vm, int cpu);
int vm_get_capability(struct vcpu *vcpu, int type, int *val);
int vm_set_capability(struct vcpu *vcpu, int type, int val);
int vm_inject_exception(struct vcpu *vcpu, uint64_t scause);
@@ -182,24 +172,6 @@
void vm_exit_suspended(struct vcpu *vcpu, uint64_t pc);
void vm_exit_debug(struct vcpu *vcpu, uint64_t pc);
void vm_exit_astpending(struct vcpu *vcpu, uint64_t pc);
-
-static __inline int
-vcpu_rendezvous_pending(struct vm_eventinfo *info)
-{
-
- return (*((uintptr_t *)(info->rptr)) != 0);
-}
-
-static __inline int
-vcpu_suspended(struct vm_eventinfo *info)
-{
-
- return (*info->sptr);
-}
-
-void *vcpu_stats(struct vcpu *vcpu);
-struct vm_mem *vm_mem(struct vm *vm);
-
#endif /* _KERNEL */
#define VM_DIR_READ 0
diff --git a/sys/riscv/vmm/vmm.c b/sys/riscv/vmm/vmm.c
--- a/sys/riscv/vmm/vmm.c
+++ b/sys/riscv/vmm/vmm.c
@@ -272,12 +272,6 @@
vm_init(vm, false);
}
-const char *
-vm_name(struct vm *vm)
-{
- return (vm->name);
-}
-
int
vm_gla2gpa_nofault(struct vcpu *vcpu, struct vm_guest_paging *paging,
uint64_t gla, int prot, uint64_t *gpa, int *is_fault)
@@ -393,19 +387,6 @@
vmexit->exitcode = VM_EXITCODE_DEBUG;
}
-void *
-vcpu_stats(struct vcpu *vcpu)
-{
-
- return (vcpu->stats);
-}
-
-struct vm_mem *
-vm_mem(struct vm *vm)
-{
- return (&vm->mem);
-}
-
static void
restore_guest_fpustate(struct vcpu *vcpu)
{
@@ -478,20 +459,6 @@
return (vmmops_setcap(vcpu->cookie, type, val));
}
-struct vm *
-vcpu_vm(struct vcpu *vcpu)
-{
-
- return (vcpu->vm);
-}
-
-int
-vcpu_vcpuid(struct vcpu *vcpu)
-{
-
- return (vcpu->vcpuid);
-}
-
void *
vcpu_get_cookie(struct vcpu *vcpu)
{
@@ -499,13 +466,6 @@
return (vcpu->cookie);
}
-struct vcpu *
-vm_vcpu(struct vm *vm, int vcpuid)
-{
-
- return (vm->vcpu[vcpuid]);
-}
-
int
vm_get_register(struct vcpu *vcpu, int reg, uint64_t *retval)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 6, 1:23 AM (18 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24852621
Default Alt Text
D53586.id.diff (12 KB)
Attached To
Mode
D53586: vmm: Move common accessors and vm_eventinfo into sys/dev/vmm
Attached
Detach File
Event Timeline
Log In to Comment