Skip to contentSkip to conversation

TXT: Intel(R) TXT and tboot kernel support

RFC PATCH In review Joseph Cihula 1 participant 1 message Oct 7, 2008

Subsystems (5)
x86 ACPI Security (LSM) Hibernation +1 more subsystems
lore
Share & tools
lore
#0 lore raw

RFC PATCH 3/3 TXT: Intel(R) TXT and tboot kernel support

(re-posted with apologies for formatting and email addresses)

Signed-off-by:  Shane Wang <[email protected]>
Signed-off-by:  Joseph Cihula <[email protected]>
Signed-off-by:  Gang Wei <[email protected]>

---

arch/x86/configs/i386_defconfig +0 -0
diff -r 29cfdc52a076 arch/x86/configs/i386_defconfig
@@ -54,6 +54,7 @@ CONFIG_X86_TRAMPOLINE=y

CONFIG_X86_TRAMPOLINE=y
CONFIG_KTIME_SCALAR=y CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" +# CONFIG_TXT is not set

#
# General setup

arch/x86/configs/x86_64_defconfig +0 -0
diff -r 29cfdc52a076 arch/x86/configs/x86_64_defconfig
@@ -54,6 +54,7 @@ CONFIG_X86_TRAMPOLINE=y

CONFIG_X86_TRAMPOLINE=y
# CONFIG_KTIME_SCALAR is not set CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" +# CONFIG_TXT is not set

#
# General setup

arch/x86/kernel/Makefile +0 -0
diff -r 29cfdc52a076 arch/x86/kernel/Makefile
@@ -44,6 +44,7 @@ obj-$(CONFIG_X86_32)		+= tls.o

obj-$(CONFIG_X86_32) += tls.o
obj-$(CONFIG_IA32_EMULATION) += tls.o
obj-y += step.o
+obj-$(CONFIG_TXT) += tboot.o
obj-$(CONFIG_STACKTRACE) += stacktrace.o
obj-y += cpu/
obj-y += acpi/

arch/x86/kernel/reboot.c +0 -0
diff -r 29cfdc52a076 arch/x86/kernel/reboot.c
@@ -20,6 +20,8 @@

#else

# include <asm/iommu.h>
#endif
+
+#include <asm/tboot.h>

/*
* Power off function, if any
@@ -456,11 +458,13 @@ static void native_machine_restart(char

	if (!reboot_force)
		machine_shutdown();
+	tboot_shutdown(TB_SHUTDOWN_REBOOT);
	machine_emergency_restart();
}

static void native_machine_halt(void)
{
+ tboot_shutdown(TB_SHUTDOWN_HALT);
}

static void native_machine_power_off(void)
@@ -470,6 +474,8 @@ static void native_machine_power_off(voi

			machine_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 +0 -0
diff -r 29cfdc52a076 arch/x86/kernel/setup.c
@@ -115,6 +115,8 @@ struct boot_params __initdata boot_param

#else
struct boot_params boot_params;
#endif
+
+#include <asm/tboot.h>

/*
* Machine setup..
@@ -833,6 +835,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/tboot.c new file +257 -0

257 lines not on this page · raw message

arch/x86/power/cpu_32.c +0 -0
diff -r 29cfdc52a076 arch/x86/power/cpu_32.c
@@ -11,6 +11,7 @@

#include <linux/suspend.h>
#include <asm/mtrr.h>
#include <asm/mce.h>
+#include <asm/tboot.h>

static struct saved_context saved_context;

@@ -136,5 +137,8 @@ void restore_processor_state(void) void restore_processor_state(void)

{
	__restore_processor_state(&saved_context);

+
+ /* Clean up memory mapping for tboot range */
+ clean_up_tboot_mapping();
}
EXPORT_SYMBOL(restore_processor_state);

arch/x86/power/cpu_64.c +0 -0
diff -r 29cfdc52a076 arch/x86/power/cpu_64.c
@@ -14,6 +14,7 @@

#include <asm/page.h>
#include <asm/pgtable.h>
#include <asm/mtrr.h>
+#include <asm/tboot.h>

static void fix_processor_context(void);

@@ -131,6 +132,9 @@ void restore_processor_state(void) void restore_processor_state(void)

{
	__restore_processor_state(&saved_context);

+
+ /* Clean up memory mapping for tboot range */
+ clean_up_tboot_mapping();
}

static void fix_processor_context(void)

drivers/acpi/hardware/hwsleep.c +0 -0
diff -r 29cfdc52a076 drivers/acpi/hardware/hwsleep.c
@@ -44,6 +44,7 @@
 

#include <acpi/acpi.h>
#include <acpi/actables.h>
+#include <asm/tboot.h>

