[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/4] xen/acpi: Rework acpi_os_map_memory() and acpi_os_unmap_memory()


  • To: Julien Grall <julien@xxxxxxx>
  • From: Rahul Singh <Rahul.Singh@xxxxxxx>
  • Date: Tue, 29 Sep 2020 11:10:11 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ibCHE4+jSnvlz5Rsnu55g75oNhtwChMB8neQAThfUeA=; b=D09pNS8GA4cG/yvHK2eoYJ8tVHpKNBrBPq8/yQZsdqqok8UgbMI4OOApri32cuwlqDkFNmIvckiAE+N5xgw7lr1ECx4aR0FWRs7DqzoPR77zYhEFQMJDGvh/rOI/OPEbnZOHL0MCLk33RNTwuQioeslh6tAyB1kBGXHr7MrgCL1ZAK/Bvu6wwxc2I/TnEBD+MVIu07Qs9ofMeX/WFo1/i9+3Hi6LfxsOWwx/5MD0bQo5HgzLZD2KO2WlopFz7In0rRTzPq0h4SQ6JrvzkGggB/0e7j9xdv/sVmtzPDJy0Oqso7pEPVzktLTYnYtwltLpVLCSE4wfWdEDDnNGEewMgA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LDBhofVybdGp1EnsVVs3ZoLjQzSGarOFFMSZn0ICd+A6orgMmT5c29xT+zfmnzDqrXNVANNjQkYy3jOKqPWmaKRp1jhsrhr5oXjzpu6Qd7uFkeTlBckkEZI4FKAIGngLa7T1QARUlYQ7wEoXMjCuefw9w0j/Onqjr1OuY2yOJ8fbwf0U+5I/4UmJ0SmQGTF8dTVxOpXMSZMmz80M9DM8o825KmnWb/hgN3PJUTXVXWkC4O8iU7uDEvYg3xR4De6l8mGyZAT9wq3wTY0AuTFKoMgZqbGe3whqmY2236AbkWg1BdjIh4gSwMkVgrRUeLUYHzxjwyzO/UBH6PJJoq0j7A==
  • Authentication-results-original: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "alex.bennee@xxxxxxxxxx" <alex.bennee@xxxxxxxxxx>, "masami.hiramatsu@xxxxxxxxxx" <masami.hiramatsu@xxxxxxxxxx>, "ehem+xen@xxxxxxx" <ehem+xen@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Andre Przywara <Andre.Przywara@xxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 29 Sep 2020 11:10:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHWlEeqTjM+UnBm00C6Ass2V2ltOKl/ePwA
  • Thread-topic: [PATCH 1/4] xen/acpi: Rework acpi_os_map_memory() and acpi_os_unmap_memory()

Hello,

> On 26 Sep 2020, at 9:55 pm, Julien Grall <julien@xxxxxxx> wrote:
> 
> From: Julien Grall <jgrall@xxxxxxxxxx>
> 
> The functions acpi_os_{un,}map_memory() are meant to be arch-agnostic
> while the __acpi_os_{un,}map_memory() are meant to be arch-specific.
> 
> Currently, the former are still containing x86 specific code.
> 
> To avoid this rather strange split, the generic helpers are reworked so
> they are arch-agnostic. This requires the introduction of a new helper
> __acpi_os_unmap_memory() that will undo any mapping done by
> __acpi_os_map_memory().
> 
> Currently, the arch-helper for unmap is basically a no-op so it only
> returns whether the mapping was arch specific. But this will change
> in the future.
> 
> Note that the x86 version of acpi_os_map_memory() was already able to
> able the 1MB region. Hence why there is no addition of new code.
> 
> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>

