diff mbox

[v3,5/5] ACPI: ARM64: support for ACPI_TABLE_UPGRADE

Message ID 20160602174910.30428-1-aleksey.makarov@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Aleksey Makarov June 2, 2016, 5:49 p.m. UTC
From: Jon Masters <jcm@redhat.com>

This patch adds support for ACPI_TABLE_UPGRADE for ARM64

To access initrd image we need to move initialization
of linear mapping a bit earlier.

The implementation of the feature acpi_table_upgrade()
(drivers/acpi/tables.c) works with initrd data represented as an array
in virtual memory.  It uses some library utility to find the redefined
tables in that array and iterates over it to copy the data to new
allocated memory.  So to access the initrd data via fixmap
we need to rewrite it considerably.

In x86 arch, kernel memory is already mapped by the time when
acpi_table_upgrade() and acpi_boot_table_init() are called so I
think that we can just move this mapping one function earlier too.

Signed-off-by: Jon Masters <jcm@redhat.com>
Signed-off-by: Aleksey Makarov <aleksey.makarov@linaro.org>
---
 arch/arm64/Kconfig            | 1 +
 arch/arm64/include/asm/acpi.h | 2 ++
 arch/arm64/kernel/setup.c     | 6 ++++--
 3 files changed, 7 insertions(+), 2 deletions(-)

Comments

Aleksey Makarov June 14, 2016, 3:51 p.m. UTC | #1
On 06/02/2016 08:49 PM, Aleksey Makarov wrote:
> From: Jon Masters <jcm@redhat.com>
> 
> This patch adds support for ACPI_TABLE_UPGRADE for ARM64

Hi Catalin, Will,

Can you review this v3 patch please?  I changed PFN_PHYS(max_pfn) to
MEMBLOCK_ALLOC_ACCESSIBLE.

Thank you
Aleksey Makarov

> To access initrd image we need to move initialization
> of linear mapping a bit earlier.
> 
> The implementation of the feature acpi_table_upgrade()
> (drivers/acpi/tables.c) works with initrd data represented as an array
> in virtual memory.  It uses some library utility to find the redefined
> tables in that array and iterates over it to copy the data to new
> allocated memory.  So to access the initrd data via fixmap
> we need to rewrite it considerably.
> 
> In x86 arch, kernel memory is already mapped by the time when
> acpi_table_upgrade() and acpi_boot_table_init() are called so I
> think that we can just move this mapping one function earlier too.
> 
> Signed-off-by: Jon Masters <jcm@redhat.com>
> Signed-off-by: Aleksey Makarov <aleksey.makarov@linaro.org>
> ---
>  arch/arm64/Kconfig            | 1 +
>  arch/arm64/include/asm/acpi.h | 2 ++
>  arch/arm64/kernel/setup.c     | 6 ++++--
>  3 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 87c48ad..baee459 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -5,6 +5,7 @@ config ARM64
>  	select ACPI_REDUCED_HARDWARE_ONLY if ACPI
>  	select ACPI_MCFG if ACPI
>  	select ARCH_HAS_DEVMEM_IS_ALLOWED
> +	select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
>  	select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
>  	select ARCH_HAS_ELF_RANDOMIZE
>  	select ARCH_HAS_GCOV_PROFILE_ALL
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> index aee323b..c7aefc5 100644
> --- a/arch/arm64/include/asm/acpi.h
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -113,4 +113,6 @@ static inline const char *acpi_get_enable_method(int cpu)
>  pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr);
>  #endif
>  
> +#define ACPI_TABLE_UPGRADE_MAX_PHYS MEMBLOCK_ALLOC_ACCESSIBLE
> +
>  #endif /*_ASM_ACPI_H*/
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index feab2ee..4bce811 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -261,11 +261,13 @@ void __init setup_arch(char **cmdline_p)
>  	efi_init();
>  	arm64_memblock_init();
>  
> +	paging_init();
> +
> +	acpi_table_upgrade();
> +
>  	/* Parse the ACPI tables for possible boot-time configuration */
>  	acpi_boot_table_init();
>  
> -	paging_init();
> -
>  	if (acpi_disabled)
>  		unflatten_device_tree();
>  
>
Will Deacon June 14, 2016, 4:41 p.m. UTC | #2
On Tue, Jun 14, 2016 at 06:51:19PM +0300, Aleksey Makarov wrote:
> 
> On 06/02/2016 08:49 PM, Aleksey Makarov wrote:
> > From: Jon Masters <jcm@redhat.com>
> > 
> > This patch adds support for ACPI_TABLE_UPGRADE for ARM64
> 
> Hi Catalin, Will,
> 
> Can you review this v3 patch please?  I changed PFN_PHYS(max_pfn) to
> MEMBLOCK_ALLOC_ACCESSIBLE.

I'm inclined to agree with Mark that this is something that should be
done by the bootloader (e.g. GRUB) if it's needed, rather than something
we should support in the kernel. Jon pitched the feature as a developer
aid for triaging problems, so it's not like we're in a state where some
widely available machine cannot currently boot Linux without this.

Having said that, the patch isn't exactly invasive and I suspect it's
only a matter of time before we will actually want something like this.
So I've come full circle on this patch:

Acked-by: Will Deacon <will.deacon@arm.com>

Will
diff mbox

Patch

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 87c48ad..baee459 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -5,6 +5,7 @@  config ARM64
 	select ACPI_REDUCED_HARDWARE_ONLY if ACPI
 	select ACPI_MCFG if ACPI
 	select ARCH_HAS_DEVMEM_IS_ALLOWED
+	select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
 	select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
 	select ARCH_HAS_ELF_RANDOMIZE
 	select ARCH_HAS_GCOV_PROFILE_ALL
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
index aee323b..c7aefc5 100644
--- a/arch/arm64/include/asm/acpi.h
+++ b/arch/arm64/include/asm/acpi.h
@@ -113,4 +113,6 @@  static inline const char *acpi_get_enable_method(int cpu)
 pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr);
 #endif
 
+#define ACPI_TABLE_UPGRADE_MAX_PHYS MEMBLOCK_ALLOC_ACCESSIBLE
+
 #endif /*_ASM_ACPI_H*/
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index feab2ee..4bce811 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -261,11 +261,13 @@  void __init setup_arch(char **cmdline_p)
 	efi_init();
 	arm64_memblock_init();
 
+	paging_init();
+
+	acpi_table_upgrade();
+
 	/* Parse the ACPI tables for possible boot-time configuration */
 	acpi_boot_table_init();
 
-	paging_init();
-
 	if (acpi_disabled)
 		unflatten_device_tree();