Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions configs/config.pcengines_apu2_drtm_payload
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
CONFIG_LOCALVERSION="v0.9.1"
CONFIG_OPTION_BACKEND_NONE=y
CONFIG_VENDOR_PCENGINES=y
CONFIG_VBOOT=y
CONFIG_PXE_ROM_ID="8086,157b"
CONFIG_CONSOLE_CBMEM_BUFFER_SIZE=0x100000
CONFIG_EDK2_BOOT_TIMEOUT=6
CONFIG_TPM_MEASURED_BOOT=y
CONFIG_EDK2_BOOTSPLASH_FILE="3rdparty/dasharo-blobs/dasharo/bootsplash.bmp"
CONFIG_LAUNCH_DRTM_PAYLOAD=y
CONFIG_UDK_202005_BINDING=y
CONFIG_NO_GFX_INIT=y
CONFIG_DRIVERS_EFI_VARIABLE_STORE=y
CONFIG_TPM2=y
CONFIG_BOOTMEDIA_LOCK_CHIP=y
CONFIG_BOOTMEDIA_LOCK_WPRO_VBOOT_RO=y
CONFIG_BOOTMEDIA_LOCK_IN_VERSTAGE=y
CONFIG_BOOTMEDIA_SPI_LOCK_PIN=y
CONFIG_DEFAULT_CONSOLE_LOGLEVEL_1=y
# CONFIG_CONSOLE_USE_LOGLEVEL_PREFIX is not set
# CONFIG_CONSOLE_USE_ANSI_ESCAPES is not set
CONFIG_PAYLOAD_EDK2=y
CONFIG_EDK2_USE_EDK2_PLATFORMS=y
CONFIG_EDK2_PLATFORMS_REPOSITORY="https://github.com/Dasharo/edk2-platforms"
CONFIG_EDK2_PLATFORMS_TAG_OR_REV="1002a59639f111a2f8178b77d1f5fde0ea8d976f"
CONFIG_EDK2_CBMEM_LOGGING=y
CONFIG_EDK2_HAVE_EFI_SHELL=y
# CONFIG_EDK2_PS2_SUPPORT is not set
CONFIG_EDK2_SERIAL_SUPPORT=y
CONFIG_BUILD_IPXE=y
CONFIG_IPXE_ADD_SCRIPT=y
CONFIG_IPXE_SCRIPT="3rdparty/dasharo-blobs/dasharo/dasharo.ipxe"
CONFIG_IPXE_CUSTOM_BUILD_ID="0123456789"
CONFIG_DASHARO=y
CONFIG_EDK2_ENABLE_IPXE=y
# CONFIG_EDK2_SECURE_BOOT_DEFAULT_ENABLE is not set
CONFIG_EDK2_SATA_PASSWORD=y
CONFIG_EDK2_OPAL_PASSWORD=y
CONFIG_EDK2_SETUP_PASSWORD=y
CONFIG_EDK2_PERFORMANCE_MEASUREMENT_ENABLE=y
CONFIG_EDK2_DASHARO_SYSTEM_FEATURES=y
CONFIG_EDK2_DASHARO_SECURITY_OPTIONS=y
CONFIG_EDK2_DASHARO_USB_CONFIG=y
CONFIG_EDK2_DASHARO_NETWORK_CONFIG=y
CONFIG_EDK2_DASHARO_CHIPSET_CONFIG=y
CONFIG_EDK2_DASHARO_SERIAL_REDIRECTION_DEFAULT_ENABLE=y
CONFIG_EDK2_HAVE_2ND_UART=y
CONFIG_EDK2_BOOT_MENU_KEY=0x0014
CONFIG_EDK2_SETUP_MENU_KEY=0x0008
CONFIG_EDK2_DISABLE_OPTION_ROMS=y
CONFIG_EDK2_CREATE_PREINSTALLED_BOOT_OPTIONS=y
1 change: 1 addition & 0 deletions payloads/external/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Memtest86Plus/memtest86plus/
iPXE/ipxe/
skiboot/skiboot
skiboot/build
skl/secure-kernel-loader/
13 changes: 13 additions & 0 deletions payloads/external/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -578,3 +578,16 @@ doom.wad-file := $(strip $(CONFIG_COREDOOM_WAD_FILE))
doom.wad-type := raw
doom.wad-compression := $(CBFS_SECONDARY_PAYLOAD_COMPRESS_FLAG)
endif

