public inbox for linux-efi@vger.kernel.org
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: Dave Young <dyoung@redhat.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>,
	Ingo Molnar <mingo@kernel.org>,
	linux-kernel@vger.kernel.org, kernel-team@fb.com,
	kexec@lists.infradead.org, linux-efi@vger.kernel.org
Subject: Re: kexec regression since 4.9 caused by efi
Date: Thu, 9 Mar 2017 01:54:08 -0800	[thread overview]
Message-ID: <20170309095408.GA17883@vader> (raw)
In-Reply-To: <20170309063806.GB17257@dhcp-128-65.nay.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 974 bytes --]

On Thu, Mar 09, 2017 at 02:38:06PM +0800, Dave Young wrote:
> Add efi/kexec list.
> 
> On 03/08/17 at 12:16pm, Omar Sandoval wrote:

[snip]

> I have no more clue yet from your provided log, but the runtime value is
> odd to me. It is set in below code:
> 
> arch/x86/platform/efi/efi.c: efi_systab_init()
> 	efi_systab.runtime = data ?
> 			     (void *)(unsigned long)data->runtime :
> 			     (void *)(unsigne long)systab64->runtime;
> 
> Here data is the setup_data passed by kexec-tools from normal kernel to
> kexec kernel, efi_setup_data structure is like below: 
> struct efi_setup_data {
>         u64 fw_vendor;
>         u64 runtime;
>         u64 tables;
>         u64 smbios;
>         u64 reserved[8];
> };
> 
> kexec-tools get the runtime address from /sys/firmware/efi/runtime
> 
> So can you do some debuggin on your side, eg. see the sysfs runtime
> value is correct or not. And add some printk in efi init path etc.

The attached patch fixes this for me.

[-- Attachment #2: 0001-efi-adjust-virt_addr-when-splitting-descriptors-in-e.patch --]
[-- Type: text/x-diff, Size: 2223 bytes --]

>From 4b343f0b0b408469f28c973ea52877797a166313 Mon Sep 17 00:00:00 2001
Message-Id: <4b343f0b0b408469f28c973ea52877797a166313.1489053164.git.osandov@fb.com>
From: Omar Sandoval <osandov@fb.com>
Date: Thu, 9 Mar 2017 01:46:19 -0800
Subject: [PATCH] efi: adjust virt_addr when splitting descriptors in
 efi_memmap_insert()

When we split efi memory descriptors, we adjust the physical address but
not the virtual address it maps to. This leads to bogus memory mappings
later when these virtual addresses are used.

This fixes a kexec boot regression since 8e80632fb23f ("efi/esrt: Use
efi_mem_reserve() and avoid a kmalloc()"), although the bug was only
exposed by that commit.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 drivers/firmware/efi/memmap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/firmware/efi/memmap.c b/drivers/firmware/efi/memmap.c
index 78686443cb37..ca614db76faf 100644
--- a/drivers/firmware/efi/memmap.c
+++ b/drivers/firmware/efi/memmap.c
@@ -298,6 +298,7 @@ void __init efi_memmap_insert(struct efi_memory_map *old_memmap, void *buf,
 			memcpy(new, old, old_memmap->desc_size);
 			md = new;
 			md->phys_addr = m_end + 1;
+			md->virt_addr += md->phys_addr - start;
 			md->num_pages = (end - md->phys_addr + 1) >>
 				EFI_PAGE_SHIFT;
 		}
@@ -312,6 +313,7 @@ void __init efi_memmap_insert(struct efi_memory_map *old_memmap, void *buf,
 			md = new;
 			md->attribute |= m_attr;
 			md->phys_addr = m_start;
+			md->virt_addr += md->phys_addr - start;
 			md->num_pages = (m_end - m_start + 1) >>
 				EFI_PAGE_SHIFT;
 			/* last part */
@@ -319,6 +321,7 @@ void __init efi_memmap_insert(struct efi_memory_map *old_memmap, void *buf,
 			memcpy(new, old, old_memmap->desc_size);
 			md = new;
 			md->phys_addr = m_end + 1;
+			md->virt_addr += md->phys_addr - start;
 			md->num_pages = (end - m_end) >>
 				EFI_PAGE_SHIFT;
 		}
@@ -333,6 +336,7 @@ void __init efi_memmap_insert(struct efi_memory_map *old_memmap, void *buf,
 			memcpy(new, old, old_memmap->desc_size);
 			md = new;
 			md->phys_addr = m_start;
+			md->virt_addr += md->phys_addr - start;
 			md->num_pages = (end - md->phys_addr + 1) >>
 				EFI_PAGE_SHIFT;
 			md->attribute |= m_attr;
-- 
2.12.0


  reply	other threads:[~2017-03-09  9:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170308201616.GC8598@vader>
2017-03-09  6:38 ` kexec regression since 4.9 caused by efi Dave Young
2017-03-09  9:54   ` Omar Sandoval [this message]
2017-03-09 11:53     ` Ard Biesheuvel
2017-03-10  1:39       ` Dave Young
2017-03-16 12:15       ` Matt Fleming
2017-03-10  1:42     ` Dave Young
2017-03-13  7:37     ` Dave Young
     [not found]       ` <20170313073748.GA6332-0VdLhd/A9Pl+NNSt+8eSiB/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2017-03-16 12:41         ` Matt Fleming
2017-03-16 17:50           ` Omar Sandoval
     [not found]             ` <20170316175048.GA25230-o7BRevgTZE6xlMhWRU56u/MCgOUTN/qS0E9HWUfgJXw@public.gmane.org>
2017-04-03 23:54               ` Omar Sandoval
     [not found]           ` <20170316124132.GF6261-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2017-03-17  2:09             ` Dave Young
     [not found]               ` <20170317020951.GA3942-0VdLhd/A9Pl+NNSt+8eSiB/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2017-03-17 13:25                 ` Ard Biesheuvel
2017-03-17 13:32                 ` Matt Fleming
     [not found]                   ` <20170317133232.GI6261-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2017-03-20  2:14                     ` Dave Young
     [not found]                       ` <20170320021412.GA3793-0VdLhd/A9Pl+NNSt+8eSiB/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2017-03-21  7:48                         ` Dave Young
     [not found]                           ` <20170321074826.GA4571-0VdLhd/A9Pl+NNSt+8eSiB/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2017-03-22 16:10                             ` Ard Biesheuvel
     [not found]                               ` <CAKv+Gu-hD9TbSX7iyWZSJ+S2SV5n95S+hcYGnH4OBfi_=M49hA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-23  2:43                                 ` Dave Young
2017-04-04 13:37                         ` Matt Fleming
2017-04-05  1:23                           ` Dave Young

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=20170309095408.GA17883@vader \
    --to=osandov@osandov.com \
    --cc=dyoung@redhat.com \
    --cc=kernel-team@fb.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@codeblueprint.co.uk \
    --cc=mingo@kernel.org \
    /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