blob: b0ff9be3296493c2293e0f1e8583d75a8f137875 [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 Heymans53164ba2021-05-06 11:15:32 +020032$(CBNT_PROV):
33 printf " CBNT_PROV building tool\n"
Arthur Heymans2ef2e472021-02-08 14:28:03 +010034 cd 3rdparty/intel-sec-tools; \
35 GO111MODULE=on go mod download; \
36 GO111MODULE=on go mod verify; \
Arthur Heymansf69cece2021-05-04 08:15:22 +020037 GO111MODULE=on go build -o $(top)/$@ cmd/cbnt-prov/*.go
Arthur Heymans2ef2e472021-02-08 14:28:03 +010038
Arthur Heymans53164ba2021-05-06 11:15:32 +020039$(CBNT_CFG): $(call strip_quotes, $(CONFIG_INTEL_CBNT_CBNT_PROV_CFG_FILE))
40 cp $(CONFIG_INTEL_CBNT_CBNT_PROV_CFG_FILE) $@
Arthur Heymans2ef2e472021-02-08 14:28:03 +010041
Arthur Heymans15412c02021-02-08 22:38:40 +010042ifeq ($(CONFIG_INTEL_CBNT_GENERATE_BPM),y)
Arthur Heymans53164ba2021-05-06 11:15:32 +020043ifeq ($(CONFIG_INTEL_CBNT_CBNT_PROV_BPM_USE_CFG_FILE),y)
44$(obj)/bpm_unsigned.bin: $(obj)/coreboot.rom $(CBNT_PROV) $(CBNT_CFG)
45 printf " CBNT_PROV creating unsigned BPM using config file\n"
46 $(CBNT_PROV) bpm-gen $@ $< --config=$(CBNT_CFG) --cut
Arthur Heymans3d5319e2021-02-19 19:39:56 +010047else
Arthur Heymans53164ba2021-05-06 11:15:32 +020048$(obj)/bpm_unsigned.bin: $(obj)/coreboot.rom $(CBNT_PROV)
49 printf " CBNT_PROV creating unsigned BPM\n"
Arthur Heymans53164ba2021-05-06 11:15:32 +020050 $(CBNT_PROV) bpm-gen $@ $< --revision=$(CONFIG_INTEL_CBNT_BPM_REVISION) \
Arthur Heymans3d5319e2021-02-19 19:39:56 +010051 --svn=$(CONFIG_INTEL_CBNT_BPM_SVN) \
52 --acmsvn=$(CONFIG_INTEL_CBNT_ACM_SVN) \
53 --nems=$(CONFIG_INTEL_CBNT_NUM_NEM_PAGES) \
54 --pbet=$(CONFIG_INTEL_CBNT_PBET) \
55 --ibbflags=$(CONFIG_INTEL_CBNT_IBB_FLAGS) \
56 --entrypoint=$(shell printf "%d" 0xfffffff0) \
Arthur Heymans8b91c9f2021-03-31 12:21:32 +020057 --ibbhash=$(PK_HASH_ALG_SHA256),$(PK_HASH_ALG_SHA1),$(PK_HASH_ALG_SHA384) \
Arthur Heymansf69cece2021-05-04 08:15:22 +020058 --coreboot \
59 --sinitmin=$(CONFIG_INTEL_CBNT_SINIT_SVN) \
Arthur Heymans3d5319e2021-02-19 19:39:56 +010060 --txtflags=0 \
61 --powerdowninterval=$(CONFIG_INTEL_CBNT_PD_INTERVAL) \
62 --acpibaseoffset=$(shell printf "%d" $(CONFIG_INTEL_ACPI_BASE_ADDRESS)) \
63 --powermbaseoffset=$(shell printf "%d" $(CONFIG_INTEL_PCH_PWRM_BASE_ADDRESS)) \
64 --cmosoff0=$(shell printf "%d" $(CONFIG_INTEL_CBNT_CMOS_OFFSET)) \
65 --cmosoff1=$(call int-add, $(CONFIG_INTEL_CBNT_CMOS_OFFSET) 1) \
66 --cut \
67 --out=$(obj)/bpm_cfg.json
68endif
Arthur Heymans15412c02021-02-08 22:38:40 +010069
Arthur Heymans6362df32021-03-17 12:23:20 +010070ifeq ($(CONFIG_INTEL_CBNT_BPM_ONLY_UNSIGNED),y)
71build_complete:: $(obj)/bpm_unsigned.bin
72 @printf "\n** WARNING **\n"
73 @printf "Build generated an unsigned BPM image: build/bpm_unsigned.bin.\n"
74 @printf "The resulting image will not work with CBnT.\n"
75 @printf "After you have externally signed the image you can add it to the coreboot image:\n"
76 @printf "$$ cbfstool build/coreboot.rom add -f bpm.bin -n boot_policy_manifest.bin -t raw -a 16\n"
77 @printf "$$ ifittool -r COREBOOT -a -n boot_policy_manifest.bin -t 12 -s 12 -f build/coreboot.rom\n"
78else
Arthur Heymans53164ba2021-05-06 11:15:32 +020079$(obj)/bpm.bin: $(obj)/bpm_unsigned.bin $(CBNT_PROV) $(call strip_quotes, $(CONFIG_INTEL_CBNT_BPM_PRIV_KEY_FILE))
80 printf " CBNT_PROV signing real BPM\n"
81 $(CBNT_PROV) bpm-sign $< $@ $(CONFIG_INTEL_CBNT_BPM_PRIV_KEY_FILE) ""
Arthur Heymans15412c02021-02-08 22:38:40 +010082
83# Add BPM at the end of the build when all files have been added
84files_added:: $(obj)/bpm.bin
85 printf " CBNT Adding BPM\n"
86 $(CBFSTOOL) $(obj)/coreboot.rom add -f $< -n boot_policy_manifest.bin -a 0x10 -t raw
87 printf " IFITTOOL Adding BPM\n"
88 $(IFITTOOL) -r COREBOOT -a -n boot_policy_manifest.bin -t 12 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -f $(obj)/coreboot.rom
89
Arthur Heymans6362df32021-03-17 12:23:20 +010090endif # CONFIG_INTEL_CBNT_BPM_ONLY_UNSIGNED
91
Arthur Heymans15412c02021-02-08 22:38:40 +010092else # CONFIG_INTEL_CBNT_GENERATE_BPM
Arthur Heymans6362df32021-03-17 12:23:20 +010093
Arthur Heymans94fe0862020-10-15 13:57:52 +020094ifneq ($(CONFIG_INTEL_CBNT_BOOT_POLICY_MANIFEST_BINARY),"")
95cbfs-files-y += boot_policy_manifest.bin
96boot_policy_manifest.bin-file := $(CONFIG_INTEL_CBNT_BOOT_POLICY_MANIFEST_BINARY)
97boot_policy_manifest.bin-type := raw
98boot_policy_manifest.bin-align := 0x10
99
Arthur Heymanseeacd832021-02-19 17:14:23 +0100100$(call add_intermediate, add_bpm_fit, $(IFITTOOL) set_fit_ptr)
Arthur Heymans94fe0862020-10-15 13:57:52 +0200101 $(IFITTOOL) -r COREBOOT -a -n boot_policy_manifest.bin -t 12 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -f $<
102endif
Arthur Heymans15412c02021-02-08 22:38:40 +0100103endif # CONFIG_INTEL_CBNT_GENERATE_BPM
Arthur Heymans94fe0862020-10-15 13:57:52 +0200104
Arthur Heymans2ef2e472021-02-08 14:28:03 +0100105ifeq ($(CONFIG_INTEL_CBNT_GENERATE_KM),y)
Arthur Heymans53164ba2021-05-06 11:15:32 +0200106ifeq ($(CONFIG_INTEL_CBNT_CBNT_PROV_KM_USE_CFG_FILE),y)
107$(obj)/km_unsigned.bin: $(obj)/km_pub.pem $(CBNT_PROV) $(CBNT_CFG)
108 printf " CBNT_PROV creating unsigned KM using config file\n"
109 $(CBNT_PROV) km-gen $@ $< --config=$(CBNT_CFG)
Arthur Heymans05143242021-02-08 19:41:23 +0100110else
Arthur Heymans53164ba2021-05-06 11:15:32 +0200111$(obj)/km_unsigned.bin: $(obj)/km_pub.pem $(obj)/bpm_pub.pem $(CBNT_PROV)
112 printf " CBNT_PROV creating unsigned KM\n"
113 $(CBNT_PROV) km-gen $@ $< --revision=$(CONFIG_INTEL_CBNT_KM_REVISION) \
Arthur Heymans05143242021-02-08 19:41:23 +0100114 --svn=$(CONFIG_INTEL_CBNT_KM_SVN) \
115 --id=$(CONFIG_INTEL_CBNT_KM_ID) \
116 --pkhashalg=$(PK_HASH_ALG_SHA256) \
117 --bpmpubkey=$(obj)/bpm_pub.pem \
118 --bpmhashalgo=$(PK_HASH_ALG_SHA256) \
119 --out=$(obj)/km_cfg.json
120endif
Arthur Heymans2ef2e472021-02-08 14:28:03 +0100121
Arthur Heymans53164ba2021-05-06 11:15:32 +0200122$(obj)/km.bin: $(obj)/km_unsigned.bin $(CBNT_PROV) $(call strip_quotes, $(CONFIG_INTEL_CBNT_KM_PRIV_KEY_FILE))
123 printf " CBNT_PROV signing KM\n"
124 $(CBNT_PROV) km-sign $< $@ $(CONFIG_INTEL_CBNT_KM_PRIV_KEY_FILE) ""
Arthur Heymans2ef2e472021-02-08 14:28:03 +0100125
126KM_FILE=$(obj)/km.bin
127else
128KM_FILE=$(CONFIG_INTEL_CBNT_KEY_MANIFEST_BINARY)
129endif
130
131ifneq ($(KM_FILE),"")
Arthur Heymans5e0119e2021-03-17 12:03:39 +0100132ifeq ($(CONFIG_INTEL_CBNT_KM_ONLY_UNSIGNED),y)
133$(call add_intermediate, gen_unsigned_km, $(obj)/km_unsigned.bin)
134 @printf "Generating unsgined KM\n"
135
136build_complete::
137 @printf "\n** WARNING **\n"
138 @printf "Build generated an unsigned KM image: build/km_unsiged.bin.\n"
139 @printf "The resulting image will not work with CBnT.\n"
140 @printf "After you have externally signed the image you can add it to the coreboot image:\n"
141 @printf "$$ cbfstool build/coreboot.rom add -f km.bin -n key_manifest.bin -t raw -a 16\n"
142 @printf "$$ ifittool -r COREBOOT -a -n key_manifest.bin -t 11 -s 12 -f build/coreboot.rom\n"
143
144else
Arthur Heymans94fe0862020-10-15 13:57:52 +0200145cbfs-files-y += key_manifest.bin
Arthur Heymans2ef2e472021-02-08 14:28:03 +0100146key_manifest.bin-file := $(KM_FILE)
Arthur Heymans94fe0862020-10-15 13:57:52 +0200147key_manifest.bin-type := raw
148key_manifest.bin-align := 0x10
149
Arthur Heymanseeacd832021-02-19 17:14:23 +0100150$(call add_intermediate, add_km_fit, $(IFITTOOL) set_fit_ptr)
Arthur Heymans94fe0862020-10-15 13:57:52 +0200151 $(IFITTOOL) -r COREBOOT -a -n key_manifest.bin -t 11 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -f $<
152endif
153
Arthur Heymans5e0119e2021-03-17 12:03:39 +0100154endif # CONFIG_INTEL_CBNT_KM_ONLY_UNSIGNED
Arthur Heymans94fe0862020-10-15 13:57:52 +0200155endif # CONFIG_INTEL_CBNT_SUPPORT