All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efi: arm: Don't mark ACPI reclaim memory as MEMBLOCK_NOMAP
@ 2017-06-05  8:04 ` Ard Biesheuvel
  0 siblings, 0 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2017-06-05  8:04 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-efi-u79uwXL29TY76Z2rM5mHXA
  Cc: matt-mF/unelCI9GS6iBeEJttW/XRex20P6io, mark.rutland-5wv7dgnIgG8,
	leif.lindholm-QSEj5FYQhm4dnm+yROfE0A, james.morse-5wv7dgnIgG8,
	Ard Biesheuvel

On ARM, regions of memory that are described by UEFI as having special
significance to the firmware itself are omitted from the linear mapping.
This is necessary since we cannot guarantee that alternate mappings of
the same physical region will use attributes that are compatible with
the ones we use for the linear mapping, and aliases with mismatched
attributes are prohibited by the architecture.

The above does not apply to ACPI reclaim regions: such regions have no
special significance to the firmware, and it is up to the OS to decide
whether or not to preserve them after it has consumed their contents,
and for how long, after which time the OS can use the memory in any way
it likes. In the Linux case, such regions are preserved indefinitely,
and are simply treated the same way as other 'reserved' memory types.

Punching holes into the linear mapping causes page table fragmentation,
which increases TLB pressure, and so we should avoid doing so if we can.
So add a special case for regions of type EFI_ACPI_RECLAIM_MEMORY, and
memblock_reserve() them instead of marking them MEMBLOCK_NOMAP.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/firmware/efi/arm-init.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c
index 1027d7b44358..0aa4ce7b4fbb 100644
--- a/drivers/firmware/efi/arm-init.c
+++ b/drivers/firmware/efi/arm-init.c
@@ -159,6 +159,7 @@ static __init int is_usable_memory(efi_memory_desc_t *md)
 	switch (md->type) {
 	case EFI_LOADER_CODE:
 	case EFI_LOADER_DATA:
+	case EFI_ACPI_RECLAIM_MEMORY:
 	case EFI_BOOT_SERVICES_CODE:
 	case EFI_BOOT_SERVICES_DATA:
 	case EFI_CONVENTIONAL_MEMORY:
@@ -211,6 +212,10 @@ static __init void reserve_regions(void)
 
 			if (!is_usable_memory(md))
 				memblock_mark_nomap(paddr, size);
+
+			/* keep ACPI reclaim memory intact for kexec etc. */
+			if (md->type == EFI_ACPI_RECLAIM_MEMORY)
+				memblock_reserve(paddr, size);
 		}
 	}
 }
-- 
2.9.3

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

* [PATCH] efi: arm: Don't mark ACPI reclaim memory as MEMBLOCK_NOMAP
@ 2017-06-05  8:04 ` Ard Biesheuvel
  0 siblings, 0 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2017-06-05  8:04 UTC (permalink / raw)
  To: linux-arm-kernel

On ARM, regions of memory that are described by UEFI as having special
significance to the firmware itself are omitted from the linear mapping.
This is necessary since we cannot guarantee that alternate mappings of
the same physical region will use attributes that are compatible with
the ones we use for the linear mapping, and aliases with mismatched
attributes are prohibited by the architecture.

The above does not apply to ACPI reclaim regions: such regions have no
special significance to the firmware, and it is up to the OS to decide
whether or not to preserve them after it has consumed their contents,
and for how long, after which time the OS can use the memory in any way
it likes. In the Linux case, such regions are preserved indefinitely,
and are simply treated the same way as other 'reserved' memory types.

Punching holes into the linear mapping causes page table fragmentation,
which increases TLB pressure, and so we should avoid doing so if we can.
So add a special case for regions of type EFI_ACPI_RECLAIM_MEMORY, and
memblock_reserve() them instead of marking them MEMBLOCK_NOMAP.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/firmware/efi/arm-init.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c
index 1027d7b44358..0aa4ce7b4fbb 100644
--- a/drivers/firmware/efi/arm-init.c
+++ b/drivers/firmware/efi/arm-init.c
@@ -159,6 +159,7 @@ static __init int is_usable_memory(efi_memory_desc_t *md)
 	switch (md->type) {
 	case EFI_LOADER_CODE:
 	case EFI_LOADER_DATA:
+	case EFI_ACPI_RECLAIM_MEMORY:
 	case EFI_BOOT_SERVICES_CODE:
 	case EFI_BOOT_SERVICES_DATA:
 	case EFI_CONVENTIONAL_MEMORY:
@@ -211,6 +212,10 @@ static __init void reserve_regions(void)
 
 			if (!is_usable_memory(md))
 				memblock_mark_nomap(paddr, size);
+
+			/* keep ACPI reclaim memory intact for kexec etc. */
+			if (md->type == EFI_ACPI_RECLAIM_MEMORY)
+				memblock_reserve(paddr, size);
 		}
 	}
 }
