linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 0/2] EFI urgent fixes
@ 2016-05-31 10:23 Matt Fleming
       [not found] ` <1464690224-4503-1-git-send-email-matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Fleming @ 2016-05-31 10:23 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H . Peter Anvin
  Cc: Matt Fleming, Ard Biesheuvel,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA, Catalin Marinas, Dan Williams,
	Dennis Chen, K. Y. Srinivasan, Mark Rutland, Mark Salter,
	Steve Capper, Steve McIntyre, Steven Rostedt, Vitaly Kuznetsov,
	Will Deacon

Folks, please pull the following urgent patches which fix a boot crash
when using the "noefi" parameter and the debug output on arm.

The following changes since commit 1a695a905c18548062509178b98bc91e67510864:

  Linux 4.7-rc1 (2016-05-29 09:29:24 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.git tags/efi-urgent

for you to fetch changes up to 1f0cf3892caeab20a99c19f5523499be77b533cd:

  efi/arm: Fix the format of debug message from efi (2016-05-30 22:51:53 +0100)

----------------------------------------------------------------
 * Fix crash when booting with the "noefi" kernel parameter, caused by
   recent changes to for_each_efi_memory_desc_in_map() - Vitaly Kuznetsov

 * Unscramble the debug output on arm when efi=debug and memblock=debug
   is passed on the kernel cmdline - Dennis Chen

----------------------------------------------------------------
Dennis Chen (1):
      efi/arm: Fix the format of debug message from efi

Vitaly Kuznetsov (1):
      efi: Fix for_each_efi_memory_desc_in_map() for empty memmaps

 drivers/firmware/efi/arm-init.c | 14 ++++++--------
 include/linux/efi.h             |  2 +-
 2 files changed, 7 insertions(+), 9 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] efi: Fix for_each_efi_memory_desc_in_map() for empty memmaps
       [not found] ` <1464690224-4503-1-git-send-email-matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
