On Wed, Jul 02, 2014 at 11:38:48AM -0400, Stefan Berger wrote:
This patch implements the TCG BIOS interrupt handler 1ah. It is for example used by trusted grub.
This patch adds an implementation of SHA1 (following NIST specs., IETF RFC 3147 and Wikipedia) for speeding up measurements of code. Trusted Grub for example makes use of this interface and measures (calculates SHA1) of the Linux kernel and initrd. Those files can be rather large and hunting their bytes through the TIS interface as part of the int handler commands invoked by trusted grub does take quite some time due to the many vmexits the interface is creating (one per byte).
There is also a threshold for the size of data to hash (100k) below which the TPM is used and above the internal faster SHA1 algorithm is used.
This patch for example enables trusted grub to interact with the TPM and take additional measurements.
[...]
--- a/src/tcgbios.h +++ b/src/tcgbios.h @@ -373,6 +373,10 @@ enum ipltype { IPL_EL_TORITO_2 };
+void tcpa_interrupt_handler32(struct bregs *regs); +void _cfunc32flat_tcpa_interrupt_handler32(struct bregs *regs);
The _cfunc32flat_XXX functions shouldn't be put in headers. Just put the declaration next to where it is used.
--- a/src/util.h +++ b/src/util.h @@ -76,6 +76,7 @@ u32 find_resume_vector(void); void acpi_reboot(void); void find_acpi_features(void); extern struct smbios_entry_point *SMBiosAddr; +struct smbios_entry_point *get_smbios_entry_point(); void copy_smbios(void *pos); void display_uuid(void); void copy_table(void *pos); @@ -234,4 +235,34 @@ void vgahook_setup(struct pci_device *pci); // version (auto generated file out/version.c) extern const char VERSION[];
+static inline u32 rol(u32 val, u16 rol) +{
- u32 res;
- __asm__ __volatile__ ("rol %%cl, %%eax"
: "=a" (res)
: "a" (val), "c" (rol));
- return res;
+}
This should go in x86.h.
+static inline u64 bswap_64(u64 val) +{
- u32 hi = (u32)(val >> 32);
- u32 lo = (u32)val;
- __asm__ __volatile__ ("bswap %%eax"
: "=a" (lo)
: "a" (lo));
- __asm__ __volatile__ ("bswap %%eax"
: "=a" (hi)
: "a" (hi));
- return ((u64)lo << 32 | hi);
+}
An equivalent of the above is already in byteorder.h.
-Kevin