Commit 98014068 authored by Boris Ostrovsky's avatar Boris Ostrovsky Committed by Juergen Gross

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: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
parent 515e6541
...@@ -54,6 +54,9 @@ ...@@ -54,6 +54,9 @@
* charge of setting up it's own stack, GDT and IDT. * charge of setting up it's own stack, GDT and IDT.
*/ */
#define PVH_GDT_ENTRY_CANARY 4
#define PVH_CANARY_SEL (PVH_GDT_ENTRY_CANARY * 8)
ENTRY(pvh_start_xen) ENTRY(pvh_start_xen)
cld cld
...@@ -98,6 +101,12 @@ ENTRY(pvh_start_xen) ...@@ -98,6 +101,12 @@ ENTRY(pvh_start_xen)
/* 64-bit entry point. */ /* 64-bit entry point. */
.code64 .code64
1: 1:
/* Set base address in stack canary descriptor. */
mov $MSR_GS_BASE,%ecx
mov $_pa(canary), %eax
xor %edx, %edx
wrmsr
call xen_prepare_pvh call xen_prepare_pvh
/* startup_64 expects boot_params in %rsi. */ /* startup_64 expects boot_params in %rsi. */
...@@ -107,6 +116,17 @@ ENTRY(pvh_start_xen) ...@@ -107,6 +116,17 @@ ENTRY(pvh_start_xen)
#else /* CONFIG_X86_64 */ #else /* CONFIG_X86_64 */
/* Set base address in stack canary descriptor. */
movl $_pa(gdt_start),%eax
movl $_pa(canary),%ecx
movw %cx, (PVH_GDT_ENTRY_CANARY * 8) + 2(%eax)
shrl $16, %ecx
movb %cl, (PVH_GDT_ENTRY_CANARY * 8) + 4(%eax)
movb %ch, (PVH_GDT_ENTRY_CANARY * 8) + 7(%eax)
mov $PVH_CANARY_SEL,%eax
mov %eax,%gs
call mk_early_pgtbl_32 call mk_early_pgtbl_32
mov $_pa(initial_page_table), %eax mov $_pa(initial_page_table), %eax
...@@ -150,9 +170,13 @@ gdt_start: ...@@ -150,9 +170,13 @@ gdt_start:
.quad GDT_ENTRY(0xc09a, 0, 0xfffff) /* __KERNEL_CS */ .quad GDT_ENTRY(0xc09a, 0, 0xfffff) /* __KERNEL_CS */
#endif #endif
.quad GDT_ENTRY(0xc092, 0, 0xfffff) /* __KERNEL_DS */ .quad GDT_ENTRY(0xc092, 0, 0xfffff) /* __KERNEL_DS */
.quad GDT_ENTRY(0x4090, 0, 0x18) /* PVH_CANARY_SEL */
gdt_end: gdt_end:
.balign 4 .balign 16
canary:
.fill 48, 1, 0
early_stack: early_stack:
.fill 256, 1, 0 .fill 256, 1, 0
early_stack_end: early_stack_end:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment