[PATCH 3/4] xen/PVH: Set up GS segment for stack canary

From: Boris Ostrovsky
Date: Mon Apr 30 2018 - 12:21:49 EST


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@xxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
---
arch/x86/xen/xen-pvh.S | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/arch/x86/xen/xen-pvh.S b/arch/x86/xen/xen-pvh.S
index 373fef0..4eed586 100644
--- a/arch/x86/xen/xen-pvh.S
+++ b/arch/x86/xen/xen-pvh.S
@@ -54,6 +54,9 @@
* 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)
cld

@@ -64,6 +67,9 @@ ENTRY(pvh_start_xen)
mov %eax,%es
mov %eax,%ss

+ mov $(PVH_CANARY_SEL),%eax
+ mov %eax,%gs
+
/* Stash hvm_start_info. */
mov $_pa(pvh_start_info), %edi
mov %ebx, %esi
@@ -150,6 +156,7 @@ gdt_start:
.quad 0x00cf9a000000ffff /* __BOOT_CS */
#endif
.quad 0x00cf92000000ffff /* __BOOT_DS */
+ .quad 0x0040900000000018 /* PVH_CANARY_SEL */
gdt_end:

.balign 4
--
2.9.3