From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937878AbdCJOcQ (ORCPT ); Fri, 10 Mar 2017 09:32:16 -0500 Received: from mout.gmx.net ([212.227.15.15]:57845 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933347AbdCJOcN (ORCPT ); Fri, 10 Mar 2017 09:32:13 -0500 Message-ID: <1489156308.4706.0.camel@gmx.de> Subject: Re: kexec, x86/purgatory: Cleanup the unholy mess From: Mike Galbraith To: Thomas Gleixner Cc: Borislav Petkov , "Tobin C. Harding" , LKML , Nicholas Mc Guire , Vivek Goyal , x86@kernel.org Date: Fri, 10 Mar 2017 15:31:48 +0100 In-Reply-To: References: <1489153665.4410.4.camel@gmx.de> Content-Type: text/plain; charset="us-ascii" X-Mailer: Evolution 3.16.5 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:vyFNMGHNG9GqBZs7cS+AQu34oNY47EQxy3qzKTPo5EIULhRVmk4 6AcVLaQTl1PFY+xN0J0hqvfvCzh1jGabmEkPStQxSevQ9Si34kRtlG2l+scny+5Tso8HoJY +3JzR70r3KdDybYwjihO4LKqef5gbIAgPG/PUNQaoKadeJJ9e71iEpLHIENApw2gHxIPVry obkmgPclHRu5fWmZJrEwQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:krLWUQC8Tsw=:Vq9vceNt4JtF/Kv08MXGwv e3GpVdYHhUSzKGGS329GMvGgpcmrlQepVsuvLMNyR/FNLymC8XCqbbvYdb/K85zX35do7SuXc /XeOlrCdSv5FyaDJTob/ASm79b5R2tf3r5Yu7oMUcmoAnH97/efUYc6HRJYWXZfeg+omW990t sfyzqZ3lO/SSAac0ECbDzGi7d6MZ55XpjCU8xV9zkX9c9yGwUpzgATQkfQYUTCUFeW9JiaNAj sMKcTJ1+y0GkWm4GUbIG9UL3ZVanFdUwcT9LmAJurAd/TcEHHOVRJG20FpWdEHYxyKdaXBfpS SigtA3j9tLKtPcPUGEB8Q5uL0imRyJGSY4TFWLKxe+fW2jddZhuqe7vAgWJPOVHfWpOEZ+nBx L/T+xWRkiF5rjdiQd3Nx9kGfkAowGLtGvB+0i1o3V3FmhnUZiYx3x56+tqeBby6DqMw87IxL9 EGKOXlxOUqdmv6l7ZUXuWZ+NQ4ygcKU3Nj83tRGtDKJiMFVXLvXWembkQ6ah2nGycQ4Z+TaiK 2kOueppUVLmCZV5yWGOYUY5YRgGBMEWabxCHxyIc+S2M5T/CvuLHJsyZQ2855WY0MJMhaAccz UlzjCuiiPJ2jZFWxxNOS44slA2vwzBiw9WB2coTYCggFAL7pLXs82dz/Uhge83OV7HxXyGpKn YvEMnlrBRPFX06A6E6LcUSy9jl+BZkROiVEAWGK0oSeP5JYekjwn81hny6dKe6ofOodnX0Fna 9K8cGuzJHoE0VYNDrDXbDZLle0+XSrYbjx7mBamTsyCzG1agUqlO+ASu+2CYA2h3ksU2QxdYZ VfJytHR Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2017-03-10 at 14:57 +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. Stuffing the lot into .kexec-purgatory worked. --- arch/x86/purgatory/purgatory.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/arch/x86/purgatory/purgatory.c +++ b/arch/x86/purgatory/purgatory.c @@ -16,13 +16,13 @@ #include "sha256.h" #include "../boot/string.h" -unsigned long purgatory_backup_dest; -unsigned long purgatory_backup_src; -unsigned long purgatory_backup_sz; +unsigned long purgatory_backup_dest __section(.kexec-purgatory); +unsigned long purgatory_backup_src __section(.kexec-purgatory); +unsigned long purgatory_backup_sz __section(.kexec-purgatory); -u8 purgatory_sha256_digest[SHA256_DIGEST_SIZE]; +u8 purgatory_sha256_digest[SHA256_DIGEST_SIZE] __section(.kexec-purgatory); -struct kexec_sha_region purgatory_sha_regions[KEXEC_SEGMENT_MAX]; +struct kexec_sha_region purgatory_sha_regions[KEXEC_SEGMENT_MAX] __section(.kexec-purgatory); /* * On x86, second kernel requries first 640K of memory to boot. Copy