intel_txt: Intel(R) TXT and tboot kernel support
Subsystems (8)
RFC PATCH v3 2/2 intel_txt: Intel(R) TXT and tboot kernel support
Linux support for Intel(R) Trusted Execution Technology.
Documentation/intel_txt.txt | 187 ++++++++++++++++++++++++ Documentation/x86/zero-page.txt | 1 arch/x86/include/asm/bootparam.h | 3 arch/x86/include/asm/fixmap.h | 3 arch/x86/include/asm/tboot.h | 154 +++++++++++++++++++ arch/x86/kernel/Makefile | 1 arch/x86/kernel/reboot.c | 14 + arch/x86/kernel/setup.c | 4 arch/x86/kernel/smpboot.c | 6 arch/x86/kernel/tboot.c | 302 +++++++++++++++++++++++++++++++++++++++ drivers/acpi/acpica/hwsleep.c | 33 ++++ drivers/pci/dmar.c | 6 drivers/pci/intel-iommu.c | 26 +++ init/main.c | 3 kernel/cpu.c | 6 security/Kconfig | 22 ++ 16 files changed, 764 insertions(+), 7 deletions(-)
Signed-off-by: Joseph Cihula <[email protected]> Signed-off-by: Shane Wang <[email protected]> Signed-off-by: Gang Wei <[email protected]>
---
arch/x86/include/asm/bootparam.h +2 -1
@@ -84,7 +84,8 @@ struct efi_info {struct boot_params {struct screen_info screen_info;/* 0x000 */ struct apm_bios_info apm_bios_info;/* 0x040 */ -__u8 _pad2[12 ];/* 0x054 */ +__u8 _pad2[4 ];/* 0x054 */ +__u64 tboot_shared_addr;/* 0x058 */ struct ist_info ist_info;/* 0x060 */ __u8 _pad3[16 ];/* 0x070 */ __u8 hd0_info[16 ];/* obsolete! */ /* 0x080 */
arch/x86/include/asm/fixmap.h +3 -0
@@ -132,6 +132,9 @@ enum fixed_addresses {#ifdef CONFIG_X86_32 FIX_WP_TEST,#endif +#ifdef CONFIG_INTEL_TXT +FIX_TBOOT_SHARED_BASE , +#endif __end_of_fixed_addresses };
arch/x86/include/asm/tboot.h +154 -0
154 lines not on this page · raw message
arch/x86/kernel/Makefile +1 -0
@@ -47,6 +47,7 @@ obj-$(CONFIG_X86_DS) += ds.o obj-$(CONFIG_X86_32) += tls.o obj-$(CONFIG_IA32_EMULATION) += tls.o obj-y += step.o +obj-$(CONFIG_INTEL_TXT) += tboot.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-y += cpu/ obj-y += acpi/
arch/x86/kernel/reboot.c +12 -2
@@ -24,6 +24,8 @@# include <asm/iommu.h> #endif +#include <asm/tboot.h> +/* * Power off function, if any */
@@ -443,6 +445,8 @@ static void native_machine_emergency_resif (reboot_emergency)emergency_vmx_disable_all (); +tboot_shutdown (TB_SHUTDOWN_REBOOT ); +/* Tell the BIOS if we want cold or warm reboot */ *((unsigned short *)__va (0x472 )) = reboot_mode;
@@ -508,11 +512,13 @@ static void native_machine_emergency_resvoid native_machine_shutdown (void ) { -/* Stop the cpus and apics */ #ifdef CONFIG_SMP -/* The boot cpu is always logical cpu 0 */ int reboot_cpu_id =0 ; +#endif + +/* Stop the cpus and apics */ +#ifdef CONFIG_SMP #ifdef CONFIG_X86_32 /* See if there has been given a command line override */
@@ -569,6 +575,8 @@ static void native_machine_halt(void)/* stop other cpus and apics */ machine_shutdown (); +tboot_shutdown (TB_SHUTDOWN_HALT ); +/* stop this cpu */ stop_this_cpu (NULL ); }
@@ -580,6 +588,8 @@ static void native_machine_power_off(voimachine_shutdown ();pm_power_off (); } +/* a fallback in case there is no PM info available */ +tboot_shutdown (TB_SHUTDOWN_HALT ); }struct machine_ops machine_ops = {
arch/x86/kernel/setup.c +4 -0
@@ -137,6 +137,8 @@ struct boot_params __initdata boot_paramstruct boot_params boot_params;#endif +#include <asm/tboot.h> +/* * Machine setup.. */
@@ -939,6 +941,8 @@ void __init setup_arch(char **cmdline_p)paravirt_pagetable_setup_done (swapper_pg_dir);paravirt_post_allocator_init (); +tboot_probe (); +#ifdef CONFIG_X86_64 map_vsyscall ();#endif
arch/x86/kernel/smpboot.c +5 -1
@@ -62,6 +62,7 @@#include <asm/vmi.h> #include <asm/apic.h> #include <asm/setup.h> +#include <asm/tboot.h> #include <asm/uv/uv.h> #include <linux/mc146818rtc.h>
@@ -1313,7 +1314,10 @@ void play_dead_common(void)void native_play_dead (void ) {play_dead_common (); -wbinvd_halt (); +if (tboot_in_measured_env ()) +tboot_shutdown (TB_SHUTDOWN_WFS ); +else +wbinvd_halt (); }#else /* ... !CONFIG_HOTPLUG_CPU */
arch/x86/kernel/tboot.c +302 -0
302 lines not on this page · raw message
Documentation/intel_txt.txt +187 -0
187 lines not on this page · raw message
Documentation/x86/zero-page.txt +1 -0
@@ -12,6 +12,7 @@ Offset Proto Name Meaning 000/040 ALL screen_info Text mode or frame buffer information (struct screen_info) 040/014 ALL apm_bios_info APM BIOS information (struct apm_bios_info) +058/008 ALL tboot_shared_addr Physical address of tboot shared page 060/010 ALL ist_info Intel SpeedStep (IST) BIOS support information (struct ist_info) 080/010 ALL hd0_info hd0 disk parameter, OBSOLETE!!
drivers/acpi/acpica/hwsleep.c +33 -0
@@ -45,6 +45,7 @@#include <acpi/acpi.h> #include "accommon.h" #include "actables.h" +#include <asm/tboot.h> #define _COMPONENT ACPI_HARDWAREACPI_MODULE_NAME ("hwsleep" )
@@ -342,6 +343,38 @@ acpi_status asmlinkage acpi_enter_sleep_ACPI_FLUSH_CPU_CACHE (); +#ifdef CONFIG_INTEL_TXT +#define TB_COPY_GAS (tbg, g) \ + tbg.space_id = g.space_id; \ + tbg.bit_width = g.bit_width; \ + tbg.bit_offset = g.bit_offset; \ + tbg.access_width = g.access_width; \ + tbg.address = g.address; + +if (tboot_in_measured_env ()) { +TB_COPY_GAS (tboot_shared->acpi_sinfo.pm1a_cnt_blk, + acpi_gbl_FADT.xpm1a_control_block); +TB_COPY_GAS (tboot_shared->acpi_sinfo.pm1b_cnt_blk, + acpi_gbl_FADT.xpm1b_control_block); +TB_COPY_GAS (tboot_shared->acpi_sinfo.pm1a_evt_blk, + acpi_gbl_FADT.xpm1a_event_block); +TB_COPY_GAS (tboot_shared->acpi_sinfo.pm1b_evt_blk, + acpi_gbl_FADT.xpm1b_event_block); + tboot_shared->acpi_sinfo.pm1a_cnt_val = pm1a_control; + tboot_shared->acpi_sinfo.pm1b_cnt_val = pm1b_control; +/* we need phys addr of waking vector, but can't use +virt_to_phys() on &acpi_gbl_FACS because it is ioremap'ed, +so calc from FACS phys addr */ + tboot_shared->acpi_sinfo.wakeup_vector = acpi_gbl_FADT.facs + + offsetof(struct acpi_table_facs , firmware_waking_vector); + tboot_shared->acpi_sinfo.vector_width =32 ; + tboot_shared->acpi_sinfo.kernel_s3_resume_vector = + acpi_wakeup_address; + +tboot_sleep (sleep_state); + } +#endif +/* Write #2: Write both SLP_TYP + SLP_EN */ status =acpi_hw_write_pm1_control (pm1a_control, pm1b_control);
drivers/pci/dmar.c +6 -0
@@ -33,6 +33,7 @@#include <linux/timer.h> #include <linux/irq.h> #include <linux/interrupt.h> +#include <asm/tboot.h> #undef PREFIX#define PREFIX "DMAR:"
@@ -329,6 +330,11 @@ parse_dmar_table(void)*/ dmar_table_detect (); +/* ACPI tables may not be DMA protected by tboot, so use DMAR copy */ +/* SINIT saved in SinitMleData in TXT heap (which is DMA protected) */ +if (tboot_in_measured_env ()) + dmar_tbl =tboot_get_dmar_table (); + dmar = (struct acpi_table_dmar *)dmar_tbl;if (!dmar)return -ENODEV ;
drivers/pci/intel-iommu.c +24 -2
@@ -38,6 +38,7 @@#include <linux/intel-iommu.h> #include <linux/sysdev.h> #include <asm/cacheflush.h> +#include <asm/tboot.h> #include <asm/iommu.h> #include "pci.h"
@@ -2775,12 +2776,31 @@ static int __init init_iommu_sysfs(void)int __init intel_iommu_init (void ) {int ret =0 ; +int force_on =0 ; -if (dmar_table_init ()) +/* VT-d is required for a TXT/tboot launch, so enforce that */ +if (tboot_in_measured_env ()) { +if (no_iommu || swiotlb || dmar_disabled) +printk (KERN_WARNING "TXT: Forcing Intel-IOMMU to enabled\n" ); + dmar_disabled =0 ; +#ifdef CONFIG_SWIOTLB + swiotlb =0 ; +#endif + no_iommu =0 ; + force_on =1 ; + } + +if (dmar_table_init ()) { +if (force_on) +panic ("TXT: Failed to initialize DMAR table\n" );return -ENODEV ; + } -if (dmar_dev_scope_init ()) +if (dmar_dev_scope_init ()) { +if (force_on) +panic ("TXT: Failed to initialize DMAR device scope\n" );return -ENODEV ; + }/* * Check the need for DMA-remapping initialization now.
@@ -2796,6 +2816,8 @@ int __init intel_iommu_init(void) ret =init_dmars ();if (ret) { +if (force_on) +panic ("TXT: Failed to initialize DMARs\n" );printk (KERN_ERR "IOMMU: dmar init failed\n" );put_iova_domain (&reserved_iova_list);iommu_exit_mempool ();
init/main.c +3 -0
@@ -69,6 +69,7 @@#include <asm/io.h> #include <asm/bugs.h> #include <asm/setup.h> +#include <asm/tboot.h> #include <asm/sections.h> #include <asm/cacheflush.h> #include <trace/kmemtrace.h>
@@ -696,6 +697,8 @@ asmlinkage void __init start_kernel(voidftrace_init (); +tboot_create_trampoline (); +/* Do the rest non-__init'ed, we're now alive */ rest_init (); }
kernel/cpu.c +5 -1
@@ -14,6 +14,7 @@#include <linux/kthread.h> #include <linux/stop_machine.h> #include <linux/mutex.h> +#include <asm/tboot.h> #ifdef CONFIG_SMP /* Serializes the updates to cpu_online_mask, cpu_present_mask */
@@ -379,7 +380,7 @@ static cpumask_var_t frozen_cpus;int disable_nonboot_cpus (void ) { -int cpu, first_cpu, error; +int cpu, first_cpu, error, num_cpus =0 ; error =stop_machine_create ();if (error)
@@ -394,6 +395,7 @@ int disable_nonboot_cpus(void)for_each_online_cpu (cpu) {if (cpu == first_cpu)continue ; + num_cpus++; error =_cpu_down (cpu,1 );if (!error) {cpumask_set_cpu (cpu, frozen_cpus);
@@ -404,6 +406,8 @@ int disable_nonboot_cpus(void)break ; } } +/* ensure all CPUs have gone into wait-for-SIPI */ +tboot_wait_for_aps (num_cpus);if (!error) {BUG_ON (num_online_cpus () >1 );/* Make sure the CPUs won't be enabled by someone else */
security/Kconfig +22 -0
@@ -133,6 +133,28 @@ config SECURITY_DEFAULT_MMAP_MIN_ADDR /proc/sys/vm/mmap_min_addr tunable. +config INTEL_TXT + bool "Enable Intel(R) Trusted Execution Technology (Intel(R) TXT)" + depends on EXPERIMENTAL && X86 && DMAR + help + This option enables support for booting the kernel with the + Trusted Boot (tboot) module. This will utilize + Intel(R) Trusted Execution Technology to perform a measured launch + of the kernel. If the system does not support Intel(R) TXT, this + will have no effect. + + Intel TXT will provide higher assurance of sysem configuration and + initial state as well as data reset protection. This is used to + create a robust initial kernel measurement and verification. + + See <http://www.intel.com/technology/security/> for more information + about Intel(R) TXT. + See <http://tboot.sourceforge.net> for more information about tboot. + See Documentation/intel_txt.txt for a description of how to enable + Intel TXT support in a kernel boot. + + If you are unsure as to whether this is required, answer N. + source security/selinux/Kconfig source security/smack/Kconfig source security/tomoyo/Kconfig
arch/x86/include/asm/fixmap.h enum fixed_addresses { · line 137
Quoted 11 lines · On Thu, 07 May 2009 21:49:07 -0700 Joseph Cihula <[email protected]>…
Linux support for Intel(R) Trusted Execution Technology.
arch/x86/include/asm/fixmap.h +3
-0@@ -132,6 +132,9 @@ enum fixed_addresses {#ifdef CONFIG_X86_32 FIX_WP_TEST,#endif +#ifdef CONFIG_INTEL_TXT + FIX_TBOOT_SHARED_BASE, +#endif
Curious. Does this "shared" page get documented anywhere in the code?
It can't use ioremap() or early_ioremap()?
arch/x86/include/asm/fixmap.h enum fixed_addresses {
Quoted 13 lines
arch/x86/include/asm/fixmap.h +7
-0__end_of_fixed_addresses }; +struct tboot_uuid { +u32 data1; +u16 data2; +u16 data3; +u16 data4; +u8 data5[6 ]; +} __attribute__ ((__packed__ ));
Please use __packed everywhere.
Quoted 21 lines
arch/x86/include/asm/fixmap.h +21
-0+/* used to communicate between tboot and the launched kernel */ + +#define TB_KEY_SIZE 64/* 512 bits */ + +#define MAX_TB_MAC_REGIONS 32 +struct tboot_mac_region { +u64 start;/* must be 64 byte -aligned */ +u32 size;/* must be 64 byte -granular */ +} __attribute__ ((__packed__ )); + +/* GAS - Generic Address Structure (ACPI 2.0+) */ +struct tboot_acpi_generic_address { +u8 space_id; +u8 bit_width; +u8 bit_offset; +u8 access_width; +u64 address; +} __attribute__ ((__packed__ )); + +/* combines Sx info from FADT and FACS tables per ACPI 2.0+ spec +(http://www.acpi.info/) */
arch/x86/include/asm/fixmap.h
Quoted 10 lines
arch/x86/include/asm/fixmap.h +10
-0+struct tboot_acpi_sleep_info { +struct tboot_acpi_generic_address pm1a_cnt_blk; +struct tboot_acpi_generic_address pm1b_cnt_blk; +struct tboot_acpi_generic_address pm1a_evt_blk; +struct tboot_acpi_generic_address pm1b_evt_blk; +u16 pm1a_cnt_val; +u16 pm1b_cnt_val; +u64 wakeup_vector; +u32 vector_width; +u64 kernel_s3_resume_vector;
Indenting broke in many places.
I didn't see a `depends on ACPI' in Kconfig. Is it needed?
Quoted 19 lines
arch/x86/include/asm/fixmap.h +19
-0+} __attribute__ ((__packed__)); + +struct tboot_shared { +/* version 3+ fields: */ +struct tboot_uuid uuid;/* TBOOT_SHARED_UUID */ +u32 version;/* Version number: 5 is current */ +u32 log_addr;/* physical addr of tb_log_t log */ +u32 shutdown_entry;/* entry point for tboot shutdown */ +u32 shutdown_type;/* type of shutdown (TB_SHUTDOWN_*) */ +struct tboot_acpi_sleep_info + acpi_sinfo;/* where kernel put acpi sleep info in Sx */ +u32 tboot_base;/* starting addr for tboot */ +u32 tboot_size;/* size of tboot */ +u8 num_mac_regions;/* number mem regions to MAC on S3 */ +/* contig regions memory to MAC on S3 */ +struct tboot_mac_region mac_regions[MAX_TB_MAC_REGIONS ]; +/* version 4+ fields: */ +/* populated by tboot; will be encrypted */ +u8 s3_key[TB_KEY_SIZE ];
arch/x86/include/asm/fixmap.h
Quoted 10 lines
arch/x86/include/asm/fixmap.h +10
-0+/* version 5+ fields: */ +u8 reserved_align[3 ];/* used to 4byte-align num_in_wfs */ +u32 num_in_wfs;/* number of processors in wait-for-SIPI */ +} __attribute__ ((__packed__)); + +/* UUID for tboot_shared data struct to facilitate matching */ +/* {663C8DFF-E8B3-4b82-AABF-19EA4D057A08} */ +#define TBOOT_SHARED_UUID \ + ((struct tboot_uuid){ 0x663c8dff, 0xe8b3, 0x4b82, 0xaabf, \ + { 0x19, 0xea, 0x4d, 0x5, 0x7a, 0x8 } })
Strange. A
static struct tboot_uuid uuid __initdata = { ... };within tboot_probe() would suffice.
Quoted 7 lines
arch/x86/include/asm/fixmap.h +7
-0+extern struct tboot_shared *tboot_shared; + +static inline int tboot_in_measured_env (void ) +{ +return tboot_shared !=NULL ; +} +
arch/x86/include/asm/fixmap.h
Quoted 10 lines
arch/x86/include/asm/fixmap.h +7
-0+ +#include <linux/init.h> +#include <linux/sched.h> +#include <linux/pfn.h> +#include <linux/mm.h> +#include <linux/spinlock.h> +#include <linux/init_task.h>
a newline here is typical
Quoted 29 lines
arch/x86/include/asm/fixmap.h +29
-0+#include <asm/pgtable.h> +#include <asm/pgalloc.h> +#include <asm/processor.h> +#include <asm/bootparam.h> +#include <asm/setup.h> +#include <asm/io.h> +#include <asm/e820.h> +#include <asm/tboot.h> + +/* Global pointer to shared data; NULL means no measured launch. */ +struct tboot_shared *tboot_shared__read_mostly ; + +void __init tboot_probe (void ) +{ +/* Look for valid page-aligned address for shared page. */ +if (boot_params.tboot_shared_addr ==0 ) +return ; +/* also verify that it is mapped as we expect it before calling +set_fixmap(), to reduce chance of garbage value causing crash */ +if (!e820_any_mapped (boot_params.tboot_shared_addr, + boot_params.tboot_shared_addr,E820_UNUSABLE )) { +printk (KERN_WARNING "TXT: non-0 tboot_shared_addr but it is not of type E820_UNUSABLE\n" ); +return ; + } + +/* only a natively booted kernel should be using TXT */ +if (paravirt_enabled ()) { +printk (KERN_WARNING "TXT: non-0 tboot_shared_addr but pv_ops is enabled\n" ); +return ;
arch/x86/include/asm/fixmap.h
Quoted 10 lines
arch/x86/include/asm/fixmap.h +10
-0+ } + +/* Map and check for tboot UUID. */ +set_fixmap (FIX_TBOOT_SHARED_BASE , boot_params.tboot_shared_addr); + tboot_shared = (struct tboot_shared *) +fix_to_virt (FIX_TBOOT_SHARED_BASE ); +if (memcmp (&TBOOT_SHARED_UUID , &tboot_shared->uuid, +sizeof (struct tboot_uuid ))) { +printk (KERN_WARNING "TXT: tboot_shared at 0x%lx is invalid\n" , + (unsigned long )boot_params.tboot_shared_addr);
That's a peculiar way of printing a u64, especially on 32 bit.
The code appears to be enabled for 32-bit. Is that a supported/tested/realistic combination?
Quoted 27 lines
arch/x86/include/asm/fixmap.h +24
-0+ tboot_shared =NULL ; +return ; + } +if (tboot_shared->version <5 ) { +printk (KERN_WARNING "TXT: tboot_shared version is invalid: %u\n" , + tboot_shared->version); + tboot_shared =NULL ; +return ; + } + +printk (KERN_INFO "TXT: found shared page at phys addr 0x%lx:\n" , + (unsigned long )boot_params.tboot_shared_addr); +printk (KERN_DEBUG "TXT: version: %d\n" , tboot_shared->version); +printk (KERN_DEBUG "TXT: log_addr: 0x%08x\n" , tboot_shared->log_addr); +printk (KERN_DEBUG "TXT: shutdown_entry: 0x%x\n" , + tboot_shared->shutdown_entry); +printk (KERN_DEBUG "TXT: tboot_base: 0x%08x\n" , + tboot_shared->tboot_base); +printk (KERN_DEBUG "TXT: tboot_size: 0x%x\n" , + tboot_shared->tboot_size); +} + +void tboot_shutdown (u32 shutdown_type) +{
arch/x86/include/asm/fixmap.h
Quoted 10 lines
arch/x86/include/asm/fixmap.h +10
-0+if (!tboot_in_measured_env ()) +return ; + +/* if we're being called before the 1:1 mapping is set up then just +return and let the normal shutdown happen; this should only be +due to very early panic() */ +if (!tboot_pg_dir) +return ; + +local_irq_disable ();
Mystery local_irq_disable() needs a comment, methinks.
Quoted 64 lines
arch/x86/include/asm/fixmap.h +61
-0+/* if this is S3 then set regions to MAC */ +if (shutdown_type ==TB_SHUTDOWN_S3 ) { + tboot_shared->num_mac_regions =3 ; +/* S3 resume code */ + tboot_shared->mac_regions[0 ].start = +PFN_PHYS (PFN_DOWN (acpi_wakeup_address)); + tboot_shared->mac_regions[0 ].size = +PFN_UP (WAKEUP_SIZE ) <<PAGE_SHIFT ; +/* AP trampoline code */ + tboot_shared->mac_regions[1 ].start = +PFN_PHYS (PFN_DOWN (virt_to_phys (trampoline_base))); + tboot_shared->mac_regions[1 ].size = +PFN_UP (TRAMPOLINE_SIZE ) <<PAGE_SHIFT ; +/* kernel code + data + bss */ + tboot_shared->mac_regions[2 ].start = +PFN_PHYS (PFN_DOWN (virt_to_phys (&_text))); + tboot_shared->mac_regions[2 ].size = +PFN_PHYS (PFN_UP (virt_to_phys (&_end))) - +PFN_PHYS (PFN_DOWN (virt_to_phys (&_text))); + } + + tboot_shared->shutdown_type = shutdown_type; + +switch_to_tboot_pt (); + + ((void (*)(void ))(unsigned long )tboot_shared->shutdown_entry)(); + +/* should not reach here */ +while (1 ) +halt (); +} + +struct acpi_table_header *tboot_get_dmar_table (void ) +{ +void *heap_base, *heap_ptr, *config; +struct acpi_table_header *dmar_table; + +/* ACPI tables may not be DMA protected by tboot, so use DMAR copy */ +/* SINIT saved in SinitMleData in TXT heap (which is DMA protected) */ + +/* map config space in order to get heap addr */ + config =ioremap (TXT_PUB_CONFIG_REGS_BASE ,NR_TXT_CONFIG_PAGES * +PAGE_SIZE ); +if (config ==NULL ) +return NULL ; + +/* now map TXT heap */ + heap_base =ioremap (*(u64 *)(config +TXTCR_HEAP_BASE ), + *(u64 *)(config +TXTCR_HEAP_SIZE )); +iounmap (config); +if (heap_base ==NULL ) +return NULL ; + +/* walk heap to SinitMleData */ +/* skip BiosData */ + heap_ptr = heap_base + *(u64 *)heap_base; +/* skip OsMleData */ + heap_ptr += *(u64 *)heap_ptr; +/* skip OsSinitData */ + heap_ptr += *(u64 *)heap_ptr; +/* now points to SinitMleDataSize; set to SinitMleData */
arch/x86/include/asm/fixmap.h
Quoted 10 lines
arch/x86/include/asm/fixmap.h +10
-0+ heap_ptr +=sizeof (u64); +/* get addr of DMAR table */ + dmar_table = (struct acpi_table_header *)(heap_ptr + + ((struct sinit_mle_data *)heap_ptr)->vtd_dmars_off - +sizeof (u64)); + +/* don't unmap heap because dmar.c needs access to this */ + +return dmar_table; +}
This function trusts BIOS authors rather a lot.
Quoted 15 lines
...
arch/x86/include/asm/fixmap.h +12
-0+config INTEL_TXT + bool "Enable Intel(R) Trusted Execution Technology (Intel(R) TXT)" + depends on EXPERIMENTAL && X86 && DMAR +help + This option enables support for booting the kernel with the + Trusted Boot (tboot) module. This will utilize + Intel(R) Trusted Execution Technology to perform a measured launch + of the kernel. If the system does not support Intel(R) TXT, this + will have no effect. + + Intel TXT will provide higher assurance of sysem configuration and + initial state as well as data reset protection. This is used to
arch/x86/include/asm/fixmap.h
Quoted 10 lines
arch/x86/include/asm/fixmap.h +10
-0+ create a robust initial kernel measurement and verification. + + See <http://www.intel.com/technology/security/> for more information + about Intel(R) TXT. + See <http://tboot.sourceforge.net> for more information about tboot. + See Documentation/intel_txt.txt for a description of how to enable + Intel TXT support in a kernel boot. + + If you are unsure as to whether this is required, answer N. +
The help uses a mix of tab- and space-indenting which is why it looks all messy when quoted.
Quoted 10 lines
From: Andrew Morton [mailto:[email protected]]
Sent: Thursday, May 07, 2009 11:54 PMarch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 -
Quoted 4 lines · On Thu, 07 May 2009 21:49:07 -0700 Joseph Cihula <[email protected]>…
Linux support for Intel(R) Trusted Execution Technology.
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +0
-00700
Quoted 9 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - enum fixed_addresses { · line 137
Quoted 7 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +3
-0@@ -132,6 +132,9 @@ enum fixed_addresses { #ifdef CONFIG_X86_32 FIX_WP_TEST, #endif +#ifdef CONFIG_INTEL_TXT + FIX_TBOOT_SHARED_BASE, +#endifCurious. Does this "shared" page get documented anywhere in the code?
I've added a brief comment in tboot.h.
Quoted 1 line
It can't use
ioremap()orearly_ioremap()?
The tboot_probe() fn that maps the shared page is called too early in boot to use ioremap(). And since the shared page needs to remain mapped for the lifetime of the kernel, it did not seem appropriate to use early_ioremap() (which is specified as being for temporary boot-time mappings).
Quoted 6 lines
Quoted 6 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +0
-0__end_of_fixed_addresses };
Quoted 9 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 -
Quoted 7 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +7
-0+struct tboot_uuid { + u32 data1; + u16 data2; + u16 data3; + u16 data4; + u8 data5[6]; +} __attribute__ ((__packed__));Please use
__packedeverywhere.
Done.
Quoted 25 lines
Quoted 25 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +25
-0+/* used to communicate between tboot and the launched kernel */ + +#define TB_KEY_SIZE 64 /* 512 bits */ + +#define MAX_TB_MAC_REGIONS 32 +struct tboot_mac_region { + u64 start; /* must be 64 byte -aligned */ + u32 size; /* must be 64 byte -granular */ +} __attribute__ ((__packed__)); + +/* GAS - Generic Address Structure (ACPI 2.0+) */ +struct tboot_acpi_generic_address { + u8 space_id; + u8 bit_width; + u8 bit_offset; + u8 access_width; + u64 address; +} __attribute__ ((__packed__)); + +/* combines Sx info from FADT and FACS tables per ACPI 2.0+ spec + (http://www.acpi.info/) */ +struct tboot_acpi_sleep_info { + struct tboot_acpi_generic_address pm1a_cnt_blk; + struct tboot_acpi_generic_address pm1b_cnt_blk; + struct tboot_acpi_generic_address pm1a_evt_blk;
Quoted 8 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 -
Quoted 6 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +6
-0+ struct tboot_acpi_generic_address pm1b_evt_blk; + u16 pm1a_cnt_val; + u16 pm1b_cnt_val; + u64 wakeup_vector; + u32 vector_width; + u64 kernel_s3_resume_vector;Indenting broke in many places.
Fixed.
Quoted 1 line
I didn't see a `depends on ACPI' in
Kconfig. Is it needed?
Good catch; yes, it will be needed for proper shutdown of the system. I'll add a dependency on it.
Quoted 32 lines
Quoted 19 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +19
-0+} __attribute__ ((__packed__)); + +struct tboot_shared { + /* version 3+ fields: */ + struct tboot_uuid uuid; /* TBOOT_SHARED_UUID */ + u32 version; /* Version number: 5 is current */ + u32 log_addr; /* physical addr of tb_log_t log */ + u32 shutdown_entry; /* entry point for tboot shutdown */ + u32 shutdown_type; /* type of shutdown (TB_SHUTDOWN_*) */ + struct tboot_acpi_sleep_info + acpi_sinfo; /* where kernel put acpi sleep info in Sx */ + u32 tboot_base; /* starting addr for tboot */ + u32 tboot_size; /* size of tboot */ + u8 num_mac_regions; /* number mem regions to MAC on S3 */ + /* contig regions memory to MAC on S3 */ + struct tboot_mac_region mac_regions[MAX_TB_MAC_REGIONS]; + /* version 4+ fields: */ + /* populated by tboot; will be encrypted */ + u8 s3_key[TB_KEY_SIZE];arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 -
Quoted 10 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +10
-0+ /* version 5+ fields: */ + u8 reserved_align[3]; /* used to 4byte-align num_in_wfs */ + u32 num_in_wfs; /* number of processors in wait-for-SIPI */ +} __attribute__ ((__packed__)); + +/* UUID for tboot_shared data struct to facilitate matching */ +/* {663C8DFF-E8B3-4b82-AABF-19EA4D057A08} */ +#define TBOOT_SHARED_UUID \ + ((struct tboot_uuid){ 0x663c8dff, 0xe8b3, 0x4b82, 0xaabf, \ + { 0x19, 0xea, 0x4d, 0x5, 0x7a, 0x8 } })Strange. A
Quoted 3 lines
static struct tboot_uuid uuid __initdata = { ... };within
tboot_probe()would suffice.
It seems logical to keep the definition of the UUID in the header file with the data struct that uses it. But I created a static var in tboot_probe() defined as __initdata to hold it so that the memory can be reclaimed post-init.
Quoted 10 lines
Quoted 10 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +7
-0+extern struct tboot_shared *tboot_shared; + +static inline int tboot_in_measured_env(void) +{ + return tboot_shared != NULL; +} +
Quoted 9 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 -
Quoted 7 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +7
-0+ +#include <linux/init.h> +#include <linux/sched.h> +#include <linux/pfn.h> +#include <linux/mm.h> +#include <linux/spinlock.h> +#include <linux/init_task.h>a newline here is typical
Done.
Quoted 43 lines
Quoted 12 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +12
-0+#include <asm/pgtable.h> +#include <asm/pgalloc.h> +#include <asm/processor.h> +#include <asm/bootparam.h> +#include <asm/setup.h> +#include <asm/io.h> +#include <asm/e820.h> +#include <asm/tboot.h> + +/* Global pointer to shared data; NULL means no measured launch. */ +struct tboot_shared *tboot_shared __read_mostly; +arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 -
Quoted 10 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +10
-0+void __init tboot_probe(void) +{ + /* Look for valid page-aligned address for shared page. */ + if (boot_params.tboot_shared_addr == 0) + return; + /* also verify that it is mapped as we expect it before calling + set_fixmap(), to reduce chance of garbage value causing crash */ + if (!e820_any_mapped(boot_params.tboot_shared_addr, + boot_params.tboot_shared_addr, E820_UNUSABLE)) { + printk(KERN_WARNING "TXT: non-0 tboot_shared_addr but it is not of typeE820_UNUSABLE\n");
Quoted 7 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +7
-0+ return; + } + + /* only a natively booted kernel should be using TXT */ + if (paravirt_enabled()) { + printk(KERN_WARNING "TXT: non-0 tboot_shared_addr but pv_ops is enabled\n"); + return;arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 -
Quoted 10 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +10
-0+ } + + /* Map and check for tboot UUID. */ + set_fixmap(FIX_TBOOT_SHARED_BASE, boot_params.tboot_shared_addr); + tboot_shared = (struct tboot_shared *) + fix_to_virt(FIX_TBOOT_SHARED_BASE); + if (memcmp(&TBOOT_SHARED_UUID, &tboot_shared->uuid, + sizeof(struct tboot_uuid))) { + printk(KERN_WARNING "TXT: tboot_shared at 0x%lx is invalid\n", + (unsigned long)boot_params.tboot_shared_addr);That's a peculiar way of printing a u64, especially on 32 bit.
Quoted 2 lines
The code appears to be enabled for 32-bit. Is that a supported/tested/realistic combination?
Both 32b and 64b are supported and have been tested. TXT has some address restrictions (<4GB) that resulted in some of these. However, I have converted these to %llx and removed the cast.
Quoted 25 lines
Quoted 25 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +22
-0+ tboot_shared = NULL; + return; + } + if (tboot_shared->version < 5) { + printk(KERN_WARNING "TXT: tboot_shared version is invalid: %u\n", + tboot_shared->version); + tboot_shared = NULL; + return; + } + + printk(KERN_INFO "TXT: found shared page at phys addr 0x%lx:\n", + (unsigned long)boot_params.tboot_shared_addr); + printk(KERN_DEBUG "TXT: version: %d\n", tboot_shared->version); + printk(KERN_DEBUG "TXT: log_addr: 0x%08x\n", tboot_shared->log_addr); + printk(KERN_DEBUG "TXT: shutdown_entry: 0x%x\n", + tboot_shared->shutdown_entry); + printk(KERN_DEBUG "TXT: tboot_base: 0x%08x\n", + tboot_shared->tboot_base); + printk(KERN_DEBUG "TXT: tboot_size: 0x%x\n", + tboot_shared->tboot_size); +} +
Quoted 14 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 -
Quoted 12 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +12
-0+void tboot_shutdown(u32 shutdown_type) +{ + if (!tboot_in_measured_env()) + return; + + /* if we're being called before the 1:1 mapping is set up then just + return and let the normal shutdown happen; this should only be + due to very early panic() */ + if (!tboot_pg_dir) + return; + + local_irq_disable();Mystery
local_irq_disable()needs a comment, methinks.
This isn't needed after all and has been removed.
Quoted 68 lines
Quoted 68 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +65
-0+ /* if this is S3 then set regions to MAC */ + if (shutdown_type == TB_SHUTDOWN_S3) { + tboot_shared->num_mac_regions = 3; + /* S3 resume code */ + tboot_shared->mac_regions[0].start = + PFN_PHYS(PFN_DOWN(acpi_wakeup_address)); + tboot_shared->mac_regions[0].size = + PFN_UP(WAKEUP_SIZE) << PAGE_SHIFT; + /* AP trampoline code */ + tboot_shared->mac_regions[1].start = + PFN_PHYS(PFN_DOWN(virt_to_phys(trampoline_base))); + tboot_shared->mac_regions[1].size = + PFN_UP(TRAMPOLINE_SIZE) << PAGE_SHIFT; + /* kernel code + data + bss */ + tboot_shared->mac_regions[2].start = + PFN_PHYS(PFN_DOWN(virt_to_phys(&_text))); + tboot_shared->mac_regions[2].size = + PFN_PHYS(PFN_UP(virt_to_phys(&_end))) - + PFN_PHYS(PFN_DOWN(virt_to_phys(&_text))); + } + + tboot_shared->shutdown_type = shutdown_type; + + switch_to_tboot_pt(); + + ((void(*)(void))(unsigned long)tboot_shared->shutdown_entry)(); + + /* should not reach here */ + while (1) + halt(); +} + +struct acpi_table_header *tboot_get_dmar_table(void) +{ + void *heap_base, *heap_ptr, *config; + struct acpi_table_header *dmar_table; + + /* ACPI tables may not be DMA protected by tboot, so use DMAR copy */ + /* SINIT saved in SinitMleData in TXT heap (which is DMA protected) */ + + /* map config space in order to get heap addr */ + config = ioremap(TXT_PUB_CONFIG_REGS_BASE, NR_TXT_CONFIG_PAGES * + PAGE_SIZE); + if (config == NULL) + return NULL; + + /* now map TXT heap */ + heap_base = ioremap(*(u64 *)(config + TXTCR_HEAP_BASE), + *(u64 *)(config + TXTCR_HEAP_SIZE)); + iounmap(config); + if (heap_base == NULL) + return NULL; + + /* walk heap to SinitMleData */ + /* skip BiosData */ + heap_ptr = heap_base + *(u64 *)heap_base; + /* skip OsMleData */ + heap_ptr += *(u64 *)heap_ptr; + /* skip OsSinitData */ + heap_ptr += *(u64 *)heap_ptr; + /* now points to SinitMleDataSize; set to SinitMleData */ + heap_ptr += sizeof(u64); + /* get addr of DMAR table */ + dmar_table = (struct acpi_table_header *)(heap_ptr + + ((struct sinit_mle_data *)heap_ptr)->vtd_dmars_off -
Quoted 8 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 -
Quoted 6 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +6
-0+ sizeof(u64)); + + /* don't unmap heap because dmar.c needs access to this */ + + return dmar_table; +}This function trusts BIOS authors rather a lot.
Not really--this data structure gets validated as part of the TXT launch process and only tboot and the kernel execute after that point. So since none of them modify this structure, it should still be valid (as valid as any other kernel data struct which does not get re-validated on every use).
Quoted 19 lines
Quoted 19 lines
...
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +17
-0+config INTEL_TXT + bool "Enable Intel(R) Trusted Execution Technology (Intel(R) TXT)" + depends on EXPERIMENTAL && X86 && DMAR + help + This option enables support for booting the kernel with the + Trusted Boot (tboot) module. This will utilize + Intel(R) Trusted Execution Technology to perform a measured launch + of the kernel. If the system does not support Intel(R) TXT, this + will have no effect. + + Intel TXT will provide higher assurance of sysem configuration and + initial state as well as data reset protection. This is used to + create a robust initial kernel measurement and verification. + + See <http://www.intel.com/technology/security/> for more information + about Intel(R) TXT. + See <http://tboot.sourceforge.net> for more information about tboot.
Quoted 8 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 -
Quoted 5 lines
arch/x86/include/asm/fixmap.h 2009-05-07 08:07:17.000000000 - renamed from arch/x86/include/asm/fixmap.h 2009-04-29 21:48:16.000000000 -0700 +5
-0+ See Documentation/intel_txt.txt for a description of how to enable + Intel TXT support in a kernel boot. + + If you are unsure as to whether this is required, answer N. +The help uses a mix of tab- and space-indenting which is why it looks all messy when quoted.
Fixed.
arch/x86/kernel/tboot.c line 163
Quoted 5 lines · Joseph Cihula
arch/x86/kernel/tboot.c +5
-0+/* if we're being called before the 1:1 mapping is set up then just +return and let the normal shutdown happen; this should only be +due to very early panic() */ +if (!tboot_pg_dir) +return ;
Please use the customary comment style:
/*
* Comment .....
* ...... goes here:
*/
specified in Documentation/CodingStyle. Please fix this in all other multi-line comments in your patch as well.
Quoted 15 lines
arch/x86/kernel/tboot.c +15
-0+if (shutdown_type ==TB_SHUTDOWN_S3 ) { + tboot_shared->num_mac_regions =3 ; +/* S3 resume code */ + tboot_shared->mac_regions[0 ].start = +PFN_PHYS (PFN_DOWN (acpi_wakeup_address)); + tboot_shared->mac_regions[0 ].size = +PFN_UP (WAKEUP_SIZE ) <<PAGE_SHIFT ; +/* AP trampoline code */ + tboot_shared->mac_regions[1 ].start = +PFN_PHYS (PFN_DOWN (virt_to_phys (trampoline_base))); + tboot_shared->mac_regions[1 ].size = +PFN_UP (TRAMPOLINE_SIZE ) <<PAGE_SHIFT ; +/* kernel code + data + bss */ + tboot_shared->mac_regions[2 ].start = +PFN_PHYS (PFN_DOWN (virt_to_phys (&_text)));
arch/x86/kernel/tboot.c line 192
Quoted 10 lines
arch/x86/kernel/tboot.c +10
-0+ tboot_shared->mac_regions[2 ].size = +PFN_PHYS (PFN_UP (virt_to_phys (&_end))) - +PFN_PHYS (PFN_DOWN (virt_to_phys (&_text))); + } + + tboot_shared->shutdown_type = shutdown_type; + +switch_to_tboot_pt (); + + ((void (*)(void ))(unsigned long )tboot_shared->shutdown_entry)();
shutdown_entry should probably have a proper function pointer type, to avoid this ugliness.
Ingo
Quoted 13 lines
From: Ingo Molnar [mailto:[email protected]]
Sent: Friday, May 08, 2009 2:58 AMarch/x86/kernel/tboot.c line 163
Quoted 5 lines · Joseph Cihula
arch/x86/kernel/tboot.c +5
-0+/* if we're being called before the 1:1 mapping is set up then just +return and let the normal shutdown happen; this should only be +due to very early panic() */ +if (!tboot_pg_dir) +return ;Please use the customary comment style:
Quoted 7 lines
/*
* Comment .....
* ...... goes here:*/specified in
Documentation/CodingStyle. Please fix this in all other multi-line comments in your patch as well.
Will do.
Quoted 20 lines
Quoted 20 lines
arch/x86/kernel/tboot.c +20
-0+if (shutdown_type ==TB_SHUTDOWN_S3 ) { + tboot_shared->num_mac_regions =3 ; +/* S3 resume code */ + tboot_shared->mac_regions[0 ].start = +PFN_PHYS (PFN_DOWN (acpi_wakeup_address)); + tboot_shared->mac_regions[0 ].size = +PFN_UP (WAKEUP_SIZE ) <<PAGE_SHIFT ; +/* AP trampoline code */ + tboot_shared->mac_regions[1 ].start = +PFN_PHYS (PFN_DOWN (virt_to_phys (trampoline_base))); + tboot_shared->mac_regions[1 ].size = +PFN_UP (TRAMPOLINE_SIZE ) <<PAGE_SHIFT ; +/* kernel code + data + bss */ + tboot_shared->mac_regions[2 ].start = +PFN_PHYS (PFN_DOWN (virt_to_phys (&_text))); + tboot_shared->mac_regions[2 ].size = +PFN_PHYS (PFN_UP (virt_to_phys (&_end))) - +PFN_PHYS (PFN_DOWN (virt_to_phys (&_text))); + } +
Quoted 8 lines
arch/x86/kernel/tboot.c line 192
Quoted 5 lines
arch/x86/kernel/tboot.c +5
-0+ tboot_shared->shutdown_type = shutdown_type; + +switch_to_tboot_pt (); + + ((void (*)(void ))(unsigned long )tboot_shared->shutdown_entry)();
shutdown_entryshould probably have a proper function pointer type, to avoid this ugliness.
Since pointer types are different lengths depending on whether it is a 32b or 64b build environment, that would not allow a separately-compiled tboot to be used with both 32b and 64b kernels.
Joe
Quoted 52 lines · Cihula, Joseph
Quoted 13 lines
From: Ingo Molnar [mailto:[email protected]]
Sent: Friday, May 08, 2009 2:58 AMarch/x86/kernel/tboot.c line 163
Quoted 5 lines · Joseph Cihula
arch/x86/kernel/tboot.c +5
-0+/* if we're being called before the 1:1 mapping is set up then just +return and let the normal shutdown happen; this should only be +due to very early panic() */ +if (!tboot_pg_dir) +return ;Please use the customary comment style:
Quoted 7 lines
/*
* Comment .....
* ...... goes here:*/specified in
Documentation/CodingStyle. Please fix this in all other multi-line comments in your patch as well.Will do.
Quoted 20 lines
Quoted 20 lines
arch/x86/kernel/tboot.c +20
-0+if (shutdown_type ==TB_SHUTDOWN_S3 ) { + tboot_shared->num_mac_regions =3 ; +/* S3 resume code */ + tboot_shared->mac_regions[0 ].start = +PFN_PHYS (PFN_DOWN (acpi_wakeup_address)); + tboot_shared->mac_regions[0 ].size = +PFN_UP (WAKEUP_SIZE ) <<PAGE_SHIFT ; +/* AP trampoline code */ + tboot_shared->mac_regions[1 ].start = +PFN_PHYS (PFN_DOWN (virt_to_phys (trampoline_base))); + tboot_shared->mac_regions[1 ].size = +PFN_UP (TRAMPOLINE_SIZE ) <<PAGE_SHIFT ; +/* kernel code + data + bss */ + tboot_shared->mac_regions[2 ].start = +PFN_PHYS (PFN_DOWN (virt_to_phys (&_text))); + tboot_shared->mac_regions[2 ].size = +PFN_PHYS (PFN_UP (virt_to_phys (&_end))) - +PFN_PHYS (PFN_DOWN (virt_to_phys (&_text))); + } +Quoted 8 lines
arch/x86/kernel/tboot.c line 192
Quoted 5 lines
arch/x86/kernel/tboot.c +5
-0+ tboot_shared->shutdown_type = shutdown_type; + +switch_to_tboot_pt (); + + ((void (*)(void ))(unsigned long )tboot_shared->shutdown_entry)();
shutdown_entryshould probably have a proper function pointer type, to avoid this ugliness.
Quoted 4 lines
Since pointer types are different lengths depending on whether it is a 32b or 64b build environment, that would not allow a separately-compiled tboot to be used with both 32b and 64b kernels.
then the sign extension is done slightly wrong/unclean i guess. Wouldnt:
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ ((void(*)(void))(long)tboot_shared->shutdown_entry)();
be better? Or is shutdown_entry always mapped into [0..2GB) on 64-bit? Even then, not sign-extending RIP addresses is wrong and invites bugs/restrictions.
Ingo
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
+ ((void(*)(void))(long)tboot_shared->shutdown_entry)();
be better? Or is
shutdown_entryalways mapped into [0..2GB) on
0..4GB and this code runs in a identity mapping.
Quoted 2 lines
64-bit? Even then, not sign-extending RIP addresses is wrong and invites bugs/restrictions.
You never have to sign extend when going from 32bit to 64bit on x86-64.
-andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Quoted 1 line · Joseph Cihula
Linux support for Intel(R) Trusted Execution Technology.
It should be noted that one of the prime purposes of the Trusted Execution Technology (TXT), aka LaGrande Technology is for DRM enforcement systems that can be nearly uncrackable.
It can be used for other things, such as restricting who can look at your medical records (basically, the same technology that prevents you from breaking the DRM on say, a high-definition movie from Hollywood) can also be used to enforced who can look at your certain records, such as medical records in a highly secure and non-circumvental fashion.
Ross Anderson was one of the first to write about these concerns, over five years ago:
http://www.cl.cam.ac.uk/~rja14/tcpa-faq.html
It's interesting that his 2003 document was able to predict the emergence of the LaGrande Technology (see question 15 in the above FAQ).
So we should expect a certain amount of controversy and people lobbying to resist the acceptance of this patch.
Regards,
- Ted
Quoted 8 lines · Theodore Tso
Ross Anderson was one of the first to write about these concerns, over five years ago:
http://www.cl.cam.ac.uk/~rja14/tcpa-faq.htmlIt's interesting that his 2003 document was able to predict the emergence of the LaGrande Technology (see question 15 in the above FAQ).
Many thanks for pointing this out!
Strange enough, nobody seems to care. I have carefully read Ross Andersons report, and I'm more than concerned now. Because I'm not a kernel programmer, I can not see by myself what these patches will do to the Linux kernel at all, so I can only hope that Linus will not let them in if they can be misused to what Ross Anderson describes in his paper.
Regards,
Heinz.
James Morris
maintainerQuoted 2 lines · Theodore Tso
So we should expect a certain amount of controversy and people lobbying to resist the acceptance of this patch.
FWIW, here's my response to an earlier private enquiry from John on the topic:
I'd prefer discussion to be public, so I don't mind leaving more detailed discussion to that.
There has been considerable discussion on the issue, following Linus' statement (which I'm sure you're aware of):
http://marc.info/?l=linux-kernel&m=105115686114064&w=2
My position is similar -- people can decide for themselves whether they want to use DRM technology. I'm also confident that technical measures taken to prevent real freedom will always be broken (when have they ever not been?)
I also feel there may be genuinely useful applications of some of the technology (e.g. sealing disk encryption keys in the TPM a la BitLocker).
I'm fairly neutral on the technology itself and feel that "market pressure" from users as well as local regulatory policy (e.g. anti-trust laws) should determine how the technology is used, rather than the views of a few kernel hackers.
- James
Signature · 2 lines
James Morris <[email protected]>
Quoted 35 lines
From: James Morris [mailto:[email protected]]
Sent: Thursday, May 14, 2009 5:18 PMQuoted 2 lines · Theodore Tso
So we should expect a certain amount of controversy and people lobbying to resist the acceptance of this patch.
FWIW, here's my response to an earlier private enquiry from John on the topic:
I'd prefer discussion to be public, so I don't mind leaving more detailed discussion to that.
There has been considerable discussion on the issue, following Linus' statement (which I'm sure you're aware of):
http://marc.info/?l=linux-kernel&m=105115686114064&w=2
My position is similar -- people can decide for themselves whether they want to use DRM technology. I'm also confident that technical measures taken to prevent real freedom will always be broken (when have they ever not been?)
I also feel there may be genuinely useful applications of some of the technology (e.g. sealing disk encryption keys in the TPM a la BitLocker).
I'm fairly neutral on the technology itself and feel that "market pressure" from users as well as local regulatory policy (e.g. anti-trust laws) should determine how the technology is used, rather than the views of a few kernel hackers.
Quoted 4 lines
- James
--
James Morris
<[email protected]>
For a balanced view on Trusted Computing, people should also read David Safford's (IBM) rebuttal whitepaper at: http://www.research.ibm.com/gsal/tcpa/tcpa_rebuttal.pdf.
As James points out, there has been a lot written, argued, and debated about Trusted Computing and I would encourage those who are concerned about it to read the discussions and then look at the documentation and presentations on Intel(R) Trusted Execution Technology (Intel(R) TXT). Any technology can be used for good or bad, but Intel has tried to ensure that users have control of TXT.
I would also encourage those who are concerned about these patches to look at the Linux code and tboot code to satisfy themselves that it is providing exactly what we have claimed.
Joe
Quoted 1 line · Joseph
For a balanced view [] read [] rebuttal
By definition a rebuttal is not balanced.
Quoted 7 lines
From: Joe Perches [mailto:[email protected]]
Sent: Thursday, May 14, 2009 6:51 PMQuoted 1 line · Joseph
For a balanced view [] read [] rebuttal
By definition a rebuttal is not balanced.
But once a person understands both sides of the issue, perhaps *his/her view* will be.
Joe
James Morris
maintainerFWIW,
There are some new slides from a talk by the InvisbleThings folk on this topic which should help people understand some of the benefits and pitfalls of this technology at a high level:
http://theinvisiblethings.blogspot.com/2009/05/thoughts-about-trusted-computing.html
Signature · 2 lines
James Morris <[email protected]>
Quoted 4 lines · Joseph
For a balanced view on Trusted Computing, people should also read David Safford's (IBM) rebuttal whitepaper at:
http://www.research.ibm.com/gsal/tcpa/tcpa_rebuttal.pdf.
Note that most of what David wrote about in his paper was specific to TCPA, and not necessarily the TXT/LaGrande technology. I recently defended TCPA to someone who expressed concerns about IMA going into the kernel, on the grounds that TCPA was so badly done it was almost impossible to use it to create a workable DRM system. Given how TCPA works, this is definitely true, and I judge that the benefits (being able to protect private keys under the user's controlled) outwieghs the potential downsides (namely that of DRM, given that it was pretty much impossible to make a workable DRM system using the TCPA/IMA architecture alone).
However, it seems to me that TXT/LaGrande's main purpose for existence was to repair the defects in TCPA that made it essentially unsuable for DRM purposes. With TCPA, any time you changed *anything* in the boot path --- installed a new BIOS, upgraded to a new kernel to fix a security vulnerability, updated to a new Nvidia proprietary video driver slightly less likely to crash your sustem --- it would change the trusted boot measurements, and would require an exchange to "Circuity City DIVX hotline" (as a generic stand-in for whoever is Hollywood's current monkey paw towards trying to implement DRM) to approve a transfer of the TCPA trusted keys, which would be essentially be a consumer support nightmare, and there would be no way for "Circuit City" to know whether the kernel you are claiming was the latest update from Fedora or Novell or Canonical was really an authorized upgrade, or whether it was a custom kernel with patches to tap into video and audio paths to steal Hollywood's precious bodily fluids.
With TXT, however, all of these problems go away. What you end up booting is completely under "Circit City's DIVX's" control, and may include a miniature Windows environment running in the trusted environment; it could then take over a portion of the screen for the video output, and the hardware would have special features set up to prevent the host OS from having any access to the video output of the movie player running in the TXT environment. (This was how Intel presented the LaGrande technology to the Kernel Summit several years ago, and I assume the capabilities of TXT hasn't change significantly since then.)
Essentially, it's hard for me to think up situations where the TCPA chip would not be sufficient in terms of being a solution to a security problem that has the user's best interests at heart, rather than that of Hollywood, and where TXT would be a such a solution. Medical records are perhaps the best example I can come up with; and maybe some kind of bank security system where you're only allowed to engage in on-line banking if you run a bank-supplied application in the TXT environment. However, it's hard for me to believe banks and hospitals will invest in solutions that implement these sorts of benign solutions, and it's all too easy for me to believe that Hollywood will invest in these sorts of solutions.
That being said, it's not clear to me that stopping the technology from going into Linux really isn't going to help matters; realistically, the Linux desktop is miniscule[1], and whether or not we add support for TXT in the mainline Linux kernel isn't going to stop Hollywood's plans. A much better approach would be for the FSF to organize a boycott urging users users not to buy *any* hardware that is TXT enabled, whether it is going to be booting Windows, MacOS X, or Linux. And note that I said *hardware*, not CPU. In order for TXT to work, the BIOS, motherboard, video chipset, etc., all have to be working in concert in order to provide a secure environment that can't be tapped in by the Host OS.
[1] The one potential risk I could see is TXT being used in Moblin, and that being used as a scheme to implement DRM ala Hollywood style. But realistically, even if we don't let it into mainline kernel, it won't stop Moblin hardware vendors from shipping it.
The bottom line is it this is a social problem, not a technical problem, and probably needs to be solved by social means (i.e., an FSF-led boycott). But from a technical point of view, I would be shocked if the first major user of the TXT technology *wasn't* to provide DRM enforcement of one kind or another.
Regards,
- Ted
BTW, see this slide set:
http://invisiblethingslab.com/resources/bh09dc/Attacking%20Intel%20TXT%20-%20slides.pdf
For more details about why a TCPA-style solution (referred to in the slide set as a Static Root of Trust Measurement) doesn't really work for widespread consumer-usable DRM, where as a Dynamic Root of Trust Measurement (DRTM) scheme, such as provided by TXT, makes this be a much more tractable solution.
Also see their early results for attacking TXT via bugs in the SMM Bios. The one thing which is not discussed much in this slide decks is the hardware implemented features which lock out the Host OS from being able to read or modify memory used by the trusted code running in the secure VM (which must be locked into memory) once the SENTER instruction is given.
Obviously, yes, it's all under the user's control --- you don't have to boot a TXT VM image. On the other hand, you don't have to have access to your on-line banking, medical records, or watch a movie from Hollywood, and in the future, it might be that running TXT is the only way to do that. (The argument that it's always under the user's control is a standard line used by people defending DRM --- after all, you don't have to listen to the protected music, or watch the protected movie. It shifts the ground from the question societal question of "is DRM good for society", to a user freedom question, which is always true --- of course, user's are also free to boycott purchases of hardware that enable DRM; that is also their choice.)
- Ted
Hi!
Quoted 10 lines
With TXT, however, all of these problems go away. What you end up booting is completely under "Circit City's DIVX's" control, and may include a miniature Windows environment running in the trusted environment; it could then take over a portion of the screen for the video output, and the hardware would have special features set up to prevent the host OS from having any access to the video output of the movie player running in the TXT environment. (This was how Intel presented the LaGrande technology to the Kernel Summit several years ago, and I assume the capabilities of TXT hasn't change significantly since then.)
How does this interact with keyboard handling?
Quoted 11 lines
Essentially, it's hard for me to think up situations where the TCPA chip would not be sufficient in terms of being a solution to a security problem that has the user's best interests at heart, rather than that of Hollywood, and where TXT would be a such a solution. Medical records are perhaps the best example I can come up with; and maybe some kind of bank security system where you're only allowed to engage in on-line banking if you run a bank-supplied application in the TXT environment. However, it's hard for me to believe banks and hospitals will invest in solutions that implement these sorts of benign solutions, and it's all too easy for me to believe that Hollywood will invest in these sorts of solutions.
I suspect it does not 'protect' keyboard at all, meaning it is only useful for drm.
Quoted 5 lines
The bottom line is it this is a social problem, not a technical problem, and probably needs to be solved by social means (i.e., an FSF-led boycott). But from a technical point of view, I would be shocked if the first major user of the TXT technology *wasn't* to provide DRM enforcement of one kind or another.
I see not merging / dropping changes only useful for drm from linux kernelas a valid 'social means'...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 6 lines
Quoted 6 lines
I'd prefer discussion to be public, so I don't mind leaving more detailed discussion to that.
There has been considerable discussion on the issue, following Linus' statement (which I'm sure you're aware of):
Quoted 6 lines
Quoted 6 lines
http://marc.info/?l=linux-kernel&m=105115686114064&w=2
My position is similar -- people can decide for themselves whether they want to use DRM technology. I'm also confident that technical measures taken to prevent real freedom will always be broken (when have they ever not been?)
Linus says he hates drm but does not want to stop it through legal means, because its impossible. Does that mean we should merge any random drm crap? I hope not.
Quoted 8 lines
Quoted 8 lines
I also feel there may be genuinely useful applications of some of the technology (e.g. sealing disk encryption keys in the TPM a la BitLocker).
I'm fairly neutral on the technology itself and feel that "market pressure" from users as well as local regulatory policy (e.g. anti-trust laws) should determine how the technology is used, rather than the views of a few kernel hackers.
So some of the technology is useful -> we merge all of it?
Quoted 3 lines
For a balanced view on Trusted Computing, people should also read David Safford's (IBM) rebuttal whitepaper at:
http://www.research.ibm.com/gsal/tcpa/tcpa_rebuttal.pdf.
Sorry, but that article is full of hype, nothing balanced on it. Plus it speaks about different technology. Plus it is intentionally misleading.
Quoted 2 lines
Technology (Intel(R) TXT). Any technology can be used for good or bad, but Intel has tried to ensure that users have control of TXT.
I don't see where you got that nonsense.
Try using atomic bomb for something good. Then try to use tv remote control for something bad.
TXT was specifically designed to enable atomic bombs^W^W drm, and I see no other reasonable use.
Quoted 3 lines
I would also encourage those who are concerned about these patches to look at the Linux code and tboot code to satisfy themselves that it is providing exactly what we have claimed.
I certainly hope booting secure sandbox is root-only operation... is it?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 6 lines · Richard M Stallman
Linus says he hates drm but does not want to stop it through legal means, because its impossible.
It is quite possible to block use of DRM in Linux. All they need to do is move to GPLv3. Eben Moglen worked out for them how they could do this if they want to.
Actually, moving Linux to GPLv3 would do absolutely nothing to stop DRM as implemented by the LaGrande/TXT technology. That's because what is actually running inside the trusted execution environment doesn't have to be GPL'ed code at all. It doesn't even really need to be an OS, since it relies on Linux to effectively be a sophisticated bootloader and networking stack and windowing manager for it.
This is one of the reasons why I've always personally thought it was a very bad idea to try to stop DRM via copyright licenses such as the GPLv3; you might be able to prevent one which requires a "trusted kernel", via the GPLv3's "anti-TIVO clause". However, the LaGrande/TXT doesn't require a trusted kernel. You can modify the kernel all you want. However, if the kernel tries tampering with the trusted image which TXT provides, it will be detected and the trusted boot operation will fail --- but the code which does the digital signature check and the code running in the tboot environment isn't GPL'ed code at all, and part of the enforcement is done in hardware.
Consider the situation where the DRM'ed code was running as part of Windows Vista, and so a Linux user downloaded code which ran the DRM'ed application under Windows Vista under KVM in an virtual environment. It's obvious that whether Linux is licensed under GPLv2 or GPLv3 would make no difference in prohibited the DRM'ed code to be run in VM, right? TXT is basically this, except that (a) the hardware provides strong protection against tampering once the trusted environment is established, and (b) there are well defined interfaces for thet trusted enviroment use the filesystem, device drivers, and networking stack of the host OS to do its I/O (with everything stored in the filesystem, or fetched over the network, protected via either encryption or digital signatures, or both).
GPLv3 simply won't help address the DRM issue in this situation --- just as the GPLv3 won't prevent the next Bernie Madoff from using GPL'ed software to run a Ponzi scheme. Sometimes, you can't use copyright licenses to prevent people from doing evil things with the software that we write and maintain. That doesn't excuse the bad use cases; just that copyright licenses isn't the right tool to use to prevent these situations from happening.
- Ted
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 4 lines · rms
This scheme must be very different from anything I've heard of before. Can you tell me where to find a description?
I want to study whether it really avoids being affected by GPLv3, and how we can fight against it.
Some description is here:
http://en.wikipedia.org/wiki/Trusted_Execution_Technology .
And yes, I believe it avoids GPLv3: TXT allows user (I _hope_ it is root-only) to boot tamper-free sandbox. As long as Windows (or something) runs in the sandbox, I believe even GPLv3 would allow that.
OTOH... I do not think mainline kernel should support this. It does not add anything to the user's security, and allows all kinds of nasty DRMs.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 9 lines
Quoted 2 lines
So we should expect a certain amount of controversy and people lobbying to resist the acceptance of this patch.
FWIW, here's my response to an earlier private enquiry from John on the topic:
I'd prefer discussion to be public, so I don't mind leaving more detailed discussion to that.
Quoted 7 lines
There has been considerable discussion on the issue, following Linus' statement (which I'm sure you're aware of):
http://marc.info/?l=linux-kernel&m=105115686114064&w=2
My position is similar -- people can decide for themselves whether they want to use DRM technology.
Actually, they can not. Basically, my neighbors decide if I have to
use the DRM technology. Because as soon as too many of them use it ISPs/banks/youtube will just make it mandatory.
I dont't think my neighbors should have that kind of power over me, and the only way to ensure that seems to be keeping TXT and similar stuff far away from mainline.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
H. Peter Anvin
reviewerQuoted 5 lines · Pavel Machek
I dont't think my neighbors should have that kind of power over me, and the only way to ensure that seems to be keeping TXT and similar stuff far away from mainline.
If with "mainline" you mean Windows, you might have a chance there... :(
Do note:
Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.