Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xen/PVH: Set up GS segment for stack canary

We are making calls to C code (e.g. xen_prepare_pvh()) which may use
stack canary (stored in GS segment).

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>

authored by

Boris Ostrovsky and committed by
Juergen Gross
98014068 515e6541

+25 -1
+25 -1
arch/x86/xen/xen-pvh.S
··· 54 54 * charge of setting up it's own stack, GDT and IDT. 55 55 */ 56 56 57 + #define PVH_GDT_ENTRY_CANARY 4 58 + #define PVH_CANARY_SEL (PVH_GDT_ENTRY_CANARY * 8) 59 + 57 60 ENTRY(pvh_start_xen) 58 61 cld 59 62 ··· 101 98 /* 64-bit entry point. */ 102 99 .code64 103 100 1: 101 + /* Set base address in stack canary descriptor. */ 102 + mov $MSR_GS_BASE,%ecx 103 + mov $_pa(canary), %eax 104 + xor %edx, %edx 105 + wrmsr 106 + 104 107 call xen_prepare_pvh 105 108 106 109 /* startup_64 expects boot_params in %rsi. */ ··· 115 106 jmp *%rax 116 107 117 108 #else /* CONFIG_X86_64 */ 109 + 110 + /* Set base address in stack canary descriptor. */ 111 + movl $_pa(gdt_start),%eax 112 + movl $_pa(canary),%ecx 113 + movw %cx, (PVH_GDT_ENTRY_CANARY * 8) + 2(%eax) 114 + shrl $16, %ecx 115 + movb %cl, (PVH_GDT_ENTRY_CANARY * 8) + 4(%eax) 116 + movb %ch, (PVH_GDT_ENTRY_CANARY * 8) + 7(%eax) 117 + 118 + mov $PVH_CANARY_SEL,%eax 119 + mov %eax,%gs 118 120 119 121 call mk_early_pgtbl_32 120 122 ··· 170 150 .quad GDT_ENTRY(0xc09a, 0, 0xfffff) /* __KERNEL_CS */ 171 151 #endif 172 152 .quad GDT_ENTRY(0xc092, 0, 0xfffff) /* __KERNEL_DS */ 153 + .quad GDT_ENTRY(0x4090, 0, 0x18) /* PVH_CANARY_SEL */ 173 154 gdt_end: 174 155 175 - .balign 4 156 + .balign 16 157 + canary: 158 + .fill 48, 1, 0 159 + 176 160 early_stack: 177 161 .fill 256, 1, 0 178 162 early_stack_end: