Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 1 | /* Xen-specific pieces of head.S, intended to be included in the right |
| 2 | place in head.S */ |
| 3 | |
| 4 | #ifdef CONFIG_XEN |
| 5 | |
| 6 | #include <linux/elfnote.h> |
Sam Ravnborg | 08b6d29 | 2008-01-30 13:33:25 +0100 | [diff] [blame] | 7 | #include <linux/init.h> |
Jeremy Fitzhardinge | 7077c33 | 2008-07-08 15:06:35 -0700 | [diff] [blame] | 8 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 9 | #include <asm/boot.h> |
Jeremy Fitzhardinge | 7077c33 | 2008-07-08 15:06:35 -0700 | [diff] [blame] | 10 | #include <asm/asm.h> |
Jeremy Fitzhardinge | 0341c14 | 2009-02-13 11:14:01 -0800 | [diff] [blame] | 11 | #include <asm/page_types.h> |
Jeremy Fitzhardinge | 7077c33 | 2008-07-08 15:06:35 -0700 | [diff] [blame] | 12 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 13 | #include <xen/interface/elfnote.h> |
Mukesh Rathor | 4e903a2 | 2013-12-31 11:16:25 -0500 | [diff] [blame] | 14 | #include <xen/interface/features.h> |
Jeremy Fitzhardinge | 7e0edc1 | 2008-05-31 01:33:04 +0100 | [diff] [blame] | 15 | #include <asm/xen/interface.h> |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 16 | |
Mukesh Rathor | 4e903a2 | 2013-12-31 11:16:25 -0500 | [diff] [blame] | 17 | #ifdef CONFIG_XEN_PVH |
| 18 | #define PVH_FEATURES_STR "|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel" |
| 19 | /* Note the lack of 'hvm_callback_vector'. Older hypervisor will |
| 20 | * balk at this being part of XEN_ELFNOTE_FEATURES, so we put it in |
| 21 | * XEN_ELFNOTE_SUPPORTED_FEATURES which older hypervisors will ignore. |
| 22 | */ |
| 23 | #define PVH_FEATURES ((1 << XENFEAT_writable_page_tables) | \ |
| 24 | (1 << XENFEAT_auto_translated_physmap) | \ |
| 25 | (1 << XENFEAT_supervisor_mode_kernel) | \ |
| 26 | (1 << XENFEAT_hvm_callback_vector)) |
| 27 | /* The XENFEAT_writable_page_tables is not stricly neccessary as we set that |
| 28 | * up regardless whether this CONFIG option is enabled or not, but it |
| 29 | * clarifies what the right flags need to be. |
| 30 | */ |
| 31 | #else |
| 32 | #define PVH_FEATURES_STR "" |
| 33 | #define PVH_FEATURES (0) |
| 34 | #endif |
| 35 | |
Sam Ravnborg | 08b6d29 | 2008-01-30 13:33:25 +0100 | [diff] [blame] | 36 | __INIT |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 37 | ENTRY(startup_xen) |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 38 | cld |
Jeremy Fitzhardinge | 8c5e5ac | 2008-07-08 15:06:44 -0700 | [diff] [blame] | 39 | #ifdef CONFIG_X86_32 |
| 40 | mov %esi,xen_start_info |
| 41 | mov $init_thread_union+THREAD_SIZE,%esp |
| 42 | #else |
| 43 | mov %rsi,xen_start_info |
| 44 | mov $init_thread_union+THREAD_SIZE,%rsp |
| 45 | #endif |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 46 | jmp xen_start_kernel |
Sam Ravnborg | 08b6d29 | 2008-01-30 13:33:25 +0100 | [diff] [blame] | 47 | |
| 48 | __FINIT |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 49 | |
Mukesh Rathor | a2ef5dc | 2014-09-10 16:36:06 -0700 | [diff] [blame] | 50 | #ifdef CONFIG_XEN_PVH |
| 51 | /* |
| 52 | * xen_pvh_early_cpu_init() - early PVH VCPU initialization |
| 53 | * @cpu: this cpu number (%rdi) |
| 54 | * @entry: true if this is a secondary vcpu coming up on this entry |
| 55 | * point, false if this is the boot CPU being initialized for |
| 56 | * the first time (%rsi) |
| 57 | * |
| 58 | * Note: This is called as a function on the boot CPU, and is the entry point |
| 59 | * on the secondary CPU. |
| 60 | */ |
| 61 | ENTRY(xen_pvh_early_cpu_init) |
| 62 | mov %rsi, %r11 |
| 63 | |
| 64 | /* Gather features to see if NX implemented. */ |
| 65 | mov $0x80000001, %eax |
| 66 | cpuid |
| 67 | mov %edx, %esi |
| 68 | |
| 69 | mov $MSR_EFER, %ecx |
| 70 | rdmsr |
| 71 | bts $_EFER_SCE, %eax |
| 72 | |
| 73 | bt $20, %esi |
| 74 | jnc 1f /* No NX, skip setting it */ |
| 75 | bts $_EFER_NX, %eax |
| 76 | 1: wrmsr |
| 77 | #ifdef CONFIG_SMP |
| 78 | cmp $0, %r11b |
| 79 | jne cpu_bringup_and_idle |
| 80 | #endif |
| 81 | ret |
| 82 | |
| 83 | #endif /* CONFIG_XEN_PVH */ |
| 84 | |
Jeremy Fitzhardinge | a987b16 | 2008-06-16 15:01:56 -0700 | [diff] [blame] | 85 | .pushsection .text |
Konrad Rzeszutek Wilk | 7d0642b | 2012-07-11 15:03:18 -0400 | [diff] [blame] | 86 | .balign PAGE_SIZE |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 87 | ENTRY(hypercall_page) |
Konrad Rzeszutek Wilk | 7d0642b | 2012-07-11 15:03:18 -0400 | [diff] [blame] | 88 | #define NEXT_HYPERCALL(x) \ |
| 89 | ENTRY(xen_hypercall_##x) \ |
| 90 | .skip 32 |
| 91 | |
| 92 | NEXT_HYPERCALL(set_trap_table) |
| 93 | NEXT_HYPERCALL(mmu_update) |
| 94 | NEXT_HYPERCALL(set_gdt) |
| 95 | NEXT_HYPERCALL(stack_switch) |
| 96 | NEXT_HYPERCALL(set_callbacks) |
| 97 | NEXT_HYPERCALL(fpu_taskswitch) |
| 98 | NEXT_HYPERCALL(sched_op_compat) |
| 99 | NEXT_HYPERCALL(platform_op) |
| 100 | NEXT_HYPERCALL(set_debugreg) |
| 101 | NEXT_HYPERCALL(get_debugreg) |
| 102 | NEXT_HYPERCALL(update_descriptor) |
| 103 | NEXT_HYPERCALL(ni) |
| 104 | NEXT_HYPERCALL(memory_op) |
| 105 | NEXT_HYPERCALL(multicall) |
| 106 | NEXT_HYPERCALL(update_va_mapping) |
| 107 | NEXT_HYPERCALL(set_timer_op) |
| 108 | NEXT_HYPERCALL(event_channel_op_compat) |
| 109 | NEXT_HYPERCALL(xen_version) |
| 110 | NEXT_HYPERCALL(console_io) |
| 111 | NEXT_HYPERCALL(physdev_op_compat) |
| 112 | NEXT_HYPERCALL(grant_table_op) |
| 113 | NEXT_HYPERCALL(vm_assist) |
| 114 | NEXT_HYPERCALL(update_va_mapping_otherdomain) |
| 115 | NEXT_HYPERCALL(iret) |
| 116 | NEXT_HYPERCALL(vcpu_op) |
| 117 | NEXT_HYPERCALL(set_segment_base) |
| 118 | NEXT_HYPERCALL(mmuext_op) |
| 119 | NEXT_HYPERCALL(xsm_op) |
| 120 | NEXT_HYPERCALL(nmi_op) |
| 121 | NEXT_HYPERCALL(sched_op) |
| 122 | NEXT_HYPERCALL(callback_op) |
| 123 | NEXT_HYPERCALL(xenoprof_op) |
| 124 | NEXT_HYPERCALL(event_channel_op) |
| 125 | NEXT_HYPERCALL(physdev_op) |
| 126 | NEXT_HYPERCALL(hvm_op) |
| 127 | NEXT_HYPERCALL(sysctl) |
| 128 | NEXT_HYPERCALL(domctl) |
| 129 | NEXT_HYPERCALL(kexec_op) |
| 130 | NEXT_HYPERCALL(tmem_op) /* 38 */ |
| 131 | ENTRY(xen_hypercall_rsvr) |
| 132 | .skip 320 |
| 133 | NEXT_HYPERCALL(mca) /* 48 */ |
| 134 | NEXT_HYPERCALL(arch_1) |
| 135 | NEXT_HYPERCALL(arch_2) |
| 136 | NEXT_HYPERCALL(arch_3) |
| 137 | NEXT_HYPERCALL(arch_4) |
| 138 | NEXT_HYPERCALL(arch_5) |
| 139 | NEXT_HYPERCALL(arch_6) |
| 140 | .balign PAGE_SIZE |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 141 | .popsection |
| 142 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 143 | ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux") |
| 144 | ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6") |
| 145 | ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0") |
Jeremy Fitzhardinge | 8c5e5ac | 2008-07-08 15:06:44 -0700 | [diff] [blame] | 146 | #ifdef CONFIG_X86_32 |
Jeremy Fitzhardinge | 7077c33 | 2008-07-08 15:06:35 -0700 | [diff] [blame] | 147 | ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __PAGE_OFFSET) |
Jeremy Fitzhardinge | 8c5e5ac | 2008-07-08 15:06:44 -0700 | [diff] [blame] | 148 | #else |
| 149 | ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map) |
| 150 | #endif |
Jeremy Fitzhardinge | 7077c33 | 2008-07-08 15:06:35 -0700 | [diff] [blame] | 151 | ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, _ASM_PTR startup_xen) |
| 152 | ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page) |
Mukesh Rathor | 4e903a2 | 2013-12-31 11:16:25 -0500 | [diff] [blame] | 153 | ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii "!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR) |
| 154 | ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES, .long (PVH_FEATURES) | |
| 155 | (1 << XENFEAT_writable_page_tables) | |
| 156 | (1 << XENFEAT_dom0)) |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 157 | ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes") |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 158 | ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic") |
Jeremy Fitzhardinge | 7e0edc1 | 2008-05-31 01:33:04 +0100 | [diff] [blame] | 159 | ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, |
| 160 | .quad _PAGE_PRESENT; .quad _PAGE_PRESENT) |
| 161 | ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1) |
Juergen Gross | d1e9abd | 2014-09-17 06:12:36 +0200 | [diff] [blame] | 162 | ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1) |
Jeremy Fitzhardinge | 7077c33 | 2008-07-08 15:06:35 -0700 | [diff] [blame] | 163 | ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, _ASM_PTR __HYPERVISOR_VIRT_START) |
Jeremy Fitzhardinge | 8c5e5ac | 2008-07-08 15:06:44 -0700 | [diff] [blame] | 164 | ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0) |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 165 | |
| 166 | #endif /*CONFIG_XEN */ |