Add BIOS boot measurement
Measure the on-disk grub core on BIOS systems - unlike UEFI, the firmware can't do this stage for us.
This commit is contained in:
parent
f22ee4487c
commit
1e32d63145
2 changed files with 73 additions and 1 deletions
|
@ -19,6 +19,8 @@
|
|||
#include <grub/symbol.h>
|
||||
#include <grub/machine/boot.h>
|
||||
|
||||
#define TPM 1
|
||||
|
||||
/*
|
||||
* defines for the code go here
|
||||
*/
|
||||
|
@ -58,6 +60,21 @@ _start:
|
|||
/* this sets up for the first run through "bootloop" */
|
||||
movw $LOCAL(firstlist), %di
|
||||
|
||||
#ifdef TPM
|
||||
/* clear EAX to remove potential garbage */
|
||||
xorl %eax, %eax
|
||||
/* 8(%di) = number of sectors to read */
|
||||
movw 8(%di), %ax
|
||||
|
||||
/* Multiply number of sectors to read with 512 bytes. EAX is 32bit
|
||||
* which is large enough to hold values of up to 4GB. I doubt there
|
||||
* will ever be a core.img larger than that. ;-) */
|
||||
shll $9, %eax
|
||||
|
||||
/* write result to bytes_to_measure var */
|
||||
movl %eax, bytes_to_measure
|
||||
#endif
|
||||
|
||||
/* save the sector number of the second sector in %ebp */
|
||||
movl (%di), %ebp
|
||||
|
||||
|
@ -295,6 +312,29 @@ LOCAL(copy_buffer):
|
|||
/* END OF MAIN LOOP */
|
||||
|
||||
LOCAL(bootit):
|
||||
#ifdef TPM
|
||||
pusha
|
||||
movw $0xBB07, %ax /* TCG_CompactHashLogExtendEvent */
|
||||
|
||||
movw $0x0, %bx
|
||||
movw %bx, %es
|
||||
|
||||
/* We've already measured the first 512 bytes, now measure the rest */
|
||||
xorl %edi, %edi
|
||||
movw $(GRUB_BOOT_MACHINE_KERNEL_ADDR + 0x200), %di
|
||||
|
||||
movl $0x41504354, %ebx /* EBX = "TCPA" */
|
||||
|
||||
/* %ecx = The length, in bytes, of the buffer to measure */
|
||||
movl $bytes_to_measure, %esi
|
||||
movl (%esi), %ecx
|
||||
xorl %esi, %esi
|
||||
movl $0x9, %edx /* PCR 9 */
|
||||
|
||||
int $0x1A
|
||||
|
||||
popa
|
||||
#endif
|
||||
/* print a newline */
|
||||
MSG(notification_done)
|
||||
popw %dx /* this makes sure %dl is our "boot" drive */
|
||||
|
@ -329,6 +369,10 @@ geometry_error_string: .asciz "Geom"
|
|||
read_error_string: .asciz "Read"
|
||||
general_error_string: .asciz " Error"
|
||||
|
||||
#ifdef TPM
|
||||
bytes_to_measure: .long 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* message: write the string pointed to by %si
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue