Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932356AbcCBWMV (ORCPT ); Wed, 2 Mar 2016 17:12:21 -0500 Received: from torg.zytor.com ([198.137.202.12]:47924 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754083AbcCBWMS (ORCPT ); Wed, 2 Mar 2016 17:12:18 -0500 Subject: Re: [RFC PATCH] x86: Make sure verify_cpu has a good stack To: Borislav Petkov References: <1456917606-4979-1-git-send-email-bp@alien8.de> <20160302162530.GA8362@pd.tnic> <086BE61B-DCCC-4105-90A2-295A487C7F6F@zytor.com> <20160302181556.GD8362@pd.tnic> <56D73349.3020609@zytor.com> <20160302195053.GG8362@pd.tnic> <56D75C8D.90800@zytor.com> <20160302214654.GK8362@pd.tnic> <56D7612A.4080107@zytor.com> <20160302220954.GL8362@pd.tnic> Cc: Brian Gerst , X86 ML , LKML , Tom Lendacky From: "H. Peter Anvin" Message-ID: <56D76527.5020806@zytor.com> Date: Wed, 2 Mar 2016 14:11:51 -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: <20160302220954.GL8362@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 Content-Length: 1050 Lines: 33 On 03/02/16 14:09, Borislav Petkov wrote: > On Wed, Mar 02, 2016 at 01:54:50PM -0800, H. Peter Anvin wrote: >> A relocating bootloader is one that doesn't load the kernel at >> CONFIG_PHYSICAL_ADDRESS. The EFI stub is one example. >> >> __START_KERNEL_map is not relocated. On x86-64 we do relocation by >> pointing the page tables at a different address. >> >> So I really think we need this to be a leaq, so we take a nonstandard >> load address into consideration. > > Hmm, but __START_KERNEL_map is a simple macro: > > #define __START_KERNEL_map _AC(0xffffffff80000000, UL) That should not be a problem. > > Ok, I think you want to do something like this for stack_start too: > > /* > * Compute the delta between the address I am compiled to run at and the > * address I am actually running at. > */ > leaq _text(%rip), %rbp > subq $_text - __START_KERNEL_map, %rbp > ... > > in the normal case %rbp is 0, of course. > Not sure if we need a reference to _text here. -hpa