Skip to content

Commit 38a5fee

Browse files
committed
x86: Secure Launch kernel early boot stub
The Secure Launch (SL) stub provides the entry point for Intel TXT to jump to during the dynamic launch. The symbol sl_stub_entry is that entry point and its offset into the kernel is conveyed to the launching code using the Measured Launch Environment (MLE) header in the structure named mle_header. The offset of the MLE header is set in the kernel_info. The startup SL routines (in sl_stub.S) contain the very early dynamic launch setup code responsible for setting up the basic operating environment to allow the normal kernel startup_32 code to proceed. It is also responsible for properly waking and handling the APs on Intel platforms. The routine sl_main() runs after entering 64b mode in the setup kernel. It is responsible for measuring configuration and module information before it is used. An example of entities measured on Intel x86 are the boot params, the kernel command line, the TXT heap, any external initramfs, etc. In addition this routine does some early setup and validation of the environment like locating the TPM event log and validating the location of various buffers to ensure they are protected and not overlapping. Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com> Signed-off-by: Ross Philipson <ross.philipson@oracle.com>
1 parent 3dc7372 commit 38a5fee

7 files changed

Lines changed: 1481 additions & 0 deletions

File tree

Documentation/arch/x86/boot.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,14 @@ Protocol: 2.00+
482482
- If 1, KASLR enabled.
483483
- If 0, KASLR disabled.
484484

485+
Bit 2 (kernel internal): SLAUNCH_FLAG
486+
487+
- Used internally by the setup kernel to communicate
488+
Secure Launch status to the kernel proper.
489+
490+
- If 1, Secure Launch enabled.
491+
- If 0, Secure Launch disabled.
492+
485493
Bit 5 (write): QUIET_FLAG
486494

487495
- If 0, print early messages.
@@ -1037,6 +1045,19 @@ Offset/size: 0x000c/4
10371045

10381046
This field contains maximal allowed type for setup_data and setup_indirect structs.
10391047

1048+
============ =================
1049+
Field name: mle_header_offset
1050+
Offset/size: 0x0010/4
1051+
============ =================
1052+
1053+
This field contains the offset to the Secure Launch Measured Launch Environment
1054+
(MLE) header. This offset is used to locate information needed during a secure
1055+
late launch using Intel TXT. If the offset is zero, the kernel does not have
1056+
Secure Launch capabilities. The MLE entry point is called from TXT on the BSP
1057+
following a successful measured launch. The specific state of the processors is
1058+
outlined in the TXT Software Development Guide, the latest can be found here:
1059+
https://www.intel.com/content/dam/www/public/us/en/documents/guides/intel-txt-software-development-guide.pdf
1060+
10401061

10411062
The Kernel Command Line
10421063
=======================

arch/x86/boot/compressed/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ endif
115115
slaunch-objs += $(obj)/sha1.o
116116
slaunch-objs += $(obj)/sha256.o
117117
slaunch-objs += $(obj)/early_tpm_extend.o
118+
slaunch-objs += $(obj)/sl_main.o
119+
slaunch-objs += $(obj)/sl_stub.o
118120

119121
vmlinux-objs-$(CONFIG_SECURE_LAUNCH) += $(slaunch-objs)
120122

arch/x86/boot/compressed/head_64.S

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,13 @@ SYM_CODE_START(startup_64)
412412
pushq $0
413413
popfq
414414

415+
#ifdef CONFIG_SECURE_LAUNCH
416+
/* Ensure the relocation region is covered by a PMR */
417+
movq %rbx, %rdi
418+
movl $(_bss - startup_32), %esi
419+
callq sl_check_region
420+
#endif
421+
415422
/*
416423
* Copy the compressed kernel to the end of our buffer
417424
* where decompression in place becomes safe.
@@ -454,6 +461,28 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
454461
shrq $3, %rcx
455462
rep stosq
456463

464+
#ifdef CONFIG_SECURE_LAUNCH
465+
/*
466+
* Have to do the final early sl stub work in 64b area.
467+
*
468+
* *********** NOTE ***********
469+
*
470+
* Several boot params get used before we get a chance to measure
471+
* them in this call. This is a known issue and we currently don't
472+
* have a solution. The scratch field doesn't matter. There is no
473+
* obvious way to do anything about the use of kernel_alignment or
474+
* init_size though these seem low risk with all the PMR and overlap
475+
* checks in place.
476+
*/
477+
movq %r15, %rdi
478+
callq sl_main
479+
480+
/* Ensure the decompression location is covered by a PMR */
481+
movq %rbp, %rdi
482+
movq output_len(%rip), %rsi
483+
callq sl_check_region
484+
#endif
485+
457486
call load_stage2_idt
458487

459488
/* Pass boot_params to initialize_identity_maps() */

0 commit comments

Comments
 (0)