# SKL

payloads/external/skl/secure-kernel-loader/skl.bin:
$(MAKE) -C payloads/external/skl CC="$(HOSTCC)" \
CONFIG_SKL_REPOSITORY=$(CONFIG_SKL_REPOSITORY) \
CONFIG_SKL_TAG_OR_REV=$(CONFIG_SKL_TAG_OR_REV)

cbfs-files-$(CONFIG_LAUNCH_DRTM_PAYLOAD) += $(CONFIG_CBFS_PREFIX)/drtm_payload
$(CONFIG_CBFS_PREFIX)/drtm_payload-file := payloads/external/skl/secure-kernel-loader/skl.bin
$(CONFIG_CBFS_PREFIX)/drtm_payload-type := raw
$(CONFIG_CBFS_PREFIX)/drtm_payload-compression := $(CBFS_PAYLOAD_COMPRESS_FLAG)
$(CONFIG_CBFS_PREFIX)/drtm_payload-options := $(ADDITIONAL_PAYLOAD_CONFIG)
34 changes: 34 additions & 0 deletions payloads/external/skl/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## SPDX-License-Identifier: GPL-2.0-only
project_git_repo=$(CONFIG_SKL_REPOSITORY)
project_dir=secure-kernel-loader

all: skl

checkout:
if [ ! -d "$(project_dir)" ]; then \
git clone --recurse-submodules "$(project_git_repo)" -j5; \
fi
cd "$(project_dir)"; \
if ! git rev-parse --verify -q $(CONFIG_SKL_TAG_OR_REV)^{object} >/dev/null; then \
echo " $(CONFIG_SKL_TAG_OR_REV) is not a valid git reference"; \
exit 1;\
fi; \
if git status --ignore-submodules=dirty | grep -q "nothing to commit, working tree clean"; then \
echo " Checking out secure-kernel-loader $(CONFIG_SKL_TAG_OR_REV)"; \
git checkout --detach $(CONFIG_SKL_TAG_OR_REV) -f; \
else \
echo " Working directory not clean; will not overwrite"; \
fi; \
git submodule update --init --checkout


skl: checkout
$(MAKE) -C $(project_dir) DEBUG=y

clean:
test -d $(project_dir) && $(MAKE) -C $(project_dir) clean || exit 0

distclean:
rm -rf $(project_dir)

.PHONY: checkout skl clean distclean
1 change: 1 addition & 0 deletions src/soc/amd/common/Kconfig.common
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ source "src/soc/amd/common/block/*/Kconfig"
source "src/soc/amd/common/fsp/Kconfig"
source "src/soc/amd/common/pi/Kconfig"
source "src/soc/amd/common/psp_verstage/Kconfig"
source "src/soc/amd/common/skl/Kconfig"

config APCB_BLOBS_DIR
string "Mainboard blobs path"
Expand Down
1 change: 1 addition & 0 deletions src/soc/amd/common/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ subdirs-y += block
subdirs-y += fsp
subdirs-y += pi
subdirs-y += vboot
subdirs-$(CONFIG_LAUNCH_DRTM_PAYLOAD) += skl

CPPFLAGS_common += -I$(src)/soc/amd/common/vboot/include

Expand Down
27 changes: 27 additions & 0 deletions src/soc/amd/common/skl/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-License-Identifier: GPL-2.0-only

config LAUNCH_DRTM_PAYLOAD
bool "Launch DRTM payload before the real one"
default n
depends on MEMORY_MAPPED_TPM && ARCH_RAMSTAGE_X86_32
help
Launch DRTM payload before the real one. This makes it possible to
put root of trust in hardware for platforms that don't support SRTM.

