xref: /freebsd/sys/modules/vmm/Makefile (revision 7937bfbc0ca53fe7cdd0d54414f9296e273a518e)
1.include <kmod.opts.mk>
2
3KMOD=	vmm
4
5.if ${MACHINE_CPUARCH} == "amd64"
6SRCS+=	opt_acpi.h		\
7	opt_bhyve_snapshot.h	\
8	opt_ddb.h
9.endif
10
11SRCS+=	acpi_if.h bus_if.h device_if.h pci_if.h pcib_if.h vnode_if.h
12
13CFLAGS+= -DVMM_KEEP_STATS
14CFLAGS+= -I${SRCTOP}/sys/${MACHINE}/vmm
15CFLAGS+= -I${SRCTOP}/sys/${MACHINE}/vmm/io
16
17# generic vmm support
18.PATH: ${SRCTOP}/sys/dev/vmm ${SRCTOP}/sys/${MACHINE}/vmm
19
20SRCS+=	vmm.c			\
21	vmm_dev.c		\
22	vmm_dev_machdep.c	\
23	vmm_instruction_emul.c	\
24	vmm_stat.c
25
26.if ${MACHINE_CPUARCH} == "aarch64"
27DPSRCS+=	assym.inc
28
29# TODO: Add the new EL2 code
30SRCS+=	vmm_arm64.c \
31	vmm_reset.c \
32	vmm_call.S \
33	vmm_handlers.c \
34	vmm_mmu.c \
35	vmm_vhe_exception.S \
36	vmm_vhe.c \
37	vmm_hyp_el2.S
38
39.PATH: ${SRCTOP}/sys/${MACHINE}/vmm/io
40SRCS+=	vgic.c \
41	vgic_if.h \
42	vgic_if.c \
43	vgic_v3.c \
44	vtimer.c
45
46CLEANFILES+=	vmm_nvhe_exception.o vmm_nvhe.o
47
48CLEANFILES+=	vmm_hyp_blob.elf.full
49CLEANFILES+=	vmm_hyp_blob.elf vmm_hyp_blob.bin
50
51vmm_nvhe_exception.o: vmm_nvhe_exception.S
52	${CC} -c -x assembler-with-cpp -DLOCORE \
53	    ${NOSAN_CFLAGS:N-mbranch-protection*} ${.IMPSRC} -o ${.TARGET} -fpie
54
55vmm_nvhe.o: vmm_nvhe.c
56	${CC} -c ${NOSAN_CFLAGS:N-mbranch-protection*} ${.IMPSRC} \
57	    -o ${.TARGET} -fpie
58
59vmm_hyp_blob.elf.full:	vmm_nvhe_exception.o vmm_nvhe.o
60	${LD} -m ${LD_EMULATION} -Bdynamic -L ${SYSDIR}/conf -T ${SYSDIR}/conf/ldscript.arm64 \
61	    ${_LDFLAGS:N-zbti-report*} --no-warn-mismatch --warn-common --export-dynamic \
62	    --dynamic-linker /red/herring -X -o ${.TARGET} ${.ALLSRC} \
63	    --defsym=_start='0x0' --defsym=text_start='0x0'
64
65vmm_hyp_blob.elf:	vmm_hyp_blob.elf.full
66	${OBJCOPY} --strip-debug ${.ALLSRC} ${.TARGET}
67
68vmm_hyp_blob.bin:	vmm_hyp_blob.elf
69	${OBJCOPY} --output-target=binary ${.ALLSRC} ${.TARGET}
70
71vmm_hyp_el2.o:	vmm_hyp_blob.bin
72
73.elif ${MACHINE_CPUARCH} == "amd64"
74DPSRCS+=	vmx_assym.h svm_assym.h
75DPSRCS+=	vmx_genassym.c svm_genassym.c offset.inc
76
77CFLAGS+= -I${SRCTOP}/sys/amd64/vmm/intel
78CFLAGS+= -I${SRCTOP}/sys/amd64/vmm/amd
79
80SRCS+=	vmm_host.c	\
81	vmm_ioport.c	\
82	vmm_lapic.c	\
83	vmm_mem.c	\
84	vmm_util.c	\
85	x86.c
86
87.PATH: ${SRCTOP}/sys/${MACHINE}/vmm/io
88SRCS+=	iommu.c		\
89	ppt.c           \
90	vatpic.c	\
91	vatpit.c	\
92	vhpet.c		\
93	vioapic.c	\
94	vlapic.c	\
95	vpmtmr.c	\
96	vrtc.c
97
98# intel-specific files
99.PATH: ${SRCTOP}/sys/amd64/vmm/intel
100SRCS+=	ept.c		\
101	vmcs.c		\
102	vmx_msr.c	\
103	vmx_support.S	\
104	vmx.c		\
105	vtd.c
106
107# amd-specific files
108.PATH: ${SRCTOP}/sys/amd64/vmm/amd
109SRCS+=	vmcb.c		\
110	amdiommu.c	\
111	ivhd_if.c	\
112	ivhd_if.h	\
113	svm.c		\
114	svm_support.S	\
115	npt.c		\
116	ivrs_drv.c	\
117	amdvi_hw.c	\
118	svm_msr.c
119
120SRCS.BHYVE_SNAPSHOT=	vmm_snapshot.c
121
122CLEANFILES+=	vmx_assym.h vmx_genassym.o svm_assym.h svm_genassym.o
123
124OBJS_DEPEND_GUESS.vmx_support.o+= vmx_assym.h
125OBJS_DEPEND_GUESS.svm_support.o+= svm_assym.h
126.endif
127
128vmx_assym.h:    vmx_genassym.o
129	sh ${SYSDIR}/kern/genassym.sh vmx_genassym.o > ${.TARGET}
130
131svm_assym.h:    svm_genassym.o
132	sh ${SYSDIR}/kern/genassym.sh svm_genassym.o > ${.TARGET}
133
134vmx_support.o:
135	${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
136	    ${.IMPSRC} -o ${.TARGET}
137
138svm_support.o:
139	${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
140	    ${.IMPSRC} -o ${.TARGET}
141
142hyp_genassym.o: offset.inc
143	${CC} -c ${NOSAN_CFLAGS:N-flto:N-fno-common} -fcommon ${.IMPSRC}
144
145vmx_genassym.o: offset.inc
146	${CC} -c ${NOSAN_CFLAGS:N-flto*:N-fno-common} -fcommon ${.IMPSRC}
147
148svm_genassym.o: offset.inc
149	${CC} -c ${NOSAN_CFLAGS:N-flto*:N-fno-common} -fcommon ${.IMPSRC}
150
151.include <bsd.kmod.mk>
152