-- 
2.9.3

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

* Re: [PATCH] efi: arm: Don't mark ACPI reclaim memory as MEMBLOCK_NOMAP
  2017-06-05  8:04 ` Ard Biesheuvel
@ 2017-06-05  9:08     ` Mark Rutland
  -1 siblings, 0 replies; 6+ messages in thread
From: Mark Rutland @ 2017-06-05  9:08 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	matt-mF/unelCI9GS6iBeEJttW/XRex20P6io,
	leif.lindholm-QSEj5FYQhm4dnm+yROfE0A, james.morse-5wv7dgnIgG8

On Mon, Jun 05, 2017 at 08:04:35AM +0000, Ard Biesheuvel wrote:
> On ARM, regions of memory that are described by UEFI as having special
> significance to the firmware itself are omitted from the linear mapping.
> This is necessary since we cannot guarantee that alternate mappings of
> the same physical region will use attributes that are compatible with
> the ones we use for the linear mapping, and aliases with mismatched
> attributes are prohibited by the architecture.
> 
> The above does not apply to ACPI reclaim regions: such regions have no
> special significance to the firmware, and it is up to the OS to decide
> whether or not to preserve them after it has consumed their contents,
> and for how long, after which time the OS can use the memory in any way
> it likes. In the Linux case, such regions are preserved indefinitely,
> and are simply treated the same way as other 'reserved' memory types.
> 
> Punching holes into the linear mapping causes page table fragmentation,
> which increases TLB pressure, and so we should avoid doing so if we can.
> So add a special case for regions of type EFI_ACPI_RECLAIM_MEMORY, and
> memblock_reserve() them instead of marking them MEMBLOCK_NOMAP.
> 
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Sounds sane to me. FWIW:

Acked-by: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>

Thanks,
Mark.

> ---
>  drivers/firmware/efi/arm-init.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c
> index 1027d7b44358..0aa4ce7b4fbb 100644
> --- a/drivers/firmware/efi/arm-init.c
> +++ b/drivers/firmware/efi/arm-init.c
> @@ -159,6 +159,7 @@ static __init int is_usable_memory(efi_memory_desc_t *md)
>  	switch (md->type) {
>  	case EFI_LOADER_CODE:
>  	case EFI_LOADER_DATA:
> +	case EFI_ACPI_RECLAIM_MEMORY:
>  	case EFI_BOOT_SERVICES_CODE:
>  	case EFI_BOOT_SERVICES_DATA:
>  	case EFI_CONVENTIONAL_MEMORY:
> @@ -211,6 +212,10 @@ static __init void reserve_regions(void)
>  
>  			if (!is_usable_memory(md))
>  				memblock_mark_nomap(paddr, size);
> +
> +			/* keep ACPI reclaim memory intact for kexec etc. */
> +			if (md->type == EFI_ACPI_RECLAIM_MEMORY)
> +				memblock_reserve(paddr, size);
>  		}
>  	}
>  }
> -- 
> 2.9.3
> 

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

* [PATCH] efi: arm: Don't mark ACPI reclaim memory as MEMBLOCK_NOMAP
@ 2017-06-05  9:08     ` Mark Rutland
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Rutland @ 2017-06-05  9:08 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jun 05, 2017 at 08:04:35AM +0000, Ard Biesheuvel wrote:
> On ARM, regions of memory that are described by UEFI as having special
> significance to the firmware itself are omitted from the linear mapping.
> This is necessary since we cannot guarantee that alternate mappings of
> the same physical region will use attributes that are compatible with
> the ones we use for the linear mapping, and aliases with mismatched
> attributes are prohibited by the architecture.
> 
> The above does not apply to ACPI reclaim regions: such regions have no
> special significance to the firmware, and it is up to the OS to decide
> whether or not to preserve them after it has consumed their contents,
> and for how long, after which time the OS can use the memory in any way
> it likes. In the Linux case, such regions are preserved indefinitely,
> and are simply treated the same way as other 'reserved' memory types.
> 
> Punching holes into the linear mapping causes page table fragmentation,
> which increases TLB pressure, and so we should avoid doing so if we can.
> So add a special case for regions of type EFI_ACPI_RECLAIM_MEMORY, and
> memblock_reserve() them instead of marking them MEMBLOCK_NOMAP.
> 
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Sounds sane to me. FWIW:

Acked-by: Mark Rutland <mark.rutland@arm.com>

Thanks,
Mark.

> ---
>  drivers/firmware/efi/arm-init.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c
> index 1027d7b44358..0aa4ce7b4fbb 100644
> --- a/drivers/firmware/efi/arm-init.c
> +++ b/drivers/firmware/efi/arm-init.c
> @@ -159,6 +159,7 @@ static __init int is_usable_memory(efi_memory_desc_t *md)
>  	switch (md->type) {
>  	case EFI_LOADER_CODE:
>  	case EFI_LOADER_DATA:
> +	case EFI_ACPI_RECLAIM_MEMORY:
>  	case EFI_BOOT_SERVICES_CODE:
>  	case EFI_BOOT_SERVICES_DATA:
>  	case EFI_CONVENTIONAL_MEMORY:
> @@ -211,6 +212,10 @@ static __init void reserve_regions(void)
>  
>  			if (!is_usable_memory(md))
>  				memblock_mark_nomap(paddr, size);
> +
> +			/* keep ACPI reclaim memory intact for kexec etc. */
> +			if (md->type == EFI_ACPI_RECLAIM_MEMORY)
> +				memblock_reserve(paddr, size);
>  		}
>  	}
>  }
> -- 
> 2.9.3
> 

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

* Re: [PATCH] efi: arm: Don't mark ACPI reclaim memory as MEMBLOCK_NOMAP
  2017-06-05  9:08     ` Mark Rutland