Reviewed-by: Rahul Singh <rahul.singh@xxxxxxx>
Tested-by: Rahul Singh <rahul.singh@xxxxxxx>
> ---
> xen/arch/arm/acpi/lib.c | 10 ++++++++++
> xen/arch/x86/acpi/lib.c | 18 ++++++++++++++++++
> xen/drivers/acpi/osl.c  | 34 ++++++++++++++++++----------------
> xen/include/xen/acpi.h  |  1 +
> 4 files changed, 47 insertions(+), 16 deletions(-)
> 
> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> index 4fc6e17322c1..2192a5519171 100644
> --- a/xen/arch/arm/acpi/lib.c
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -30,6 +30,10 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
>     unsigned long base, offset, mapped_size;
>     int idx;
> 
> +    /* No arch specific implementation after early boot */
> +    if ( system_state >= SYS_STATE_boot )
> +        return NULL;
> +
>     offset = phys & (PAGE_SIZE - 1);
>     mapped_size = PAGE_SIZE - offset;
>     set_fixmap(FIXMAP_ACPI_BEGIN, maddr_to_mfn(phys), PAGE_HYPERVISOR);
> @@ -49,6 +53,12 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
>     return ((char *) base + offset);
> }
> 
> +bool __acpi_unmap_table(void *ptr, unsigned long size)
> +{
> +    return ( vaddr >= FIXMAP_ADDR(FIXMAP_ACPI_BEGIN) &&
> +             vaddr < (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE) );
> +}
> +
> /* True to indicate PSCI 0.2+ is implemented */
> bool __init acpi_psci_present(void)
> {
> diff --git a/xen/arch/x86/acpi/lib.c b/xen/arch/x86/acpi/lib.c
> index 265b9ad81905..77803f4d4c63 100644
> --- a/xen/arch/x86/acpi/lib.c
> +++ b/xen/arch/x86/acpi/lib.c
> @@ -46,6 +46,10 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
>       if ((phys + size) <= (1 * 1024 * 1024))
>               return __va(phys);
> 
> +     /* No arch specific implementation after early boot */
> +     if (system_state >= SYS_STATE_boot)
> +             return NULL;
> +
>       offset = phys & (PAGE_SIZE - 1);
>       mapped_size = PAGE_SIZE - offset;
>       set_fixmap(FIX_ACPI_END, phys);
> @@ -66,6 +70,20 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
>       return ((char *) base + offset);
> }
> 
> +bool __acpi_unmap_table(void *ptr, unsigned long size)
> +{
> +     unsigned long vaddr = (unsigned long)ptr;
> +
> +     if (vaddr >= DIRECTMAP_VIRT_START &&
> +         vaddr < DIRECTMAP_VIRT_END) {
> +             ASSERT(!((__pa(ptr) + size - 1) >> 20));
> +             return true;
> +     }
> +
> +     return (vaddr >= __fix_to_virt(FIX_ACPI_END)) &&
> +             (vaddr < (__fix_to_virt(FIX_ACPI_BEGIN) + PAGE_SIZE));
> +}
> +
> unsigned int acpi_get_processor_id(unsigned int cpu)
> {
>       unsigned int acpiid, apicid;
> diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
> index 4c8bb7839eda..100eee72def2 100644
> --- a/xen/drivers/acpi/osl.c
> +++ b/xen/drivers/acpi/osl.c
> @@ -92,27 +92,29 @@ acpi_physical_address __init 
> acpi_os_get_root_pointer(void)
> void __iomem *
> acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
> {
> -     if (system_state >= SYS_STATE_boot) {
> -             mfn_t mfn = _mfn(PFN_DOWN(phys));
> -             unsigned int offs = phys & (PAGE_SIZE - 1);
> -
> -             /* The low first Mb is always mapped on x86. */
> -             if (IS_ENABLED(CONFIG_X86) && !((phys + size - 1) >> 20))
> -                     return __va(phys);
> -             return __vmap(&mfn, PFN_UP(offs + size), 1, 1,
> -                           ACPI_MAP_MEM_ATTR, VMAP_DEFAULT) + offs;
> -     }
> -     return __acpi_map_table(phys, size);
> +     void *ptr;
> +     mfn_t mfn = _mfn(PFN_DOWN(phys));
> +     unsigned int offs = phys & (PAGE_SIZE - 1);
> +
> +     /* Try the arch specific implementation first */
> +     ptr = __acpi_map_table(phys, size);
> +     if (ptr)
> +             return ptr;
> +
> +     /* No common implementation for early boot map */
> +     if (unlikely(system_state < SYS_STATE_boot))
> +          return NULL;
> +
> +     ptr = __vmap(&mfn, PFN_UP(offs + size), 1, 1,
> +                  ACPI_MAP_MEM_ATTR, VMAP_DEFAULT);
> +
> +     return !ptr ? NULL : (ptr + offs);
> }
> 
> void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
> {
> -     if (IS_ENABLED(CONFIG_X86) &&
> -         (unsigned long)virt >= DIRECTMAP_VIRT_START &&
> -         (unsigned long)virt < DIRECTMAP_VIRT_END) {
> -             ASSERT(!((__pa(virt) + size - 1) >> 20));
> +     if (__acpi_unmap_table(virt, size))
>               return;
> -     }
> 
>       if (system_state >= SYS_STATE_boot)
>               vunmap((void *)((unsigned long)virt & PAGE_MASK));
> diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
> index c945ab05c864..5a84a4bf54e0 100644
> --- a/xen/include/xen/acpi.h
> +++ b/xen/include/xen/acpi.h
> @@ -68,6 +68,7 @@ typedef int (*acpi_table_entry_handler) (struct 
> acpi_subtable_header *header, co
> 
> unsigned int acpi_get_processor_id (unsigned int cpu);
> char * __acpi_map_table (paddr_t phys_addr, unsigned long size);
> +bool __acpi_unmap_table(void *ptr, unsigned long size);
> int acpi_boot_init (void);
> int acpi_boot_table_init (void);
> int acpi_numa_init (void);
> -- 
> 2.17.1
> 
> 

Regards,
Rahul




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.