Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measured boot for KGPE-D16 not working #740

Closed
Tonux599 opened this issue Jun 6, 2020 · 15 comments
Closed

Measured boot for KGPE-D16 not working #740

Tonux599 opened this issue Jun 6, 2020 · 15 comments

Comments

@Tonux599
Copy link
Contributor

Tonux599 commented Jun 6, 2020

Setting 'CONFIG_MEASURED_BOOT=y' in this boards config causes it to fail to build with the error below. Currently with a compatible TPM module only PCRs 4 and 7 are populated meaning that the boot block, ROM stage, RAM stage and the kernel/initrd are not measured and as such, the TPMTOTP will not reflect any changes.

tail /home/user/tonux599-heads/build/log/coreboot.log
-----
    CC         ramstage/southbridge/amd/sb700/pci.o
    CC         ramstage/southbridge/amd/sb700/ramtop.o
    CC         ramstage/southbridge/amd/sb700/reset.o
    CC         ramstage/southbridge/amd/sb700/sata.o
    CC         ramstage/southbridge/amd/sb700/sb700.o
    CC         ramstage/southbridge/amd/sb700/sm.o
    CC         ramstage/southbridge/amd/sb700/smbus.o
    CC         ramstage/southbridge/amd/sb700/spi.o
    CC         ramstage/southbridge/amd/sb700/usb.o
    CC         ramstage/security/tpm/tss/tcg-2.0/tss.o
src/security/tpm/tss/tcg-2.0/tss.c:309:10: error: conflicting types for 'tlcl_define_space'
 uint32_t tlcl_define_space(uint32_t space_index, size_t space_size)
          ^~~~~~~~~~~~~~~~~
In file included from src/security/tpm/tss/tcg-2.0/tss_structures.h:18,
                 from src/security/tpm/tss/tcg-2.0/tss.c:15:
src/security/tpm/tss.h:65:10: note: previous declaration of 'tlcl_define_space' was here
 uint32_t tlcl_define_space(uint32_t index, uint32_t perm, uint32_t size);
          ^~~~~~~~~~~~~~~~~
make[1]: *** [Makefile:356: kgpe-d16-workstation-nouveau/ramstage/security/tpm/tss/tcg-2.0/tss.o] Error 1
@Tonux599
Copy link
Contributor Author

Tonux599 commented Jun 6, 2020

Looking in ramstage/security/tpm/tss/ shows folders tcg-1.2 and tcg-2.0 which I'm assuming relates to TPM1.2 & TPM2.0. The build is failing when dealing with the TPM2.0 folder so just need to stop it from doing that as only TPM1.2 is supported anyway. @flawedworld I noticed in #442 looks very similar to this. Any tips?

@Tonux599
Copy link
Contributor Author

Tonux599 commented Jun 6, 2020

Commenting out select TPM2 in the boards Kconfig gives a successful build. Will test and report back.
Edit: ROM works but PCRs 0-3 not populated. Measured boot still not functional.

@flawedworld
Copy link
Contributor

@Tonux599 The solution for T430 was to backport the TPM - see 5a033fa

@tlaurion
Copy link
Collaborator

tlaurion commented Jun 7, 2020

Commenting out select TPM2 in the boards Kconfig gives a successful build. Will test and report back.
Edit: ROM works but PCRs 0-3 not populated. Measured boot still not functional.

@Tonux599 gave the most love I could to #472 . Would love to hear your findings for TPM 1.2 support. Buying a module myself now.

@Tonux599
Copy link
Contributor Author

Tonux599 commented Jun 8, 2020

CBMEM log reveals a bit, TPM is initialised okay. Its when PCRs are extended that it fails. See below.

TPM initialization.
TPM: Init
Found TPM SLB9635 TT 1.2 by Infineon
TPM: Open
TPM: Startup
TPM: command 0x99 returned 0x0
TPM: OK.
TPM: pcr 3 measure ff02b338 @ 3524: a1615718de98d6d619812c6b9fd3c3f5177bc137
src/drivers/pc80/tpm/tis.c:515 unexpected TPM status 0xff
src/drivers/pc80/tpm/tis.c:711 failed sending data to TPM
TPM: command 0x14 send/receive failed: 0x10000001

@tlaurion this is going out my expertise a bit so if you have any input or know anyone please tag :)

