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

[NOT FOR MERGE] Intel txt aem 2.06 rebased #20

Closed

Conversation

krystian-hebel
Copy link
Member

This PR is made to show and test SKINIT changes on top of what was sent to QubesOS/qubes-grub2#13. After review intel-txt-aem-2.06-rebased should be used to overwrite intel-txt-aem-2.06, and -testing can be removed.

@krystian-hebel krystian-hebel force-pushed the intel-txt-aem-2.06-rebased branch 2 times, most recently from f96f544 to 67d7167 Compare April 26, 2024 14:16
Daniel Kiper and others added 28 commits April 26, 2024 16:22
It does not make sense to have separate headers for separate static
functions. Additionally, we have to add some constants with MSR addresses
in subsequent patches. So, make one common place to store them.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
... to grub_rdmsr() and grub_wrmsr() respectively. New names are more
obvious than older ones.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Currently rdmsr and wrmsr commands have own MSR support detection code.
This code is the same. So, it is duplicated. Additionally, this code
cannot be reused by others. Hence, extract this code to a function and
make it public. By the way, improve a code a bit.

Additionally, use GRUB_ERR_BAD_DEVICE instead of GRUB_ERR_BUG to signal
an error because errors encountered by this new routine are not bugs.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
...to avoid potential conflicts and confusion.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Subsequent patches will use that constant.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
…acros

Subsequent patches will use those macros and constant.

Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
The functions calculate lowest and highest available RAM
addresses respectively.

Both functions are needed to calculate PMR boundaries for
Intel TXT secure launcher introduced by subsequent patches.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
...to avoid naming collision with TPM TIS and CRB driver introduced
by subsequent patch.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
It will be used by Intel TXT secure launcher introduced
by subsequent patches.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Some of the commands declared in header files will be implemented in
the follow-up commits.

Signed-off-by: Ross Philipson <ross.philipson@oracle.com>
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Provide definitions of structures and basic functions for constructing
and parsing of SLRT.

Signed-off-by: Ross Philipson <ross.philipson@oracle.com>
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Signed-off-by: Ross Philipson <ross.philipson@oracle.com>
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Ross Philipson <ross.philipson@oracle.com>
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Signed-off-by: Ross Philipson <ross.philipson@oracle.com>
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Signed-off-by: Ross Philipson <ross.philipson@oracle.com>
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Signed-off-by: Ross Philipson <ross.philipson@oracle.com>
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Signed-off-by: Ross Philipson <ross.philipson@oracle.com>
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
GRUB_MULTIBOOT(get_mbi_size) doesn't look like an accurate source of the
final size, more like a minimal memory buffer size.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
The code makes sure that MBI entry goes first in DRTM, so the payload
can measure it first on launch.

SLRT table is allocated on the heap first, size for it is reserved
inside TXT heap by TXT code and data is later copied into its final
place.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Signed-off-by: Tomasz Żyjewski <tomasz.zyjewski@3mdeb.com>
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
This still runs CI twice in a PR.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
After QubesOS/qubes-grub2#13 got merged, some
of the commits were duplicated, causing build system to fail. Skip
those commits and add the rest starting at the next available
patch-start number.

Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
This updates `struct grub_slr_entry_dl_info`:
 * by adding `dlme_base` and `dlme_size` which weren't necessary for
   Intel TXT because the same information is passed via OS2SINIT data
 * by changing `dlme_entry` from `grub_uint64_t` to `grub_uint32_t`
   because that should be enough for an offset

Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Update `slaunch_module` global only if new module passed all checks.

