Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/vmm/amd/vmcb.h
Show All 25 Lines | |||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#ifndef _VMCB_H_ | #ifndef _VMCB_H_ | ||||
#define _VMCB_H_ | #define _VMCB_H_ | ||||
struct svm_softc; | |||||
#define BIT(n) (1ULL << n) | #define BIT(n) (1ULL << n) | ||||
/* | /* | ||||
* Secure Virtual Machine: AMD64 Programmer's Manual Vol2, Chapter 15 | * Secure Virtual Machine: AMD64 Programmer's Manual Vol2, Chapter 15 | ||||
* Layout of VMCB: AMD64 Programmer's Manual Vol2, Appendix B | * Layout of VMCB: AMD64 Programmer's Manual Vol2, Appendix B | ||||
*/ | */ | ||||
/* vmcb_ctrl->intercept[] array indices */ | /* vmcb_ctrl->intercept[] array indices */ | ||||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
#define VMCB_ACCESS(o, w) (0x80000000 | (((w) & 0xF) << 16) | \ | #define VMCB_ACCESS(o, w) (0x80000000 | (((w) & 0xF) << 16) | \ | ||||
((o) & 0xFFF)) | ((o) & 0xFFF)) | ||||
#define VMCB_ACCESS_OK(v) ((v) & 0x80000000 ) | #define VMCB_ACCESS_OK(v) ((v) & 0x80000000 ) | ||||
#define VMCB_ACCESS_BYTES(v) (((v) >> 16) & 0xF) | #define VMCB_ACCESS_BYTES(v) (((v) >> 16) & 0xF) | ||||
#define VMCB_ACCESS_OFFSET(v) ((v) & 0xFFF) | #define VMCB_ACCESS_OFFSET(v) ((v) & 0xFFF) | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
struct svm_softc; | |||||
pmooney_pfmooney.com: Rather than requiring forward definitions here and in the other headers (vlapic, vhpet, etc)… | |||||
Done Inline ActionsForward declarations were seemed like the preferred implementation. Including headers may be problematic, especially if those include other headers. darius.mihaim_gmail.com: Forward declarations were seemed like the preferred implementation. Including headers may be… | |||||
Not Done Inline ActionsI strongly disagree. Practically everywhere else, shared types declarations are pulled in via headers. What about this situation makes it so complicated that doing so isn't feasible? pmooney_pfmooney.com: I strongly disagree. Practically everywhere else, shared types declarations are pulled in via… | |||||
Not Done Inline ActionsForward declarations are used extensively in FreeBSD when the header only needs to reference the pointer type. I guess I don’t understand why you strongly disagree with using them appropriately. cem: Forward declarations are used extensively in FreeBSD when the header only needs to reference… | |||||
struct vm_snapshot_meta; | |||||
/* VMCB save state area segment format */ | /* VMCB save state area segment format */ | ||||
struct vmcb_segment { | struct vmcb_segment { | ||||
uint16_t selector; | uint16_t selector; | ||||
uint16_t attrib; | uint16_t attrib; | ||||
uint32_t limit; | uint32_t limit; | ||||
uint64_t base; | uint64_t base; | ||||
} __attribute__ ((__packed__)); | } __attribute__ ((__packed__)); | ||||
CTASSERT(sizeof(struct vmcb_segment) == 16); | CTASSERT(sizeof(struct vmcb_segment) == 16); | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | |||||
CTASSERT(sizeof(struct vmcb) == PAGE_SIZE); | CTASSERT(sizeof(struct vmcb) == PAGE_SIZE); | ||||
CTASSERT(offsetof(struct vmcb, state) == 0x400); | CTASSERT(offsetof(struct vmcb, state) == 0x400); | ||||
int vmcb_read(struct svm_softc *sc, int vcpu, int ident, uint64_t *retval); | int vmcb_read(struct svm_softc *sc, int vcpu, int ident, uint64_t *retval); | ||||
int vmcb_write(struct svm_softc *sc, int vcpu, int ident, uint64_t val); | int vmcb_write(struct svm_softc *sc, int vcpu, int ident, uint64_t val); | ||||
int vmcb_setdesc(void *arg, int vcpu, int ident, struct seg_desc *desc); | int vmcb_setdesc(void *arg, int vcpu, int ident, struct seg_desc *desc); | ||||
int vmcb_getdesc(void *arg, int vcpu, int ident, struct seg_desc *desc); | int vmcb_getdesc(void *arg, int vcpu, int ident, struct seg_desc *desc); | ||||
int vmcb_seg(struct vmcb *vmcb, int ident, struct vmcb_segment *seg); | int vmcb_seg(struct vmcb *vmcb, int ident, struct vmcb_segment *seg); | ||||
#ifdef BHYVE_SNAPSHOT | |||||
int vmcb_getany(struct svm_softc *sc, int vcpu, int ident, uint64_t *val); | |||||
int vmcb_setany(struct svm_softc *sc, int vcpu, int ident, uint64_t val); | |||||
int vmcb_snapshot_desc(void *arg, int vcpu, int reg, | |||||
struct vm_snapshot_meta *meta); | |||||
int vmcb_snapshot_any(struct svm_softc *sc, int vcpu, int ident, | |||||
struct vm_snapshot_meta *meta); | |||||
#endif | |||||
#endif /* _KERNEL */ | #endif /* _KERNEL */ | ||||
#endif /* _VMCB_H_ */ | #endif /* _VMCB_H_ */ |
Rather than requiring forward definitions here and in the other headers (vlapic, vhpet, etc) for struct vm_snapshot_meta, why not include machine/vmm_snapshot.h? It's required for the function implementation anyways.