@tlaurion
Copy link
Collaborator

tlaurion commented Jun 9, 2020

@Tonux599 please link your branch so I can review. Intuition is that coreboot config being at fault.

@Tonux599
Copy link
Contributor Author

Tonux599 commented Jun 9, 2020

@Tonux599 please link your branch so I can review. Intuition is that coreboot config being at fault.

This branch outlines my current efforts. Thanks @tlaurion

@tlaurion
Copy link
Collaborator

tlaurion commented Jun 9, 2020

@tlaurion is TPM on stock? will try to search again it

@0rb677 https://www.ebay.ca/itm/Asus-TPM-Module-20-pin-1-02G-ver-1-2-compatible/114247958589 is what I bought, delivered before end of June.

@tlaurion
Copy link
Collaborator

tlaurion commented Jun 9, 2020

@Tonux599 #712 (comment)

@Tonux599
Copy link
Contributor Author

Tonux599 commented Jun 9, 2020

@tlaurion just a heads up the module I use is 1.02H, not sure if there is any difference.
Bit more info in cbmem from setting CONFIG_DEBUG_TPM=y, see below. Thought: can PCRs be different sizes on different modules? I'm wondering if the sha1 sum is too big to fit in the PCR.

TPM initialization.
TPM: Init
lpc_tpm: Read reg 0xf00 returns 0xb15d1
Found TPM SLB9635 TT 1.2 by Infineon
TPM: Open
lpc_tpm: Read reg 0x0 returns 0x81
lpc_tpm: Write reg 0x0 with 0x2
lpc_tpm: Read reg 0x0 returns 0xa1
lpc_tpm: Write reg 0x18 with 0x40
lpc_tpm: Read reg 0x18 returns 0x40
TPM: Startup
lpc_tpm: Read reg 0x18 returns 0x40
lpc_tpm: Read reg 0x19 returns 0x8
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0xc1
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0xc
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Read reg 0x18 returns 0x8
lpc_tpm: Read reg 0x18 returns 0x88
lpc_tpm: Read reg 0x18 returns 0x88
lpc_tpm: Read reg 0x19 returns 0x8
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0x99
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Read reg 0x18 returns 0x8
lpc_tpm: Read reg 0x18 returns 0x88
lpc_tpm: Read reg 0x18 returns 0x88
lpc_tpm: Read reg 0x19 returns 0x8
lpc_tpm: Write reg 0x18 with 0x1
lpc_tpm: Read reg 0x18 returns 0x8
lpc_tpm: Read reg 0x18 returns 0x80
lpc_tpm: Read reg 0x18 returns 0x80
lpc_tpm: Write reg 0x18 with 0x20
lpc_tpm: Read reg 0x18 returns 0x80
lpc_tpm: Read reg 0x18 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x90
lpc_tpm: Read reg 0x19 returns 0x8
lpc_tpm: Read reg 0x24 returns 0x0
lpc_tpm: Read reg 0x24 returns 0xc4
lpc_tpm: Read reg 0x24 returns 0x0
lpc_tpm: Read reg 0x24 returns 0x0
lpc_tpm: Read reg 0x24 returns 0x0
lpc_tpm: Read reg 0x24 returns 0xa
lpc_tpm: Read reg 0x24 returns 0x0
lpc_tpm: Read reg 0x24 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x90
lpc_tpm: Read reg 0x18 returns 0x90
lpc_tpm: Read reg 0x19 returns 0x2
lpc_tpm: Read reg 0x24 returns 0x0
lpc_tpm: Read reg 0x24 returns 0x0
lpc_tpm: Read reg 0x18 returns 0x80
lpc_tpm: Read reg 0x18 returns 0x80
lpc_tpm: Write reg 0x18 with 0x40
lpc_tpm: Read reg 0x18 returns 0x80
lpc_tpm: Write reg 0x18 with 0x40
lpc_tpm: Read reg 0x18 returns 0x40
TPM: command 0x99 returned 0x0
lpc_tpm: Read reg 0x0 returns 0xa1
lpc_tpm: Write reg 0x0 with 0x20
lpc_tpm: Read reg 0x0 returns 0x81
TPM: OK.
TPM: pcr 3 measure ff02b578 @ 3524: a1615718de98d6d619812c6b9fd3c3f5177bc137
lpc_tpm: Read reg 0x18 returns 0xff
lpc_tpm: Read reg 0x19 returns 0xffff
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0xc1
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0x22
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0x14
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0x0
lpc_tpm: Write reg 0x18 with 0x3
lpc_tpm: Write reg 0x18 with 0xa1
lpc_tpm: Write reg 0x18 with 0x61
lpc_tpm: Write reg 0x18 with 0x57
lpc_tpm: Write reg 0x18 with 0x18
lpc_tpm: Write reg 0x18 with 0xde
lpc_tpm: Write reg 0x18 with 0x98
lpc_tpm: Write reg 0x18 with 0xd6
lpc_tpm: Write reg 0x18 with 0xd6
lpc_tpm: Write reg 0x18 with 0x19
lpc_tpm: Write reg 0x18 with 0x81
lpc_tpm: Write reg 0x18 with 0x2c
lpc_tpm: Write reg 0x18 with 0x6b
lpc_tpm: Write reg 0x18 with 0x9f
lpc_tpm: Write reg 0x18 with 0xd3
lpc_tpm: Write reg 0x18 with 0xc3
lpc_tpm: Write reg 0x18 with 0xf5
lpc_tpm: Write reg 0x18 with 0x17
lpc_tpm: Write reg 0x18 with 0x7b
lpc_tpm: Write reg 0x18 with 0xc1
lpc_tpm: Read reg 0x18 returns 0xff
lpc_tpm: Read reg 0x18 returns 0xff
lpc_tpm: Read reg 0x19 returns 0xffff
lpc_tpm: Write reg 0x18 with 0x37
lpc_tpm: Read reg 0x18 returns 0xff
lpc_tpm: Read reg 0x18 returns 0xff
lpc_tpm: Read reg 0x18 returns 0xff
src/drivers/pc80/tpm/tis.c:515 unexpected TPM status 0xff
src/drivers/pc80/tpm/tis.c:711 failed sending data to TPM
TPM: command 0x14 send/receive failed: 0x10000001

