Re: [PATCH v7 00/12] EFI Specific Purpose Memory Support

2019-10-16 Thread Dan Williams
On Tue, Oct 15, 2019 at 11:55 PM Ard Biesheuvel
 wrote:
>
> On Wed, 16 Oct 2019 at 03:13, Dan Williams  wrote:
> >
> > Changes since v6 [1]:
> > - Collect Ard's ack / review on patches 5-7, but not on patch 4 since it
> >   needed a non-trivial rework for linker error reported by the 0day robot.
> >
> > - Fixup "efi: Common enable/disable infrastructure for EFI soft
> >   reservation" with a new dependency on CONFIG_EFI_STUB for
> >   CONFIG_EFI_SOFT_RESERVE since the efi_soft_reserve_enabled() helper is
> >   only built with EFI_STUB=y and the support depends on early reservations
> >   to keep the kernel text from landing in the reservation.
>
> As far as I know, GRUB on x86 still boots without the EFI stub by
> default (i.e., using the 'linux' command instead of the 'linuxefi'
> command), so even if you build the stub, it is not going to be called
> in many cases. Is that going to be a problem?

It only becomes a problem if kaslr decides to land the kernel on top
of the soft-reservation. However, I think it's ok to say that if you
need the reservation to be honored in all circumstances, arrange to
boot in EFI mode.

>
> > This also
> >   moved the IS_ENABLED(CONFIG_EFI_SOFT_RESERVE) check into the header so
> >   that the stub does not try to link to __efi_soft_reserve_enabled() in
> >   the EFI_STUB=n case.
> >
> > - Rework "x86/efi: EFI soft reservation to E820 enumeration" to always
> >   add the full EFI memory map when EFI_MEMORY_SP ranges are found. This
> >   simplifies the logic to just add the full EFI map rather than try to
> >   tease out just the EFI_MEMORY_SP ranges. (Ard)
> >
> > [1]: 
> > https://lore.kernel.org/lkml/157066227329.1059972.5659620631541203458.st...@dwillia2-desk3.amr.corp.intel.com/
> >
> > ---
> > Merge notes:
> >
> > Hi Ingo,
> >
> > I'm still looking for Ard's ack on the revised patch 4, but otherwise
> > feel like this is ready for your consideration.
> >
>
> Patch 4 looks fine to me,
>
> Reviewed-by: Ard Biesheuvel 

Thanks for the help.


Re: [PATCH v7 00/12] EFI Specific Purpose Memory Support

2019-10-16 Thread Ard Biesheuvel
On Wed, 16 Oct 2019 at 03:13, Dan Williams  wrote:
>
> Changes since v6 [1]:
> - Collect Ard's ack / review on patches 5-7, but not on patch 4 since it
>   needed a non-trivial rework for linker error reported by the 0day robot.
>
> - Fixup "efi: Common enable/disable infrastructure for EFI soft
>   reservation" with a new dependency on CONFIG_EFI_STUB for
>   CONFIG_EFI_SOFT_RESERVE since the efi_soft_reserve_enabled() helper is
>   only built with EFI_STUB=y and the support depends on early reservations
>   to keep the kernel text from landing in the reservation.

As far as I know, GRUB on x86 still boots without the EFI stub by
default (i.e., using the 'linux' command instead of the 'linuxefi'
command), so even if you build the stub, it is not going to be called
in many cases. Is that going to be a problem?

> This also
>   moved the IS_ENABLED(CONFIG_EFI_SOFT_RESERVE) check into the header so
>   that the stub does not try to link to __efi_soft_reserve_enabled() in
>   the EFI_STUB=n case.
>
> - Rework "x86/efi: EFI soft reservation to E820 enumeration" to always
>   add the full EFI memory map when EFI_MEMORY_SP ranges are found. This
>   simplifies the logic to just add the full EFI map rather than try to
>   tease out just the EFI_MEMORY_SP ranges. (Ard)
>
> [1]: 
> https://lore.kernel.org/lkml/157066227329.1059972.5659620631541203458.st...@dwillia2-desk3.amr.corp.intel.com/
>
> ---
> Merge notes:
>
> Hi Ingo,
>
> I'm still looking for Ard's ack on the revised patch 4, but otherwise
> feel like this is ready for your consideration.
>