#define _COMPONENT ACPI_HARDWARE
ACPI_MODULE_NAME("hwsleep")
@@ -77,6 +78,13 @@ acpi_set_firmware_waking_vector(acpi_phy

	if (ACPI_FAILURE(status)) {
		return_ACPI_STATUS(status);
	}

+
+#ifdef CONFIG_TXT
+ if (tboot_in_measured_env()) {
+ tboot_shared->s3_k_wakeup_entry = (uint32_t)physical_address;
+ physical_address = tboot_shared->s3_tb_wakeup_entry;
+ }
+#endif

	/* Set the vector */

@@ -238,6 +246,29 @@ acpi_status acpi_enter_sleep_state_prep(

ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep)

+#ifdef CONFIG_TXT
+static void tboot_sleep(u8 sleep_state)
+{
+ uint32_t shutdown_type;
+
+ switch (sleep_state) {
+ case ACPI_STATE_S3:
+ shutdown_type = TB_SHUTDOWN_S3;
+ break;
+ case ACPI_STATE_S4:
+ shutdown_type = TB_SHUTDOWN_S4;
+ break;
+ case ACPI_STATE_S5:
+ shutdown_type = TB_SHUTDOWN_S5;
+ break;
+ default:
+ return;
+ }
+
+ tboot_shutdown(shutdown_type);
+}
+#endif
+ /*******************************************************************************
*
* FUNCTION: acpi_enter_sleep_state
@@ -361,6 +392,20 @@ acpi_status asmlinkage acpi_enter_sleep_

	PM1Acontrol |= sleep_enable_reg_info->access_bit_mask;
	PM1Bcontrol |= sleep_enable_reg_info->access_bit_mask;

+
+#ifdef CONFIG_TXT
+ if (tboot_in_measured_env()) {
+ tboot_shared->acpi_sinfo.pm1a_cnt =
+ (uint16_t)acpi_gbl_FADT.xpm1a_control_block.address;
+ tboot_shared->acpi_sinfo.pm1b_cnt =
+ (uint16_t)acpi_gbl_FADT.xpm1b_control_block.address;
+ tboot_shared->acpi_sinfo.pm1a_cnt_val = PM1Acontrol;
+ tboot_shared->acpi_sinfo.pm1b_cnt_val = PM1Bcontrol;
+ tboot_sleep(sleep_state);
+ printk(KERN_DEBUG "TBOOT failed entering s3 state\n");
+ return_ACPI_STATUS(AE_ERROR);
+ }
+#endif

	/* Write #2: SLP_TYP + SLP_EN */
include/asm-x86/bootparam.h +0 -0
diff -r 29cfdc52a076 include/asm-x86/bootparam.h
@@ -62,6 +62,7 @@ struct setup_header {
	__u32	payload_offset;
	__u32	payload_length;
	__u64	setup_data;

+ __u32 tboot_shared_addr;
} __attribute__((packed));

struct sys_desc_table {

include/asm-x86/fixmap_32.h +0 -0
diff -r 29cfdc52a076 include/asm-x86/fixmap_32.h
@@ -85,6 +85,9 @@ enum fixed_addresses {

#ifdef CONFIG_PARAVIRT
FIX_PARAVIRT_BOOTMAP,
#endif
+#ifdef CONFIG_TXT
+ FIX_TBOOT_SHARED_BASE,
+#endif

	__end_of_permanent_fixed_addresses,
	/*
	 * 256 temporary boot-time mappings, used by early_ioremap(),
include/asm-x86/fixmap_64.h +0 -0
diff -r 29cfdc52a076 include/asm-x86/fixmap_64.h
@@ -56,6 +56,9 @@ enum fixed_addresses {
#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
	FIX_OHCI1394_BASE,

#endif
+#ifdef CONFIG_TXT
+ FIX_TBOOT_SHARED_BASE,
+#endif

	__end_of_permanent_fixed_addresses,
	/*
	 * 256 temporary boot-time mappings, used by early_ioremap(),
include/asm-x86/tboot.h new file +100 -0

100 lines not on this page · raw message

security/Kconfig +0 -0
diff -r 29cfdc52a076 security/Kconfig
@@ -115,6 +115,23 @@ config SECURITY_DEFAULT_MMAP_MIN_ADDR

/proc/sys/vm/mmap_min_addr tunable.

+config TXT

+        bool "Enable Intel(R) Trusted Execution Technology (TXT)"
+        depends on EXPERIMENTAL && X86
+        help
+          This option enables support for booting the kernel with
+          the Trusted Boot (tboot) module. This will utilize
+          Intel(R) Trusted Execution Technology (TXT) to perform a
+          measured launch of the kernel. If the system does not
+          support TXT, this will have no effect.
+
+          See <http://www.intel.com/technology/security/> for more
+          information about Intel(R) TXT.
+          And see <http://tboot.sourceforge.net> for more information
+          about tboot.

+
+ If you are unsure as to whether this is required, answer N.
+
source security/selinux/Kconfig
source security/smack/Kconfig