Skip to content

Commit 602d0d4

Browse files
committed
drtm: enable DRTM in SKL
Incorporate AMD's PSP functions in SKL to perform the DRTM sequence. Use the AMDSL C preprocessor flag to separate the AMD DRTM code path. Signed-off-by: Jagannathan Raman <[email protected]>
1 parent 5aea44d commit 602d0d4

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

main.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <string.h>
3131
#include <printk.h>
3232
#include <dev.h>
33+
#include <psp.h>
3334

3435
const skl_info_t __used skl_info = {
3536
.uuid = {
@@ -39,6 +40,7 @@ const skl_info_t __used skl_info = {
3940
.version = 0,
4041
};
4142

43+
#if !defined(AMDSL)
4244
static void extend_pcr(struct tpm *tpm, void *data, u32 size, u32 pcr, char *ev)
4345
{
4446
u8 hash[SHA1_DIGEST_SIZE];
@@ -65,6 +67,7 @@ static void extend_pcr(struct tpm *tpm, void *data, u32 size, u32 pcr, char *ev)
6567

6668
print("PCR extended\n");
6769
}
70+
#endif /* AMDSL */
6871

6972
/*
7073
* Even though die() has both __attribute__((noreturn)) and unreachable(),
@@ -117,6 +120,7 @@ static void do_dma(void)
117120
}
118121
#endif
119122

123+
#if !defined(AMDSL)
120124
static void dma_protection_setup(void)
121125
{
122126
u32 iommu_cap;
@@ -231,6 +235,8 @@ static void dma_protection_setup(void)
231235
#endif
232236
}
233237

238+
#endif /* AMDSL */
239+
234240
/*
235241
* Function return ABI magic:
236242
*
@@ -243,8 +249,70 @@ typedef struct {
243249
void *dlme_arg; /* %edx */
244250
} asm_return_t;
245251

252+
253+
#if defined(AMDSL)
254+
255+
static asm_return_t amdsl_launch()
256+
{
257+
struct slr_entry_dl_info *dl_info;
258+
asm_return_t ret;
259+
260+
dl_info = next_entry_with_tag(NULL, SLR_ENTRY_DL_INFO);
261+
262+
if ( dl_info == NULL
263+
|| dl_info->hdr.size != sizeof(*dl_info)
264+
|| end_of_slrt() < _p(&dl_info[1])
265+
|| dl_info->dlme_base >= 0x100000000ULL
266+
|| dl_info->dlme_base + dl_info->dlme_size >= 0x100000000ULL
267+
|| dl_info->dlme_entry >= dl_info->dlme_size
268+
|| dl_info->bl_context.bootloader != SLR_BOOTLOADER_GRUB )
269+
{
270+
print("Bad bootloader data format\n");
271+
reboot();
272+
}
273+
274+
pci_init();
275+
276+
if (discover_psp()) {
277+
print("AMDSL: PSP found\n");
278+
} else {
279+
print("AMDSL: PSP NOT found\n");
280+
}
281+
282+
if (!drtm_launch()) {
283+
print("AMDSL: skl_linux: DRTM launch failed\n");
284+
} else {
285+
print("AMDSL: skl_linux: DRTM launch successful\n");
286+
}
287+
288+
if (!drtm_extend_ossl_digest((u64)dl_info->dlme_base, dl_info->dlme_size)) {
289+
print("DRTM: skl_linux: failed to extend OSSL digest\n");
290+
}
291+
292+
ret.dlme_entry = _p(dl_info->dlme_base + dl_info->dlme_entry);
293+
ret.dlme_arg = _p(dl_info->bl_context.context);
294+
295+
/* End of the line, off to the protected mode entry into the kernel */
296+
print("dlme_entry:\n");
297+
hexdump(ret.dlme_entry, 0x100);
298+
print("dlme_arg:\n");
299+
hexdump(ret.dlme_arg, 0x280);
300+
print("skl_base:\n");
301+
hexdump(_start, 0x100);
302+
print("bootloader_data:\n");
303+
hexdump(&bootloader_data, bootloader_data.size);
304+
305+
print("amdsl_launch() is about to exit\n");
306+
307+
return ret;
308+
}
309+
310+
#endif /* AMDSL */
311+
246312
asm_return_t skl_main(void)
247313
{
314+
#if !defined(AMDSL)
315+
248316
struct tpm *tpm;
249317
struct slr_entry_dl_info *dl_info;
250318
asm_return_t ret;
@@ -314,4 +382,10 @@ asm_return_t skl_main(void)
314382
print("skl_main() is about to exit\n");
315383

316384
return ret;
385+
386+
#else /* AMDSL */
387+
388+
return amdsl_launch();
389+
390+
#endif /* AMDSL */
317391
}

0 commit comments

Comments
 (0)