-
Notifications
You must be signed in to change notification settings - Fork 3
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
Intel txt aem 2.06 testing #16
Conversation
fa228ba
to
2a10c64
Compare
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>
2a10c64
to
66004ae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename all read
and write
functions to include the number of bits they access, so read64
instead of readq
(and similar for other functions). Also please document the magic numbers used in the SLRT calls
grub-core/loader/i386/linux.c
Outdated
prot_size = ALIGN_UP (prot_size, GRUB_TXT_PMR_ALIGN); | ||
|
||
if (prot_size > GRUB_TXT_MLE_MAX_SIZE) | ||
{ | ||
err = GRUB_ERR_OUT_OF_RANGE; | ||
goto fail; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be reordered to make sure ALIGN_UP
cannot overflow?
grub-core/loader/i386/linux.c
Outdated
/* TODO the initrd image and size can have hi bits but for now assume always < 4G */ | ||
grub_slaunch_add_slrt_policy_entry (17, | ||
GRUB_SLR_ET_RAMDISK, | ||
/*flags=*/0, | ||
boot_params->ramdisk_image, | ||
boot_params->ramdisk_size, | ||
"Measured Kernel initrd"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be checked?
grub-core/loader/i386/linux.c
Outdated
if (! ctx.real_mode_target) | ||
return grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate real mode pages"); | ||
|
||
{ | ||
grub_relocator_chunk_t ch; | ||
grub_size_t sz; | ||
|
||
if (grub_add (ctx.real_size, efi_mmap_size, &sz)) | ||
if (grub_add (ctx.real_size, efi_mmap_size + ap_wake_block_size, &sz)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use grub_add()
here too?
|
||
for (i = 0, cur = modules; i < modcnt; i++, cur = cur->next) | ||
{ | ||
grub_slaunch_add_slrt_policy_entry (17, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does 17 come from?
info_table_size = __builtin_offsetof (struct grub_txt_acm_info_table, length) | ||
+ sizeof(ptr->length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought stddef.h
is available in freestanding code. On my system (GCC with Fedora 39) it is provided by the compiler, not libc, and it only provides definitions for macros, structs, and typedefs that are defined by the compiler.
return proc_id_list; | ||
} | ||
|
||
static int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typedef _Bool bool
? That said, I thought <stdbool.h>
was available even in freestanding mode. You don’t get a libc in freestanding mode, but <stdbool.h>
is the compiler’s job to provide, not libc’s.
/* Can read the size field of next entry? */ | ||
if ( grub_add (addr, sizeof(*next), &addr) ) | ||
return NULL; | ||
|
||
/* Does next element's header fit within the table? */ | ||
if (addr >= grub_slr_end_of_entries (table)) | ||
return NULL; | ||
|
||
next = (struct grub_slr_entry_hdr *) (addr - sizeof(*next)); | ||
|
||
/* Does next element fit within the table? */ | ||
if (grub_slr_end_of_entries (table) - (addr - sizeof(*next)) < next->size) | ||
return NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* Can read the size field of next entry? */ | |
if ( grub_add (addr, sizeof(*next), &addr) ) | |
return NULL; | |
/* Does next element's header fit within the table? */ | |
if (addr >= grub_slr_end_of_entries (table)) | |
return NULL; | |
next = (struct grub_slr_entry_hdr *) (addr - sizeof(*next)); | |
/* Does next element fit within the table? */ | |
if (grub_slr_end_of_entries (table) - (addr - sizeof(*next)) < next->size) | |
return NULL; | |
/* Does next element's header fit within the table? */ | |
if (addr >= grub_slr_end_of_entries (table) - sizeof(*next)) | |
return NULL; | |
next = (struct grub_slr_entry_hdr *) addr); | |
/* Does next element fit within the table? */ | |
if (grub_slr_end_of_entries (table) - addr < next->size) | |
return NULL; | |
/* Does next element include a header? */ | |
if (next->size < sizeof(*next)) | |
return NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DemiMarie could you mark discussions as resolved wherever you're happy with the change?
info_table_size = __builtin_offsetof (struct grub_txt_acm_info_table, length) | ||
+ sizeof(ptr->length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I've mistook it with stdint.h
, which in theory is available since C99, but compilers still have problems with it.
In any case, GRUB seems to avoid standard headers in core code, except for stdarg.h
. They are used in OS utilities and libraries, but not in the bootloader itself, so I don't feel comfortable including it just for this.
return proc_id_list; | ||
} | ||
|
||
static int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same reasoning as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
if (!entry) /* Start from the beginning */ | ||
entry = (struct grub_slr_entry_hdr *)((grub_uint8_t *) table + sizeof(*table)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That falls into the “input is known trusted here” case.
#define GRUB_MSR_EFER_LME (1<<8) /* Enable Long Mode/IA-32e */ | ||
#define GRUB_MSR_EFER_LMA (1<<10) /* Long Mode/IA-32e Active */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason I could not find this in my copy, probably because I was not looking at the right place. Consider this resolved.
GRUB_MOD_INIT (slaunch) | ||
{ | ||
cmd_slaunch = grub_register_command ("slaunch", grub_cmd_slaunch, | ||
NULL, N_("Enable secure launcher")); | ||
cmd_slaunch_module = grub_register_command ("slaunch_module", grub_cmd_slaunch_module, | ||
NULL, N_("Load secure launcher module from file")); | ||
cmd_slaunch_state = grub_register_command ("slaunch_state", grub_cmd_slaunch_state, | ||
NULL, N_("Display secure launcher state")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be resolved.
info_table_size = __builtin_offsetof (struct grub_txt_acm_info_table, length) | ||
+ sizeof(ptr->length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s fine, you can resolve this.
return proc_id_list; | ||
} | ||
|
||
static int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Not worth blocking merge.
grub-core/loader/i386/txt/verify.c
Outdated
N_("TXT heap is not configured correctly")); | ||
|
||
bios_size = grub_txt_bios_data_size (txt_heap); | ||
/* We support versions >= 4, but bios_data->mle_flags is in versions >= 5. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, SNB_IVB_SINIT_20190708_PW.bin
is version 4 but it has mle_flags
. Fu Thanks, Intel.
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>
efdb40d
to
d57eb43
Compare
GitHub isn’t allowing it, sadly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay
Those two sneaky errors were breaking boot on Optiplex... I'll redo the same tests on HP just in case before clearing debug output and finally preparing patches for qubes-grub2 |
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>
9dc582a
to
58c9a06
Compare
No regression on HP, debug output cleared, fixes squashed to appropriate commits. Running per-commit build test (for bisectability) and will send patches tomorrow. |
Reviewed on TrenchBoot/grub#16 Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
@DemiMarie can you send me signed message with commit ID which you approve (can be pasted clearsigned here, or via email)? |
Cleanup: @krystian-hebel, so this got upstreamed and we won't need this PR and branches anymore? |
FSVO upstreamed, it was implemented in Qubes GRUB repo. Can be closed. |
No description provided.