Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 1 | ifeq ($(CONFIG_INTEL_CBNT_SUPPORT),y) |
| 2 | |
Arthur Heymans | 2390754 | 2021-03-16 19:28:50 +0100 | [diff] [blame] | 3 | ramstage-y += cmos.c |
| 4 | |
Arthur Heymans | 8b91c9f | 2021-03-31 12:21:32 +0200 | [diff] [blame^] | 5 | # As specified in Intel Trusted Execution Technology and Boot Guard Server BIOS |
| 6 | # Specification, document number # 558294 |
| 7 | PK_HASH_ALG_SHA1:=4 |
| 8 | PK_HASH_ALG_SHA256:=11 |
| 9 | PK_HASH_ALG_SHA384:=12 |
| 10 | |
Arthur Heymans | 21176dd | 2021-03-17 15:33:26 +0100 | [diff] [blame] | 11 | # The private key also contains the public key, so use that if a private key is provided. |
| 12 | ifeq ($(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 > $@ |
| 15 | else 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 $< $@ |
| 18 | endif |
| 19 | |
| 20 | # The private key also contains the public key, so use that if a private key is provided. |
| 21 | ifeq ($(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 > $@ |
| 24 | else 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 $< $@ |
| 27 | endif |
| 28 | |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 29 | CBNT_PROV:=$(obj)/cbnt-prov |
Arthur Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 30 | CBNT_CFG:=$(obj)/cbnt.json |
| 31 | |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 32 | $(CBNT_PROV): |
| 33 | printf " CBNT_PROV building tool\n" |
Arthur Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 34 | cd 3rdparty/intel-sec-tools; \ |
| 35 | GO111MODULE=on go mod download; \ |
| 36 | GO111MODULE=on go mod verify; \ |
Arthur Heymans | f69cece | 2021-05-04 08:15:22 +0200 | [diff] [blame] | 37 | GO111MODULE=on go build -o $(top)/$@ cmd/cbnt-prov/*.go |
Arthur Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 38 | |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 39 | $(CBNT_CFG): $(call strip_quotes, $(CONFIG_INTEL_CBNT_CBNT_PROV_CFG_FILE)) |
| 40 | cp $(CONFIG_INTEL_CBNT_CBNT_PROV_CFG_FILE) $@ |
Arthur Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 41 | |
Arthur Heymans | 15412c0 | 2021-02-08 22:38:40 +0100 | [diff] [blame] | 42 | ifeq ($(CONFIG_INTEL_CBNT_GENERATE_BPM),y) |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 43 | ifeq ($(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 Heymans | 3d5319e | 2021-02-19 19:39:56 +0100 | [diff] [blame] | 47 | else |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 48 | $(obj)/bpm_unsigned.bin: $(obj)/coreboot.rom $(CBNT_PROV) |
| 49 | printf " CBNT_PROV creating unsigned BPM\n" |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 50 | $(CBNT_PROV) bpm-gen $@ $< --revision=$(CONFIG_INTEL_CBNT_BPM_REVISION) \ |
Arthur Heymans | 3d5319e | 2021-02-19 19:39:56 +0100 | [diff] [blame] | 51 | --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 Heymans | 8b91c9f | 2021-03-31 12:21:32 +0200 | [diff] [blame^] | 57 | --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] | 58 | --coreboot \ |
| 59 | --sinitmin=$(CONFIG_INTEL_CBNT_SINIT_SVN) \ |
Arthur Heymans | 3d5319e | 2021-02-19 19:39:56 +0100 | [diff] [blame] | 60 | --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 |
| 68 | endif |
Arthur Heymans | 15412c0 | 2021-02-08 22:38:40 +0100 | [diff] [blame] | 69 | |
Arthur Heymans | 6362df3 | 2021-03-17 12:23:20 +0100 | [diff] [blame] | 70 | ifeq ($(CONFIG_INTEL_CBNT_BPM_ONLY_UNSIGNED),y) |
| 71 | build_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" |
| 78 | else |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 79 | $(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 Heymans | 15412c0 | 2021-02-08 22:38:40 +0100 | [diff] [blame] | 82 | |
| 83 | # Add BPM at the end of the build when all files have been added |
| 84 | files_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 Heymans | 6362df3 | 2021-03-17 12:23:20 +0100 | [diff] [blame] | 90 | endif # CONFIG_INTEL_CBNT_BPM_ONLY_UNSIGNED |
| 91 | |
Arthur Heymans | 15412c0 | 2021-02-08 22:38:40 +0100 | [diff] [blame] | 92 | else # CONFIG_INTEL_CBNT_GENERATE_BPM |
Arthur Heymans | 6362df3 | 2021-03-17 12:23:20 +0100 | [diff] [blame] | 93 | |
Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 94 | ifneq ($(CONFIG_INTEL_CBNT_BOOT_POLICY_MANIFEST_BINARY),"") |
| 95 | cbfs-files-y += boot_policy_manifest.bin |
| 96 | boot_policy_manifest.bin-file := $(CONFIG_INTEL_CBNT_BOOT_POLICY_MANIFEST_BINARY) |
| 97 | boot_policy_manifest.bin-type := raw |
| 98 | boot_policy_manifest.bin-align := 0x10 |
| 99 | |
Arthur Heymans | eeacd83 | 2021-02-19 17:14:23 +0100 | [diff] [blame] | 100 | $(call add_intermediate, add_bpm_fit, $(IFITTOOL) set_fit_ptr) |
Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 101 | $(IFITTOOL) -r COREBOOT -a -n boot_policy_manifest.bin -t 12 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -f $< |
| 102 | endif |
Arthur Heymans | 15412c0 | 2021-02-08 22:38:40 +0100 | [diff] [blame] | 103 | endif # CONFIG_INTEL_CBNT_GENERATE_BPM |
Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 104 | |
Arthur Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 105 | ifeq ($(CONFIG_INTEL_CBNT_GENERATE_KM),y) |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 106 | ifeq ($(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 Heymans | 0514324 | 2021-02-08 19:41:23 +0100 | [diff] [blame] | 110 | else |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 111 | $(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 Heymans | 0514324 | 2021-02-08 19:41:23 +0100 | [diff] [blame] | 114 | --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 |
| 120 | endif |
Arthur Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 121 | |
Arthur Heymans | 53164ba | 2021-05-06 11:15:32 +0200 | [diff] [blame] | 122 | $(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 Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 125 | |
| 126 | KM_FILE=$(obj)/km.bin |
| 127 | else |
| 128 | KM_FILE=$(CONFIG_INTEL_CBNT_KEY_MANIFEST_BINARY) |
| 129 | endif |
| 130 | |
| 131 | ifneq ($(KM_FILE),"") |
Arthur Heymans | 5e0119e | 2021-03-17 12:03:39 +0100 | [diff] [blame] | 132 | ifeq ($(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 | |
| 136 | build_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 | |
| 144 | else |
Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 145 | cbfs-files-y += key_manifest.bin |
Arthur Heymans | 2ef2e47 | 2021-02-08 14:28:03 +0100 | [diff] [blame] | 146 | key_manifest.bin-file := $(KM_FILE) |
Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 147 | key_manifest.bin-type := raw |
| 148 | key_manifest.bin-align := 0x10 |
| 149 | |
Arthur Heymans | eeacd83 | 2021-02-19 17:14:23 +0100 | [diff] [blame] | 150 | $(call add_intermediate, add_km_fit, $(IFITTOOL) set_fit_ptr) |
Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 151 | $(IFITTOOL) -r COREBOOT -a -n key_manifest.bin -t 11 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -f $< |
| 152 | endif |
| 153 | |
Arthur Heymans | 5e0119e | 2021-03-17 12:03:39 +0100 | [diff] [blame] | 154 | endif # CONFIG_INTEL_CBNT_KM_ONLY_UNSIGNED |
Arthur Heymans | 94fe086 | 2020-10-15 13:57:52 +0200 | [diff] [blame] | 155 | endif # CONFIG_INTEL_CBNT_SUPPORT |