Received: by 10.223.176.5 with SMTP id f5csp2692298wra; Thu, 1 Feb 2018 04:41:11 -0800 (PST) X-Google-Smtp-Source: AH8x2246bIhJD85rcPkhVpJd1yFMhyBkczzwMNvVx5kOyPbozJARFZTxT15liqj09GmF2DfhjpUN X-Received: by 10.99.61.205 with SMTP id k196mr91829pga.370.1517488871183; Thu, 01 Feb 2018 04:41:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517488871; cv=none; d=google.com; s=arc-20160816; b=ALyHX0P810s/DiwmhrUSid9WCUVMDXQ61y6XqK3KFuRZPSX4eIg0MYEXoKOiyrQ3wB y6bqgLHoLDcsyNwxzLoybscWUhxHxBuIDN5Gv9/1DuPk+fYK8FVC7ywJzThLWNhTnlZj HvNTvQGEaARtd84/EUEFEIGlGkDmjZJuPb2GbBRkOdVADQpDMtUaY72Hce188UajKrRA apOaKrr6eT0UwK5ca/TksWrttCRovRmIlYP++hvjtiTKVln08Y3hoqW7YgxbCY5FG4A5 3QDmHb2wvpvEg+bTwF8IouPeAktzmQYOp5e7nBYKheCqe3mPXTNDiIgYhe2AsBOyA3n1 iWyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=HUJFbB2uQYZ7Nus1r1m2ud5hqrkGK5JBhjIdQBpu+vI=; b=lTjMDmVt+Vn4jPJtdecVoQo9/G+CUMWv4pB0PrhUZfV9dFrpy2JNPw2AxVIuN1airP M3oMhTRj/I3FRMAf0VAaa9PaZ5/naGnIxon2LyPaEK8hMYW2D4Wa5oNpQKPBFk8FXRXn hne4AyO2bRC8gY23VwOaXHuS6kfvefan+qyKj3FE5zE7mIxR5ubabvDJakwe/Vd2Xmgh oYVVqhhld8b/6eF28huFC2QHemd7sXZy97gZpaXWcKfnjhV3BpgmWSE6zEBxjLEyP0ug tI1Q5Xe4whOVVqxX1jYPA8rfId6HLKBOXfq8QsubtTkxUpisZX7R8LQEyXYUFcCmpcbq gzUg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u27si1654000pfk.385.2018.02.01.04.40.56; Thu, 01 Feb 2018 04:41:11 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752556AbeBAMk3 (ORCPT + 99 others); Thu, 1 Feb 2018 07:40:29 -0500 Received: from mx2.suse.de ([195.135.220.15]:35954 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752516AbeBAMkW (ORCPT ); Thu, 1 Feb 2018 07:40:22 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BD47EAD00; Thu, 1 Feb 2018 12:40:20 +0000 (UTC) From: Juergen Gross To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org Cc: boris.ostrovsky@oracle.com, Juergen Gross , stable@vger.kernel.org Subject: [PATCH v2] x86/xen: init %gs very early to avoid page faults with stack protector Date: Thu, 1 Feb 2018 13:40:19 +0100 Message-Id: <20180201124019.11693-1-jgross@suse.com> X-Mailer: git-send-email 2.13.6 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When running as Xen pv guest %gs is initialized some time after C code is started. Depending on stack protector usage this might be too late, resulting in page faults. So setup %gs and MSR_GS_BASE in assembly code already. Cc: stable@vger.kernel.org Signed-off-by: Juergen Gross --- arch/x86/xen/xen-head.S | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S index 497cc55a0c16..96f26e026783 100644 --- a/arch/x86/xen/xen-head.S +++ b/arch/x86/xen/xen-head.S @@ -9,7 +9,9 @@ #include #include +#include #include +#include #include #include @@ -35,6 +37,20 @@ ENTRY(startup_xen) mov %_ASM_SI, xen_start_info mov $init_thread_union+THREAD_SIZE, %_ASM_SP +#ifdef CONFIG_X86_64 + /* Set up %gs. + * + * The base of %gs always points to the bottom of the irqstack + * union. If the stack protector canary is enabled, it is + * located at %gs:40. Note that, on SMP, the boot cpu uses + * init data section till per cpu areas are set up. + */ + movl $MSR_GS_BASE,%ecx + movq $INIT_PER_CPU_VAR(irq_stack_union),%rax + cdq + wrmsr +#endif + jmp xen_start_kernel END(startup_xen) __FINIT -- 2.13.6