Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1597873

Re: kexec, x86/purgatory: Cleanup the unholy mess

From Mike Galbraith <efault@gmx.de>
Newsgroups linux.kernel
Subject Re: kexec, x86/purgatory: Cleanup the unholy mess
Date 2017-03-10 15:40 +0100
Message-ID <tjtS4-5k0-69@gated-at.bofh.it> (permalink)
References <tjrGA-3S0-97@gated-at.bofh.it> <tjt5F-4JP-49@gated-at.bofh.it> <tjtfl-4NB-49@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

kexec, x86/purgatory: Cleanup the unholy mess Thomas Gleixner <tglx@linutronix.de> - 2017-03-10 13:20 +0100
  Re: kexec, x86/purgatory: Cleanup the unholy mess Mike Galbraith <efault@gmx.de> - 2017-03-10 14:50 +0100
    Re: kexec, x86/purgatory: Cleanup the unholy mess Thomas Gleixner <tglx@linutronix.de> - 2017-03-10 15:00 +0100
      Re: kexec, x86/purgatory: Cleanup the unholy mess Vivek Goyal <vgoyal@redhat.com> - 2017-03-10 15:30 +0100
        Re: kexec, x86/purgatory: Cleanup the unholy mess Thomas Gleixner <tglx@linutronix.de> - 2017-03-10 16:00 +0100
          Re: kexec, x86/purgatory: Cleanup the unholy mess Vivek Goyal <vgoyal@redhat.com> - 2017-03-10 16:10 +0100
      Re: kexec, x86/purgatory: Cleanup the unholy mess Mike Galbraith <efault@gmx.de> - 2017-03-10 15:40 +0100
        Re: kexec, x86/purgatory: Cleanup the unholy mess Mike Galbraith <efault@gmx.de> - 2017-03-10 16:00 +0100
          Re: kexec, x86/purgatory: Cleanup the unholy mess Thomas Gleixner <tglx@linutronix.de> - 2017-03-10 16:40 +0100
            Re: kexec, x86/purgatory: Cleanup the unholy mess Mike Galbraith <efault@gmx.de> - 2017-03-10 19:20 +0100
        Re: kexec, x86/purgatory: Cleanup the unholy mess Thomas Gleixner <tglx@linutronix.de> - 2017-03-10 16:00 +0100
  [tip:x86/urgent] kexec, x86/purgatory: Unbreak it and clean it up tip-bot for Thomas Gleixner <tipbot@zytor.com> - 2017-03-10 21:20 +0100

csiph-web