From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937905AbdCJOY2 (ORCPT ); Fri, 10 Mar 2017 09:24:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60234 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933347AbdCJOY0 (ORCPT ); Fri, 10 Mar 2017 09:24:26 -0500 Date: Fri, 10 Mar 2017 09:24:18 -0500 From: Vivek Goyal To: Thomas Gleixner Cc: Mike Galbraith , Borislav Petkov , "Tobin C. Harding" , LKML , Nicholas Mc Guire , x86@kernel.org, Dave Young , Baoquan He Subject: Re: kexec, x86/purgatory: Cleanup the unholy mess Message-ID: <20170310142418.GA20954@redhat.com> References: <1489153665.4410.4.camel@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 10 Mar 2017 14:24:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 10, 2017 at 02:57:38PM +0100, Thomas Gleixner wrote: > On Fri, 10 Mar 2017, Mike Galbraith wrote: > > On Fri, 2017-03-10 at 13:17 +0100, Thomas Gleixner wrote: > > > The purgatory code defines global variables which are referenced via a > > > symbol lookup in the kexec code (core and arch). > > > > > > A recent commit addressing sparse warning made these static and thereby > > > broke kexec file. > > > > > > Why did this happen? Simply because the whole machinery is undocumented and > > > lacks any form of forward declarations. The variable names are unspecific > > > and lack a prefix, so adding forward declarations creates shadow variables > > > in the core code. Aside of that the code relies on magic constants and > > > duplicate struct definitions with no way to ensure that these things stay > > > in sync. > > > > > > Unbreak kexec and cleanup the mess by: > > > > > > - Adding proper forward declarations and document the usage > > > - Use the proper common defines instead of magic constants > > > - Add a purgatory_ prefix to have a proper name space > > > - Use ARRAY_SIZE() instead of a homebrewn reimplementation > > > > > > Fixes: 72042a8c7b01 ("x86/purgatory: Make functions and variables static") > > > > Well, almost fixes. > > > > [ 15.118820] kexec: symbol 'purgatory_sha_regions' in common section > > [ 15.119187] kexec-bzImage64: Loading purgatory failed > > Bah. /me goes to investigate. I think we probably will have to initialize these global variables in purgatory itself and that puts them in .data section and relocation works. That's how the code was intially. I initialized value of purgatory_sha256_digest in the code and then did "readelf -a purgatory.o" and symbol section index changed from COM to 3. 13: 0000000000000000 32 OBJECT GLOBAL DEFAULT 3 purgatory_sha256_digest [ 3] .data PROGBITS 0000000000000000 00000120 0000000000000020 0000000000000000 WA 0 0 32 Thanks Vivek