Received: by 10.192.165.148 with SMTP id m20csp335042imm; Wed, 9 May 2018 13:34:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpTgxSQEi3Vz2uUOSOUa2PUHGYuxu+/ApcjSdlEi8e3dwXNxggmfcyqg9N7Ogu9pes/32K8 X-Received: by 2002:a63:56:: with SMTP id 83-v6mr35864746pga.29.1525898046497; Wed, 09 May 2018 13:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525898046; cv=none; d=google.com; s=arc-20160816; b=0Gw4GODt7vVvrjktSYT3D2bEI0a1NaSno/VnojQg05dWoUgQA/5bq48877crknBDtn QVMIoVKLEhVbaXk8jrEtKOjb4wcTtKyvyycVxoR+JDsgwxTi9gA9RMSKpXCpA7gMis0X AvLAXjdMpQh8XoelEmJ8HfauQbUrdWNehyhBdlou/XpHxmg4H12LoPf83ovUDn2wKFv8 qaOiESm5N4W4ijqQ/F5l50Ju3SRysPwdGBU75y1hsxM49Hw7GmmAZMDH/zr14vLF9kVZ SKCYEPTv5DUz5AOC3wQq2egSBIWDwLbUEdRH87NpTmbtblWSXtXHZ+5wU1BHNfgH83PQ B/Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=BdVJiMp52M0JRl2Kx39VpDK37vdypdcICueh14r7uLc=; b=atRed3NMWWtG3dGONh7KIQG2JGFlc0xm+NWsHDs8a0HhZXIMagyBf7XVHmwf/No3vE DL2UoYNt19MlD6P/835OID2iCrKh1FIuHmIOtTlY4u+ha+DMGHGtJ2a9ijiI16OF4NcJ j0+w1QV7RmcbZ+fMglxD8rkQ/7rs/cmIEvj1yJmXbpgGBPSA/rwdp0rqFUZq73XeRErI Z9lkX3KRu7I/ZcxwZpuM2VIIJzK2qzW741hEPPG62GYpwnrJ6LCxzeM1WKSaV7yHLsL/ 3i+jGrBh9w8AeCticWp27ksb4+K+ajt/k2e40yaDrSh8deOPli7+ey/w7u37CeZmNV2x 3obw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=NEu9Vx20; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11-v6si27642841plt.284.2018.05.09.13.33.51; Wed, 09 May 2018 13:34:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=NEu9Vx20; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964956AbeEIUbS (ORCPT + 99 others); Wed, 9 May 2018 16:31:18 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:34726 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934932AbeEIUbQ (ORCPT ); Wed, 9 May 2018 16:31:16 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w49KUl6P023945; Wed, 9 May 2018 20:31:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=BdVJiMp52M0JRl2Kx39VpDK37vdypdcICueh14r7uLc=; b=NEu9Vx20ZFzFOTdDsxCRjsk+0YH9LkbGJS7/22+dxDIO4H1yEt++47lXspOsx9F9OT06 qkTB83mbbOJgNJOo1Yn/K895BdKeMr0/JTAZoN43/GnyC7/Fm0U/Xvmb+mZ1m9o+DDk2 K6Qv45Hbo5aV3BhagU3hDBZMRNY9TEa6WU7uy1FHKvuqtqrrgidb0PBz7sL/bblX6ugI XVb5goXqW/QmYX+GWslFOXDmG7tdOZQPv6ubCobYyKIxrqwxAcqsyEOwOm9Um70cjbZY E78qXJZYfAQIxHoa0c9XkK2C0BEF22VIKAA9wHU2xDJa4D95imVydu1y+DBUoq+v6sFt lA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2hv6m4gf5t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 May 2018 20:31:12 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w49KVBlT009679 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 May 2018 20:31:12 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w49KVB7V030514; Wed, 9 May 2018 20:31:11 GMT Received: from dhcp-burlington7-2nd-B-east-10-152-55-162.usdhcp.oraclecorp.com.com (/10.152.32.65) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 09 May 2018 13:31:10 -0700 From: Boris Ostrovsky To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: jgross@suse.com, Boris Ostrovsky Subject: [PATCH v2 1/2] xen/PVH: Set up GS segment for stack canary Date: Wed, 9 May 2018 16:33:17 -0400 Message-Id: <20180509203318.2611-2-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180509203318.2611-1-boris.ostrovsky@oracle.com> References: <20180509203318.2611-1-boris.ostrovsky@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8888 signatures=668698 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=914 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805090191 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We are making calls to C code (e.g. xen_prepare_pvh()) which may use stack canary (stored in GS segment). (We have to set the segment base to @canary at runtime just like head_32.S does, from where the code fragment is taken) Signed-off-by: Boris Ostrovsky --- arch/x86/xen/xen-pvh.S | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/x86/xen/xen-pvh.S b/arch/x86/xen/xen-pvh.S index e1a5fbe..22d43eb 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,17 @@ ENTRY(pvh_start_xen) mov %eax,%es mov %eax,%ss + /* Set base address in stack canary descriptor. */ + movl _pa(gdt_start),%eax + movl $_pa(canary),%ecx + movw %cx, (PVH_GDT_ENTRY_CANARY * 8) + 0(%eax) + shrl $16, %ecx + movb %cl, (PVH_GDT_ENTRY_CANARY * 8) + 2(%eax) + movb %ch, (PVH_GDT_ENTRY_CANARY * 8) + 5(%eax) + + mov $PVH_CANARY_SEL,%eax + mov %eax,%gs + /* Stash hvm_start_info. */ mov $_pa(pvh_start_info), %edi mov %ebx, %esi @@ -150,9 +164,12 @@ gdt_start: .quad GDT_ENTRY(0xc09a, 0, 0xfffff) /* __KERNEL_CS */ #endif .quad GDT_ENTRY(0xc092, 0, 0xfffff) /* __KERNEL_DS */ + .quad GDT_ENTRY(0x4090, 0, 0x18) /* PVH_CANARY_SEL */ gdt_end: - .balign 4 + .balign 16 +canary: + .fill 24, 1, 0 early_stack: .fill 256, 1, 0 early_stack_end: -- 2.9.3