xen/arm: Fix and clean-up for ACPI and EFI
v2 cover xen/arm: Fix and clean-up for ACPI and EFI
Hi all,
This patch series contains a bunch of fix and clean-up for ACPI and EFI on ARM64.
For all the changes see in each patch.
Cheers,
Julien Grall (4):
xen/arm: efi: Avoid duplicating the addition of a new bank xen/arm: efi: Avoid duplicating the addition of a new efi memory
descriptor
xen/arm: efi: Rework acpi_create_efi_mmap_table to avoid
memory_map[offset]
xen/arm: acpi: Move the ACPI banks in bootinfo
xen/arch/arm/efi/efi-boot.h | 36 +++++++++++++------------- xen/arch/arm/efi/efi-dom0.c | 61 +++++++++++++++++++++------------------------ xen/arch/arm/efi/efi-dom0.h | 8 ------ xen/include/asm-arm/setup.h | 3 +++ 4 files changed, 51 insertions(+), 57 deletions(-) delete mode 100644 xen/arch/arm/efi/efi-dom0.h
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v2 1/4 xen/arm: efi: Avoid duplicating the addition of a new bank
The code to add a new bank is duplicated twice. Add a new helper that checks if the maximum of bank has not reached and adds the bank.
---
Changes in v2:
- Add Stefano's reviewed-by
- Mark the function as __init
--- xen/arch/arm/efi/efi-boot.h | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-)
xen/arch/arm/efi/efi-boot.h +19 -16
@@ -124,15 +124,28 @@ static void __init *lookup_fdt_config_table(EFI_SYSTEM_TABLE *sys_table)return fdt; } +static bool __init meminfo_add_bank (struct meminfo *mem, +EFI_MEMORY_DESCRIPTOR *desc) +{ +struct membank *bank; + +if ( mem->nr_banks >NR_MEM_BANKS ) +return false; + + bank = &mem->bank[mem->nr_banks]; + bank->start = desc->PhysicalStart; + bank->size = desc->NumberOfPages *EFI_PAGE_SIZE ; + + mem->nr_banks++; + +return true; +} +static EFI_STATUS __init efi_process_memory_map_bootinfo (EFI_MEMORY_DESCRIPTOR *map,UINTN mmap_size,UINTN desc_size) {int Index; -int i =0 ; -#ifdef CONFIG_ACPI -int j =0 ; -#endif EFI_MEMORY_DESCRIPTOR *desc_ptr = map;for ( Index =0 ; Index < (mmap_size / desc_size); Index++ )
@@ -142,37 +155,27 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR * (desc_ptr->Type == EfiBootServicesCode || desc_ptr->Type == EfiBootServicesData)) ) { -if ( i >=NR_MEM_BANKS ) +if ( !meminfo_add_bank (&bootinfo.mem, desc_ptr) ) { PrintStr(L"Warning: All " __stringify(NR_MEM_BANKS)" bootinfo mem banks exhausted.\r\n" );break ; } - bootinfo.mem.bank[i].start = desc_ptr->PhysicalStart; - bootinfo.mem.bank[i].size = desc_ptr->NumberOfPages *EFI_PAGE_SIZE ; - ++i; }#ifdef CONFIG_ACPI else if ( desc_ptr->Type == EfiACPIReclaimMemory ) { -if ( j >=NR_MEM_BANKS ) +if ( !meminfo_add_bank (&acpi_mem, desc_ptr) ) { PrintStr(L"Error: All " __stringify(NR_MEM_BANKS)" acpi meminfo mem banks exhausted.\r\n" );return EFI_LOAD_ERROR ; } - acpi_mem.bank[j].start = desc_ptr->PhysicalStart; - acpi_mem.bank[j].size = desc_ptr->NumberOfPages *EFI_PAGE_SIZE ; - ++j; }#endif desc_ptr =NextMemoryDescriptor (desc_ptr, desc_size); } - bootinfo.mem.nr_banks = i; -#ifdef CONFIG_ACPI - acpi_mem.nr_banks = j; -#endif return EFI_SUCCESS ; }
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v2 2/4 xen/arm: efi: Avoid duplicating the addition of a new efi memory descriptor
In reply to Julien GrallThe code to add a new memory descriptor is duplicated three times. Add a new helper that adds the descriptor.
---
Changes in v2:
- Add Stefano's reviewed-by
--- xen/arch/arm/efi/efi-dom0.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
xen/arch/arm/efi/efi-dom0.c +20 -20
@@ -96,6 +96,18 @@ void __init acpi_create_efi_system_table(struct domain *d, tbl_add[TBL_EFIT ].size = table_size; } +static void __init fill_efi_memory_descriptor (EFI_MEMORY_DESCRIPTOR *desc, +UINT32 type, +EFI_PHYSICAL_ADDRESS start, +UINT64 size) +{ + desc->Type = type; + desc->PhysicalStart = start; +BUG_ON (size &EFI_PAGE_MASK ); + desc->NumberOfPages =EFI_SIZE_TO_PAGES (size); + desc->Attribute =EFI_MEMORY_WB ; +} +void __init acpi_create_efi_mmap_table (struct domain *d,const struct meminfo *mem,struct membank tbl_add[])
@@ -110,28 +122,16 @@ void __init acpi_create_efi_mmap_table(struct domain *d, offset =0 ;for ( i =0 ; i < mem->nr_banks; i++, offset++ ) - { - memory_map[offset].Type = EfiConventionalMemory; - memory_map[offset].PhysicalStart = mem->bank[i].start; -BUG_ON (mem->bank[i].size &EFI_PAGE_MASK ); - memory_map[offset].NumberOfPages =EFI_SIZE_TO_PAGES (mem->bank[i].size); - memory_map[offset].Attribute =EFI_MEMORY_WB ; - } +fill_efi_memory_descriptor (&memory_map[offset], EfiConventionalMemory, + mem->bank[i].start, mem->bank[i].size);for ( i =0 ; i < acpi_mem.nr_banks; i++, offset++ ) - { - memory_map[offset].Type = EfiACPIReclaimMemory; - memory_map[offset].PhysicalStart = acpi_mem.bank[i].start; -BUG_ON (acpi_mem.bank[i].size &EFI_PAGE_MASK ); - memory_map[offset].NumberOfPages =EFI_SIZE_TO_PAGES (acpi_mem.bank[i].size); - memory_map[offset].Attribute =EFI_MEMORY_WB ; - } - - memory_map[offset].Type = EfiACPIReclaimMemory; - memory_map[offset].PhysicalStart = d->arch.efi_acpi_gpa; -BUG_ON (d->arch.efi_acpi_len &EFI_PAGE_MASK ); - memory_map[offset].NumberOfPages =EFI_SIZE_TO_PAGES (d->arch.efi_acpi_len); - memory_map[offset].Attribute =EFI_MEMORY_WB ; +fill_efi_memory_descriptor (&memory_map[offset], EfiACPIReclaimMemory, + acpi_mem.bank[i].start, + acpi_mem.bank[i].size); + +fill_efi_memory_descriptor (&memory_map[offset], EfiACPIReclaimMemory, + d->arch.efi_acpi_gpa, d->arch.efi_acpi_len); tbl_add[TBL_MMAP ].start = d->arch.efi_acpi_gpa +acpi_get_table_offset (tbl_add,TBL_MMAP );
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v2 3/4 xen/arm: efi: Rework acpi_create_efi_mmap_table to avoid memory_map[offset]
In reply to Julien GrallThe code contains a lot of memory_map[offset]. This could be simplified by incrementing the descriptor pointer every time.
---
Changes in v2:
- Add Stefano's reviewed-by
--- xen/arch/arm/efi/efi-dom0.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
xen/arch/arm/efi/efi-dom0.c +8 -9
@@ -112,25 +112,24 @@ void __init acpi_create_efi_mmap_table(struct domain *d,const struct meminfo *mem, struct membank tbl_add[]) { - EFI_MEMORY_DESCRIPTOR *memory_map; -unsigned int i, offset; + EFI_MEMORY_DESCRIPTOR *desc; +unsigned int i;u8 *base_ptr; base_ptr = d->arch.efi_acpi_table +acpi_get_table_offset (tbl_add,TBL_MMAP ); - memory_map = (EFI_MEMORY_DESCRIPTOR *)base_ptr; + desc = (EFI_MEMORY_DESCRIPTOR *)base_ptr; - offset =0 ; -for ( i =0 ; i < mem->nr_banks; i++, offset++ ) -fill_efi_memory_descriptor (&memory_map[offset], EfiConventionalMemory, +for ( i =0 ; i < mem->nr_banks; i++, desc++ ) +fill_efi_memory_descriptor (desc, EfiConventionalMemory, mem->bank[i].start, mem->bank[i].size); -for ( i =0 ; i < acpi_mem.nr_banks; i++, offset++ ) -fill_efi_memory_descriptor (&memory_map[offset], EfiACPIReclaimMemory, +for ( i =0 ; i < acpi_mem.nr_banks; i++, desc++ ) +fill_efi_memory_descriptor (desc, EfiACPIReclaimMemory, acpi_mem.bank[i].start, acpi_mem.bank[i].size); -fill_efi_memory_descriptor (&memory_map[offset], EfiACPIReclaimMemory, +fill_efi_memory_descriptor (desc, EfiACPIReclaimMemory, d->arch.efi_acpi_gpa, d->arch.efi_acpi_len); tbl_add[TBL_MMAP ].start = d->arch.efi_acpi_gpa
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v2 4/4 xen/arm: acpi: Move the ACPI banks in bootinfo
In reply to Julien GrallCurrently the acpi banks are stored in a separate variable and have an header just for them.
This variable can be moved in the structure bootinfo removing an header and a global variable.
---
Changes in v2:
- Add Stefano's reviewed-by
--- xen/arch/arm/efi/efi-boot.h | 3 +-- xen/arch/arm/efi/efi-dom0.c | 12 +++++------- xen/arch/arm/efi/efi-dom0.h | 8 -------- xen/include/asm-arm/setup.h | 3 +++ 4 files changed, 9 insertions(+), 17 deletions(-) delete mode 100644 xen/arch/arm/efi/efi-dom0.h
xen/arch/arm/efi/efi-boot.h +1 -2
@@ -7,7 +7,6 @@#include <xen/libfdt/libfdt.h> #include <asm/setup.h> #include <asm/smp.h> -#include "efi-dom0.h" void noreturnefi_xen_start (void *fdt_ptr,uint32_t fdt_size);void __flush_dcache_area (const void *vaddr,unsigned long size);
@@ -165,7 +164,7 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *#ifdef CONFIG_ACPI else if ( desc_ptr->Type == EfiACPIReclaimMemory ) { -if ( !meminfo_add_bank (&acpi_mem, desc_ptr) ) +if ( !meminfo_add_bank (&bootinfo.acpi, desc_ptr) ) { PrintStr(L"Error: All " __stringify(NR_MEM_BANKS)" acpi meminfo mem banks exhausted.\r\n" );
xen/arch/arm/efi/efi-dom0.c +5 -7
@@ -22,7 +22,6 @@*/ #include "efi.h" -#include "efi-dom0.h" #include <xen/sched.h> #include <xen/pfn.h> #include <xen/libfdt/libfdt.h>
@@ -32,7 +31,6 @@#define XZ_EXTERN STATIC#include "../../../common/xz/crc32.c" -struct meminfo __initdata acpi_mem;/* Constant to indicate "Xen" in unicode u16 format */ static const CHAR16 xen_efi_fw_vendor[] = {0x0058 ,0x0065 ,0x006E ,0x0000 };
@@ -46,7 +44,7 @@ size_t __init estimate_efi_size(int mem_nr_banks)int acpi_mem_nr_banks =0 ;if ( !acpi_disabled ) - acpi_mem_nr_banks = acpi_mem.nr_banks; + acpi_mem_nr_banks = bootinfo.acpi.nr_banks; size =ROUNDUP (est_size + ect_size + fw_vendor_size,8 );/* plus 1 for new created tables */
@@ -124,10 +122,10 @@ void __init acpi_create_efi_mmap_table(struct domain *d,fill_efi_memory_descriptor (desc, EfiConventionalMemory, mem->bank[i].start, mem->bank[i].size); -for ( i =0 ; i < acpi_mem.nr_banks; i++, desc++ ) +for ( i =0 ; i < bootinfo.acpi.nr_banks; i++, desc++ )fill_efi_memory_descriptor (desc, EfiACPIReclaimMemory, - acpi_mem.bank[i].start, - acpi_mem.bank[i].size); + bootinfo.acpi.bank[i].start, + bootinfo.acpi.bank[i].size);fill_efi_memory_descriptor (desc, EfiACPIReclaimMemory, d->arch.efi_acpi_gpa, d->arch.efi_acpi_len);
@@ -135,7 +133,7 @@ void __init acpi_create_efi_mmap_table(struct domain *d, tbl_add[TBL_MMAP ].start = d->arch.efi_acpi_gpa +acpi_get_table_offset (tbl_add,TBL_MMAP ); tbl_add[TBL_MMAP ].size =sizeof (EFI_MEMORY_DESCRIPTOR ) - * (mem->nr_banks + acpi_mem.nr_banks +1 ); + * (mem->nr_banks + bootinfo.acpi.nr_banks +1 ); }/* Create /hypervisor/uefi node for efi properties. */
xen/arch/arm/efi/efi-dom0.h deleted +0 -8
@@ -1,8 +0,0 @@ -#ifndef __ARM_EFI_DOM0_H__ -#define __ARM_EFI_DOM0_H__ - -#include <asm/setup.h> - -extern struct meminfo acpi_mem; - -#endif
xen/include/asm-arm/setup.h +3 -0
@@ -43,6 +43,9 @@ struct bootmodules {struct bootinfo {struct meminfo mem;struct bootmodules modules; +#ifdef CONFIG_ACPI +struct meminfo acpi; +#endif };extern struct bootinfo bootinfo;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 6 lines · Julien Grall
Hi all,
This patch series contains a bunch of fix and clean-up for ACPI and EFI on ARM64.
For all the changes see in each patch.
committed
Quoted 10 lines
Cheers,
Julien Grall (4):
xen/arm: efi: Avoid duplicating the addition of a new bank xen/arm: efi: Avoid duplicating the addition of a new efi memory
descriptor
xen/arm: efi: Reworkacpi_create_efi_mmap_tableto avoid
memory_map[offset]
xen/arm: acpi: Move the ACPI banks in bootinfo
Quoted 10 lines
xen/arch/arm/efi/efi-boot.h | 36 +++++++++++++------------- xen/arch/arm/efi/efi-dom0.c | 61 +++++++++++++++++++++------------------------ xen/arch/arm/efi/efi-dom0.h | 8 ------ xen/include/asm-arm/setup.h | 3 +++ 4 files changed, 51 insertions(+), 57 deletions(-) delete mode 100644 xen/arch/arm/efi/efi-dom0.hSignature · 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel