blob: 9b00d7dfafe95f9e5da7c2cc29a73557289563e5 [file] [log] [blame]
Arthur Heymans94fe0862020-10-15 13:57:52 +02001ifeq ($(CONFIG_INTEL_CBNT_SUPPORT),y)
2
Arthur Heymans23907542021-03-16 19:28:50 +01003ramstage-y += cmos.c
4
Arthur Heymans8b91c9f2021-03-31 12:21:32 +02005# As specified in Intel Trusted Execution Technology and Boot Guard Server BIOS
6# Specification, document number # 558294
7PK_HASH_ALG_SHA1:=4
8PK_HASH_ALG_SHA256:=11
9PK_HASH_ALG_SHA384:=12
10
Arthur Heymans21176dd2021-03-17 15:33:26 +010011# The private key also contains the public key, so use that if a private key is provided.
12ifeq ($(CONFIG_INTEL_CBNT_NEED_KM_PRIV_KEY),y)
13$(obj)/km_pub.pem: $(call strip_quotes, $(CONFIG_INTEL_CBNT_KM_PRIV_KEY_FILE))
14 openssl pkey -in $< -pubout > $@
15else ifeq ($(CONFIG_INTEL_CBNT_NEED_KM_PUB_KEY),y)
16$(obj)/km_pub.pem: $(call strip_quotes, $(CONFIG_INTEL_CBNT_KM_PUB_KEY_FILE))
17 cp $< $@
18endif
19
20# The private key also contains the public key, so use that if a private key is provided.
21ifeq ($(CONFIG_INTEL_CBNT_NEED_BPM_PRIV_KEY),y)
22$(obj)/bpm_pub.pem: $(call strip_quotes, $(CONFIG_INTEL_CBNT_BPM_PRIV_KEY_FILE))
23 openssl pkey -in $< -pubout > $@
24else ifeq ($(CONFIG_INTEL_CBNT_NEED_BPM_PUB_KEY),y)
25$(obj)/bpm_pub.pem: $(call strip_quotes, $(CONFIG_INTEL_CBNT_BPM_PUB_KEY_FILE))
26 cp $< $@
27endif
28
Arthur Heymans53164ba2021-05-06 11:15:32 +020029CBNT_PROV:=$(obj)/cbnt-prov
Arthur Heymans2ef2e472021-02-08 14:28:03 +010030CBNT_CFG:=$(obj)/cbnt.json
31
Arthur Heymans0250a782021-03-31 16:54:37 +020032ifneq ($(CONFIG_INTEL_CBNT_PROV_EXTERNAL_BIN),y)
Arthur Heymans53164ba2021-05-06 11:15:32 +020033$(CBNT_PROV):
34 printf " CBNT_PROV building tool\n"
Arthur Heymans2ef2e472021-02-08 14:28:03 +010035 cd 3rdparty/intel-sec-tools; \
36 GO111MODULE=on go mod download; \
37 GO111MODULE=on go mod verify; \
Arthur Heymansf69cece2021-05-04 08:15:22 +020038 GO111MODULE=on go build -o $(top)/$@ cmd/cbnt-prov/*.go
Arthur Heymans0250a782021-03-31 16:54:37 +020039else
40$(CBNT_PROV): $(call strip_quotes, $(CONFIG_INTEL_CBNT_PROV_EXTERNAL_BIN_PATH))
41 cp $< $@
42endif
Arthur Heymans2ef2e472021-02-08 14:28:03 +010043
Arthur Heymans53164ba2021-05-06 11:15:32 +020044$(CBNT_CFG): $(call strip_quotes, $(CONFIG_INTEL_CBNT_CBNT_PROV_CFG_FILE))
45 cp $(CONFIG_INTEL_CBNT_CBNT_PROV_CFG_FILE) $@
Arthur Heymans2ef2e472021-02-08 14:28:03 +010046
Arthur Heymans15412c02021-02-08 22:38:40 +010047ifeq ($(CONFIG_INTEL_CBNT_GENERATE_BPM),y)
Arthur Heymans53164ba2021-05-06 11:15:32 +020048ifeq ($(CONFIG_INTEL_CBNT_CBNT_PROV_BPM_USE_CFG_FILE),y)
49$(obj)/bpm_unsigned.bin: $(obj)/coreboot.rom $(CBNT_PROV) $(CBNT_CFG)
50 printf " CBNT_PROV creating unsigned BPM using config file\n"
51 $(CBNT_PROV) bpm-gen $@ $< --config=$(CBNT_CFG) --cut
Arthur Heymans3d5319e2021-02-19 19:39:56 +010052else
Arthur Heymans53164ba2021-05-06 11:15:32 +020053$(obj)/bpm_unsigned.bin: $(obj)/coreboot.rom $(CBNT_PROV)
54 printf " CBNT_PROV creating unsigned BPM\n"
Arthur Heymans53164ba2021-05-06 11:15:32 +020055 $(CBNT_PROV) bpm-gen $@ $< --revision=$(CONFIG_INTEL_CBNT_BPM_REVISION) \
Arthur Heymans3d5319e2021-02-19 19:39:56 +010056 --svn=$(CONFIG_INTEL_CBNT_BPM_SVN) \
57 --acmsvn=$(CONFIG_INTEL_CBNT_ACM_SVN) \
58 --nems=$(CONFIG_INTEL_CBNT_NUM_NEM_PAGES) \
59 --pbet=$(CONFIG_INTEL_CBNT_PBET) \
60 --ibbflags=$(CONFIG_INTEL_CBNT_IBB_FLAGS) \
61 --entrypoint=$(shell printf "%d" 0xfffffff0) \
Arthur Heymans8b91c9f2021-03-31 12:21:32 +020062 --ibbhash=$(PK_HASH_ALG_SHA256),$(PK_HASH_ALG_SHA1),$(PK_HASH_ALG_SHA384) \
Arthur Heymansf69cece2021-05-04 08:15:22 +020063 --coreboot \
64 --sinitmin=$(CONFIG_INTEL_CBNT_SINIT_SVN) \
Arthur Heymans3d5319e2021-02-19 19:39:56 +010065 --txtflags=0 \
66 --powerdowninterval=$(CONFIG_INTEL_CBNT_PD_INTERVAL) \
67 --acpibaseoffset=$(shell printf "%d" $(CONFIG_INTEL_ACPI_BASE_ADDRESS)) \
68 --powermbaseoffset=$(shell printf "%d" $(CONFIG_INTEL_PCH_PWRM_BASE_ADDRESS)) \
69 --cmosoff0=$(shell printf "%d" $(CONFIG_INTEL_CBNT_CMOS_OFFSET)) \
70 --cmosoff1=$(call int-add, $(CONFIG_INTEL_CBNT_CMOS_OFFSET) 1) \
71 --cut \
72 --out=$(obj)/bpm_cfg.json
73endif
Arthur Heymans15412c02021-02-08 22:38:40 +010074
Arthur Heymans6362df32021-03-17 12:23:20 +010075ifeq ($(CONFIG_INTEL_CBNT_BPM_ONLY_UNSIGNED),y)
76build_complete:: $(obj)/bpm_unsigned.bin
77 @printf "\n** WARNING **\n"
78 @printf "Build generated an unsigned BPM image: build/bpm_unsigned.bin.\n"
79 @printf "The resulting image will not work with CBnT.\n"
80 @printf "After you have externally signed the image you can add it to the coreboot image:\n"
81 @printf "$$ cbfstool build/coreboot.rom add -f bpm.bin -n boot_policy_manifest.bin -t raw -a 16\n"
82 @printf "$$ ifittool -r COREBOOT -a -n boot_policy_manifest.bin -t 12 -s 12 -f build/coreboot.rom\n"
83else
Arthur Heymans53164ba2021-05-06 11:15:32 +020084$(obj)/bpm.bin: $(obj)/bpm_unsigned.bin $(CBNT_PROV) $(call strip_quotes, $(CONFIG_INTEL_CBNT_BPM_PRIV_KEY_FILE))
85 printf " CBNT_PROV signing real BPM\n"
86 $(CBNT_PROV) bpm-sign $< $@ $(CONFIG_INTEL_CBNT_BPM_PRIV_KEY_FILE) ""
Arthur Heymans15412c02021-02-08 22:38:40 +010087
88# Add BPM at the end of the build when all files have been added
89files_added:: $(obj)/bpm.bin
90 printf " CBNT Adding BPM\n"
91 $(CBFSTOOL) $(obj)/coreboot.rom add -f $< -n boot_policy_manifest.bin -a 0x10 -t raw
92 printf " IFITTOOL Adding BPM\n"
93 $(IFITTOOL) -r COREBOOT -a -n boot_policy_manifest.bin -t 12 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -f $(obj)/coreboot.rom
94
Arthur Heymans6362df32021-03-17 12:23:20 +010095endif # CONFIG_INTEL_CBNT_BPM_ONLY_UNSIGNED
96
Arthur Heymans15412c02021-02-08 22:38:40 +010097else # CONFIG_INTEL_CBNT_GENERATE_BPM
Arthur Heymans6362df32021-03-17 12:23:20 +010098
Arthur Heymans94fe0862020-10-15 13:57:52 +020099ifneq ($(CONFIG_INTEL_CBNT_BOOT_POLICY_MANIFEST_BINARY),"")
100cbfs-files-y += boot_policy_manifest.bin
101boot_policy_manifest.bin-file := $(CONFIG_INTEL_CBNT_BOOT_POLICY_MANIFEST_BINARY)
102boot_policy_manifest.bin-type := raw
103boot_policy_manifest.bin-align := 0x10
104
Arthur Heymanseeacd832021-02-19 17:14:23 +0100105$(call add_intermediate, add_bpm_fit, $(IFITTOOL) set_fit_ptr)
Arthur Heymans94fe0862020-10-15 13:57:52 +0200106 $(IFITTOOL) -r COREBOOT -a -n boot_policy_manifest.bin -t 12 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -f $<
107endif
Arthur Heymans15412c02021-02-08 22:38:40 +0100108endif # CONFIG_INTEL_CBNT_GENERATE_BPM
Arthur Heymans94fe0862020-10-15 13:57:52 +0200109
Arthur Heymans2ef2e472021-02-08 14:28:03 +0100110ifeq ($(CONFIG_INTEL_CBNT_GENERATE_KM),y)
Arthur Heymans53164ba2021-05-06 11:15:32 +0200111ifeq ($(CONFIG_INTEL_CBNT_CBNT_PROV_KM_USE_CFG_FILE),y)
112$(obj)/km_unsigned.bin: $(obj)/km_pub.pem $(CBNT_PROV) $(CBNT_CFG)
113 printf " CBNT_PROV creating unsigned KM using config file\n"
114 $(CBNT_PROV) km-gen $@ $< --config=$(CBNT_CFG)
Arthur Heymans05143242021-02-08 19:41:23 +0100115else
Arthur Heymans53164ba2021-05-06 11:15:32 +0200116$(obj)/km_unsigned.bin: $(obj)/km_pub.pem $(obj)/bpm_pub.pem $(CBNT_PROV)
117 printf " CBNT_PROV creating unsigned KM\n"
118 $(CBNT_PROV) km-gen $@ $< --revision=$(CONFIG_INTEL_CBNT_KM_REVISION) \
Arthur Heymans05143242021-02-08 19:41:23 +0100119 --svn=$(CONFIG_INTEL_CBNT_KM_SVN) \
120 --id=$(CONFIG_INTEL_CBNT_KM_ID) \
121 --pkhashalg=$(PK_HASH_ALG_SHA256) \
122 --bpmpubkey=$(obj)/bpm_pub.pem \
123 --bpmhashalgo=$(PK_HASH_ALG_SHA256) \
124 --out=$(obj)/km_cfg.json
125endif
Arthur Heymans2ef2e472021-02-08 14:28:03 +0100126
Arthur Heymans53164ba2021-05-06 11:15:32 +0200127$(obj)/km.bin: $(obj)/km_unsigned.bin $(CBNT_PROV) $(call strip_quotes, $(CONFIG_INTEL_CBNT_KM_PRIV_KEY_FILE))
128 printf " CBNT_PROV signing KM\n"
129 $(CBNT_PROV) km-sign $< $@ $(CONFIG_INTEL_CBNT_KM_PRIV_KEY_FILE) ""
Arthur Heymans2ef2e472021-02-08 14:28:03 +0100130
131KM_FILE=$(obj)/km.bin
132else
133KM_FILE=$(CONFIG_INTEL_CBNT_KEY_MANIFEST_BINARY)
134endif
135
136ifneq ($(KM_FILE),"")
Arthur Heymans5e0119e2021-03-17 12:03:39 +0100137ifeq ($(CONFIG_INTEL_CBNT_KM_ONLY_UNSIGNED),y)
138$(call add_intermediate, gen_unsigned_km, $(obj)/km_unsigned.bin)
139 @printf "Generating unsgined KM\n"
140
141build_complete::
142 @printf "\n** WARNING **\n"
143 @printf "Build generated an unsigned KM image: build/km_unsiged.bin.\n"
144 @printf "The resulting image will not work with CBnT.\n"
145 @printf "After you have externally signed the image you can add it to the coreboot image:\n"
146 @printf "$$ cbfstool build/coreboot.rom add -f km.bin -n key_manifest.bin -t raw -a 16\n"
147 @printf "$$ ifittool -r COREBOOT -a -n key_manifest.bin -t 11 -s 12 -f build/coreboot.rom\n"
148
149else
Arthur Heymans94fe0862020-10-15 13:57:52 +0200150cbfs-files-y += key_manifest.bin
Arthur Heymans2ef2e472021-02-08 14:28:03 +0100151key_manifest.bin-file := $(KM_FILE)
Arthur Heymans94fe0862020-10-15 13:57:52 +0200152key_manifest.bin-type := raw
153key_manifest.bin-align := 0x10
154
Arthur Heymanseeacd832021-02-19 17:14:23 +0100155$(call add_intermediate, add_km_fit, $(IFITTOOL) set_fit_ptr)
Arthur Heymans94fe0862020-10-15 13:57:52 +0200156 $(IFITTOOL) -r COREBOOT -a -n key_manifest.bin -t 11 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -f $<
157endif
158
Arthur Heymans5e0119e2021-03-17 12:03:39 +0100159endif # CONFIG_INTEL_CBNT_KM_ONLY_UNSIGNED
Arthur Heymans94fe0862020-10-15 13:57:52 +0200160endif # CONFIG_INTEL_CBNT_SUPPORT