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


Groups > linux.kernel > #1233261

Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime

From Ard Biesheuvel <ard.biesheuvel@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime
Date 2015-09-26 20:20 +0200
Message-ID <qd2eK-7JC-25@gated-at.bofh.it> (permalink)
References <qcJlL-5Zx-9@gated-at.bofh.it> <qcJlL-5Zx-7@gated-at.bofh.it> <qcQGB-7R0-1@gated-at.bofh.it> <qd18Z-6cT-9@gated-at.bofh.it> <qd1sl-6zC-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 26 September 2015 at 10:20, H. Peter Anvin <hpa@zytor.com> wrote:
> I think it "works" because the affected BIOSes don't put spaces between the chunks.  I have discussed this with Matt.
>

Forgive the ASCII art but perhaps an illustration might help:

before the 2.5 feature, PE/COFF runtime images were remapped as
illustrated here:

                                PA                        VA
+---------------+         +---------------+
|               |         |               |
| PE/COFF .text |         |    EFI        |
|               |         |    Runtime    |
+- - - - - - - -+    =>   |    Services   |----+
|               |         |    Code       |    |    :               :
| PE/COFF .data |         |               |    |    :               :
|               |         |               |    |    +---------------+
+---------------+         +---------------+    |    |               |
|               |         |               |    |    |    EFI        |
:               :         :               :    |    |    Runtime    |
:               :         :               :    +--->|    Services   |
|               |         |               |         |    Code       |
+---------------+         +---------------+         |               |
|               |         |               |         |               |
| PE/COFF .text |         |    EFI        |         +---------------+
|               |         |    Runtime    |         :      gap      :
+- - - - - - - -+    =>   |    Services   |---+     +---------------+
|               |         |    Code       |   |     |               |
| PE/COFF .data |         |               |   |     |    EFI        |
|               |         |               |   |     |    Runtime    |
+---------------+         +---------------+   +---->|    Services   |
|               |         |               |         |    Code       |
:               :         :               :         |               |
:               :         :               :         |               |
:               :         :               :         +---------------+
:               :         :               :         :               :

Since the affected symbol references only exist between PE/COFF .text
and PE/COFF .data, there is never a problem since each is PE/COFF
image is mapped as a single region.
However, with the new feature enabled, this no longer holds:
                                PA                        VA
+---------------+         +---------------+
|               |         |               |
| PE/COFF .text |         |    RtServices |----+
|               |         |    Code       |    |
+- - - - - - - -+    =>   +---------------+    |    +---------------+
|               |         |    RtServices |    +--->|    RtServices |
| PE/COFF .data |         |    Data       |         |    Code       |
|               |         |               |----+    +---------------+
+---------------+         +---------------+    |    :     gap       :
|               |         |               |    |    +---------------+
:               :         :               :    +--->|    RtServices |
:               :         :               :         |    Data       |
|               |         |               |         +---------------+
+---------------+         +---------------+         :     gap       :
|               |         |               |         +---------------+
| PE/COFF .text |         |    RtServices |-------->|    RtServices |
|               |         |    Code       |         |    Code       |
+- - - - - - - -+    =>   +---------------+         +---------------+
|               |         |    RtServices |         :     gap       :
| PE/COFF .data |         |    Data       |---+     +---------------+
|               |         |               |   |     |    RtServices |
+---------------+         +---------------+   +---->|    Data       |
|               |         |               |         |               |
:               :         :               :         +---------------+
:               :         :               :         :               :
:               :         :               :         :               :

The illustration uses gaps, but obviously, this applies equally to
inverting the mapping order, since the PE/COFF .text and .data
sections will end up out of order.

-- 
Ard.


