ia64/xen-unstable

view xen/arch/x86/tboot.c @ 19085:ef156b933aad

vt-d: Do not explicitly exclude tboot ranges from dom0 vt-d
mappings. tboot is not registered as RAM in e820 tables, and hence
will not be mapped anyway (fails memory_is_conventional_ram() check).

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Sun Jan 25 10:16:11 2009 +0000 (2009-01-25)
parents e265878e8f65
children 1dc576b683c6
line source
1 #include <xen/config.h>
2 #include <xen/init.h>
3 #include <xen/types.h>
4 #include <xen/lib.h>
5 #include <xen/sched.h>
6 #include <asm/fixmap.h>
7 #include <asm/page.h>
8 #include <asm/processor.h>
9 #include <asm/tboot.h>
11 /* tboot=<physical address of shared page> */
12 static char opt_tboot[20] = "";
13 string_param("tboot", opt_tboot);
15 /* Global pointer to shared data; NULL means no measured launch. */
16 tboot_shared_t *g_tboot_shared;
18 static const uuid_t tboot_shared_uuid = TBOOT_SHARED_UUID;
20 void __init tboot_probe(void)
21 {
22 tboot_shared_t *tboot_shared;
23 unsigned long p_tboot_shared;
25 /* Look for valid page-aligned address for shared page. */
26 p_tboot_shared = simple_strtoul(opt_tboot, NULL, 0);
27 if ( (p_tboot_shared == 0) || ((p_tboot_shared & ~PAGE_MASK) != 0) )
28 return;
30 /* Map and check for tboot UUID. */
31 set_fixmap(FIX_TBOOT_SHARED_BASE, p_tboot_shared);
32 tboot_shared = (tboot_shared_t *)fix_to_virt(FIX_TBOOT_SHARED_BASE);
33 if ( memcmp(&tboot_shared_uuid, (uuid_t *)tboot_shared, sizeof(uuid_t)) )
34 return;
36 g_tboot_shared = tboot_shared;
37 printk("TBOOT: found shared page at phys addr %lx:\n", p_tboot_shared);
38 printk(" version: %d\n", tboot_shared->version);
39 printk(" log_addr: 0x%08x\n", tboot_shared->log_addr);
40 printk(" shutdown_entry32: 0x%08x\n", tboot_shared->shutdown_entry32);
41 printk(" shutdown_entry64: 0x%08x\n", tboot_shared->shutdown_entry64);
42 printk(" shutdown_type: %d\n", tboot_shared->shutdown_type);
43 printk(" s3_tb_wakeup_entry: 0x%08x\n", tboot_shared->s3_tb_wakeup_entry);
44 printk(" s3_k_wakeup_entry: 0x%08x\n", tboot_shared->s3_k_wakeup_entry);
45 printk(" &acpi_sinfo: 0x%p\n", &tboot_shared->acpi_sinfo);
46 if ( tboot_shared->version >= 0x02 )
47 {
48 printk(" tboot_base: 0x%08x\n", tboot_shared->tboot_base);
49 printk(" tboot_size: 0x%x\n", tboot_shared->tboot_size);
50 }
51 }
53 void tboot_shutdown(uint32_t shutdown_type)
54 {
55 uint32_t map_base, map_size;
56 int err;
58 g_tboot_shared->shutdown_type = shutdown_type;
60 local_irq_disable();
62 /* Create identity map for tboot shutdown code. */
63 if ( g_tboot_shared->version >= 0x02 )
64 {
65 map_base = PFN_DOWN(g_tboot_shared->tboot_base);
66 map_size = PFN_UP(g_tboot_shared->tboot_size);
67 }
68 else
69 {
70 map_base = 0;
71 map_size = PFN_UP(0xa0000);
72 }
74 err = map_pages_to_xen(map_base << PAGE_SHIFT, map_base, map_size,
75 __PAGE_HYPERVISOR);
76 if ( err != 0 )
77 {
78 printk("error (0x%x) mapping tboot pages (mfns) @ 0x%x, 0x%x\n", err,
79 map_base, map_size);
80 return;
81 }
83 write_ptbase(idle_vcpu[0]);
85 #ifdef __x86_64__
86 asm volatile ( "call *%%rdi" :: "D" (g_tboot_shared->shutdown_entry64) );
87 #else
88 asm volatile ( "call *%0" :: "r" (g_tboot_shared->shutdown_entry32) );
89 #endif
91 BUG(); /* should not reach here */
92 }
94 int tboot_in_measured_env(void)
95 {
96 return (g_tboot_shared != NULL);
97 }
99 /*
100 * Local variables:
101 * mode: C
102 * c-set-style: "BSD"
103 * c-basic-offset: 4
104 * tab-width: 4
105 * indent-tabs-mode: nil
106 * End:
107 */