if LAUNCH_DRTM_PAYLOAD

config SKL_REPOSITORY
string "URL to git repository for secure-kernel-loader"
default "https://github.com/TrenchBoot/secure-kernel-loader.git"
help
TODO

config SKL_TAG_OR_REV
string "Insert a commit's SHA-1 or a branch name"
default "de1899007d038eeacf5edb8e63c0f0a4b3e265c4"
help
The commit's SHA-1 or branch name of the revision to use. This must exist in
SKL_REPOSITORY, and in the case of a branch name, prefixed with origin i.e.
"origin/skl-loader-amdsl-v11"

endif # LAUNCH_DRTM_PAYLOAD
5 changes: 5 additions & 0 deletions src/soc/amd/common/skl/Makefile.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only

ramstage-$(CONFIG_LAUNCH_DRTM_PAYLOAD) += skinit.c

CPPFLAGS_common += -I$(src)/soc/amd/common/skl/include/
129 changes: 129 additions & 0 deletions src/soc/amd/common/skl/include/slrt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef __SLRT_H__
#define __SLRT_H__

#include <types.h>

/* SLR Table header values */
#define SLR_TABLE_MAGIC 0x4452544d
#define SLR_TABLE_REVISION 1

/* Current revisions for the policy and UEFI config */
#define SLR_POLICY_REVISION 1
#define SLR_UEFI_CONFIG_REVISION 1

/* SLR defined architectures */
#define SLR_INTEL_TXT 1
#define SLR_AMD_SKINIT 2

/* SLR defined bootloaders */
#define SLR_BOOTLOADER_INVALID 0
#define SLR_BOOTLOADER_GRUB 1

/* Log formats */
#define SLR_DRTM_TPM12_LOG 1
#define SLR_DRTM_TPM20_LOG 2

/* Array Lengths */
#define TPM_EVENT_INFO_LENGTH 32

/* Tags */
#define SLR_ENTRY_INVALID 0x0000
#define SLR_ENTRY_DL_INFO 0x0001
#define SLR_ENTRY_LOG_INFO 0x0002
#define SLR_ENTRY_ENTRY_POLICY 0x0003
#define SLR_ENTRY_INTEL_INFO 0x0004
#define SLR_ENTRY_AMD_INFO 0x0005
#define SLR_ENTRY_ARM_INFO 0x0006
#define SLR_ENTRY_UEFI_INFO 0x0007
#define SLR_ENTRY_UEFI_CONFIG 0x0008
#define SLR_ENTRY_END 0xffff

/*
* sl_header as given by AMD
*/
struct sl_header {
u16 skl_entry_point;
u16 skl_measured_size;
u8 reserved[62];
u16 skl_info_offset;
u16 bootloader_data_offset;
} __packed;

/*
* Common SLRT Table Header
*/
struct slr_entry_hdr {
u32 tag;
u32 size;
} __packed;

/*
* Primary Secure Launch Resource Table Header
*/
struct slr_table {
u32 magic;
u16 revision;
u16 architecture;
u32 size;
u32 max_size;
/* Not really a flex array, don't use it that way! */
struct slr_entry_hdr entries[];
} __packed;

/*
* Boot loader context
*/
struct slr_bl_context {
u16 bootloader;
u16 reserved[3];
u64 context;
} __packed;

/*
* DRTM Dynamic Launch Configuration
*/
struct slr_entry_dl_info {
struct slr_entry_hdr hdr;
u64 dce_size;
u64 dce_base;
u64 dlme_size;
u64 dlme_base;
u64 dlme_entry; /* Offset from dlme_base */
struct slr_bl_context bl_context;
u64 dl_handler;
} __packed;

/*
* TPM Log Information
*/
struct slr_entry_log_info {
struct slr_entry_hdr hdr;
u16 format;
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;
u16 psp_version;
u16 reserved[3];
} __packed;

static inline void *next_entry(void* t)
{
void *x = t + ((struct slr_entry_hdr*)t)->size;
return x;
}

#endif /* __SLRT_H__ */
Loading
Loading