From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754777AbcCCUWj (ORCPT ); Thu, 3 Mar 2016 15:22:39 -0500 Received: from torg.zytor.com ([198.137.202.12]:52324 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751207AbcCCUWi (ORCPT ); Thu, 3 Mar 2016 15:22:38 -0500 Subject: Re: [RFC PATCH] x86: Make sure verify_cpu has a good stack To: Borislav Petkov References: <20160302195053.GG8362@pd.tnic> <56D75C8D.90800@zytor.com> <20160302214654.GK8362@pd.tnic> <56D7612A.4080107@zytor.com> <20160302220954.GL8362@pd.tnic> <56D76527.5020806@zytor.com> <20160302222842.GM8362@pd.tnic> <20160303122836.GC24621@pd.tnic> <395B06E1-314F-4F8A-9C89-57F8E4A61B3D@zytor.com> <20160303162952.GE24621@pd.tnic> Cc: Brian Gerst , X86 ML , LKML , Tom Lendacky From: "H. Peter Anvin" Message-ID: <56D89CEE.9070406@zytor.com> Date: Thu, 3 Mar 2016 12:22:06 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160303162952.GE24621@pd.tnic> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/03/16 08:29, Borislav Petkov wrote: > On Thu, Mar 03, 2016 at 07:26:06AM -0800, H. Peter Anvin wrote: >> Why -8? > > GLOBAL(stack_start) > .quad init_thread_union+THREAD_SIZE-8 > ^^^ > > But I don't see why it needed the -8 then. It came with a conglomerate > dump in 2002: > > commit af53c7a2c81399b805b6d4eff887401a5e50feef > Author: Andi Kleen > Date: Fri Apr 19 20:23:17 2002 -0700 > > [PATCH] x86-64 architecture specific sync for 2.5.8 > > > - /* Setup the first kernel stack (this instruction is modified by smpboot) */ > - .byte 0x48, 0xb8 /* movq *init_rsp,%rax */ > -init_rsp: > - .quad init_thread_union+THREAD_SIZE > - movq %rax, %rsp > > ... > > - > - /* SMP bootup changes this */ > + /* SMP bootup changes these two */ > .globl initial_code > initial_code: > .quad x86_64_start_kernel > + .globl init_rsp > +init_rsp: > + .quad init_thread_union+THREAD_SIZE-8 > + > --- > > But since we decrement first and then copy to stack ptr when we push, I > don't see why we need the -8. > > Do you have a better clue? > The only thing I can think of is that the -8 creates a null pointer that terminates a stack trace. -hpa