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