> On September 26, 2015 10:01:14 AM PDT, Andy Lutomirski <luto@amacapital.net> wrote:
>>On Fri, Sep 25, 2015 at 10:56 PM, Ingo Molnar <mingo@kernel.org> wrote:
>>>
>>> So this commit worries me.
>>>
>>> This bug is a good find, and the fix is obviously needed and urgent,
>>but I'm not
>>> sure about the implementation at all. (I've Cc:-ed a few more x86 low
>>level
>>> gents.)
>>>
>>> * Matt Fleming <matt@codeblueprint.co.uk> wrote:
>>>> +             /*
>>>> +              * Starting in UEFI v2.5 the EFI_PROPERTIES_TABLE
>>>> +              * config table feature requires us to map all entries
>>>> +              * in the same order as they appear in the EFI memory
>>>> +              * map. That is to say, entry N must have a lower
>>>> +              * virtual address than entry N+1. This is because the
>>>> +              * firmware toolchain leaves relative references in
>>>> +              * the code/data sections, which are split and become
>>>> +              * separate EFI memory regions. Mapping things
>>>> +              * out-of-order leads to the firmware accessing
>>>> +              * unmapped addresses.
>>>> +              *
>>
>>I'm clearly missing something.  What is EFI doing that it doesn't care
>>how big the gap between sections is but it still requires them to be
>>in order?  It's not as though x86_64 has an addressing mode that
>>allows only non-negative offsets.
>>
>>--Andy
>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


Thread

[PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Matt Fleming <matt@codeblueprint.co.uk> - 2015-09-26 00:10 +0200
  Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Ingo Molnar <mingo@kernel.org> - 2015-09-26 08:00 +0200
    Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2015-09-26 08:50 +0200
    Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Matt Fleming <matt@codeblueprint.co.uk> - 2015-09-26 15:50 +0200
      Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Ingo Molnar <mingo@kernel.org> - 2015-09-27 09:10 +0200
        Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2015-09-28 08:50 +0200
          Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Ingo Molnar <mingo@kernel.org> - 2015-09-28 10:30 +0200
            Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2015-09-28 12:00 +0200
              Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Ingo Molnar <mingo@kernel.org> - 2015-09-29 11:20 +0200
                Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2015-09-29 12:50 +0200
                Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Matt Fleming <matt@codeblueprint.co.uk> - 2015-09-29 16:20 +0200
                Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Matt Fleming <matt@codeblueprint.co.uk> - 2015-09-29 16:00 +0200
    Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Andy Lutomirski <luto@amacapital.net> - 2015-09-26 19:10 +0200
      Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime "H. Peter Anvin" <hpa@zytor.com> - 2015-09-26 19:30 +0200
        Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2015-09-26 20:20 +0200
          Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Matt Fleming <matt@codeblueprint.co.uk> - 2015-09-26 22:00 +0200
            Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2015-09-26 22:10 +0200
              Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime "H. Peter Anvin" <hpa@zytor.com> - 2015-09-26 22:30 +0200
                Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Andy Lutomirski <luto@amacapital.net> - 2015-09-27 18:40 +0200
                Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Matthew Garrett <mjg59@srcf.ucam.org> - 2015-09-27 20:40 +0200
                Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Ingo Molnar <mingo@kernel.org> - 2015-09-28 08:20 +0200
                Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Matthew Garrett <mjg59@srcf.ucam.org> - 2015-09-28 09:10 +0200
                Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Laszlo Ersek <lersek@redhat.com> - 2015-09-30 00:00 +0200
                Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2015-09-30 11:40 +0200
                Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Andy Lutomirski <luto@amacapital.net> - 2015-09-30 18:50 +0200
                Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime James Bottomley <jbottomley@odin.com> - 2015-09-30 19:30 +0200
                Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime "H. Peter Anvin" <hpa@zytor.com> - 2015-09-30 03:00 +0200
          Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime "H. Peter Anvin" <hpa@zytor.com> - 2015-09-26 22:00 +0200
        Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Matt Fleming <matt@codeblueprint.co.uk> - 2015-09-26 22:00 +0200
      Re: [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Ingo Molnar <mingo@kernel.org> - 2015-09-27 09:00 +0200
  [tip:core/urgent] x86/efi:   Fix boot crash by mapping EFI memmap entries bottom-up at runtime,   instead of top-down tip-bot for Matt Fleming <tipbot@zytor.com> - 2015-10-01 15:00 +0200
    Re: [tip:core/urgent] x86/efi: Fix boot crash by mapping EFI memmap  entries bottom-up at runtime, instead of top-down Matt Fleming <matt@codeblueprint.co.uk> - 2015-10-02 11:50 +0200

csiph-web