Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2320388imm; Thu, 7 Jun 2018 08:44:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJSl/5z54aL77PeSQ6VChOBCeNlk169jsATwi0hSla1r36L+DK1QgC2vW24HqrGEbaemXPN X-Received: by 2002:a63:a702:: with SMTP id d2-v6mr2076752pgf.246.1528386246668; Thu, 07 Jun 2018 08:44:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528386246; cv=none; d=google.com; s=arc-20160816; b=ByLCI/bZ+GuFij4JFFMMxKmKDF9U+zXkohiMbkcF8dIgJNBaG0DUq2ZgcdH452s+Hj L6y1AtxBfZqIu+qWWjPNm2h0seXB4O8uitx67iuf8Or7uDJgO0ZXiKTrWyRWaHeJxtdp lJSkzvndjrIOaW/LGhyrvnSRfIAe92zHSADz2OhKml1w+rRnPxRzSEi4a6ENqrFBD5J0 X9VkJmRAsVMCdERHsfZeeXa7cHz40TzJskhpqjGWSL0pHCkqD0X283mkJMUvfBIfrcfp /cLh66IhySVLpvFhu5qYjmjDXr2tiB1RS1/uamhBJgP6Js7Da2TV2yCpTS3hS9mrpLC1 rb5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=545MLw8d6sfOz+ZrY9AJsrAQYP16lap2/D5fPiZ441w=; b=C3/jQGl8+MxI1+VS/POuG3mEKzCzE21Z0ZhaWk9924wEtZRgFOxXmBD401tF0edDv+ pz1iBG5adgpWLtUal6yzhobZuz1XRWY2UUlOUb4V+mOeb6iL3Slwp0btRviUrcfGVJwB PsA5B1u2QrZ4+kFelMBYyVmfmLSPTseReUrstxJ0e46m8LDTTNIYszNeeON0BuqMJikK J596N/4/ObDCLp/sKdHSrvLVfnYc6t9jJE+5Xy9AHOnCAjqRmqHHyD7SObaBxsX3F2mt NbcYyylgtlELZslAZKhQcP63FOYI/51qHg6iDLZVc4SLKY0Ms/OLE5R/kjVtEeu9iDdV Sasw== 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 32-v6si54302423plc.252.2018.06.07.08.43.52; Thu, 07 Jun 2018 08:44: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; 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 S934595AbeFGOlb (ORCPT + 99 others); Thu, 7 Jun 2018 10:41:31 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:40590 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932931AbeFGOl2 (ORCPT ); Thu, 7 Jun 2018 10:41:28 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbj-0005a0-5W; Thu, 07 Jun 2018 15:09:43 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb5-0002yz-JY; Thu, 07 Jun 2018 15:09:03 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Juergen Gross" , "Boris Ostrovsky" , "Chris Patterson" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 194/410] x86/xen: init %gs very early to avoid page faults with stack protector In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Juergen Gross commit 4f277295e54c5b7340e48efea3fc5cc21a2872b7 upstream. 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. Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Tested-by: Chris Patterson Signed-off-by: Juergen Gross [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- --- a/arch/x86/xen/xen-head.S +++ b/arch/x86/xen/xen-head.S @@ -8,7 +8,9 @@ #include #include +#include #include +#include #include #include @@ -42,7 +44,20 @@ ENTRY(startup_xen) #else mov %rsi,xen_start_info mov $init_thread_union+THREAD_SIZE,%rsp + + /* 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 __FINIT