linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: joeyli <jlee@suse.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: "Lee, Chun-Yi" <joeyli.kernel@gmail.com>,
	linux-efi@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Takashi Iwai <tiwai@suse.de>, Vivek Goyal <vgoyal@redhat.com>,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] efi: Fix the size not consistent issue when unmapping memory map
Date: Fri, 4 May 2018 15:29:16 +0800	[thread overview]
Message-ID: <20180504072916.GR4235@linux-l9pv.suse> (raw)
In-Reply-To: <CAKv+Gu_1vNmNy6vYEdSRW6r97DSxj_t=1LmWFE-nsv7oA=1ApQ@mail.gmail.com>

Hi Ard,

On Thu, May 03, 2018 at 02:05:51PM +0200, Ard Biesheuvel wrote:
> On 2 May 2018 at 08:17, Lee, Chun-Yi <joeyli.kernel@gmail.com> wrote:
> > When using kdump, SOMETIMES the "size not consistent" warning message
> > shows up when the crash kernel boots with early_ioremap_debug parameter:
> >
> > WARNING: CPU: 0 PID: 0 at ../mm/early_ioremap.c:182 early_iounmap+0x4f/0x12c()
> > early_iounmap(ffffffffff200180, 00000118) [0] size not consistent 00000120
> >
> > The root cause is that the unmapping size of memory map doesn't
> > match with the original size when mapping:
> >
> > in __efi_memmap_init()
> >         map.map = early_memremap(phys_map, data->size);
> >
> > in efi_memmap_unmap()
> >         size = efi.memmap.desc_size * efi.memmap.nr_map;
> >         early_memunmap(efi.memmap.map, size);
> >
> > But the efi.memmap.nr_map is from __efi_memmap_init(). The remainder
> > of size was discarded when calculating the nr_map:
> >         map.nr_map = data->size / data->desc_size;
> >
> > When the original size of memory map region does not equal to the
> > result of multiplication. The "size not consistent" warning
> > will be triggered.
> >
> > This issue sometimes was hit by kdump because kexec set the efi map
> > size to align with 16 when loading crash kernel image:
> >
> > in bzImage64_load()
> >         efi_map_sz = efi_get_runtime_map_size();
> >         efi_map_sz = ALIGN(efi_map_sz, 16);
> >
> > Dave Young's a841aa83d patch fixed kexec issue. On UEFI side, this
> > patch changes the logic in the unmapping function. Using the end
> > address of map to calcuate original size.
> >
> 
> Why do we still need this patch? I.e., in which circumstances will
> efi_memory_map_data::size assume a value that is rounded up or
> otherwise incorrect?
>

There have no other case except kexec. But I think that it's better
to sync mapping/unmapping size between __efi_memmap_init() and 
efi_memmap_unmap(). 


Thanks
Joey Lee
 
> > Thank Randy Wright for his report and testing. And also thank
> > Takashi Iwai for his help to trace issue.
> >
> > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > Cc: Takashi Iwai <tiwai@suse.de>
> > Cc: Vivek Goyal <vgoyal@redhat.com>
> > Cc: Ingo Molnar <mingo@redhat.com>
> > Tested-by: Randy Wright <rwright@hpe.com>
> > Signed-off-by: "Lee, Chun-Yi" <jlee@suse.com>
> > ---
> >  drivers/firmware/efi/memmap.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/firmware/efi/memmap.c b/drivers/firmware/efi/memmap.c
> > index 5fc7052..1f592d8 100644
> > --- a/drivers/firmware/efi/memmap.c
> > +++ b/drivers/firmware/efi/memmap.c
> > @@ -121,7 +121,7 @@ void __init efi_memmap_unmap(void)
> >         if (!efi.memmap.late) {
> >                 unsigned long size;
> >
> > -               size = efi.memmap.desc_size * efi.memmap.nr_map;
> > +               size = efi.memmap.map_end - efi.memmap.map;
> >                 early_memunmap(efi.memmap.map, size);
> >         } else {
> >                 memunmap(efi.memmap.map);
> > --
> > 2.10.2
> >

  reply	other threads:[~2018-05-04  7:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-02  6:17 [PATCH] efi: Fix the size not consistent issue when unmapping memory map Lee, Chun-Yi
2018-05-03 12:05 ` Ard Biesheuvel
2018-05-04  7:29   ` joeyli [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-04-13  6:27 Lee, Chun-Yi
2018-04-16  2:57 ` Dave Young
2018-04-16  3:09   ` Dave Young
2018-04-16  6:37     ` joeyli
2018-04-17  0:35       ` Randy Wright
2018-04-17  1:20         ` joeyli
2018-04-17  2:41         ` Dave Young
2018-04-17 20:34         ` Randy Wright
2018-04-16  6:34   ` joeyli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180504072916.GR4235@linux-l9pv.suse \
    --to=jlee@suse.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=joeyli.kernel@gmail.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tiwai@suse.de \
    --cc=vgoyal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).