From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760542AbcDMLs3 (ORCPT ); Wed, 13 Apr 2016 07:48:29 -0400 Received: from terminus.zytor.com ([198.137.202.10]:57170 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759527AbcDMLsV (ORCPT ); Wed, 13 Apr 2016 07:48:21 -0400 Date: Wed, 13 Apr 2016 04:47:38 -0700 From: tip-bot for Borislav Petkov Message-ID: Cc: torvalds@linux-foundation.org, tglx@linutronix.de, bp@suse.de, hpa@zytor.com, mingo@kernel.org, thomas.lendacky@amd.com, linux-kernel@vger.kernel.org, brgerst@gmail.com, peterz@infradead.org, mika.penttila@nextfour.com Reply-To: mika.penttila@nextfour.com, peterz@infradead.org, brgerst@gmail.com, linux-kernel@vger.kernel.org, thomas.lendacky@amd.com, mingo@kernel.org, hpa@zytor.com, bp@suse.de, tglx@linutronix.de, torvalds@linux-foundation.org In-Reply-To: <1459434062-31055-1-git-send-email-bp@alien8.de> References: <1459434062-31055-1-git-send-email-bp@alien8.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/asm] x86/asm: Make sure verify_cpu() has a good stack Git-Commit-ID: 91ed140d6c1e168b11bbbddac4f6066f40a0c6b5 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 91ed140d6c1e168b11bbbddac4f6066f40a0c6b5 Gitweb: http://git.kernel.org/tip/91ed140d6c1e168b11bbbddac4f6066f40a0c6b5 Author: Borislav Petkov AuthorDate: Thu, 31 Mar 2016 16:21:02 +0200 Committer: Ingo Molnar CommitDate: Wed, 13 Apr 2016 11:52:19 +0200 x86/asm: Make sure verify_cpu() has a good stack 04633df0c43d ("x86/cpu: Call verify_cpu() after having entered long mode too") added the call to verify_cpu() for sanitizing CPU configuration. The latter uses the stack minimally and it can happen that we land in startup_64() directly from a 64-bit bootloader. Then we want to use our own, known good stack. Do that. APs don't need this as the trampoline sets up a stack for them. Reported-by: Tom Lendacky Signed-off-by: Borislav Petkov Cc: Brian Gerst Cc: Linus Torvalds Cc: Mika Penttilä Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1459434062-31055-1-git-send-email-bp@alien8.de Signed-off-by: Ingo Molnar --- arch/x86/kernel/head_64.S | 8 ++++++++ include/asm-generic/vmlinux.lds.h | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index 3de91a7..5df831e 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S @@ -65,6 +65,14 @@ startup_64: * tables and then reload them. */ + /* + * Setup stack for verify_cpu(). "-8" because stack_start is defined + * this way, see below. Our best guess is a NULL ptr for stack + * termination heuristics and we don't want to break anything which + * might depend on it (kgdb, ...). + */ + leaq (__end_init_task - 8)(%rip), %rsp + /* Sanitize CPU configuration */ call verify_cpu diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 339125b..6a67ab9 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -245,7 +245,9 @@ #define INIT_TASK_DATA(align) \ . = ALIGN(align); \ - *(.data..init_task) + VMLINUX_SYMBOL(__start_init_task) = .; \ + *(.data..init_task) \ + VMLINUX_SYMBOL(__end_init_task) = .; /* * Read only Data