Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3371906imm; Thu, 17 May 2018 07:47:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqKGsOzPwXUNN/jZwbzvQLVagfskStz3g8VM37nEdSqSjX3kCwOobdw4yTexT87pTj8dn8v X-Received: by 2002:a17:902:bb0b:: with SMTP id l11-v6mr5610662pls.190.1526568426843; Thu, 17 May 2018 07:47:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526568426; cv=none; d=google.com; s=arc-20160816; b=KADOV4KTS4+XdF0zMEXLSERC6XzBpXUpYhiZHs82ejPxaSa1vWhrjZC1Znw2xgbVyd A5iln8L7joUOjz3pG/yUR5Lhvvl1HLm1EQjC1jy6pddW8c7nKaXmBrtXzy7m4CnoT02x FiW+B9vhc4el+APYp4maTwfP0/8o8FfXNsmWBfPajzrBbwyi6gy9Q1ITG0gxYRr35s5J cmRgofPQ/e6EZDlI1+71lUAZ/6IiQw1lWjpyMbTOugxTNqe/0KZAnhrgvrmqQu78qdKK hUBgyybV84wyOefGKu7Ezyf8hafFlrnkMvM3QPiVoasS8tG7h1qEuW2Map2LewD8jfrq unpQ== 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=qIwenBKjh/lOLhOFjLAPMhZaKm5Fqs2BdGtLqarmI+Y=; b=VMta8FkgSJ9o3EBzMgUrVZojUPF0pHZTWTronQy/QRLour+JYzmljwMQAGKQ6K7bxw h4UWbcS7esavH/ezxgvPUiUoqPs+tYaVW9yb7/GOPjKinAZgJnqYVi3do/MbIWnqpYuF Fwv1tT202NP/T1PS83aUBMEWeQKNhN4Wgd8IqLgWl8kiDgFWbeVT+m4utB8rCzusBTrY TR/1xlM5JiXyrG/WXequU2UEIvkWXyZXGZWImiOsJM3Kfi7pHTaxMnCEto5+KYkf84pw 4REFXyAEZADBo/AkuXctBVJOML60AuHIUC/7+Vo3tfAGrdhwm8Sz8kFFLKPOK38c35Fe VYPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=qj808zNX; 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 bb5-v6si5004892plb.80.2018.05.17.07.46.45; Thu, 17 May 2018 07:47: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=qj808zNX; 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 S1752518AbeEQOpI (ORCPT + 99 others); Thu, 17 May 2018 10:45:08 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:60718 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752475AbeEQOpF (ORCPT ); Thu, 17 May 2018 10:45:05 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4HEexCc191685; Thu, 17 May 2018 14:45:01 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=qIwenBKjh/lOLhOFjLAPMhZaKm5Fqs2BdGtLqarmI+Y=; b=qj808zNXSnWNo8jscvtVQJIq9TDTfEkCUN/UyXSB6Oe5QhhToqAc5rxcc+3e1ZqlP55d XXCcZA7Tgm5dlG/y///jDrnWBg84GsHWPhWBe20GYPUfBeRuWsuIbgdSDC2X47+qzgnZ DghItaQWu4qwY6H4XoHWpwLZP1f1dHtRW4qrZCPcnZ37UHCQ+GK8s21/el2rCgo2SGpe CduW3SIuNj0N2OMdbcrA/3v/x7M5whPrsw2CtHs9rDIpx1dbP0vkKGiKbhjUE8BmcGja ntli/HxB3Y448JQJd4Dp1Nr9blCk4D3ZRuuftvSRD0bl/1MkFX+/9pxmSajVOrwWQxh4 Gw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2hx29whjgc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 May 2018 14:45:00 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w4HEj0Nb018389 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 May 2018 14:45:00 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w4HEixTj019914; Thu, 17 May 2018 14:45:00 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 ; Thu, 17 May 2018 07:44:59 -0700 From: Boris Ostrovsky To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: jgross@suse.com, JBeulich@suse.com, Boris Ostrovsky Subject: [PATCH v3 1/2] xen/PVH: Set up GS segment for stack canary Date: Thu, 17 May 2018 10:47:22 -0400 Message-Id: <20180517144723.21585-2-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180517144723.21585-1-boris.ostrovsky@oracle.com> References: <20180517144723.21585-1-boris.ostrovsky@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8895 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=966 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805170136 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). Signed-off-by: Boris Ostrovsky --- arch/x86/xen/xen-pvh.S | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/arch/x86/xen/xen-pvh.S b/arch/x86/xen/xen-pvh.S index e1a5fbe..0db540c 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 @@ -98,6 +104,12 @@ ENTRY(pvh_start_xen) /* 64-bit entry point. */ .code64 1: + /* Set base address in stack canary descriptor. */ + mov $MSR_GS_BASE,%ecx + mov $canary, %rax + cdq + wrmsr + call xen_prepare_pvh /* startup_64 expects boot_params in %rsi. */ @@ -107,6 +119,14 @@ ENTRY(pvh_start_xen) #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) + 0(%eax) + shrl $16, %ecx + movb %cl, (PVH_GDT_ENTRY_CANARY * 8) + 2(%eax) + movb %ch, (PVH_GDT_ENTRY_CANARY * 8) + 5(%eax) + call mk_early_pgtbl_32 mov $_pa(initial_page_table), %eax @@ -150,9 +170,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