@Tonux599
Copy link
Contributor Author

Tonux599 commented Jun 9, 2020

From #712

Ordered the TPM 1.2 module off of ebay and should receive it prior of end of June. Will get back at #740 once received, but haven't seen any coreboot changes in the config there for infineon support? Maybe I missed it.

Will investigate however from casual looking it looks like there shouldn't be any additional options to support infineon TPM as I assume that all comply with the same standard.

@ghost
Copy link

ghost commented Jun 11, 2020

@tlaurion is TPM on stock? will try to search again it

@0rb677 https://www.ebay.ca/itm/Asus-TPM-Module-20-pin-1-02G-ver-1-2-compatible/114247958589 is what I bought, delivered before end of June.

@tlaurion Bought it too.

Estimated delivery:  Sun, Jun 28–Wed, Jul 15

@tlaurion
Copy link
Collaborator

tlaurion commented Aug 6, 2020

@Tonux599 #472 (comment)

@tlaurion
Copy link
Collaborator

tlaurion commented Aug 7, 2020

Seems like it would be possible to exclude mrc from measurements in coreboot config linked to a board.

Tonux599 pushed a commit to Tonux599/heads that referenced this issue Nov 28, 2020
Changing CONFIG_USB_BOOT_DEV to sdc1, adding back CONFIG_BOOT_STATIC_IP to 192.168.2.3, adding dual console to OpenBMC and tty0 in attempt to have QubesOS graphic installer which complains with no networking when attempting to start VNC

Adding dual console to OpenBmc and tty0

putting kgpe-d16-coreboot.conf in defconfig format

NO_HZ wasn't included in kernel config. Adding it.

Wasn't able to have both console firing up QubesOS gui installer, complaining about hvc1 console errors. Splitting up Workstation and server config. This one works for Worstation

Removing serial configuration and static IP stuff since we have a workstation here.

Seperate Workstation and Server board configurations until dual console truely works through QubesOS gui installation. kgpe-d16 board config removed until then.

Placing files in good directories

Corrrect flashrom options for kgpe-d16 server and workstation boards

kgpe-d16 linux: NO_HZ_IDLE instead of NO_HZ

