Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 1 | ifeq ($(CONFIG_INTEL_CBNT_SUPPORT),y) |
| 2 | |
Arthur Heymans | ee55d71 | 2021-05-12 16:22:05 +0200 | [diff] [blame] | 3 | all-y += logging.c |
Arthur Heymans | 2390754 | 2021-03-16 19:28:50 +0100 | [diff] [blame] | 4 | ramstage-y += cmos.c |
| 5 | |
Arthur Heymans | 8b91c9f | 2021-03-31 12:21:32 +0200 | [diff] [blame] | 6 | # As specified in Intel Trusted Execution Technology and Boot Guard Server BIOS |
| 7 | # Specification, document number # 558294 |
| 8 | PK_HASH_ALG_SHA1:=4 |
| 9 | PK_HASH_ALG_SHA256:=11 |
| 10 | PK_HASH_ALG_SHA384:=12 |
| 11 | |
Arthur Heymans | 21176dd | 2021-03-17 15:33:26 +0100 | [diff] [blame] | 12 | # The private key also contains the public key, so use that if a private key is provided. |
| 13 | ifeq ($(CONFIG_INTEL_CBNT_NEED_KM_PRIV_KEY),y) |
| 14 | $(obj)/km_pub.pem: $(call strip_quotes, $(CONFIG_INTEL_CBNT_KM_PRIV_KEY_FILE)) |
| 15 | openssl pkey -in $< -pubout > $@ |
| 16 | else ifeq ($(CONFIG_INTEL_CBNT_NEED_KM_PUB_KEY),y) |
| 17 | $(obj)/km_pub.pem: $(call strip_quotes, $(CONFIG_INTEL_CBNT_KM_PUB_KEY_FILE)) |
| 18 | cp $< $@ |
| 19 | endif |
| 20 | |
| 21 | # The private key also contains the public key, so use that if a private key is provided. |
| 22 | ifeq ($(CONFIG_INTEL_CBNT_NEED_BPM_PRIV_KEY),y) |
| 23 | $(obj)/bpm_pub.pem: $(call strip_quotes, $(CONFIG_INTEL_CBNT_BPM_PRIV_KEY_FILE)) |
| 24 | openssl pkey -in $< -pubout > $@ |
| 25 | else ifeq ($(CONFIG_INTEL_CBNT_NEED_BPM_PUB_KEY),y) |
| 26 | $(obj)/bpm_pub.pem: $(call strip_quotes, $(CONFIG_INTEL_CBNT_BPM_PUB_KEY_FILE)) |
| 27 | cp $< $@ |
| 28 | endif |
| 29 | |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 30 | CBNT_PROV:=$(obj)/cbnt-prov |
Arthur Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 31 | CBNT_CFG:=$(obj)/cbnt.json |
| 32 | |
Arthur Heymans | 0250a78 | 2021-03-31 16:54:37 +0200 | [diff] [blame] | 33 | ifneq ($(CONFIG_INTEL_CBNT_PROV_EXTERNAL_BIN),y) |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 34 | $(CBNT_PROV): |
| 35 | printf " CBNT_PROV building tool\n" |
Arthur Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 36 | cd 3rdparty/intel-sec-tools; \ |
| 37 | GO111MODULE=on go mod download; \ |
| 38 | GO111MODULE=on go mod verify; \ |
Arthur Heymans | e76aac6 | 2021-06-18 09:40:31 +0200 | [diff] [blame] | 39 | GO111MODULE=on go build -o $(abspath $@) cmd/cbnt-prov/*.go |
Arthur Heymans | 0250a78 | 2021-03-31 16:54:37 +0200 | [diff] [blame] | 40 | else |
| 41 | $(CBNT_PROV): $(call strip_quotes, $(CONFIG_INTEL_CBNT_PROV_EXTERNAL_BIN_PATH)) |
| 42 | cp $< $@ |
| 43 | endif |
Arthur Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 44 | |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 45 | $(CBNT_CFG): $(call strip_quotes, $(CONFIG_INTEL_CBNT_CBNT_PROV_CFG_FILE)) |
| 46 | cp $(CONFIG_INTEL_CBNT_CBNT_PROV_CFG_FILE) $@ |
Arthur Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 47 | |
Arthur Heymans | 15412c0 | 2021-02-08 22:38:40 +0100 | [diff] [blame] | 48 | ifeq ($(CONFIG_INTEL_CBNT_GENERATE_BPM),y) |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 49 | ifeq ($(CONFIG_INTEL_CBNT_CBNT_PROV_BPM_USE_CFG_FILE),y) |
| 50 | $(obj)/bpm_unsigned.bin: $(obj)/coreboot.rom $(CBNT_PROV) $(CBNT_CFG) |
| 51 | printf " CBNT_PROV creating unsigned BPM using config file\n" |
| 52 | $(CBNT_PROV) bpm-gen $@ $< --config=$(CBNT_CFG) --cut |
Arthur Heymans | 3d5319e | 2021-02-19 19:39:56 +0100 | [diff] [blame] | 53 | else |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 54 | $(obj)/bpm_unsigned.bin: $(obj)/coreboot.rom $(CBNT_PROV) |
| 55 | printf " CBNT_PROV creating unsigned BPM\n" |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 56 | $(CBNT_PROV) bpm-gen $@ $< --revision=$(CONFIG_INTEL_CBNT_BPM_REVISION) \ |
Arthur Heymans | 3d5319e | 2021-02-19 19:39:56 +0100 | [diff] [blame] | 57 | --svn=$(CONFIG_INTEL_CBNT_BPM_SVN) \ |
| 58 | --acmsvn=$(CONFIG_INTEL_CBNT_ACM_SVN) \ |
| 59 | --nems=$(CONFIG_INTEL_CBNT_NUM_NEM_PAGES) \ |
| 60 | --pbet=$(CONFIG_INTEL_CBNT_PBET) \ |
| 61 | --ibbflags=$(CONFIG_INTEL_CBNT_IBB_FLAGS) \ |
| 62 | --entrypoint=$(shell printf "%d" 0xfffffff0) \ |
Arthur Heymans | 8b91c9f | 2021-03-31 12:21:32 +0200 | [diff] [blame] | 63 | --ibbhash=$(PK_HASH_ALG_SHA256),$(PK_HASH_ALG_SHA1),$(PK_HASH_ALG_SHA384) \ |
Arthur Heymans | f69cece | 2021-05-04 08:15:22 +0200 | [diff] [blame] | 64 | --sinitmin=$(CONFIG_INTEL_CBNT_SINIT_SVN) \ |
Arthur Heymans | 3d5319e | 2021-02-19 19:39:56 +0100 | [diff] [blame] | 65 | --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 |
| 73 | endif |
Arthur Heymans | 15412c0 | 2021-02-08 22:38:40 +0100 | [diff] [blame] | 74 | |
Arthur Heymans | 6362df3 | 2021-03-17 12:23:20 +0100 | [diff] [blame] | 75 | ifeq ($(CONFIG_INTEL_CBNT_BPM_ONLY_UNSIGNED),y) |
| 76 | build_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" |
| 83 | else |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 84 | $(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 Heymans | 15412c0 | 2021-02-08 22:38:40 +0100 | [diff] [blame] | 87 | |
| 88 | # Add BPM at the end of the build when all files have been added |
Arthur Heymans | 95761c5 | 2021-07-06 12:26:41 +0200 | [diff] [blame] | 89 | files_added:: $(obj)/bpm.bin $(IFITTOOL) |
Arthur Heymans | 15412c0 | 2021-02-08 22:38:40 +0100 | [diff] [blame] | 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 Heymans | 6362df3 | 2021-03-17 12:23:20 +0100 | [diff] [blame] | 95 | endif # CONFIG_INTEL_CBNT_BPM_ONLY_UNSIGNED |
| 96 | |
Arthur Heymans | 15412c0 | 2021-02-08 22:38:40 +0100 | [diff] [blame] | 97 | else # CONFIG_INTEL_CBNT_GENERATE_BPM |
Arthur Heymans | 6362df3 | 2021-03-17 12:23:20 +0100 | [diff] [blame] | 98 | |
Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 99 | ifneq ($(CONFIG_INTEL_CBNT_BOOT_POLICY_MANIFEST_BINARY),"") |
| 100 | cbfs-files-y += boot_policy_manifest.bin |
| 101 | boot_policy_manifest.bin-file := $(CONFIG_INTEL_CBNT_BOOT_POLICY_MANIFEST_BINARY) |
| 102 | boot_policy_manifest.bin-type := raw |
| 103 | boot_policy_manifest.bin-align := 0x10 |
| 104 | |
Arthur Heymans | eeacd83 | 2021-02-19 17:14:23 +0100 | [diff] [blame] | 105 | $(call add_intermediate, add_bpm_fit, $(IFITTOOL) set_fit_ptr) |
Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 106 | $(IFITTOOL) -r COREBOOT -a -n boot_policy_manifest.bin -t 12 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -f $< |
| 107 | endif |
Arthur Heymans | 15412c0 | 2021-02-08 22:38:40 +0100 | [diff] [blame] | 108 | endif # CONFIG_INTEL_CBNT_GENERATE_BPM |
Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 109 | |
Arthur Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 110 | ifeq ($(CONFIG_INTEL_CBNT_GENERATE_KM),y) |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 111 | ifeq ($(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 Heymans | 0514324 | 2021-02-08 19:41:23 +0100 | [diff] [blame] | 115 | else |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 116 | $(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 Heymans | 0514324 | 2021-02-08 19:41:23 +0100 | [diff] [blame] | 119 | --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 |
| 125 | endif |
Arthur Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 126 | |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 127 | $(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 Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 130 | |
| 131 | KM_FILE=$(obj)/km.bin |
| 132 | else |
| 133 | KM_FILE=$(CONFIG_INTEL_CBNT_KEY_MANIFEST_BINARY) |
| 134 | endif |
| 135 | |
| 136 | ifneq ($(KM_FILE),"") |
Arthur Heymans | 5e0119e | 2021-03-17 12:03:39 +0100 | [diff] [blame] | 137 | ifeq ($(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 | |
| 141 | build_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 | |
| 149 | else |
Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 150 | cbfs-files-y += key_manifest.bin |
Arthur Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 151 | key_manifest.bin-file := $(KM_FILE) |
Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 152 | key_manifest.bin-type := raw |
| 153 | key_manifest.bin-align := 0x10 |
| 154 | |
Arthur Heymans | eeacd83 | 2021-02-19 17:14:23 +0100 | [diff] [blame] | 155 | $(call add_intermediate, add_km_fit, $(IFITTOOL) set_fit_ptr) |
Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 156 | $(IFITTOOL) -r COREBOOT -a -n key_manifest.bin -t 11 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -f $< |
| 157 | endif |
| 158 | |
Arthur Heymans | 5e0119e | 2021-03-17 12:03:39 +0100 | [diff] [blame] | 159 | endif # CONFIG_INTEL_CBNT_KM_ONLY_UNSIGNED |
Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 160 | endif # CONFIG_INTEL_CBNT_SUPPORT |