Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetMemoryMap(): reserved memory property no-map #52

Closed
xypron opened this issue Aug 27, 2020 · 12 comments
Closed

GetMemoryMap(): reserved memory property no-map #52

xypron opened this issue Aug 27, 2020 · 12 comments
Milestone

Comments

@xypron
Copy link
Contributor

xypron commented Aug 27, 2020

The reserved memory node of the device-tree may have the following properties according to https://www.kernel.org/doc/Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt:

  • compatible
  • no-map
  • reusable

We need should define how these properties should be modeled in the memory map returned by GetMemoryMap().

@glikely
Copy link
Collaborator

glikely commented Aug 31, 2020

Discussed at 2020.08.31 meeting. Heinrich to propose a patch. Need clarity on expected behaviour. Is the OS expected to parse reserved-memory even when UEFI booting, or is the UEFI implementation expected to scrub the provided memory map.

xypron added a commit to xypron/ebbr that referenced this issue Aug 31, 2020
Closes: ARM-software#52

The no-map property of the /reserved-memory DT node is used by Linux to
signal that a memory region shall not be mapped and that speculative access
shall not be permitted.

The memory map returned by GetMemoryMap() does not have a flag
corresponding to no-map. So the closest thing we can do is not to include
no-map reserved memory into the map returned by GetMemoryMap().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
@glikely
Copy link
Collaborator

glikely commented Sep 9, 2020

Met with @xypron, @ardbiesheuvel, and @apalos over Zoom to discuss. Agreed that any static mapping within /reserved-memory should also be present in the UEFI memory map to protect against firmware allocating that same memory for a different purpose (e.g. type == EfiRuntimeServiceData).

If a static /reserved-memory node doesn't appear in the UEFI memory map, the OS would be able to use it providing there is not a conflict between the two, but this is a fragile scenario. If there is a conflict, then the OS should complain. Loudly.

Dynamic allocations in /reserved-memory do not need to be in the UEFI memory map because the OS is responsible for allocating them.

@xypron is going to update his proposed patch to reflect the above. Some work need to be done to map the various types of /reserved-memory nodes to entries in the UEFI map.
@glikely is going to look into putting the /reserved-memory binding details w/ UEFI interaction into the DT spec.

@ardbiesheuvel
Copy link

ardbiesheuvel commented Sep 10, 2020 via email

@xypron
Copy link
Contributor Author

xypron commented Sep 10, 2020

Dear Ard,

A definition of "dynamic /reserved-memory node" in device-tree terms is needed.

Here are some examples:

  • U-Boot receives a device tree from OpenBSI or QEMU or TF-A with a /reserved-memory node marked as no-map.
  • U-Boot loads a device tree from Linux with a /reserved-memory node marked as no-map.
  • U-Boot uses its internal device-tree with a /reserved-memory node marked as no-map.

Should U-Boot treat the respective areas as static or as dynamic?

The UEFI spec has this text: "The firmware does not return a range description for address space regions that are not backed by physical hardware. Regions that are backed by physical hardware, but are not supposed to be accessed by the OS, must be returned as EfiReservedMemoryType. The OS may use addresses of memory ranges that are not described in the memory map at its own discretion."

So UEFI distinguishes between backed by physical hardware and not backed by physical hardware. Nice said but we would have to define how this is determined.

Do you mean by dynamic a /reserved-memory node without a backing /memory node? Is this even allowable under the device-tree spec? If it is not allowable, we would not have to care about it.


Passing areas marked as /reserved-memory nodes in the device tree as BootServicesData would be a change in U-Boot.

Before we make this change we probably should check this not only against old and current Linux kernels but also against BSD.


I just had a look at EDK II. On my MacchiatoBin I See the following line when running memmap in the UEFI shell:

Reserved   0000000004000000-00000000053FFFFF 0000000000001400 0000000000000000

The 4000000-53FFFFF region relates to the no-map /reserved-memory reg = <0x0 0x4000000 0x0 0x200000> in Linux.

Best regards
Heinrich

@ardbiesheuvel
Copy link

ardbiesheuvel commented Sep 10, 2020 via email

@xypron
Copy link
Contributor Author

xypron commented Sep 10, 2020 via email

@ardbiesheuvel
Copy link

ardbiesheuvel commented Sep 10, 2020 via email

@xypron
Copy link
Contributor Author

xypron commented Sep 10, 2020 via email

@ardbiesheuvel
Copy link

ardbiesheuvel commented Sep 10, 2020 via email

@xypron
Copy link
Contributor Author

xypron commented Sep 10, 2020 via email

@glikely
Copy link
Collaborator

glikely commented Sep 14, 2020

Sounds well thought out to me. I agree and look forward to the patch!

@glikely glikely added this to the v1.1 milestone Sep 14, 2020
xypron added a commit to xypron/ebbr that referenced this issue Sep 15, 2020
Closes: ARM-software#52

The no-map property of the /reserved-memory device tree nodes is used to
signal that a memory region shall not be accessed by the operating system,
even not via speculative access.

/reserved-memory nodes without the no-map property describe memory that
have special usage by the operating system.

This difference has to be reflected in the memory map returned by
GetMemoryMap().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
xypron added a commit to xypron/ebbr that referenced this issue Sep 15, 2020
Closes: ARM-software#52

The no-map property of the /reserved-memory device tree nodes is used to
signal that a memory region shall not be accessed by the operating system,
even not via speculative access.

/reserved-memory nodes without the no-map property describe memory that
have special usage by the operating system.

This difference has to be reflected in the memory map returned by
GetMemoryMap().

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
glikely added a commit to devicetree-org/devicetree-specification that referenced this issue Sep 16, 2020
Output from discussion on EBBR issue:
ARM-software/ebbr#52

When using the UEFI ABI for booting, the DT memory map is ignored and
instead UEFI GetMemoryMap() is used to find system memory. Also, regions
described in /reserved-memory need to also be added to the UEFI memory
map to protect against overlapping allocations. The patch adds language
to cover both of those cases.

Signed-off-by: Grant Likely <grant.likely@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
glikely added a commit to devicetree-org/devicetree-specification that referenced this issue Sep 17, 2020
Output from discussion on EBBR issue:
ARM-software/ebbr#52

When using the UEFI ABI for booting, the DT memory map is ignored and
instead UEFI GetMemoryMap() is used to find system memory. Also, regions
described in /reserved-memory need to also be added to the UEFI memory
map to protect against overlapping allocations. The patch adds language
to cover both of those cases.

Signed-off-by: Grant Likely <grant.likely@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
@glikely
Copy link
Collaborator

glikely commented Oct 26, 2020

Closing because text is committed to Devicetree spec

@glikely glikely closed this as completed Oct 26, 2020
glikely added a commit to glikely/ebbr that referenced this issue Mar 11, 2021
SBBR has been superseded by Arm BBR. Update the about section to
reference BBR instead. However, none of the specification language
changes because EBBR has a relaxed set of UEFI requirements compared to
BBR.

Fixes: ARM-software#52

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants