aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/tboot.c
diff options
context:
space:
mode:
authorKeir Fraser <keir@xensource.com>2007-10-30 10:13:43 +0000
committerKeir Fraser <keir@xensource.com>2007-10-30 10:13:43 +0000
commitca560bd3f58928f2b7d0d1530d22b090bf1a0fd2 (patch)
tree3ff51af1c112389042aa7cf243688ffe03abb441 /xen/arch/x86/tboot.c
parentcb9e907b6f5a64151dda8c38b60ea764a8d38daf (diff)
downloadxen-ca560bd3f58928f2b7d0d1530d22b090bf1a0fd2.tar.gz
xen-ca560bd3f58928f2b7d0d1530d22b090bf1a0fd2.tar.bz2
xen-ca560bd3f58928f2b7d0d1530d22b090bf1a0fd2.zip
Intel(R) Trusted Execution Technology (Intel(R) TXT) support for Xen.
Signed-off-by: Joseph Cihula <joseph.cihula@intel.com>
Diffstat (limited to 'xen/arch/x86/tboot.c')
-rw-r--r--xen/arch/x86/tboot.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c
new file mode 100644
index 0000000000..dbc9b8e407
--- /dev/null
+++ b/xen/arch/x86/tboot.c
@@ -0,0 +1,70 @@
+#include <xen/config.h>
+#include <xen/init.h>
+#include <xen/types.h>
+#include <xen/lib.h>
+#include <xen/sched.h>
+#include <asm/fixmap.h>
+#include <asm/page.h>
+#include <asm/processor.h>
+#include <asm/tboot.h>
+
+/* tboot=<physical address of shared page> */
+static char opt_tboot[20] = "";
+string_param("tboot", opt_tboot);
+
+/* Global pointer to shared data; NULL means no measured launch. */
+tboot_shared_t *g_tboot_shared;
+
+static const uuid_t tboot_shared_uuid = TBOOT_SHARED_UUID;
+
+void __init tboot_probe(void)
+{
+ tboot_shared_t *tboot_shared;
+ unsigned long p_tboot_shared;
+
+ /* Look for valid page-aligned address for shared page. */
+ p_tboot_shared = simple_strtoul(opt_tboot, NULL, 0);
+ if ( (p_tboot_shared == 0) || ((p_tboot_shared & ~PAGE_MASK) != 0) )
+ return;
+
+ /* Map and check for tboot UUID. */
+ set_fixmap(FIX_TBOOT_SHARED_BASE, p_tboot_shared);
+ tboot_shared = (tboot_shared_t *)fix_to_virt(FIX_TBOOT_SHARED_BASE);
+ if ( memcmp(&tboot_shared_uuid, (uuid_t *)tboot_shared, sizeof(uuid_t)) )
+ return;
+
+ g_tboot_shared = tboot_shared;
+ printk("TBOOT: found shared page at phys addr %lx:\n", p_tboot_shared);
+ printk(" version: %d\n", tboot_shared->version);
+ printk(" log_addr: 0x%08x\n", tboot_shared->log_addr);
+ printk(" shutdown_entry32: 0x%08x\n", tboot_shared->shutdown_entry32);
+ printk(" shutdown_entry64: 0x%08x\n", tboot_shared->shutdown_entry64);
+ printk(" shutdown_type: %d\n", tboot_shared->shutdown_type);
+ printk(" s3_tb_wakeup_entry: 0x%08x\n", tboot_shared->s3_tb_wakeup_entry);
+ printk(" s3_k_wakeup_entry: 0x%08x\n", tboot_shared->s3_k_wakeup_entry);
+ printk(" &acpi_sinfo: 0x%p\n", &tboot_shared->acpi_sinfo);
+}
+
+void tboot_shutdown(uint32_t shutdown_type)
+{
+ g_tboot_shared->shutdown_type = shutdown_type;
+
+ local_irq_disable();
+
+ /* Create identity map for 0-640k to include tboot code. */
+ map_pages_to_xen(0, 0, PFN_UP(0xa0000), __PAGE_HYPERVISOR);
+ write_ptbase(idle_vcpu[0]);
+
+#ifdef __x86_64__
+ asm volatile ( "call *%%rdi" :: "D" (g_tboot_shared->shutdown_entry64) );
+#else
+ asm volatile ( "call *%0" :: "r" (g_tboot_shared->shutdown_entry32) );
+#endif
+
+ BUG(); /* should not reach here */
+}
+
+int tboot_in_measured_env(void)
+{
+ return (g_tboot_shared != NULL);
+}