@ 2016-05-31 10:23   ` Matt Fleming
  2016-05-31 10:23   ` [PATCH 2/2] efi/arm: Fix the format of debug message from efi Matt Fleming
  2016-06-06 10:02   ` [GIT PULL 0/2] EFI urgent fixes Matt Fleming
  2 siblings, 0 replies; 5+ messages in thread
From: Matt Fleming @ 2016-05-31 10:23 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H . Peter Anvin
  Cc: Vitaly Kuznetsov, Ard Biesheuvel,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA, Matt Fleming, K. Y. Srinivasan,
	Mark Salter

From: Vitaly Kuznetsov <vkuznets-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

Commit 78ce248faa3c ("efi: Iterate over efi.memmap in
for_each_efi_memory_desc()") introduced a regression for systems booted
with 'noefi' kernel option. In particular, I observe early kernel hang in
efi_find_mirror() on for_each_efi_memory_desc() call. As we don't have
efi memmap we enter this iterator with the following parameters:

efi.memmap.map = 0, efi.memmap.map_end = 0, efi.memmap.desc_size = 28

for_each_efi_memory_desc_in_map() does the following comparison:

(md) <= (efi_memory_desc_t *)((m)->map_end - (m)->desc_size);

where md = 0, (m)->map_end = 0 and (m)->desc_size = 28 but when we subtract
something from a NULL pointer wrap around happens and we end up returning
invalid pointer.

Fixes: 78ce248faa3c ("efi: Iterate over efi.memmap in for_each_efi_memory_desc()")
Signed-off-by: Vitaly Kuznetsov <vkuznets-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Mark Salter <msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: "K. Y. Srinivasan" <kys-0li6OtcxBFHby3iVrkZq2A@public.gmane.org>
Signed-off-by: Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
---
 include/linux/efi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/efi.h b/include/linux/efi.h
index c2db3ca22217..f196dd0b0f2f 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -1005,7 +1005,7 @@ extern int efi_memattr_apply_permissions(struct mm_struct *mm,
 /* Iterate through an efi_memory_map */
 #define for_each_efi_memory_desc_in_map(m, md)				   \
 	for ((md) = (m)->map;						   \
-	     (md) <= (efi_memory_desc_t *)((m)->map_end - (m)->desc_size); \
+	     ((void *)(md) + (m)->desc_size) <= (m)->map_end;		   \
 	     (md) = (void *)(md) + (m)->desc_size)
 
 /**
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] efi/arm: Fix the format of debug message from efi
       [not found] ` <1464690224-4503-1-git-send-email-matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
  2016-05-31 10:23   ` [PATCH 1/2] efi: Fix for_each_efi_memory_desc_in_map() for empty memmaps Matt Fleming
@ 2016-05-31 10:23   ` Matt Fleming
  2016-06-06 10:02   ` [GIT PULL 0/2] EFI urgent fixes Matt Fleming
  2 siblings, 0 replies; 5+ messages in thread
From: Matt Fleming @ 2016-05-31 10:23 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H . Peter Anvin
  Cc: Dennis Chen, Ard Biesheuvel, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA, Matt Fleming, Catalin Marinas,
	Dan Williams, Mark Rutland, Mark Salter, Steve Capper,
	Steve McIntyre, Steven Rostedt, Will Deacon

From: Dennis Chen <dennis.chen-5wv7dgnIgG8@public.gmane.org>

When enable debug of efi and memblock with 'efi=debug memblock=debug' appended
to the kernel command line, the debug message output for earyly_con looks like:

[    0.000000] efi:   0x0000e1050000-0x0000e105ffff [Memory Mapped I/O  |RUN|  |  |  |  |  |  |   |  |  |  |UC]
[    0.000000] efi:   0x0000e1300000-0x0000e1300fff [Memory Mapped I/O  |RUN|  |  |  |  |  |  |   |  |  |  |UC]
[    0.000000] efi:   0x0000e8200000-0x0000e827ffff [Memory Mapped I/O  |RUN|  |  |  |  |  |  |   |  |  |  |UC]
[    0.000000] efi:   0x008000000000-0x008001e7ffff [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC]
[    0.000000] memblock_add: [0x00008000000000-0x00008001e7ffff] flags 0x0 early_init_dt_add_memory_arch+0x54/0x5c
[    0.000000] *
...

This patch is trying to fix the above output messed up by memblock_add(),
so we can get below debug mesg looks more formally after applied:

[    0.000000] efi:   0x0000e1050000-0x0000e105ffff [Memory Mapped I/O  |RUN|  |  |  |  |  |  |   |  |  |  |UC]
[    0.000000] efi:   0x0000e1300000-0x0000e1300fff [Memory Mapped I/O  |RUN|  |  |  |  |  |  |   |  |  |  |UC]
[    0.000000] efi:   0x0000e8200000-0x0000e827ffff [Memory Mapped I/O  |RUN|  |  |  |  |  |  |   |  |  |  |UC]
[    0.000000] efi:   0x008000000000-0x008001e7ffff [Runtime Data       |RUN|  |  |  |  |  |  |   |WB|WT|WC|UC]*
[    0.000000] memblock_add: [0x00008000000000-0x00008001e7ffff] flags 0x0 early_init_dt_add_memory_arch+0x54/0x5c
...

Signed-off-by: Dennis Chen <dennis.chen-5wv7dgnIgG8@public.gmane.org>
Acked-by: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
Cc: Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org>
Cc: Steve Capper <steve.capper-5wv7dgnIgG8@public.gmane.org>
Cc: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
Cc: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Steve McIntyre <steve-nt0JYOx6u4DQT0dZR+AlfA@public.gmane.org>
Cc: Steven Rostedt <rostedt-nx8X9YLhiw1AfugRpC6u6w@public.gmane.org>
Cc: Dan Williams <dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Mark Salter <msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
---
 drivers/firmware/efi/arm-init.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c
index a850cbc48d8d..c49d50e68aee 100644
--- a/drivers/firmware/efi/arm-init.c
+++ b/drivers/firmware/efi/arm-init.c
@@ -174,6 +174,7 @@ static __init void reserve_regions(void)
 {
 	efi_memory_desc_t *md;
 	u64 paddr, npages, size;
+	int resv;
 
 	if (efi_enabled(EFI_DBG))
 		pr_info("Processing EFI memory map:\n");
@@ -190,12 +191,14 @@ static __init void reserve_regions(void)
 		paddr = md->phys_addr;
 		npages = md->num_pages;
 
+		resv = is_reserve_region(md);
 		if (efi_enabled(EFI_DBG)) {
 			char buf[64];
 
-			pr_info("  0x%012llx-0x%012llx %s",
+			pr_info("  0x%012llx-0x%012llx %s%s\n",
 				paddr, paddr + (npages << EFI_PAGE_SHIFT) - 1,
-				efi_md_typeattr_format(buf, sizeof(buf), md));
+				efi_md_typeattr_format(buf, sizeof(buf), md),
+				resv ? "*" : "");
 		}
 
 		memrange_efi_to_native(&paddr, &npages);
@@ -204,14 +207,9 @@ static __init void reserve_regions(void)
 		if (is_normal_ram(md))
 			early_init_dt_add_memory_arch(paddr, size);
 
-		if (is_reserve_region(md)) {
+		if (resv)
 			memblock_mark_nomap(paddr, size);
-			if (efi_enabled(EFI_DBG))
-				pr_cont("*");
-		}
 
-		if (efi_enabled(EFI_DBG))
-			pr_cont("\n");
 	}
 
 	set_bit(EFI_MEMMAP, &efi.flags);
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [GIT PULL 0/2] EFI urgent fixes
       [not found] ` <1464690224-4503-1-git-send-email-matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
  2016-05-31 10:23   ` [PATCH 1/2] efi: Fix for_each_efi_memory_desc_in_map() for empty memmaps Matt Fleming
  2016-05-31 10:23   ` [PATCH 2/2] efi/arm: Fix the format of debug message from efi Matt Fleming
@ 2016-06-06 10:02   ` Matt Fleming
  2016-06-08  7:24     ` Ingo Molnar
  2 siblings, 1 reply; 5+ messages in thread