Closes #11.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
It's measured and we better measure the binary as is without changing it
on the fly.

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Do allocation in the same way as it's done for TXT (preferring high
addresses), otherwise Xen loads Dom0 kernel over the TPM even log and
Linux ends up panicking when it detects conflict with e820 map in
Xen-specific code (why wouldn't Xen check it?  who knows).

Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
@krystian-hebel krystian-hebel force-pushed the intel-txt-aem-2.06-rebased branch from 67d7167 to f6dfae5 Compare April 26, 2024 14:23
@krystian-hebel
Copy link
Member Author

krystian-hebel commented Apr 26, 2024

To see real delta between those branches: https://github.com/TrenchBoot/grub/compare/intel-txt-aem-2.06-testing..intel-txt-aem-2.06-rebased, changes presented by GH in Files changed aren't exact because I had to move commits that added CI on top of base-commit.

Copy link
Member

@SergiiDmytruk SergiiDmytruk left a comment

Choose a reason for hiding this comment

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

Looked at the changes after not working with them for a few weeks and found some things that could be improved while doing the rebase. Also ran openQA test on Supermicro M11 with the artifacts produced by CI and it passed successfully.

/* Contrary to the TXT, on AMD we do not have vendor-provided blobs in
* reserved memory, we are using normal RAM */
err = grub_relocator_alloc_chunk_align (rel, &ch, 0,
0xffffffff - GRUB_SKINIT_SLB_SIZE,
Copy link
Member

Choose a reason for hiding this comment

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

I guess someone during future review could point out that UP_TO_TOP32() should be used here as above, could update right away.

Copy link
Member

Choose a reason for hiding this comment

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

This could be squashed into i386/skinit: Add AMD SKINIT implementation.

0xffffffff - GRUB_SKINIT_SLB_SIZE,
GRUB_SKINIT_SLB_SIZE,
GRUB_SKINIT_SLB_ALIGN,
GRUB_RELOCATOR_PREFERENCE_LOW, 1);
Copy link
Member

Choose a reason for hiding this comment

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

Given that GRUB_RELOCATOR_PREFERENCE_LOW caused us problems for TPM log, any benefits of using GRUB_RELOCATOR_PREFERENCE_HIGH here as well? In that case 0x1000000 was used for a base, so maybe there is no danger here assuming availability of aligned 64KiB below 16MiB boundary.


grub_dprintf ("slaunch", "broadcasting INIT\r\n");
*apic = 0x000c0500; // INIT, all excluding self
grub_dprintf ("slaunch", "grub_tpm_relinquish_locality\r\n");
Copy link
Member

Choose a reason for hiding this comment

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

IIRC this print might be helpful for the delay that it introduces, but the message could probably be edited to say something like "sent INIT broadcasts".

if (slp == SLP_NONE)
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("secure launch not enabled"));

if (slp > SLP_AMD_SKINIT)
Copy link
Member

Choose a reason for hiding this comment

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

There should probably be SLP_END with the slp >= SLP_END check here, because what I've done doesn't look nice.

#define GRUB_SKINIT_SLB_SIZE 0x10000
#define GRUB_SKINIT_SLB_ALIGN 0x10000

#ifndef ASM_FILE
Copy link
Member

Choose a reason for hiding this comment

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

I think this file is never included in an asm-file (directly or indirectly), so this check and defining constants after includes are unnecessary.

To avoid mismatch between OS SINIT data MLE size and MLE size from
MLE header, take the mle_size from MLE header and do not align it
to PMR size, which is 2MB.

Signed-off-by: Michał Żygowski <michal.zygowski@3mdeb.com>
@SergiiDmytruk
Copy link
Member

SergiiDmytruk commented Aug 20, 2024

Cleanup: @krystian-hebel, I think the comments were basically taken care of in tb-2.12-57-linux-amd where it's needed for upstreaming, so the branches can be renamed as stated in the OP.

@krystian-hebel
Copy link
Member Author

@krystian-hebel, I think the comments were basically taken care of in tb-2.12-57-linux-amd where it's needed for upstreaming, so the branches can be renamed as stated in the OP.

Agreed.

@krystian-hebel krystian-hebel deleted the intel-txt-aem-2.06-rebased branch August 26, 2024 11:55
@krystian-hebel krystian-hebel restored the intel-txt-aem-2.06-rebased branch August 26, 2024 12:03
@krystian-hebel
Copy link
Member Author

(had to restore branch to switch target on #23, removing again)

@krystian-hebel krystian-hebel deleted the intel-txt-aem-2.06-rebased branch August 26, 2024 12:06
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.

4 participants