Patch 4 looks fine to me,

Reviewed-by: Ard Biesheuvel 


> ---
>
> The EFI 2.8 Specification [2] introduces the EFI_MEMORY_SP ("specific
> purpose") memory attribute. This attribute bit replaces the deprecated
> ACPI HMAT "reservation hint" that was introduced in ACPI 6.2 and removed
> in ACPI 6.3.
>
> Given the increasing diversity of memory types that might be advertised
> to the operating system, there is a need for platform firmware to hint
> which memory ranges are free for the OS to use as general purpose memory
> and which ranges are intended for application specific usage. For
> example, an application with prior knowledge of the platform may expect
> to be able to exclusively allocate a precious / limited pool of high
> bandwidth memory. Alternatively, for the general purpose case, the
> operating system may want to make the memory available on a best effort
> basis as a unique numa-node with performance properties by the new
> CONFIG_HMEM_REPORTING [3] facility.
>
> In support of optionally allowing either application-exclusive and
> core-kernel-mm managed access to differentiated memory, claim
> EFI_MEMORY_SP ranges for exposure as "soft reserved" and assigned to a
> device-dax instance by default. Such instances can be directly owned /
> mapped by a platform-topology-aware application. Alternatively, with the
> new kmem facility [4], the administrator has the option to instead
> designate that those memory ranges be hot-added to the core-kernel-mm as
> a unique memory numa-node. In short, allow for the decision about what
> software agent manages soft-reserved memory to be made at runtime.
>
> The patches build on the new HMAT+HMEM_REPORTING facilities merged
> for v5.2-rc1. The implementation is tested with qemu emulation of HMAT
> [5] plus the efi_fake_mem facility for applying the EFI_MEMORY_SP
> attribute. Specific details on reproducing the test configuration are in
> patch 12.
>
> [2]: https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
> [3]: 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e1cf33aafb84
> [4]: 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c221c0b0308f
> [5]: http://patchwork.ozlabs.org/cover/1096737/
>
> ---
>
> Dan Williams (12):
>   acpi/numa: Establish a new drivers/acpi/numa/ directory
>   efi: Enumerate EFI_MEMORY_SP
>   x86/efi: Push EFI_MEMMAP check into leaf routines
>   efi: Common enable/disable infrastructure for EFI soft reservation
>   x86/efi: EFI soft reservation to E820 enumeration
>   arm/efi: EFI soft reservation to memblock
>   x86/efi: Add efi_fake_mem support for EFI_MEMORY_SP
>   lib: Uplevel the pmem "region" ida to a global allocator
>   dax: Fix alloc_dax_region() compile warning
>   device-dax: Add a driver for "hmem" devices
>   acpi/numa/hmat: Register HMAT at device_initcall level
>   acpi/numa/hmat: Register "soft reserved" memory as an "hmem" device
>
>
>  Documentation/admin-guide/kernel-parameters.txt |   19 +++
>  arch/arm64/mm/mmu.c |2
>  arch/x86/boot/compressed/eboot.c|6 +
>  arch/x86/boot/compressed/kaslr.c|   46 +++-
>  arch/x86/include/asm/e820/types.h   |8 +
>  arch/x86/include/asm/efi.h  |   17 +++
>  arch/x86/kernel/e820.c  |   

[PATCH v7 00/12] EFI Specific Purpose Memory Support

2019-10-15 Thread Dan Williams
Changes since v6 [1]:
- Collect Ard's ack / review on patches 5-7, but not on patch 4 since it
  needed a non-trivial rework for linker error reported by the 0day robot.

- Fixup "efi: Common enable/disable infrastructure for EFI soft
  reservation" with a new dependency on CONFIG_EFI_STUB for
  CONFIG_EFI_SOFT_RESERVE since the efi_soft_reserve_enabled() helper is
  only built with EFI_STUB=y and the support depends on early reservations
  to keep the kernel text from landing in the reservation. This also
  moved the IS_ENABLED(CONFIG_EFI_SOFT_RESERVE) check into the header so
  that the stub does not try to link to __efi_soft_reserve_enabled() in
  the EFI_STUB=n case.

- Rework "x86/efi: EFI soft reservation to E820 enumeration" to always
  add the full EFI memory map when EFI_MEMORY_SP ranges are found. This
  simplifies the logic to just add the full EFI map rather than try to
  tease out just the EFI_MEMORY_SP ranges. (Ard)

[1]: 
https://lore.kernel.org/lkml/157066227329.1059972.5659620631541203458.st...@dwillia2-desk3.amr.corp.intel.com/

---
Merge notes:

Hi Ingo,

I'm still looking for Ard's ack on the revised patch 4, but otherwise
feel like this is ready for your consideration.

---

The EFI 2.8 Specification [2] introduces the EFI_MEMORY_SP ("specific
purpose") memory attribute. This attribute bit replaces the deprecated
ACPI HMAT "reservation hint" that was introduced in ACPI 6.2 and removed
in ACPI 6.3.

Given the increasing diversity of memory types that might be advertised
to the operating system, there is a need for platform firmware to hint
which memory ranges are free for the OS to use as general purpose memory
and which ranges are intended for application specific usage. For
example, an application with prior knowledge of the platform may expect
to be able to exclusively allocate a precious / limited pool of high
bandwidth memory. Alternatively, for the general purpose case, the
operating system may want to make the memory available on a best effort
basis as a unique numa-node with performance properties by the new
CONFIG_HMEM_REPORTING [3] facility.

In support of optionally allowing either application-exclusive and
core-kernel-mm managed access to differentiated memory, claim
EFI_MEMORY_SP ranges for exposure as "soft reserved" and assigned to a
device-dax instance by default. Such instances can be directly owned /
mapped by a platform-topology-aware application. Alternatively, with the
new kmem facility [4], the administrator has the option to instead
designate that those memory ranges be hot-added to the core-kernel-mm as
a unique memory numa-node. In short, allow for the decision about what
software agent manages soft-reserved memory to be made at runtime.

The patches build on the new HMAT+HMEM_REPORTING facilities merged
for v5.2-rc1. The implementation is tested with qemu emulation of HMAT
[5] plus the efi_fake_mem facility for applying the EFI_MEMORY_SP
attribute. Specific details on reproducing the test configuration are in
patch 12.

[2]: https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
[3]: 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e1cf33aafb84
[4]: 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c221c0b0308f
[5]: http://patchwork.ozlabs.org/cover/1096737/

---

Dan Williams (12):
  acpi/numa: Establish a new drivers/acpi/numa/ directory
  efi: Enumerate EFI_MEMORY_SP
  x86/efi: Push EFI_MEMMAP check into leaf routines
  efi: Common enable/disable infrastructure for EFI soft reservation
  x86/efi: EFI soft reservation to E820 enumeration
  arm/efi: EFI soft reservation to memblock
  x86/efi: Add efi_fake_mem support for EFI_MEMORY_SP
  lib: Uplevel the pmem "region" ida to a global allocator
  dax: Fix alloc_dax_region() compile warning
  device-dax: Add a driver for "hmem" devices
  acpi/numa/hmat: Register HMAT at device_initcall level
  acpi/numa/hmat: Register "soft reserved" memory as an "hmem" device


 Documentation/admin-guide/kernel-parameters.txt |   19 +++
 arch/arm64/mm/mmu.c |2 
 arch/x86/boot/compressed/eboot.c|6 +
 arch/x86/boot/compressed/kaslr.c|   46 +++-
 arch/x86/include/asm/e820/types.h   |8 +
 arch/x86/include/asm/efi.h  |   17 +++
 arch/x86/kernel/e820.c  |   12 ++
 arch/x86/kernel/setup.c |   18 +--
 arch/x86/platform/efi/efi.c |   54 -
 arch/x86/platform/efi/quirks.c  |3 +
 drivers/acpi/Kconfig|9 --
 drivers/acpi/Makefile   |3 -
 drivers/acpi/hmat/Makefile  |2 
 drivers/acpi/numa/Kconfig   |7 +
 drivers/acpi/numa/Makefile  |3 +
 drivers/acpi/numa/hmat.c|  138