From: Matt Fleming @ 2016-06-06 10:02 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H . Peter Anvin
  Cc: Ard Biesheuvel, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA, Catalin Marinas, Dan Williams,
	Dennis Chen, K. Y. Srinivasan, Mark Rutland, Mark Salter,
	Steve Capper, Steve McIntyre, Steven Rostedt, Vitaly Kuznetsov,
	Will Deacon

On Tue, 31 May, at 11:23:42AM, Matt Fleming wrote:
> Folks, please pull the following urgent patches which fix a boot crash
> when using the "noefi" parameter and the debug output on arm.
> 
> The following changes since commit 1a695a905c18548062509178b98bc91e67510864:
> 
>   Linux 4.7-rc1 (2016-05-29 09:29:24 -0700)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.git tags/efi-urgent
> 
> for you to fetch changes up to 1f0cf3892caeab20a99c19f5523499be77b533cd:
> 
>   efi/arm: Fix the format of debug message from efi (2016-05-30 22:51:53 +0100)
> 
> ----------------------------------------------------------------
>  * Fix crash when booting with the "noefi" kernel parameter, caused by
>    recent changes to for_each_efi_memory_desc_in_map() - Vitaly Kuznetsov
> 
>  * Unscramble the debug output on arm when efi=debug and memblock=debug
>    is passed on the kernel cmdline - Dennis Chen
> 
> ----------------------------------------------------------------
> Dennis Chen (1):
>       efi/arm: Fix the format of debug message from efi
> 
> Vitaly Kuznetsov (1):
>       efi: Fix for_each_efi_memory_desc_in_map() for empty memmaps
> 
>  drivers/firmware/efi/arm-init.c | 14 ++++++--------
>  include/linux/efi.h             |  2 +-
>  2 files changed, 7 insertions(+), 9 deletions(-)

Ping? I see these patches queued up in tip/efi/urgent but they don't
appear to be in Linus' tree yet.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [GIT PULL 0/2] EFI urgent fixes
  2016-06-06 10:02   ` [GIT PULL 0/2] EFI urgent fixes Matt Fleming
@ 2016-06-08  7:24     ` Ingo Molnar
  0 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2016-06-08  7:24 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Thomas Gleixner, H . Peter Anvin, Ard Biesheuvel, linux-kernel,
	linux-efi, Catalin Marinas, Dan Williams, Dennis Chen,
	K. Y. Srinivasan, Mark Rutland, Mark Salter, Steve Capper,
	Steve McIntyre, Steven Rostedt, Vitaly Kuznetsov, Will Deacon


* Matt Fleming <matt@codeblueprint.co.uk> wrote:

> On Tue, 31 May, at 11:23:42AM, Matt Fleming wrote:
> > Folks, please pull the following urgent patches which fix a boot crash
> > when using the "noefi" parameter and the debug output on arm.
> > 
> > The following changes since commit 1a695a905c18548062509178b98bc91e67510864:
> > 
> >   Linux 4.7-rc1 (2016-05-29 09:29:24 -0700)
> > 
> > are available in the git repository at:
> > 
> >   git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.git tags/efi-urgent
> > 
> > for you to fetch changes up to 1f0cf3892caeab20a99c19f5523499be77b533cd:
> > 
> >   efi/arm: Fix the format of debug message from efi (2016-05-30 22:51:53 +0100)
> > 
> > ----------------------------------------------------------------
> >  * Fix crash when booting with the "noefi" kernel parameter, caused by
> >    recent changes to for_each_efi_memory_desc_in_map() - Vitaly Kuznetsov
> > 
> >  * Unscramble the debug output on arm when efi=debug and memblock=debug
> >    is passed on the kernel cmdline - Dennis Chen
> > 
> > ----------------------------------------------------------------
> > Dennis Chen (1):
> >       efi/arm: Fix the format of debug message from efi
> > 
> > Vitaly Kuznetsov (1):
> >       efi: Fix for_each_efi_memory_desc_in_map() for empty memmaps
> > 
> >  drivers/firmware/efi/arm-init.c | 14 ++++++--------
> >  include/linux/efi.h             |  2 +-
> >  2 files changed, 7 insertions(+), 9 deletions(-)
> 
> Ping? I see these patches queued up in tip/efi/urgent but they don't
> appear to be in Linus' tree yet.

Yeah, will get them to Linus later today.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-08  7:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-31 10:23 [GIT PULL 0/2] EFI urgent fixes Matt Fleming
     [not found] ` <1464690224-4503-1-git-send-email-matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-05-31 10:23   ` [PATCH 1/2] efi: Fix for_each_efi_memory_desc_in_map() for empty memmaps Matt Fleming
2016-05-31 10:23   ` [PATCH 2/2] efi/arm: Fix the format of debug message from efi Matt Fleming
2016-06-06 10:02   ` [GIT PULL 0/2] EFI urgent fixes Matt Fleming
2016-06-08  7:24     ` Ingo Molnar

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).