1#
2# This file and its contents are supplied under the terms of the
3# Common Development and Distribution License ("CDDL"), version 1.0.
4# You may only use this file in accordance with the terms of version
5# 1.0 of the CDDL.
6#
7# A full copy of the text of the CDDL should have accompanied this
8# source.  A copy of the CDDL is also available via the Internet at
9# http://www.illumos.org/license/CDDL.
10#
11
12# Copyright 2023 Oxide Computer Company
13
14include $(SRC)/cmd/Makefile.cmd
15include $(SRC)/cmd/Makefile.cmd.64
16include $(SRC)/test/Makefile.com
17
18PROG =	rdmsr \
19	wrmsr \
20	imul \
21	cpuid
22
23# These should probably go in the `vmm` tests, but since they depend on
24# in-guest payloads, it is easier to build them here.
25PROG +=	triple_fault \
26	exit_paging \
27	page_dirty \
28	exit_consistent
29
30# C-based payloads need additional utils object
31CPAYLOADS =	cpuid
32
33PAYLOADS = $(PROG)
34include ../Makefile.in_guest
35
36COMMON_OBJS =	in_guest.o common.o
37
38CLEANFILES =	$(COMMON_OBJS) $(PAYLOAD_CLEANFILES) payload_utils.o
39CLOBBERFILES =	$(PROG)
40
41ROOTOPTPKG = $(ROOT)/opt/bhyve-tests
42TESTDIR = $(ROOTOPTPKG)/tests/inst_emul
43
44CMDS = $(PROG:%=$(TESTDIR)/%)
45$(CMDS) := FILEMODE = 0555
46
47CSTD=		$(CSTD_GNU99)
48CPPFLAGS =	-I$(COMPAT)/bhyve -I$(CONTRIB)/bhyve \
49		-I$(COMPAT)/bhyve/amd64 -I$(CONTRIB)/bhyve/amd64 \
50		$(CPPFLAGS.master) \
51		-I$(SRC)/uts/intel/io/vmm \
52		-I$(SRC)/uts/intel \
53		-I../common
54
55ASFLAGS +=	-D_ASM
56ASFLAGS64 +=	-D_ASM
57
58$(PROG) :=	LDLIBS += -lvmmapi
59
60all: $(PROG)
61
62install: all $(CMDS)
63
64clean:
65	-$(RM) $(CLEANFILES)
66clobber: clean
67	-$(RM) $(CLOBBERFILES)
68
69$(CMDS): $(TESTDIR) $(PROG)
70
71$(TESTDIR):
72	$(INS.dir)
73
74$(TESTDIR)/%: %
75	$(INS.file)
76
77%: %.c pobj_%.o $(COMMON_OBJS)
78	$(LINK.c) -o $@ $^ $(LDLIBS)
79	$(POST_PROCESS)
80
81%: %.o
82	$(LINK.c) -o $@ $^ $(LDLIBS)
83	$(POST_PROCESS)
84
85$(CPAYLOADS:%=payload_%): payload_utils.o
86