From: Mark Salter <msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Catalin Marinas <catalin.marinas-5wv7dgnIgG8@public.gmane.org>
Cc: "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Will Deacon <Will.Deacon-5wv7dgnIgG8@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
"matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org"
<matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Leif Lindholm
<leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
"roy.franz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org"
<roy.franz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH 3/3] arm64: add EFI runtime services
Date: Fri, 06 Dec 2013 09:34:49 -0500 [thread overview]
Message-ID: <1386340489.1861.175.camel@deneb.redhat.com> (raw)
In-Reply-To: <20131205152510.GB974-rtzwXk+D4rEjOxct69p1ducL+3YJyIBv@public.gmane.org>
On Thu, 2013-12-05 at 15:25 +0000, Catalin Marinas wrote:
> On Fri, Nov 29, 2013 at 10:05:12PM +0000, Mark Salter wrote:
> > +
> > +#define efi_remap(cookie, size) __ioremap((cookie), (size), PAGE_KERNEL_EXEC)
> > +#define efi_ioremap(cookie, size) __ioremap((cookie), (size), \
> > + __pgprot(PROT_DEVICE_nGnRE))
> > +#define efi_unmap(cookie) __iounmap((cookie))
> > +#define efi_iounmap(cookie) __iounmap((cookie))
>
> I prefer to use the ioremap_*() functions rather than the lower-level
> __ioremap(). The ioremap_cache() should give us executable memory.
okay
>
> Looking at the code, I think we have a bug with ioremap_cache() using
> MT_NORMAL since it doesn't have the shareability bit (Device memory does
> not require this on AArch64). PROT_DEFAULT should change to
> pgprot_default | PTE_DIRTY.
>
ah, yes.
> > + if (depth != 1 ||
> > + (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
> > + return 0;
> > +
> > + pr_info("Getting EFI parameters from FDT.\n");
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-system-table", &len);
> > + if (!prop) {
> > + pr_err("No EFI system table in FDT\n");
> > + return 0;
> > + }
> > + efi_system_table = of_read_ulong(prop, len/4);
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-mmap-start", &len);
> > + if (!prop) {
> > + pr_err("No EFI memmap in FDT\n");
> > + return 0;
> > + }
> > + memmap.phys_map = (void *)of_read_ulong(prop, len/4);
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-mmap-size", &len);
> > + if (!prop) {
> > + pr_err("No EFI memmap size in FDT\n");
> > + return 0;
> > + }
> > + size = of_read_ulong(prop, len/4);
> > + memmap.map_end = memmap.phys_map + size;
> > +
> > + /* reserve memmap */
> > + memblock_reserve((u64)memmap.phys_map, size);
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-mmap-desc-size", &len);
> > + if (!prop) {
> > + pr_err("No EFI memmap descriptor size in FDT\n");
> > + return 0;
> > + }
> > + memmap.desc_size = of_read_ulong(prop, len/4);
> > +
> > + memmap.nr_map = size / memmap.desc_size;
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-mmap-desc-ver", &len);
> > + if (!prop) {
> > + pr_err("No EFI memmap descriptor version in FDT\n");
> > + return 0;
> > + }
> > + memmap.desc_version = of_read_ulong(prop, len/4);
> > +
> > + if (uefi_debug) {
> > + pr_info(" EFI system table @ %p\n", (void *)efi_system_table);
> > + pr_info(" EFI mmap @ %p-%p\n", memmap.phys_map,
> > + memmap.map_end);
> > + pr_info(" EFI mmap descriptor size = 0x%lx\n",
> > + memmap.desc_size);
> > + pr_info(" EFI mmap descriptor version = 0x%lx\n",
> > + memmap.desc_version);
> > + }
> > +
> > + return 1;
> > +}
>
> Are these checks generic to other architectures? We may do with some
> helpers to avoid duplication.
That whole function could probably be shared.
>
> > +
> > +#define PGD_END (&idmap_pg_dir[sizeof(idmap_pg_dir)/sizeof(pgd_t)])
>
> Just &idmap_pg_dir[PTRS_PER_PGD] would do (or idmap_pg_dir +
> ARRAY_SIZE(idmap_pg_dir)).
Should have been ARRAY_SIZE. I didn't want to use PTRS_PER_PGD in case
that changed.
>
> > +#ifndef CONFIG_SMP
> > +#define PMD_FLAGS (PMD_ATTRINDX(MT_NORMAL) | PMD_TYPE_SECT | PMD_SECT_AF)
> > +#else
> > +#define PMD_FLAGS (PMD_ATTRINDX(MT_NORMAL) | PMD_TYPE_SECT | PMD_SECT_AF | \
> > + PMD_SECT_S)
> > +#endif
> > +
> > +static void __init create_idmap(unsigned long addr, unsigned long len)
>
> I would change this to use the existing create_mapping() function which
> takes care of allocating pud/pmd/ptes. We shouldn't duplicate this
> functionality in two places. create_mapping() may need a slight change
> since it assumes swapper_pg_dir but it's not much. It also uses
> memblock_alloc() for early allocations.
I'll take a look at this.
>
> > +static __init int memmap_walk(struct efi_memory_map *memmap,
> > + int (*func)(efi_memory_desc_t *, void *),
> > + void *private_data, int early)
>
> Is this generic enough as a common helper between arm and arm64 (and
> maybe x86)?
Probably not as-is, but one could be made.
>
> > +static __init int reserve_region(efi_memory_desc_t *md, void *priv)
> [...]
> > +static __init void reserve_regions(void)
> [...]
> > +static int __init remap_region(efi_memory_desc_t *md, void *priv)
> [...]
> > +static int __init remap_regions(efi_memory_desc_t *map)
>
> Same here (I haven't looked at the other implementations).
Only in arm/arm64 patches and they are different.
>
> > +/*
> > + * Called from setup_arch with interrupts disabled.
> > + */
> > +void __init efi_enter_virtual_mode(void)
> > +{
> > + void *newmap;
> > + efi_status_t status;
> > + u64 mapsize, total_freed = 0;
> > + int count;
> > +
> > + if (!efi_enabled(EFI_BOOT)) {
> > + pr_info("EFI services will not be available.\n");
> > + return;
> > + }
> > +
> > + pr_info("Remapping and enabling EFI services.\n");
> > +
> > + mapsize = memmap.map_end - memmap.phys_map;
> > + memmap.map = (__force void *)ioremap_cache((phys_addr_t)memmap.phys_map,
> > + mapsize);
> > + memmap.map_end = memmap.map + mapsize;
> > +
> > + /* Map the regions we reserved earlier */
> > + newmap = alloc_bootmem(mapsize);
>
> memblock_alloc() (also check the other bootmem uses in this patch, arm64
> is using memblock).
Okay, the bootmem function do use the memblock interface with some leak
detection added, but I can use memblock directly.
>
> > + if (newmap == NULL) {
> > + pr_err("Failed to allocate new EFI memmap\n");
> > + return;
> > + }
> > +
> > + count = remap_regions(newmap);
> > + if (count <= 0) {
> > + pr_err("Failed to remap EFI regions.\n");
> > + return;
> > + }
> > +
> > + efi.memmap = &memmap;
> > +
> > + efi.systab = (__force void *)efi_lookup_mapped_addr(efi_system_table);
> > + if (efi.systab)
> > + set_bit(EFI_SYSTEM_TABLES, &arm_efi_facility);
> > +
> > + /*
> > + * efi.systab->runtime is a pointer to something guaranteed by
> > + * the UEFI specification to be 1:1 mapped.
> > + */
> > + runtime = (__force void *)efi_lookup_mapped_addr((u64)efi.systab->runtime);
> > +
> > + /* Call SetVirtualAddressMap with the physical address of the map */
> > + efi.set_virtual_address_map = runtime->set_virtual_address_map;
> > +
> > + /* boot time idmap_pg_dir is incomplete, so fill in missing parts */
> > + efi_setup_idmap();
> > +
> > + cpu_switch_mm(idmap_pg_dir, &init_mm);
> > + flush_tlb_all();
> > + flush_cache_all();
> > +
> > + status = efi.set_virtual_address_map(count * memmap.desc_size,
> > + memmap.desc_size,
> > + memmap.desc_version,
> > + newmap);
> > + cpu_set_reserved_ttbr0();
> > + flush_tlb_all();
> > + flush_cache_all();
>
> What is the point of cache flusing here?
Paranoia based on not knowing what the firmware will be caching.
If it doesn't matter and there's nothing to worry about I can drop
it.
WARNING: multiple messages have this Message-ID (diff)
From: msalter@redhat.com (Mark Salter)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] arm64: add EFI runtime services
Date: Fri, 06 Dec 2013 09:34:49 -0500 [thread overview]
Message-ID: <1386340489.1861.175.camel@deneb.redhat.com> (raw)
In-Reply-To: <20131205152510.GB974@darko.cambridge.arm.com>
On Thu, 2013-12-05 at 15:25 +0000, Catalin Marinas wrote:
> On Fri, Nov 29, 2013 at 10:05:12PM +0000, Mark Salter wrote:
> > +
> > +#define efi_remap(cookie, size) __ioremap((cookie), (size), PAGE_KERNEL_EXEC)
> > +#define efi_ioremap(cookie, size) __ioremap((cookie), (size), \
> > + __pgprot(PROT_DEVICE_nGnRE))
> > +#define efi_unmap(cookie) __iounmap((cookie))
> > +#define efi_iounmap(cookie) __iounmap((cookie))
>
> I prefer to use the ioremap_*() functions rather than the lower-level
> __ioremap(). The ioremap_cache() should give us executable memory.
okay
>
> Looking at the code, I think we have a bug with ioremap_cache() using
> MT_NORMAL since it doesn't have the shareability bit (Device memory does
> not require this on AArch64). PROT_DEFAULT should change to
> pgprot_default | PTE_DIRTY.
>
ah, yes.
> > + if (depth != 1 ||
> > + (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen at 0") != 0))
> > + return 0;
> > +
> > + pr_info("Getting EFI parameters from FDT.\n");
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-system-table", &len);
> > + if (!prop) {
> > + pr_err("No EFI system table in FDT\n");
> > + return 0;
> > + }
> > + efi_system_table = of_read_ulong(prop, len/4);
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-mmap-start", &len);
> > + if (!prop) {
> > + pr_err("No EFI memmap in FDT\n");
> > + return 0;
> > + }
> > + memmap.phys_map = (void *)of_read_ulong(prop, len/4);
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-mmap-size", &len);
> > + if (!prop) {
> > + pr_err("No EFI memmap size in FDT\n");
> > + return 0;
> > + }
> > + size = of_read_ulong(prop, len/4);
> > + memmap.map_end = memmap.phys_map + size;
> > +
> > + /* reserve memmap */
> > + memblock_reserve((u64)memmap.phys_map, size);
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-mmap-desc-size", &len);
> > + if (!prop) {
> > + pr_err("No EFI memmap descriptor size in FDT\n");
> > + return 0;
> > + }
> > + memmap.desc_size = of_read_ulong(prop, len/4);
> > +
> > + memmap.nr_map = size / memmap.desc_size;
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-mmap-desc-ver", &len);
> > + if (!prop) {
> > + pr_err("No EFI memmap descriptor version in FDT\n");
> > + return 0;
> > + }
> > + memmap.desc_version = of_read_ulong(prop, len/4);
> > +
> > + if (uefi_debug) {
> > + pr_info(" EFI system table @ %p\n", (void *)efi_system_table);
> > + pr_info(" EFI mmap @ %p-%p\n", memmap.phys_map,
> > + memmap.map_end);
> > + pr_info(" EFI mmap descriptor size = 0x%lx\n",
> > + memmap.desc_size);
> > + pr_info(" EFI mmap descriptor version = 0x%lx\n",
> > + memmap.desc_version);
> > + }
> > +
> > + return 1;
> > +}
>
> Are these checks generic to other architectures? We may do with some
> helpers to avoid duplication.
That whole function could probably be shared.
>
> > +
> > +#define PGD_END (&idmap_pg_dir[sizeof(idmap_pg_dir)/sizeof(pgd_t)])
>
> Just &idmap_pg_dir[PTRS_PER_PGD] would do (or idmap_pg_dir +
> ARRAY_SIZE(idmap_pg_dir)).
Should have been ARRAY_SIZE. I didn't want to use PTRS_PER_PGD in case
that changed.
>
> > +#ifndef CONFIG_SMP
> > +#define PMD_FLAGS (PMD_ATTRINDX(MT_NORMAL) | PMD_TYPE_SECT | PMD_SECT_AF)
> > +#else
> > +#define PMD_FLAGS (PMD_ATTRINDX(MT_NORMAL) | PMD_TYPE_SECT | PMD_SECT_AF | \
> > + PMD_SECT_S)
> > +#endif
> > +
> > +static void __init create_idmap(unsigned long addr, unsigned long len)
>
> I would change this to use the existing create_mapping() function which
> takes care of allocating pud/pmd/ptes. We shouldn't duplicate this
> functionality in two places. create_mapping() may need a slight change
> since it assumes swapper_pg_dir but it's not much. It also uses
> memblock_alloc() for early allocations.
I'll take a look at this.
>
> > +static __init int memmap_walk(struct efi_memory_map *memmap,
> > + int (*func)(efi_memory_desc_t *, void *),
> > + void *private_data, int early)
>
> Is this generic enough as a common helper between arm and arm64 (and
> maybe x86)?
Probably not as-is, but one could be made.
>
> > +static __init int reserve_region(efi_memory_desc_t *md, void *priv)
> [...]
> > +static __init void reserve_regions(void)
> [...]
> > +static int __init remap_region(efi_memory_desc_t *md, void *priv)
> [...]
> > +static int __init remap_regions(efi_memory_desc_t *map)
>
> Same here (I haven't looked at the other implementations).
Only in arm/arm64 patches and they are different.
>
> > +/*
> > + * Called from setup_arch with interrupts disabled.
> > + */
> > +void __init efi_enter_virtual_mode(void)
> > +{
> > + void *newmap;
> > + efi_status_t status;
> > + u64 mapsize, total_freed = 0;
> > + int count;
> > +
> > + if (!efi_enabled(EFI_BOOT)) {
> > + pr_info("EFI services will not be available.\n");
> > + return;
> > + }
> > +
> > + pr_info("Remapping and enabling EFI services.\n");
> > +
> > + mapsize = memmap.map_end - memmap.phys_map;
> > + memmap.map = (__force void *)ioremap_cache((phys_addr_t)memmap.phys_map,
> > + mapsize);
> > + memmap.map_end = memmap.map + mapsize;
> > +
> > + /* Map the regions we reserved earlier */
> > + newmap = alloc_bootmem(mapsize);
>
> memblock_alloc() (also check the other bootmem uses in this patch, arm64
> is using memblock).
Okay, the bootmem function do use the memblock interface with some leak
detection added, but I can use memblock directly.
>
> > + if (newmap == NULL) {
> > + pr_err("Failed to allocate new EFI memmap\n");
> > + return;
> > + }
> > +
> > + count = remap_regions(newmap);
> > + if (count <= 0) {
> > + pr_err("Failed to remap EFI regions.\n");
> > + return;
> > + }
> > +
> > + efi.memmap = &memmap;
> > +
> > + efi.systab = (__force void *)efi_lookup_mapped_addr(efi_system_table);
> > + if (efi.systab)
> > + set_bit(EFI_SYSTEM_TABLES, &arm_efi_facility);
> > +
> > + /*
> > + * efi.systab->runtime is a pointer to something guaranteed by
> > + * the UEFI specification to be 1:1 mapped.
> > + */
> > + runtime = (__force void *)efi_lookup_mapped_addr((u64)efi.systab->runtime);
> > +
> > + /* Call SetVirtualAddressMap with the physical address of the map */
> > + efi.set_virtual_address_map = runtime->set_virtual_address_map;
> > +
> > + /* boot time idmap_pg_dir is incomplete, so fill in missing parts */
> > + efi_setup_idmap();
> > +
> > + cpu_switch_mm(idmap_pg_dir, &init_mm);
> > + flush_tlb_all();
> > + flush_cache_all();
> > +
> > + status = efi.set_virtual_address_map(count * memmap.desc_size,
> > + memmap.desc_size,
> > + memmap.desc_version,
> > + newmap);
> > + cpu_set_reserved_ttbr0();
> > + flush_tlb_all();
> > + flush_cache_all();
>
> What is the point of cache flusing here?
Paranoia based on not knowing what the firmware will be caching.
If it doesn't matter and there's nothing to worry about I can drop
it.
WARNING: multiple messages have this Message-ID (diff)
From: Mark Salter <msalter@redhat.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"patches@linaro.org" <patches@linaro.org>,
Will Deacon <Will.Deacon@arm.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"matt.fleming@intel.com" <matt.fleming@intel.com>,
"linux-efi@vger.kernel.org" <linux-efi@vger.kernel.org>,
Leif Lindholm <leif.lindholm@linaro.org>,
"roy.franz@linaro.org" <roy.franz@linaro.org>
Subject: Re: [PATCH 3/3] arm64: add EFI runtime services
Date: Fri, 06 Dec 2013 09:34:49 -0500 [thread overview]
Message-ID: <1386340489.1861.175.camel@deneb.redhat.com> (raw)
In-Reply-To: <20131205152510.GB974@darko.cambridge.arm.com>
On Thu, 2013-12-05 at 15:25 +0000, Catalin Marinas wrote:
> On Fri, Nov 29, 2013 at 10:05:12PM +0000, Mark Salter wrote:
> > +
> > +#define efi_remap(cookie, size) __ioremap((cookie), (size), PAGE_KERNEL_EXEC)
> > +#define efi_ioremap(cookie, size) __ioremap((cookie), (size), \
> > + __pgprot(PROT_DEVICE_nGnRE))
> > +#define efi_unmap(cookie) __iounmap((cookie))
> > +#define efi_iounmap(cookie) __iounmap((cookie))
>
> I prefer to use the ioremap_*() functions rather than the lower-level
> __ioremap(). The ioremap_cache() should give us executable memory.
okay
>
> Looking at the code, I think we have a bug with ioremap_cache() using
> MT_NORMAL since it doesn't have the shareability bit (Device memory does
> not require this on AArch64). PROT_DEFAULT should change to
> pgprot_default | PTE_DIRTY.
>
ah, yes.
> > + if (depth != 1 ||
> > + (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
> > + return 0;
> > +
> > + pr_info("Getting EFI parameters from FDT.\n");
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-system-table", &len);
> > + if (!prop) {
> > + pr_err("No EFI system table in FDT\n");
> > + return 0;
> > + }
> > + efi_system_table = of_read_ulong(prop, len/4);
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-mmap-start", &len);
> > + if (!prop) {
> > + pr_err("No EFI memmap in FDT\n");
> > + return 0;
> > + }
> > + memmap.phys_map = (void *)of_read_ulong(prop, len/4);
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-mmap-size", &len);
> > + if (!prop) {
> > + pr_err("No EFI memmap size in FDT\n");
> > + return 0;
> > + }
> > + size = of_read_ulong(prop, len/4);
> > + memmap.map_end = memmap.phys_map + size;
> > +
> > + /* reserve memmap */
> > + memblock_reserve((u64)memmap.phys_map, size);
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-mmap-desc-size", &len);
> > + if (!prop) {
> > + pr_err("No EFI memmap descriptor size in FDT\n");
> > + return 0;
> > + }
> > + memmap.desc_size = of_read_ulong(prop, len/4);
> > +
> > + memmap.nr_map = size / memmap.desc_size;
> > +
> > + prop = of_get_flat_dt_prop(node, "linux,uefi-mmap-desc-ver", &len);
> > + if (!prop) {
> > + pr_err("No EFI memmap descriptor version in FDT\n");
> > + return 0;
> > + }
> > + memmap.desc_version = of_read_ulong(prop, len/4);
> > +
> > + if (uefi_debug) {
> > + pr_info(" EFI system table @ %p\n", (void *)efi_system_table);
> > + pr_info(" EFI mmap @ %p-%p\n", memmap.phys_map,
> > + memmap.map_end);
> > + pr_info(" EFI mmap descriptor size = 0x%lx\n",
> > + memmap.desc_size);
> > + pr_info(" EFI mmap descriptor version = 0x%lx\n",
> > + memmap.desc_version);
> > + }
> > +
> > + return 1;
> > +}
>
> Are these checks generic to other architectures? We may do with some
> helpers to avoid duplication.
That whole function could probably be shared.
>
> > +
> > +#define PGD_END (&idmap_pg_dir[sizeof(idmap_pg_dir)/sizeof(pgd_t)])
>
> Just &idmap_pg_dir[PTRS_PER_PGD] would do (or idmap_pg_dir +
> ARRAY_SIZE(idmap_pg_dir)).
Should have been ARRAY_SIZE. I didn't want to use PTRS_PER_PGD in case
that changed.
>
> > +#ifndef CONFIG_SMP
> > +#define PMD_FLAGS (PMD_ATTRINDX(MT_NORMAL) | PMD_TYPE_SECT | PMD_SECT_AF)
> > +#else
> > +#define PMD_FLAGS (PMD_ATTRINDX(MT_NORMAL) | PMD_TYPE_SECT | PMD_SECT_AF | \
> > + PMD_SECT_S)
> > +#endif
> > +
> > +static void __init create_idmap(unsigned long addr, unsigned long len)
>
> I would change this to use the existing create_mapping() function which
> takes care of allocating pud/pmd/ptes. We shouldn't duplicate this
> functionality in two places. create_mapping() may need a slight change
> since it assumes swapper_pg_dir but it's not much. It also uses
> memblock_alloc() for early allocations.
I'll take a look at this.
>
> > +static __init int memmap_walk(struct efi_memory_map *memmap,
> > + int (*func)(efi_memory_desc_t *, void *),
> > + void *private_data, int early)
>
> Is this generic enough as a common helper between arm and arm64 (and
> maybe x86)?
Probably not as-is, but one could be made.
>
> > +static __init int reserve_region(efi_memory_desc_t *md, void *priv)
> [...]
> > +static __init void reserve_regions(void)
> [...]
> > +static int __init remap_region(efi_memory_desc_t *md, void *priv)
> [...]
> > +static int __init remap_regions(efi_memory_desc_t *map)
>
> Same here (I haven't looked at the other implementations).
Only in arm/arm64 patches and they are different.
>
> > +/*
> > + * Called from setup_arch with interrupts disabled.
> > + */
> > +void __init efi_enter_virtual_mode(void)
> > +{
> > + void *newmap;
> > + efi_status_t status;
> > + u64 mapsize, total_freed = 0;
> > + int count;
> > +
> > + if (!efi_enabled(EFI_BOOT)) {
> > + pr_info("EFI services will not be available.\n");
> > + return;
> > + }
> > +
> > + pr_info("Remapping and enabling EFI services.\n");
> > +
> > + mapsize = memmap.map_end - memmap.phys_map;
> > + memmap.map = (__force void *)ioremap_cache((phys_addr_t)memmap.phys_map,
> > + mapsize);
> > + memmap.map_end = memmap.map + mapsize;
> > +
> > + /* Map the regions we reserved earlier */
> > + newmap = alloc_bootmem(mapsize);
>
> memblock_alloc() (also check the other bootmem uses in this patch, arm64
> is using memblock).
Okay, the bootmem function do use the memblock interface with some leak
detection added, but I can use memblock directly.
>
> > + if (newmap == NULL) {
> > + pr_err("Failed to allocate new EFI memmap\n");
> > + return;
> > + }
> > +
> > + count = remap_regions(newmap);
> > + if (count <= 0) {
> > + pr_err("Failed to remap EFI regions.\n");
> > + return;
> > + }
> > +
> > + efi.memmap = &memmap;
> > +
> > + efi.systab = (__force void *)efi_lookup_mapped_addr(efi_system_table);
> > + if (efi.systab)
> > + set_bit(EFI_SYSTEM_TABLES, &arm_efi_facility);
> > +
> > + /*
> > + * efi.systab->runtime is a pointer to something guaranteed by
> > + * the UEFI specification to be 1:1 mapped.
> > + */
> > + runtime = (__force void *)efi_lookup_mapped_addr((u64)efi.systab->runtime);
> > +
> > + /* Call SetVirtualAddressMap with the physical address of the map */
> > + efi.set_virtual_address_map = runtime->set_virtual_address_map;
> > +
> > + /* boot time idmap_pg_dir is incomplete, so fill in missing parts */
> > + efi_setup_idmap();
> > +
> > + cpu_switch_mm(idmap_pg_dir, &init_mm);
> > + flush_tlb_all();
> > + flush_cache_all();
> > +
> > + status = efi.set_virtual_address_map(count * memmap.desc_size,
> > + memmap.desc_size,
> > + memmap.desc_version,
> > + newmap);
> > + cpu_set_reserved_ttbr0();
> > + flush_tlb_all();
> > + flush_cache_all();
>
> What is the point of cache flusing here?
Paranoia based on not knowing what the firmware will be caching.
If it doesn't matter and there's nothing to worry about I can drop
it.
next prev parent reply other threads:[~2013-12-06 14:34 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-29 22:05 [PATCH 0/3] arm64: Add EFI stub and runtime services support Mark Salter
2013-11-29 22:05 ` Mark Salter
[not found] ` < 1385762712-17043-2-git-send-email-msalter@redhat.com>
2013-11-29 22:05 ` [PATCH 1/3] arm64: add EFI stub Mark Salter
2013-11-29 22:05 ` Mark Salter
2013-12-03 18:38 ` Will Deacon
2013-12-03 18:38 ` Will Deacon
2013-12-03 18:38 ` Will Deacon
2013-12-03 19:31 ` Roy Franz
2013-12-03 19:31 ` Roy Franz
[not found] ` <20131203183844.GA22668-MRww78TxoiP5vMa5CHWGZ34zcgK1vI+I0E9HWUfgJXw@public.gmane.org>
2013-12-03 19:31 ` Mark Salter
2013-12-03 19:31 ` Mark Salter
2013-12-03 19:31 ` Mark Salter
2013-12-05 14:18 ` Catalin Marinas
2013-12-05 14:18 ` Catalin Marinas
2013-12-05 14:18 ` Catalin Marinas
[not found] ` <20131205141853.GA974-rtzwXk+D4rEjOxct69p1ducL+3YJyIBv@public.gmane.org>
2013-12-05 14:43 ` Mark Salter
2013-12-05 14:43 ` Mark Salter
2013-12-05 14:43 ` Mark Salter
[not found] ` <1386254603.1861.120.camel-PDpCo7skNiwAicBL8TP8PQ@public.gmane.org>
2013-12-05 15:28 ` Catalin Marinas
2013-12-05 15:28 ` Catalin Marinas
2013-12-05 15:28 ` Catalin Marinas
[not found] ` < 20131205152806.GC974@darko.cambridge.arm.com>
[not found] ` <20131205152806.GC974-rtzwXk+D4rEjOxct69p1ducL+3YJyIBv@public.gmane.org>
2013-12-06 12:25 ` Grant Likely
2013-12-06 12:25 ` Grant Likely
2013-12-06 12:25 ` Grant Likely
2013-12-06 13:34 ` Mark Salter
2013-12-06 13:34 ` Mark Salter
2013-12-06 13:38 ` Leif Lindholm
2013-12-06 13:38 ` Leif Lindholm
2013-12-06 13:38 ` Leif Lindholm
2013-12-06 13:51 ` Mark Salter
2013-12-06 13:51 ` Mark Salter
2013-12-06 13:51 ` Mark Salter
2013-12-06 14:55 ` Mark Salter
2013-12-06 14:55 ` Mark Salter
2013-12-06 14:55 ` Mark Salter
2013-12-16 15:46 ` Catalin Marinas
2013-12-16 15:46 ` Catalin Marinas
2013-12-06 12:12 ` Grant Likely
2013-12-06 12:12 ` Grant Likely
2013-12-06 12:12 ` Grant Likely
[not found] ` <1385762712-17043-1-git-send-email-msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-11-29 22:05 ` [PATCH 2/3] doc: arm64: add description of EFI stub support Mark Salter
2013-11-29 22:05 ` Mark Salter
2013-11-29 22:05 ` Mark Salter
2013-11-29 22:05 ` [PATCH 3/3] arm64: add EFI runtime services Mark Salter
2013-11-29 22:05 ` Mark Salter
[not found] ` <1385762712-17043-4-git-send-email-msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-12-05 15:25 ` Catalin Marinas
2013-12-05 15:25 ` Catalin Marinas
2013-12-05 15:25 ` Catalin Marinas
[not found] ` <20131205152510.GB974-rtzwXk+D4rEjOxct69p1ducL+3YJyIBv@public.gmane.org>
2013-12-05 15:52 ` Mark Salter
2013-12-05 15:52 ` Mark Salter
2013-12-05 15:52 ` Mark Salter
[not found] ` <1386258761.1861.137.camel-PDpCo7skNiwAicBL8TP8PQ@public.gmane.org>
2013-12-05 15:59 ` Catalin Marinas
2013-12-05 15:59 ` Catalin Marinas
2013-12-05 15:59 ` Catalin Marinas
2013-12-06 14:34 ` Mark Salter [this message]
2013-12-06 14:34 ` Mark Salter
2013-12-06 14:34 ` Mark Salter
2013-12-09 13:52 ` Leif Lindholm
2013-12-09 13:52 ` Leif Lindholm
2013-12-09 13:52 ` Leif Lindholm
[not found] ` <20131209135158.GH24997-GZEopFhza0F985/tl1ce8aaDwS/vmuI7@public.gmane.org>
2013-12-10 17:58 ` Mark Salter
2013-12-10 17:58 ` Mark Salter
2013-12-10 17:58 ` Mark Salter
[not found] ` < 1385762712-17043-3-git-send-email-msalter@redhat.com>
[not found] ` <1385762712-17043-3-git-send-email-msalter-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-12-05 12:53 ` [PATCH 2/3] doc: arm64: add description of EFI stub support Grant Likely
2013-12-05 12:53 ` Grant Likely
2013-12-05 12:53 ` Grant Likely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1386340489.1861.175.camel@deneb.redhat.com \
--to=msalter-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=Will.Deacon-5wv7dgnIgG8@public.gmane.org \
--cc=catalin.marinas-5wv7dgnIgG8@public.gmane.org \
--cc=leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=patches-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=roy.franz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.