Skip to content

Commit b3fd590

Browse files
rossphilipsonkrystian-hebel
authored andcommitted
i386/linux: Add support for AMD SKINIT
Signed-off-by: Ross Philipson <ross.philipson@oracle.com> Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
1 parent bff8d04 commit b3fd590

1 file changed

Lines changed: 40 additions & 17 deletions

File tree

grub-core/loader/i386/linux.c

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <grub/i386/relocator.h>
3535
#include <grub/i18n.h>
3636
#include <grub/lib/cmdline.h>
37+
#include <grub/i386/skinit.h>
3738
#include <grub/i386/slaunch.h>
3839
#include <grub/i386/txt.h>
3940
#include <grub/linux.h>
@@ -250,7 +251,7 @@ allocate_pages (grub_size_t prot_size, grub_size_t *align,
250251
prot_mode_mem = get_virtual_current_address (ch);
251252
prot_mode_target = get_physical_target_address (ch);
252253

253-
if (grub_slaunch_platform_type () == SLP_INTEL_TXT)
254+
if (grub_slaunch_platform_type () != SLP_NONE)
254255
{
255256
/* Zero out memory to get stable MLE measurements. */
256257
grub_memset (prot_mode_mem, 0, total_size);
@@ -269,22 +270,29 @@ allocate_pages (grub_size_t prot_size, grub_size_t *align,
269270
slparams->mle_ptab_mem, (unsigned long) slparams->mle_ptab_target,
270271
(unsigned) slparams->mle_ptab_size);
271272

272-
err = grub_relocator_alloc_chunk_align (relocator, &ch, 0x1000000,
273-
0xffffffff - GRUB_PAGE_SIZE,
274-
GRUB_PAGE_SIZE, GRUB_PAGE_SIZE,
275-
GRUB_RELOCATOR_PREFERENCE_NONE, 1);
276-
if (err)
277-
goto fail;
278-
279-
slparams->slr_table_base = get_physical_target_address (ch);
280-
slparams->slr_table_size = GRUB_PAGE_SIZE;
281-
slparams->slr_table_mem = get_virtual_current_address (ch);
282-
283-
grub_memset (slparams->slr_table_mem, 0, slparams->slr_table_size);
284-
285-
grub_dprintf ("linux", "slr_table_base = %lx, slr_table_size = %x\n",
286-
(unsigned long) slparams->slr_table_base,
287-
(unsigned) slparams->slr_table_size);
273+
/*
274+
* For AMD SKINIT, SLRT is part of SLB and it will be initialized by
275+
* grub_skinit_boot_prepare().
276+
*/
277+
if (grub_slaunch_platform_type () == SLP_INTEL_TXT)
278+
{
279+
err = grub_relocator_alloc_chunk_align (relocator, &ch, 0x1000000,
280+
0xffffffff - GRUB_PAGE_SIZE,
281+
GRUB_PAGE_SIZE, GRUB_PAGE_SIZE,
282+
GRUB_RELOCATOR_PREFERENCE_NONE, 1);
283+
if (err)
284+
goto fail;
285+
286+
slparams->slr_table_base = get_physical_target_address (ch);
287+
slparams->slr_table_size = GRUB_PAGE_SIZE;
288+
slparams->slr_table_mem = get_virtual_current_address (ch);
289+
290+
grub_memset (slparams->slr_table_mem, 0, slparams->slr_table_size);
291+
292+
grub_dprintf ("linux", "slr_table_base = %lx, slr_table_size = %x\n",
293+
(unsigned long) slparams->slr_table_base,
294+
(unsigned) slparams->slr_table_size);
295+
}
288296

289297
err = grub_relocator_alloc_chunk_align (relocator, &ch, 0x1000000,
290298
0xffffffff - GRUB_SLAUNCH_TPM_EVT_LOG_SIZE,
@@ -825,6 +833,21 @@ grub_linux_boot (void)
825833
state.ecx = slparams->dce_size;
826834
state.edx = 0;
827835
}
836+
else if (state.edi == SLP_AMD_SKINIT)
837+
{
838+
slparams->boot_params_addr = ctx.real_mode_target;
839+
840+
err = grub_skinit_boot_prepare (relocator, slparams);
841+
842+
if (err != GRUB_ERR_NONE)
843+
return grub_error (err, "SKINIT preparations have failed");
844+
845+
grub_slaunch_add_slrt_policy_entries ();
846+
grub_linux_setup_slr_table (slparams);
847+
grub_slaunch_finish_slr_table ();
848+
849+
state.eax = slparams->dce_base;
850+
}
828851
else
829852
{
830853
/* FIXME. */

0 commit comments

Comments
 (0)