kgpe-d16: seperate board for workstation to be AST and gui-init based, while kgpe-d16-> kgpe-d16_server

kgpe-d16_server: boots, shows ASpeed text on VGA, controllable through BMC via SSH.

kgpe-d16_workstation on ASpeed console. WIP. (Includes CIs configs to build server and workstation)

kgpe-d16_workstation in defconfig format

kgpe-d16 boards: pass from GPG to GPG2 board definitions

kgpe-d16_workstation : Adding Cairo and FbWhpitail in board config for gui-init to work in FB mode

kgpe-d16: removing plymouth.ignore-serial-consoles to fix server terminal output

kgpe-d16: bring par with staging branch https://gitlab.com/tlaurion/heads/commits/kgpe-d16_staging

kgpe-d16 : expressively export CONFIG_TPM=n

kgpe-d16_wokstation gui-init variables were missing

kgpe-d16 boards: add CONFIG_LINUX_USB_COMPANION_CONTROLLER so that usb is recognized

linux-kgpe-d16*: add support for Pike

kgpe-d16_workstation-usb_keyboard board support addition

kgpe-d16_server-whiptail: Add board and dependencies to have gui-init in whiptail (console mode, not FbWhiptail based

GitlabCI: kgpe-d16 fixes and upstream merge of change

kgpe-d16* board: add statement to fixate coreboot version to 4.8.1 for the moment

kgpe-d16: add missing config/linux-kgpe-d16_server-whiptail.config file

KGPE-D16: community work migration to coreboot 4.11 to fix issue linuxboot#740

KGPE-D16 boards: Adding VBOOT+measured boot, musl-cross patch and 4.11 patch brought up per linuxboot#709

kgpe-d16* boards: add VBOOT Kconfig patch per @miczyg1 recommendation under linuxboot#795 (comment)

KGPE-D16* coreboot configs: Add S3NV as a Runtime data whitelist (so that it is not measured at term) per @miczyg1 recommendation under linuxboot#795 (comment)

kgpe-d16 coreboot 4.11: add https://review.coreboot.org/c/coreboot/+/36908 patch

kgpe-d16 boards: add Linux kernel version where missing.

CircleCI: Add debug output on fail for kgpe-d16 board builds to bring par with upstream after rebasing on master

coreboot module: typo correction (tabs vs spaces)

CircleCI: trying to address "g++: fatal error: Killed signal terminated program cc1plus." happening under coreboot 4.11 and coreboot 4.12 builds

CircleCI: remove past addition to test recommendation from CircleCI: "resource_class: large"

CircleCi: Ok.... lets output dmesg content prior of other logs.... I'm out of ideas. Next step, ask CircleCI for support

At this stage:
- job's "make --load" is supposed to guarantee that the number of thread doesn't exhaust pass of a load of 2 (medium, free class, CircleCI has 32 cores so possibility of a load of 32)
- "--max_old_space_size=4096" in CircleCI environement is supposed to limit memory consumption to 4096Mb of memory, the max of a medium class free tier CircleCI node

CircleCI: remove verbose build (no more V=1), in case of failed build, find all logs modified in last minute and output each of them on console.

coreboot module: implement load average respect inside of problematic CI build for coreboot 4.11+ being killed in the action (32 cores with 4Gb ram get gcc OOM)

coreboot module: replace nproc by number of Gb actually available as number of CPUs, since each thread is expected to have 1Gb of ram.

CircleCI & coreboot config: fix merge conflict rebasing on master

coreboot 4.11 kgpe-d16 vboot patches addendum, credits goes to @Tonux599

Fix merge conflicts and make sure all boards are inside of CircleCI builds. PoC build for linuxboot#867
Tonux599 pushed a commit to Tonux599/heads that referenced this issue Dec 2, 2020
Changing CONFIG_USB_BOOT_DEV to sdc1, adding back CONFIG_BOOT_STATIC_IP to 192.168.2.3, adding dual console to OpenBMC and tty0 in attempt to have QubesOS graphic installer which complains with no networking when attempting to start VNC

Adding dual console to OpenBmc and tty0

putting kgpe-d16-coreboot.conf in defconfig format

NO_HZ wasn't included in kernel config. Adding it.

Wasn't able to have both console firing up QubesOS gui installer, complaining about hvc1 console errors. Splitting up Workstation and server config. This one works for Worstation

Removing serial configuration and static IP stuff since we have a workstation here.

Seperate Workstation and Server board configurations until dual console truely works through QubesOS gui installation. kgpe-d16 board config removed until then.

Placing files in good directories

Corrrect flashrom options for kgpe-d16 server and workstation boards

kgpe-d16 linux: NO_HZ_IDLE instead of NO_HZ

kgpe-d16: seperate board for workstation to be AST and gui-init based, while kgpe-d16-> kgpe-d16_server

kgpe-d16_server: boots, shows ASpeed text on VGA, controllable through BMC via SSH.

kgpe-d16_workstation on ASpeed console. WIP. (Includes CIs configs to build server and workstation)

kgpe-d16_workstation in defconfig format

kgpe-d16 boards: pass from GPG to GPG2 board definitions

kgpe-d16_workstation : Adding Cairo and FbWhpitail in board config for gui-init to work in FB mode

kgpe-d16: removing plymouth.ignore-serial-consoles to fix server terminal output

kgpe-d16: bring par with staging branch https://gitlab.com/tlaurion/heads/commits/kgpe-d16_staging

kgpe-d16 : expressively export CONFIG_TPM=n

kgpe-d16_wokstation gui-init variables were missing

kgpe-d16 boards: add CONFIG_LINUX_USB_COMPANION_CONTROLLER so that usb is recognized

linux-kgpe-d16*: add support for Pike

kgpe-d16_workstation-usb_keyboard board support addition

kgpe-d16_server-whiptail: Add board and dependencies to have gui-init in whiptail (console mode, not FbWhiptail based

GitlabCI: kgpe-d16 fixes and upstream merge of change

kgpe-d16* board: add statement to fixate coreboot version to 4.8.1 for the moment

kgpe-d16: add missing config/linux-kgpe-d16_server-whiptail.config file

KGPE-D16: community work migration to coreboot 4.11 to fix issue linuxboot#740

KGPE-D16 boards: Adding VBOOT+measured boot, musl-cross patch and 4.11 patch brought up per linuxboot#709

kgpe-d16* boards: add VBOOT Kconfig patch per @miczyg1 recommendation under linuxboot#795 (comment)

KGPE-D16* coreboot configs: Add S3NV as a Runtime data whitelist (so that it is not measured at term) per @miczyg1 recommendation under linuxboot#795 (comment)

kgpe-d16 coreboot 4.11: add https://review.coreboot.org/c/coreboot/+/36908 patch

kgpe-d16 boards: add Linux kernel version where missing.

CircleCI: Add debug output on fail for kgpe-d16 board builds to bring par with upstream after rebasing on master

coreboot module: typo correction (tabs vs spaces)

CircleCI: trying to address "g++: fatal error: Killed signal terminated program cc1plus." happening under coreboot 4.11 and coreboot 4.12 builds

CircleCI: remove past addition to test recommendation from CircleCI: "resource_class: large"

CircleCi: Ok.... lets output dmesg content prior of other logs.... I'm out of ideas. Next step, ask CircleCI for support

At this stage:
- job's "make --load" is supposed to guarantee that the number of thread doesn't exhaust pass of a load of 2 (medium, free class, CircleCI has 32 cores so possibility of a load of 32)
- "--max_old_space_size=4096" in CircleCI environement is supposed to limit memory consumption to 4096Mb of memory, the max of a medium class free tier CircleCI node

CircleCI: remove verbose build (no more V=1), in case of failed build, find all logs modified in last minute and output each of them on console.

coreboot module: implement load average respect inside of problematic CI build for coreboot 4.11+ being killed in the action (32 cores with 4Gb ram get gcc OOM)

coreboot module: replace nproc by number of Gb actually available as number of CPUs, since each thread is expected to have 1Gb of ram.

CircleCI & coreboot config: fix merge conflict rebasing on master

coreboot 4.11 kgpe-d16 vboot patches addendum, credits goes to @Tonux599

Fix merge conflicts and make sure all boards are inside of CircleCI builds. PoC build for linuxboot#867
@Tonux599
Copy link
Contributor Author

Tonux599 commented Dec 3, 2020

Fixed with #867 which has now been merged.

@Tonux599 Tonux599 closed this as completed Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants