mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-18 20:47:55 +00:00
Changed to coreboot patch to not measure relocated modules
This commit is contained in:
parent
1a34bd9d6f
commit
87251fd1b1
@ -24,6 +24,19 @@ index 49f8672..4ca811d 100644
|
||||
endmenu
|
||||
|
||||
menu "Mainboard"
|
||||
diff --git ./src/include/program_loading.h ./src/include/program_loading.h
|
||||
index 416e2e9..40486cd 100644
|
||||
--- ./src/include/program_loading.h
|
||||
+++ ./src/include/program_loading.h
|
||||
@@ -24,6 +24,8 @@ enum {
|
||||
/* Last segment of program. Can be used to take different actions for
|
||||
* cache maintenance of a program load. */
|
||||
SEG_FINAL = 1 << 0,
|
||||
+ /* Indicate that the program segment should not be measured */
|
||||
+ SEG_NO_MEASURE = 1 << 1,
|
||||
};
|
||||
|
||||
enum prog_type {
|
||||
diff --git ./src/include/sha1.h ./src/include/sha1.h
|
||||
new file mode 100644
|
||||
index 0000000..e7e28e6
|
||||
@ -97,7 +110,7 @@ index 8f92b29..1822daf 100644
|
||||
romstage-$(CONFIG_TPM2) += tpm2_tlcl.c
|
||||
endif # CONFIG_VBOOT_SEPARATE_VERSTAGE
|
||||
diff --git ./src/lib/cbfs.c ./src/lib/cbfs.c
|
||||
index 11bce2c..c1024f9 100644
|
||||
index 11bce2c..8428245 100644
|
||||
--- ./src/lib/cbfs.c
|
||||
+++ ./src/lib/cbfs.c
|
||||
@@ -69,7 +69,11 @@ void *cbfs_boot_map_with_leak(const char *name, uint32_t type, size_t *size)
|
||||
@ -107,7 +120,7 @@ index 11bce2c..c1024f9 100644
|
||||
- return rdev_mmap(&fh.data, 0, fsize);
|
||||
+ void * buffer = rdev_mmap(&fh.data, 0, fsize);
|
||||
+
|
||||
+ prog_segment_loaded((uintptr_t)buffer, fsize, SEG_FINAL);
|
||||
+ prog_segment_loaded((uintptr_t)buffer, fsize, 0);
|
||||
+
|
||||
+ return buffer;
|
||||
}
|
||||
@ -143,14 +156,14 @@ index 11bce2c..c1024f9 100644
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+ prog_segment_loaded((uintptr_t)buffer, out_size, SEG_FINAL);
|
||||
+ prog_segment_loaded((uintptr_t)buffer, out_size, 0);
|
||||
+
|
||||
+ return out_size;
|
||||
}
|
||||
|
||||
static inline int tohex4(unsigned int c)
|
||||
diff --git ./src/lib/hardwaremain.c ./src/lib/hardwaremain.c
|
||||
index a56d68e..94f7c95 100644
|
||||
index a56d68e..8c13f5f 100644
|
||||
--- ./src/lib/hardwaremain.c
|
||||
+++ ./src/lib/hardwaremain.c
|
||||
@@ -32,6 +32,7 @@
|
||||
@ -169,52 +182,25 @@ index a56d68e..94f7c95 100644
|
||||
+// ramstage measurements go into PCR3 if we are doing measured boot
|
||||
+void platform_segment_loaded(uintptr_t start, size_t size, int flags)
|
||||
+{
|
||||
+ if (IS_ENABLED(CONFIG_MEASURED_BOOT))
|
||||
+ if (IS_ENABLED(CONFIG_MEASURED_BOOT) && !(flags & SEG_NO_MEASURE))
|
||||
+ {
|
||||
+ tlcl_measure(3, (const void*) start, size);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
diff --git ./src/lib/rmodule.c ./src/lib/rmodule.c
|
||||
index a3a74ac..f5c3ad3 100644
|
||||
index a3a74ac..bb99e5f 100644
|
||||
--- ./src/lib/rmodule.c
|
||||
+++ ./src/lib/rmodule.c
|
||||
@@ -125,10 +125,21 @@ static inline size_t rmodule_number_relocations(const struct rmodule *module)
|
||||
@@ -198,7 +198,7 @@ int rmodule_load(void *base, struct rmodule *module)
|
||||
rmodule_clear_bss(module);
|
||||
|
||||
static void rmodule_copy_payload(const struct rmodule *module)
|
||||
{
|
||||
- printk(BIOS_DEBUG, "Loading module at %p with entry %p. "
|
||||
- "filesize: 0x%x memsize: 0x%x\n",
|
||||
- module->location, rmodule_entry(module),
|
||||
- module->payload_size, rmodule_memory_size(module));
|
||||
+ const size_t mem_size = rmodule_memory_size(module);
|
||||
+
|
||||
+ printk(BIOS_DEBUG, "Loading module at %p/%p with entry %p. "
|
||||
+ "filesize: 0x%x memsize: 0x%zx\n",
|
||||
+ module->location, module->payload, rmodule_entry(module),
|
||||
+ module->payload_size, mem_size);
|
||||
+
|
||||
+ // zero the excess memory if there is any
|
||||
+ if (mem_size > module->payload_size)
|
||||
+ {
|
||||
+ memset((uint8_t*) module->location + module->payload_size,
|
||||
+ 0,
|
||||
+ mem_size - module->payload_size
|
||||
+ );
|
||||
+ }
|
||||
prog_segment_loaded((uintptr_t)module->location,
|
||||
- rmodule_memory_size(module), SEG_FINAL);
|
||||
+ rmodule_memory_size(module), SEG_FINAL | SEG_NO_MEASURE);
|
||||
|
||||
/* No need to copy the payload if the load location and the
|
||||
* payload location are the same. */
|
||||
@@ -162,7 +173,8 @@ static int rmodule_relocate(const struct rmodule *module)
|
||||
printk(PK_ADJ_LEVEL, "Adjusting %p: 0x%08lx -> 0x%08lx\n",
|
||||
adjust_loc, (unsigned long) *adjust_loc,
|
||||
(unsigned long) (*adjust_loc + adjustment));
|
||||
- *adjust_loc += adjustment;
|
||||
+
|
||||
+ *adjust_loc += adjustment;
|
||||
|
||||
reloc++;
|
||||
num_relocations--;
|
||||
return 0;
|
||||
}
|
||||
diff --git ./src/lib/sha1.c ./src/lib/sha1.c
|
||||
new file mode 100644
|
||||
index 0000000..506907f
|
||||
@ -433,7 +419,7 @@ index 49854cb..32eb128 100644
|
||||
+}
|
||||
+
|
||||
diff --git ./src/northbridge/intel/sandybridge/romstage.c ./src/northbridge/intel/sandybridge/romstage.c
|
||||
index 738e285..2b16657 100644
|
||||
index 738e285..c7c0c62 100644
|
||||
--- ./src/northbridge/intel/sandybridge/romstage.c
|
||||
+++ ./src/northbridge/intel/sandybridge/romstage.c
|
||||
@@ -29,6 +29,8 @@
|
||||
@ -483,7 +469,7 @@ index 738e285..2b16657 100644
|
||||
+
|
||||
+void platform_segment_loaded(uintptr_t start, size_t size, int flags)
|
||||
+{
|
||||
+ if (IS_ENABLED(CONFIG_MEASURED_BOOT))
|
||||
+ if (IS_ENABLED(CONFIG_MEASURED_BOOT) && !(flags & SEG_NO_MEASURE))
|
||||
+ {
|
||||
+ tlcl_measure(2, (const void*) start, size);
|
||||
+ }
|
||||
|
Loading…
Reference in New Issue
Block a user