summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/conf/Makefile.amd64
blob: e33c9d2840a9d665c140f7757bd1a53278f6cc3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#	$NetBSD: Makefile.amd64,v 1.86 2023/01/06 15:35:06 christos Exp $

# Makefile for NetBSD
#
# This makefile is constructed from a machine description:
#	config machineid
# Most changes should be made in the machine description
#	/sys/arch/amd64/conf/``machineid''
# after which you should do
#	config machineid
# Machine generic makefile changes should be made in
#	/sys/arch/amd64/conf/Makefile.amd64
# after which config should be rerun for all machines of that type.
#
# To specify debugging, add the config line: makeoptions DEBUG="-g"
# A better way is to specify -g only for a few files.
#
#	makeoptions DEBUGLIST="uvm* trap if_*"

MACHINE_ARCH=x86_64
USETOOLS?=	no
NEED_OWN_INSTALL_TARGET?=no
NOSANITIZER=
.include <bsd.init.mk>

USE_SSP?=	yes

##
## (1) port identification
##
AMD64=		$S/arch/amd64
GENASSYM_CONF=	${AMD64}/amd64/genassym.cf

##
## (2) compile settings
##
DEFCOPTS=	-O2 -fno-omit-frame-pointer
CPPFLAGS+=	-Damd64 -Dx86_64
CFLAGS+=	-mcmodel=kernel
# -mno-sse implies -mno-sse2 (etc), explicitly disable avx to be extra sure
CFLAGS+=	-mno-red-zone -mno-mmx -mno-sse -mno-avx
# make absolutely sure we don't get x87 registers used as well
CFLAGS+=	-msoft-float
# For gcc we might need this, but other compilers barf
# CFLAGS+=	-mno-fp-ret-in-387

.if ${SPECTRE_V2_GCC_MITIGATION:U0} > 0
CFLAGS+=	${${ACTIVE_CC} == "gcc" :? -mindirect-branch=thunk :}
CFLAGS+=	${${ACTIVE_CC} == "gcc" :? -mindirect-branch-register :}
.endif

.if ${KASAN:U0} > 0
.if ${HAVE_GCC:U0} > 0
KASANFLAGS=	-fsanitize=kernel-address \
		--param asan-globals=1 --param asan-stack=1 \
		--param asan-instrument-allocas=1 \
		-fsanitize-address-use-after-scope \
		-fasan-shadow-offset=0xDFFF900000000000
.elif ${HAVE_LLVM:Uno} == "yes"
KASANFLAGS=	-fsanitize=kernel-address \
		-mllvm -asan-globals=1 -mllvm -asan-stack=1 \
		-mllvm -asan-instrument-dynamic-allocas=1 \
		-mllvm -asan-use-after-scope=1 \
		-mllvm -asan-instrumentation-with-call-threshold=0 \
		-mllvm -asan-mapping-offset=0xDFFF900000000000
.endif
.for f in subr_asan.c subr_kcov.c
KASANFLAGS.${f}=	# empty
.endfor
CFLAGS+=	${KASANFLAGS.${.IMPSRC:T}:U${KASANFLAGS}}
.endif

.if ${KCSAN:U0} > 0 && ${HAVE_GCC:U0} > 0
KCSANFLAGS=	-fsanitize=thread
.for f in subr_csan.c subr_kcov.c clock.c lapic.c
KCSANFLAGS.${f}=	# empty
.endfor
CFLAGS+=	${KCSANFLAGS.${.IMPSRC:T}:U${KCSANFLAGS}}
.endif

.if ${KMSAN:U0} > 0 && ${HAVE_LLVM:Uno} == "yes"
KMSANFLAGS=	-fsanitize=kernel-memory
.for f in subr_msan.c
KMSANFLAGS.${f}=	# empty
.endfor
CFLAGS+=	${KMSANFLAGS.${.IMPSRC:T}:U${KMSANFLAGS}}
.endif

EXTRA_INCLUDES= -I$S/external/mit/xen-include-public/dist/

##
## (3) libkern and compat
##
OPT_MODULAR=	%MODULAR%

##
## (4) local objects, compile rules, and dependencies
##

##
## (5) link settings
##
TEXTADDR?=	0xffffffff80200000
.if defined(KASLR)
EXTRA_LINKFLAGS=	--split-by-file=0x100000 -r -d
KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript.kaslr
.else
EXTRA_LINKFLAGS=	-z max-page-size=0x200000
KERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript
.endif
LINKFLAGS_NORMAL=	-X
EXTRA_LINKFLAGS+=	-z noseparate-code

##
## (6) port specific target dependencies
##

# depend on CPU configuration
locore.o machdep.o: Makefile

acpi_wakeup_low.o busfunc.o cpufunc.o cpu_in_cksum.o: assym.h
linux_sigcode.o linux32_sigcode.o lock_stubs.o mptramp.o: assym.h
netbsd32_sigcode.o: assym.h

##
## (7) misc settings
##

##
## (8) config(8) generated machinery
##
%INCLUDES

%OBJS

%CFILES

%SFILES

%LOAD

%RULES

##
## (9) port independent kernel machinery
##
.include "$S/conf/Makefile.kern.inc"

## Include rules for ACPI wakecode
.include "$S/arch/x86/acpi/Makefile.wakecode.inc"

##
## (10) Appending make options.
##
%MAKEOPTIONSAPPEND