diff --git a/xen/arch/x86/include/asm/slaunch.h b/xen/arch/x86/include/asm/slaunch.h index 70101bb5d6..1d81b0de02 100644 --- a/xen/arch/x86/include/asm/slaunch.h +++ b/xen/arch/x86/include/asm/slaunch.h @@ -40,6 +40,10 @@ static inline void find_evt_log(struct slr_table *slrt, void **evt_log, } } +void map_slaunch_mem_regions(void); + +void protect_slaunch_mem_regions(void); + /* * This helper function is used to map memory using L2 page tables by aligning * mapped regions to 2MB. This way page allocator (which at this point isn't diff --git a/xen/arch/x86/intel_txt.c b/xen/arch/x86/intel_txt.c index c3471dfe1f..cc9a6d01b0 100644 --- a/xen/arch/x86/intel_txt.c +++ b/xen/arch/x86/intel_txt.c @@ -15,11 +15,7 @@ static uint64_t __initdata txt_heap_base, txt_heap_size; void __init map_txt_mem_regions(void) { - void *evt_log_addr; - uint32_t evt_log_size; - map_l2(TXT_PRIV_CONFIG_REGS_BASE, NR_TXT_CONFIG_SIZE); - map_l2(TPM_TIS_BASE, TPM_TIS_SIZE); txt_heap_base = read_txt_reg(TXTCR_HEAP_BASE); BUG_ON(txt_heap_base == 0); @@ -28,20 +24,11 @@ void __init map_txt_mem_regions(void) BUG_ON(txt_heap_size == 0); map_l2(txt_heap_base, txt_heap_size); - - find_evt_log(__va(slaunch_slrt), &evt_log_addr, &evt_log_size); - map_l2((unsigned long)evt_log_addr, evt_log_size); - if ( evt_log_addr != NULL ) - map_l2((unsigned long)evt_log_addr, evt_log_size); } void __init protect_txt_mem_regions(void) { int rc; - - void *evt_log_addr; - uint32_t evt_log_size; - uint64_t sinit_base, sinit_size; /* TXT Heap */ @@ -52,17 +39,6 @@ void __init protect_txt_mem_regions(void) txt_heap_base + txt_heap_size); BUG_ON(rc == 0); - /* TXT TPM Event Log */ - find_evt_log(__va(slaunch_slrt), &evt_log_addr, &evt_log_size); - if ( evt_log_addr != NULL ) { - printk("SLAUNCH: reserving event log (%#lx - %#lx)\n", - (uint64_t)evt_log_addr, - (uint64_t)evt_log_addr + evt_log_size); - rc = reserve_e820_ram(&e820_raw, (uint64_t)evt_log_addr, - (uint64_t)evt_log_addr + evt_log_size); - BUG_ON(rc == 0); - } - sinit_base = read_txt_reg(TXTCR_SINIT_BASE); BUG_ON(sinit_base == 0); diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 75ba2ae356..d20075197b 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -61,7 +61,6 @@ #include #include #include -#include #include #include @@ -1363,13 +1362,15 @@ void asmlinkage __init noreturn __start_xen(void) if ( slaunch_active ) { - /* Prepare for TXT-related code. */ - map_txt_mem_regions(); + /* Prepare for accesses to essential data structures setup by boot + * environment. */ + map_slaunch_mem_regions(); + /* Measure SLRT here because it gets used by init_e820(), the rest is * measured below by tpm_process_drtm_policy(). */ tpm_measure_slrt(); - /* Reserve TXT heap and SINIT. */ - protect_txt_mem_regions(); + + protect_slaunch_mem_regions(); } /* Sanitise the raw E820 map to produce a final clean version. */ diff --git a/xen/arch/x86/slaunch.c b/xen/arch/x86/slaunch.c index 24e1dd3c8b..9b29f9fe54 100644 --- a/xen/arch/x86/slaunch.c +++ b/xen/arch/x86/slaunch.c @@ -1,4 +1,6 @@ #include +#include +#include #include #include #include @@ -35,6 +37,43 @@ int __init map_l2(unsigned long paddr, unsigned long size) pages, PAGE_HYPERVISOR); } +void __init map_slaunch_mem_regions(void) +{ + void *evt_log_addr; + uint32_t evt_log_size; + + map_l2(TPM_TIS_BASE, TPM_TIS_SIZE); + + /* Vendor-specific part. It may include contain slaunch_slrt. */ + map_txt_mem_regions(); + + find_evt_log(__va(slaunch_slrt), &evt_log_addr, &evt_log_size); + if ( evt_log_addr != NULL ) + map_l2((unsigned long)evt_log_addr, evt_log_size); +} + +void __init protect_slaunch_mem_regions(void) +{ + int rc; + + void *evt_log_addr; + uint32_t evt_log_size; + + find_evt_log(__va(slaunch_slrt), &evt_log_addr, &evt_log_size); + if ( evt_log_addr != NULL ) + { + printk("SLAUNCH: reserving event log (%#lx - %#lx)\n", + (uint64_t)evt_log_addr, + (uint64_t)evt_log_addr + evt_log_size); + rc = reserve_e820_ram(&e820_raw, (uint64_t)evt_log_addr, + (uint64_t)evt_log_addr + evt_log_size); + BUG_ON(rc == 0); + } + + /* Vendor-specific part. */ + protect_txt_mem_regions(); +} + static struct slr_table *slr_get_table(void) { struct slr_table *slrt = __va(slaunch_slrt);