@ 2017-06-09  9:01       ` Ard Biesheuvel
  -1 siblings, 0 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2017-06-09  9:01 UTC (permalink / raw)
  To: Mark Rutland
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	linux-efi-u79uwXL29TY76Z2rM5mHXA, Matt Fleming, Leif Lindholm,
	James Morse

On 5 June 2017 at 09:08, Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org> wrote:
> On Mon, Jun 05, 2017 at 08:04:35AM +0000, Ard Biesheuvel wrote:
>> On ARM, regions of memory that are described by UEFI as having special
>> significance to the firmware itself are omitted from the linear mapping.
>> This is necessary since we cannot guarantee that alternate mappings of
>> the same physical region will use attributes that are compatible with
>> the ones we use for the linear mapping, and aliases with mismatched
>> attributes are prohibited by the architecture.
>>
>> The above does not apply to ACPI reclaim regions: such regions have no
>> special significance to the firmware, and it is up to the OS to decide
>> whether or not to preserve them after it has consumed their contents,
>> and for how long, after which time the OS can use the memory in any way
>> it likes. In the Linux case, such regions are preserved indefinitely,
>> and are simply treated the same way as other 'reserved' memory types.
>>
>> Punching holes into the linear mapping causes page table fragmentation,
>> which increases TLB pressure, and so we should avoid doing so if we can.
>> So add a special case for regions of type EFI_ACPI_RECLAIM_MEMORY, and
>> memblock_reserve() them instead of marking them MEMBLOCK_NOMAP.
>>
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>
> Sounds sane to me. FWIW:
>
> Acked-by: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
>

Thanks.

I have queued this in efi/next

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

* [PATCH] efi: arm: Don't mark ACPI reclaim memory as MEMBLOCK_NOMAP
@ 2017-06-09  9:01       ` Ard Biesheuvel
  0 siblings, 0 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2017-06-09  9:01 UTC (permalink / raw)
  To: linux-arm-kernel

On 5 June 2017 at 09:08, Mark Rutland <mark.rutland@arm.com> wrote:
> On Mon, Jun 05, 2017 at 08:04:35AM +0000, Ard Biesheuvel wrote:
>> On ARM, regions of memory that are described by UEFI as having special
>> significance to the firmware itself are omitted from the linear mapping.
>> This is necessary since we cannot guarantee that alternate mappings of
>> the same physical region will use attributes that are compatible with
>> the ones we use for the linear mapping, and aliases with mismatched
>> attributes are prohibited by the architecture.
>>
>> The above does not apply to ACPI reclaim regions: such regions have no
>> special significance to the firmware, and it is up to the OS to decide
>> whether or not to preserve them after it has consumed their contents,
>> and for how long, after which time the OS can use the memory in any way
>> it likes. In the Linux case, such regions are preserved indefinitely,
>> and are simply treated the same way as other 'reserved' memory types.
>>
>> Punching holes into the linear mapping causes page table fragmentation,
>> which increases TLB pressure, and so we should avoid doing so if we can.
>> So add a special case for regions of type EFI_ACPI_RECLAIM_MEMORY, and
>> memblock_reserve() them instead of marking them MEMBLOCK_NOMAP.
>>
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
> Sounds sane to me. FWIW:
>
> Acked-by: Mark Rutland <mark.rutland@arm.com>
>

Thanks.

I have queued this in efi/next

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

end of thread, other threads:[~2017-06-09  9:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-05  8:04 [PATCH] efi: arm: Don't mark ACPI reclaim memory as MEMBLOCK_NOMAP Ard Biesheuvel
2017-06-05  8:04 ` Ard Biesheuvel
     [not found] ` <20170605080435.2498-1-ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-06-05  9:08   ` Mark Rutland
2017-06-05  9:08     ` Mark Rutland
2017-06-09  9:01     ` Ard Biesheuvel
2017-06-09  9:01       ` Ard Biesheuvel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.