blob: b65f59a358a220fac788fef178fa3bc2e6dbc8d6 [file] [log] [blame]
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -07001/* 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 Ravnborg08b6d292008-01-30 13:33:25 +01007#include <linux/init.h>
Jeremy Fitzhardinge7077c332008-07-08 15:06:35 -07008
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -07009#include <asm/boot.h>
Jeremy Fitzhardinge7077c332008-07-08 15:06:35 -070010#include <asm/asm.h>
Jeremy Fitzhardinge0341c142009-02-13 11:14:01 -080011#include <asm/page_types.h>
Jeremy Fitzhardinge7077c332008-07-08 15:06:35 -070012
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070013#include <xen/interface/elfnote.h>
Mukesh Rathor4e903a22013-12-31 11:16:25 -050014#include <xen/interface/features.h>
Juergen Gross526abea2015-01-21 08:49:25 +010015#include <xen/interface/xen.h>
16#include <xen/interface/xen-mca.h>
Jeremy Fitzhardinge7e0edc12008-05-31 01:33:04 +010017#include <asm/xen/interface.h>
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070018
Mukesh Rathor4e903a22013-12-31 11:16:25 -050019#ifdef CONFIG_XEN_PVH
20#define PVH_FEATURES_STR "|writable_descriptor_tables|auto_translated_physmap|supervisor_mode_kernel"
21/* Note the lack of 'hvm_callback_vector'. Older hypervisor will
22 * balk at this being part of XEN_ELFNOTE_FEATURES, so we put it in
23 * XEN_ELFNOTE_SUPPORTED_FEATURES which older hypervisors will ignore.
24 */
25#define PVH_FEATURES ((1 << XENFEAT_writable_page_tables) | \
26 (1 << XENFEAT_auto_translated_physmap) | \
27 (1 << XENFEAT_supervisor_mode_kernel) | \
28 (1 << XENFEAT_hvm_callback_vector))
29/* The XENFEAT_writable_page_tables is not stricly neccessary as we set that
30 * up regardless whether this CONFIG option is enabled or not, but it
31 * clarifies what the right flags need to be.
32 */
33#else
34#define PVH_FEATURES_STR ""
35#define PVH_FEATURES (0)
36#endif
37
Sam Ravnborg08b6d292008-01-30 13:33:25 +010038 __INIT
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070039ENTRY(startup_xen)
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070040 cld
Jeremy Fitzhardinge8c5e5ac2008-07-08 15:06:44 -070041#ifdef CONFIG_X86_32
42 mov %esi,xen_start_info
43 mov $init_thread_union+THREAD_SIZE,%esp
44#else
45 mov %rsi,xen_start_info
46 mov $init_thread_union+THREAD_SIZE,%rsp
47#endif
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070048 jmp xen_start_kernel
Sam Ravnborg08b6d292008-01-30 13:33:25 +010049
50 __FINIT
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070051
Mukesh Rathora2ef5dc2014-09-10 16:36:06 -070052#ifdef CONFIG_XEN_PVH
53/*
54 * xen_pvh_early_cpu_init() - early PVH VCPU initialization
55 * @cpu: this cpu number (%rdi)
56 * @entry: true if this is a secondary vcpu coming up on this entry
57 * point, false if this is the boot CPU being initialized for
58 * the first time (%rsi)
59 *
60 * Note: This is called as a function on the boot CPU, and is the entry point
61 * on the secondary CPU.
62 */
63ENTRY(xen_pvh_early_cpu_init)
64 mov %rsi, %r11
65
66 /* Gather features to see if NX implemented. */
67 mov $0x80000001, %eax
68 cpuid
69 mov %edx, %esi
70
71 mov $MSR_EFER, %ecx
72 rdmsr
73 bts $_EFER_SCE, %eax
74
75 bt $20, %esi
76 jnc 1f /* No NX, skip setting it */
77 bts $_EFER_NX, %eax
781: wrmsr
79#ifdef CONFIG_SMP
80 cmp $0, %r11b
81 jne cpu_bringup_and_idle
82#endif
83 ret
84
85#endif /* CONFIG_XEN_PVH */
86
Jeremy Fitzhardingea987b162008-06-16 15:01:56 -070087.pushsection .text
Konrad Rzeszutek Wilk7d0642b2012-07-11 15:03:18 -040088 .balign PAGE_SIZE
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070089ENTRY(hypercall_page)
Juergen Gross526abea2015-01-21 08:49:25 +010090 .skip PAGE_SIZE
Konrad Rzeszutek Wilk7d0642b2012-07-11 15:03:18 -040091
Juergen Gross526abea2015-01-21 08:49:25 +010092#define HYPERCALL(n) \
93 .equ xen_hypercall_##n, hypercall_page + __HYPERVISOR_##n * 32; \
94 .type xen_hypercall_##n, @function; .size xen_hypercall_##n, 32
95#include <asm/xen-hypercalls.h>
96#undef HYPERCALL
97
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070098.popsection
99
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700100 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux")
101 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6")
102 ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0")
Jeremy Fitzhardinge8c5e5ac2008-07-08 15:06:44 -0700103#ifdef CONFIG_X86_32
Jeremy Fitzhardinge7077c332008-07-08 15:06:35 -0700104 ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __PAGE_OFFSET)
Jeremy Fitzhardinge8c5e5ac2008-07-08 15:06:44 -0700105#else
106 ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, _ASM_PTR __START_KERNEL_map)
Juergen Gross8f5b0c62015-07-17 06:51:25 +0200107 /* Map the p2m table to a 512GB-aligned user address. */
108 ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M, .quad PGDIR_SIZE)
Jeremy Fitzhardinge8c5e5ac2008-07-08 15:06:44 -0700109#endif
Jeremy Fitzhardinge7077c332008-07-08 15:06:35 -0700110 ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, _ASM_PTR startup_xen)
111 ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, _ASM_PTR hypercall_page)
Mukesh Rathor4e903a22013-12-31 11:16:25 -0500112 ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .ascii "!writable_page_tables|pae_pgdir_above_4gb"; .asciz PVH_FEATURES_STR)
113 ELFNOTE(Xen, XEN_ELFNOTE_SUPPORTED_FEATURES, .long (PVH_FEATURES) |
114 (1 << XENFEAT_writable_page_tables) |
115 (1 << XENFEAT_dom0))
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700116 ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz "yes")
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700117 ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz "generic")
Jeremy Fitzhardinge7e0edc12008-05-31 01:33:04 +0100118 ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,
119 .quad _PAGE_PRESENT; .quad _PAGE_PRESENT)
120 ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long 1)
Juergen Grossd1e9abd2014-09-17 06:12:36 +0200121 ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN, .long 1)
Jeremy Fitzhardinge7077c332008-07-08 15:06:35 -0700122 ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, _ASM_PTR __HYPERVISOR_VIRT_START)
Jeremy Fitzhardinge8c5e5ac2008-07-08 15:06:44 -0700123 ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, _ASM_PTR 0)
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700124
125#endif /*CONFIG_XEN */