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

MinnowBoard MRC based support #542

Open
wants to merge 56 commits into
base: dasharo
Choose a base branch
from
Open

MinnowBoard MRC based support #542

wants to merge 56 commits into from

Conversation

miczyg1
Copy link
Contributor

@miczyg1 miczyg1 commented Jul 25, 2024

This PR adds silicon initialization not covered by native coreboot support but done in FSP. It also contains various fixes, TXE BIOS flow and CBFS_VERIFICATION integration with TXE Secure Boot on Bay Trail platform - Intel MinnowBoard Turbot.

@miczyg1 miczyg1 force-pushed the byt_fsp_parity branch 4 times, most recently from b48cbaf to f8a10ca Compare July 25, 2024 14:06
@miczyg1 miczyg1 force-pushed the byt_fsp_parity branch 2 times, most recently from 4dfd55f to 22e27c3 Compare July 26, 2024 09:59
Base automatically changed from txe_sb_tool to dasharo July 30, 2024 10:53
@miczyg1
Copy link
Contributor Author

miczyg1 commented Jul 30, 2024

Needs this to land too: Dasharo/edk2#156

src/arch/x86/smbios.c Show resolved Hide resolved
src/device/pciexp_device.c Outdated Show resolved Hide resolved
# Put the microcode right after the manifest, so it will be verified by IBB
# and accessible without walkcbfs ASM routine if CBFS_VERIFICATION is enabled.
config CPU_MICROCODE_CBFS_LOC
# These addresses will be used by BSP to locate microcode in bootblock before
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why plural? I can see only one address.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/soc/intel/baytrail/Kconfig Outdated Show resolved Hide resolved
dd if=/dev/zero of=$@ bs=5120 count=1 2> /dev/null
dd if=$< of=$@ conv=notrunc 2> /dev/null
else
key_manifest_pos = $(call int-subtract, $(CONFIG_ROM_SIZE) 0x21000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove hardcoded size. It should be possible to use something like $(CBFSTOOL) $(1) write -r MANIFESTS -f $(CONFIG_TXE_SB_KEY_MANIFEST_PATH) to get the same result.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I get it. What is wrong with the hardcoded size?

Copy link
Contributor Author

@miczyg1 miczyg1 Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh I get it, you mean to simply put the manifest using cbfstool without defining the location. but this does not guarantee that the Key Manifest will end up in the proper location. The address of Key manifest is fixed. MANIFESTS region may be placed anywhere...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krystian-hebel so should we leave the hardcoded size?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MANIFESTS region may be placed anywhere...

Then it would be better to assert that this region is properly located, than blindly dd into offset that may be outside of MANIFESTS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it would be better to assert that this region is properly located, than blindly dd into offset that may be outside of MANIFESTS.

Yes, it could be checked somewhere. But blind DD is better than building an image which won't get the CPU out of reset...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check implemented: a52993b
Also writing the key manifest with cbfstool using MANIFESTS region.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works, but is there a reason why there are two commas in $(filter)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4a0e6c1

No reason, probably some leftover from previous attempt to get this logic working...

src/soc/intel/baytrail/txei.c Outdated Show resolved Hide resolved
src/soc/intel/baytrail/txei.c Outdated Show resolved Hide resolved
src/soc/intel/baytrail/txei.c Outdated Show resolved Hide resolved
src/soc/intel/baytrail/txei.c Show resolved Hide resolved
src/soc/intel/baytrail/txei.c Show resolved Hide resolved
@pietrushnic
Copy link
Contributor

@BeataZdunczyk @macpijan, could anyone fix the code according to Krystian's suggestion while @miczyg1 is on vacation? I also wonder if we shouldn't go upstream with those patches immediately.

@BeataZdunczyk
Copy link
Member

@pietrushnic, @miczyg1 is working today, so he will address the review and the issues raised from testing RC1. If anything is more challenging to address, we will, of course, assign the task to someone else. Upstream is out of scope for this release, but we can evaluate the effort needed.

@miczyg1 miczyg1 force-pushed the byt_fsp_parity branch 2 times, most recently from 8d7d3a3 to 5557b1a Compare August 14, 2024 13:12
@miczyg1
Copy link
Contributor Author

miczyg1 commented Aug 14, 2024

I have addressed what I could. Not sure how to address the PCIe comments properly yet.

All Intel SOCs use input pullup 20K as not connected GPIO.
Also GPIO output mode may be harmful.

Signed-off-by: Michał Żygowski <[email protected]>
Fixes a problem where changing ME binary in the config would not result
in the desired ME binary be included in the rebuilt coreboot binary.

Signed-off-by: Michał Żygowski <[email protected]>
hex
default 0x19800

endif
# Ensure the bootblock does not overlap the microcode. We have 0x6400 bytes
# of space after microcode till the ned of ROM. Make a small gap of 256 bytes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# of space after microcode till the ned of ROM. Make a small gap of 256 bytes
# of space after microcode till the end of ROM. Make a small gap of 256 bytes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/soc/intel/baytrail/romstage/romstage.c Show resolved Hide resolved
dd if=/dev/zero of=$@ bs=5120 count=1 2> /dev/null
dd if=$< of=$@ conv=notrunc 2> /dev/null
else
key_manifest_pos = $(call int-subtract, $(CONFIG_ROM_SIZE) 0x21000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works, but is there a reason why there are two commas in $(filter)?

/* get number of full 4-byte slots */
static size_t bytes_to_slots(size_t bytes)
{
return (bytes + (SLOT_SIZE - 1) + SLOT_SIZE) / SLOT_SIZE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the ceiling of size, which is then increased by one. Is this an error or is it caused by the length not including the header? In any case, this should be commented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworked it to actually do what the comment does: 6a4524e

Used ALIGN_UP like the original source of CSE HECI src/soc/intel/common/block/cse/cse.c does

Also added comments near the loops where the slots are written to explain how it works.


/* Write the body in whole slots */
for (i = 1; i < pend_slots; i++, *p++) {
write_slot(i, *p);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like out of bounds read. Either add a check that pend_len is divisible by 4, or add a comment that all the messages come from this file (i.e. there are no non-static functions with message controlled by the caller) and have sizes that are of such sizes and the check isn't necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may often be out of bound read, depending on the message length. If it is not divisible by 4, then some additional bytes may be sent at the end of message. However, ME/TXE should not care, because the real length of the message is in the message header. But we still must write 32bit slots... Of course we may always check for the message length, reallocate and copy it to a new buffer that is divisible by 4 and appended with zeros if necessary. However, the original source of CSE HECI src/soc/intel/common/block/cse/cse.c does not do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6a4524e

This is not exactly what you wanted. Although like I mentioned above, it is based on the CSE HECI from common blocks, which does the same. And TXE/CSE should not care about bytes after the message size.

case TXE_FWSTS0_COM_DEBUG:
case TXE_FWSTS0_COM_SOFT_TEMP_DISABLE:
case TXE_FWSTS0_COM_SECOVER_JMPR:
printk(BIOS_INFO, "Current TXE operation mode does not allow"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/Dasharo/coreboot/blob/dasharo/Documentation/contributing/coding_style.md#breaking-long-lines-and-strings

However, never break user-visible strings such as printk messages, because that breaks the ability to grep for them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Successfully merging this pull request may close these issues.

5 participants