Skip to content

Commit

Permalink
AMDSL: Numerous fixes to make SKL work with the v11 GRUB and Kernel
Browse files Browse the repository at this point in the history
Some of the changes needed:
 - Latest updates to SLR structures for v11 including the SLR header.
 - Update slr_entry_amd_info with new field for boot params phys addr.
 - Make sure phys addr of DLME entry point is in %ebx before jump.
 - Enable the TPM and initialize the DRTM event log else the kernel gets an
   empty buffer.

Signed-off-by: Ross Philipson <[email protected]>
  • Loading branch information
rossphilipson committed Sep 27, 2024
1 parent b93a793 commit a728113
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion head.S
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ GLOBAL(_entry)
*/
/* Linux expects Zero Page address in %esi, it is already there */
/* Multiboot2 expects MBI address in %ebx and magic number in %eax */
mov %esi, %ebx
mov %edi, %ebx
mov $MULTIBOOT2_BOOTLOADER_MAGIC, %eax
/* Simple payload expects argument on stack followed by return address */
push %esi
Expand Down
21 changes: 17 additions & 4 deletions include/slrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
* Common SLRT Table Header
*/
struct slr_entry_hdr {
u16 tag;
u16 size;
u32 tag;
u32 size;
} __packed;

/*
Expand Down Expand Up @@ -62,7 +62,7 @@ struct slr_bl_context {
*/
struct slr_entry_dl_info {
struct slr_entry_hdr hdr;
u32 dce_size;
u64 dce_size;
u64 dce_base;
u64 dlme_size;
u64 dlme_base;
Expand All @@ -77,11 +77,24 @@ struct slr_entry_dl_info {
struct slr_entry_log_info {
struct slr_entry_hdr hdr;
u16 format;
u16 reserved[3];
u16 reserved;
u32 size;
u64 addr;
} __packed;

/*
* AMD SKINIT Info table
*/
struct slr_entry_amd_info {
struct slr_entry_hdr hdr;
u64 next;
u32 type;
u32 len;
u64 slrt_size;
u64 slrt_base;
u64 boot_params_base;
} __packed;

/* Secure Kernel Loader */
extern struct slr_table bootloader_data;

Expand Down
16 changes: 15 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,27 @@ typedef struct {
static asm_return_t amdsl_launch()
{
struct slr_entry_dl_info *dl_info;
struct slr_entry_amd_info *amd_info;
struct tpm *tpm;
asm_return_t ret;

print("Enter amdsl_launch()\n");

tpm = enable_tpm();
tpm_request_locality(tpm, 2);
event_log_init(tpm);

print("TPM enabled and logging initialized\n");

dl_info = next_entry_with_tag(NULL, SLR_ENTRY_DL_INFO);
amd_info = next_entry_with_tag(NULL, SLR_ENTRY_AMD_INFO);

if ( dl_info == NULL
|| amd_info == NULL
|| dl_info->hdr.size != sizeof(*dl_info)
|| end_of_slrt() < _p(&dl_info[1])
|| amd_info->hdr.size != sizeof(*amd_info)
|| end_of_slrt() < _p(&amd_info[1])
|| dl_info->dlme_base >= 0x100000000ULL
|| dl_info->dlme_base + dl_info->dlme_size >= 0x100000000ULL
|| dl_info->dlme_entry >= dl_info->dlme_size
Expand Down Expand Up @@ -290,7 +304,7 @@ static asm_return_t amdsl_launch()
}

ret.dlme_entry = _p(dl_info->dlme_base + dl_info->dlme_entry);
ret.dlme_arg = _p(dl_info->bl_context.context);
ret.dlme_arg = _p(amd_info->boot_params_base);

/* End of the line, off to the protected mode entry into the kernel */
print("dlme_entry:\n");
Expand Down

0 comments on commit a728113

Please sign in to comment.