Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4195729ybl; Mon, 13 Jan 2020 09:25:52 -0800 (PST) X-Google-Smtp-Source: APXvYqxhp7YoX2J1DhF/ZwAZ7tcvWGp8MMqy55Q/45qfl3N8E7zEif7Qt8iezUdvuOGfMsIrcEDx X-Received: by 2002:a9d:4c81:: with SMTP id m1mr13036874otf.31.1578936352374; Mon, 13 Jan 2020 09:25:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578936352; cv=none; d=google.com; s=arc-20160816; b=bgt/m/SiL039i7LAy959/LTBbghS+Uy0uLtnJvN9N1+LmG53PQEjRE9c7GbuYwSaeQ uUdj97FRAjZ3KNlD4vqlienGsAv2qU2Og3VG0poagVHLxEi0BNMNKj2MGPHUxNX0YxWY 9V5DCo9CFX2vXFvsRZJ/FlXvtnr0hLmefWP9qMJK++qczJEGOO4xkzOoQHzHaAsmE8lu 1GW71qLY0qXOMFck8M28iM8Zfv6E6J2bIQyHG46uG1Zkx9DZvmGb40BYqvZDYIhz6BYy CmeW7n/2fH+EmANwSpm30oOdnvRrv5LHPo9YOuw44n0hS4+B0X6Mm2gp0QKy7Eg4tB4u 9oww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KgQuf3X/MqUd8EVam2DFDvbhW16r6FLStxNiblhFSy4=; b=tMcTaV8cY8uu3RxaKne8/mA9PQ+6zNwYn96h65ppi9M8yKZEHCph/gs5X2jjrhOWdW UBTlRJO6AB+nymv7fSt+mscHZsUhTFPgk/sGAAQtTcpjXntEevi33sc4GAT6Bnv/g8ul OZrS2YoxH0Du29o1W5/+iNsP7jaHfIeZimxmzkuySYIK8K/7xzSj4od949/LfOMijNpv knQYGFwWc7WHoXL9vM9Sdsu7JReM5ah3GAiaJQ4wQEJ29tjPz/2ojCqUGgZyYpCzWiCQ k/5JrQgM64yptYWxyH9s7YvAXGz8o+2WnYHd7eA59yYXH5czrQdiWSVQO7ZA0FvqrgDS lvjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="B/l4VOs2"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o14si5912615oie.257.2020.01.13.09.25.39; Mon, 13 Jan 2020 09:25:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="B/l4VOs2"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728925AbgAMRXc (ORCPT + 99 others); Mon, 13 Jan 2020 12:23:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:42482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728923AbgAMRXa (ORCPT ); Mon, 13 Jan 2020 12:23:30 -0500 Received: from dogfood.home (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr [109.210.65.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A5D5A214AF; Mon, 13 Jan 2020 17:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578936209; bh=x9TTkFxU4CKU8Ii3qVXXqis0Dv6loWv7+lGjAMLiEKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B/l4VOs2PDhOyMyZ4NGBzwr6Aa7MMMG41hkZuZpAxozyYqiJ1/BO/K3u10aYJ5jyE 7puKV3Md6Q8cCSSMp7xYYK+qvYv9qhpd8WBLug263n7BQhpwYvIPXP2Yqb1xbSFeLX vi+4a0y3qkDfuiQ9AE+h3kS9FVxUDEe0BQNHCzwA= From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Anshuman Khandual , Arnd Bergmann , Dan Williams , Dave Young , Saravana Kannan Subject: [PATCH 10/13] efi: Add a flags parameter to efi_memory_map Date: Mon, 13 Jan 2020 18:22:42 +0100 Message-Id: <20200113172245.27925-11-ardb@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200113172245.27925-1-ardb@kernel.org> References: <20200113172245.27925-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Williams In preparation for garbage collecting dynamically allocated efi memory maps, where the allocation method of memblock vs slab needs to be recalled, convert the existing 'late' flag into a 'flags' bitmask. Arrange for the flag to be passed via 'struct efi_memory_map_data'. This structure grows additional flags in follow-on changes. Signed-off-by: Dan Williams Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/memmap.c | 31 +++++++++++++++++-------------- include/linux/efi.h | 4 +++- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/drivers/firmware/efi/memmap.c b/drivers/firmware/efi/memmap.c index 38b686c67b17..4f98eb12c172 100644 --- a/drivers/firmware/efi/memmap.c +++ b/drivers/firmware/efi/memmap.c @@ -52,21 +52,20 @@ phys_addr_t __init efi_memmap_alloc(unsigned int num_entries) /** * __efi_memmap_init - Common code for mapping the EFI memory map * @data: EFI memory map data - * @late: Use early or late mapping function? * * This function takes care of figuring out which function to use to * map the EFI memory map in efi.memmap based on how far into the boot * we are. * - * During bootup @late should be %false since we only have access to - * the early_memremap*() functions as the vmalloc space isn't setup. - * Once the kernel is fully booted we can fallback to the more robust - * memremap*() API. + * During bootup EFI_MEMMAP_LATE in data->flags should be clear since we + * only have access to the early_memremap*() functions as the vmalloc + * space isn't setup. Once the kernel is fully booted we can fallback + * to the more robust memremap*() API. * * Returns zero on success, a negative error code on failure. */ static int __init -__efi_memmap_init(struct efi_memory_map_data *data, bool late) +__efi_memmap_init(struct efi_memory_map_data *data) { struct efi_memory_map map; phys_addr_t phys_map; @@ -76,7 +75,7 @@ __efi_memmap_init(struct efi_memory_map_data *data, bool late) phys_map = data->phys_map; - if (late) + if (data->flags & EFI_MEMMAP_LATE) map.map = memremap(phys_map, data->size, MEMREMAP_WB); else map.map = early_memremap(phys_map, data->size); @@ -92,7 +91,7 @@ __efi_memmap_init(struct efi_memory_map_data *data, bool late) map.desc_version = data->desc_version; map.desc_size = data->desc_size; - map.late = late; + map.flags = data->flags; set_bit(EFI_MEMMAP, &efi.flags); @@ -111,9 +110,10 @@ __efi_memmap_init(struct efi_memory_map_data *data, bool late) int __init efi_memmap_init_early(struct efi_memory_map_data *data) { /* Cannot go backwards */ - WARN_ON(efi.memmap.late); + WARN_ON(efi.memmap.flags & EFI_MEMMAP_LATE); - return __efi_memmap_init(data, false); + data->flags = 0; + return __efi_memmap_init(data); } void __init efi_memmap_unmap(void) @@ -121,7 +121,7 @@ void __init efi_memmap_unmap(void) if (!efi_enabled(EFI_MEMMAP)) return; - if (!efi.memmap.late) { + if (!(efi.memmap.flags & EFI_MEMMAP_LATE)) { unsigned long size; size = efi.memmap.desc_size * efi.memmap.nr_map; @@ -162,13 +162,14 @@ int __init efi_memmap_init_late(phys_addr_t addr, unsigned long size) struct efi_memory_map_data data = { .phys_map = addr, .size = size, + .flags = EFI_MEMMAP_LATE, }; /* Did we forget to unmap the early EFI memmap? */ WARN_ON(efi.memmap.map); /* Were we already called? */ - WARN_ON(efi.memmap.late); + WARN_ON(efi.memmap.flags & EFI_MEMMAP_LATE); /* * It makes no sense to allow callers to register different @@ -178,7 +179,7 @@ int __init efi_memmap_init_late(phys_addr_t addr, unsigned long size) data.desc_version = efi.memmap.desc_version; data.desc_size = efi.memmap.desc_size; - return __efi_memmap_init(&data, true); + return __efi_memmap_init(&data); } /** @@ -195,6 +196,7 @@ int __init efi_memmap_init_late(phys_addr_t addr, unsigned long size) int __init efi_memmap_install(phys_addr_t addr, unsigned int nr_map) { struct efi_memory_map_data data; + unsigned long flags; efi_memmap_unmap(); @@ -202,8 +204,9 @@ int __init efi_memmap_install(phys_addr_t addr, unsigned int nr_map) data.size = efi.memmap.desc_size * nr_map; data.desc_version = efi.memmap.desc_version; data.desc_size = efi.memmap.desc_size; + data.flags = efi.memmap.flags & EFI_MEMMAP_LATE; - return __efi_memmap_init(&data, efi.memmap.late); + return __efi_memmap_init(&data); } /** diff --git a/include/linux/efi.h b/include/linux/efi.h index 7e8e25b1d11c..f117d68c314e 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -767,6 +767,7 @@ struct efi_memory_map_data { unsigned long size; unsigned long desc_version; unsigned long desc_size; + unsigned long flags; }; struct efi_memory_map { @@ -776,7 +777,8 @@ struct efi_memory_map { int nr_map; unsigned long desc_version; unsigned long desc_size; - bool late; +#define EFI_MEMMAP_LATE (1UL << 0) + unsigned long flags; }; struct efi_mem_range { -- 2.20.1