From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] efi: Introduce *_continue efi_memory_desc iterators
Date: Tue, 31 May 2016 16:14:30 +0100 [thread overview]
Message-ID: <1464707672-21882-2-git-send-email-catalin.marinas@arm.com> (raw)
In-Reply-To: <1464707672-21882-1-git-send-email-catalin.marinas@arm.com>
The for_each_efi_memory_desc_continue() macro and corresponding
"_in_map" allow iterating over an efi_memory_map from a given position.
For code reuse between the existing iterator and the _continue variant,
this patch also introduces efi_memory_desc_next_entry_map().
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
---
include/linux/efi.h | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/include/linux/efi.h b/include/linux/efi.h
index c2db3ca22217..4b0d880f1cd7 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -1002,11 +1002,16 @@ extern int efi_memattr_init(void);
extern int efi_memattr_apply_permissions(struct mm_struct *mm,
efi_memattr_perm_setter fn);
+/* Find next entry in an efi_memory_map or NULL if md is last */
+#define efi_memory_desc_next_entry_map(m, md) \
+ ((md) == (efi_memory_desc_t *)((m)->map_end - (m)->desc_size) \
+ ? NULL : (void *)(md) + (m)->desc_size)
+
/* Iterate through an efi_memory_map */
#define for_each_efi_memory_desc_in_map(m, md) \
for ((md) = (m)->map; \
- (md) <= (efi_memory_desc_t *)((m)->map_end - (m)->desc_size); \
- (md) = (void *)(md) + (m)->desc_size)
+ (md); \
+ (md) = efi_memory_desc_next_entry_map(m, md))
/**
* for_each_efi_memory_desc - iterate over descriptors in efi.memmap
@@ -1017,6 +1022,16 @@ extern int efi_memattr_apply_permissions(struct mm_struct *mm,
#define for_each_efi_memory_desc(md) \
for_each_efi_memory_desc_in_map(&efi.memmap, md)
+/* Continue iterating through an efi_memory_map */
+#define for_each_efi_memory_desc_in_map_continue(m, md) \
+ for ((md) = efi_memory_desc_next_entry_map(m, md); \
+ (md); \
+ (md) = efi_memory_desc_next_entry_map(m, md))
+
+/* Continue iterating through efi.memmap */
+#define for_each_efi_memory_desc_continue(md) \
+ for_each_efi_memory_desc_in_map_continue(&efi.memmap, md)
+
/*
* Format an EFI memory descriptor's type and attributes to a user-provided
* character buffer, as per snprintf(), and return the buffer.
next prev parent reply other threads:[~2016-05-31 15:14 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-31 15:14 [PATCH 0/3] arm64: Avoid overlapping EFI regions Catalin Marinas
2016-05-31 15:14 ` Catalin Marinas [this message]
2016-06-01 10:34 ` [PATCH 1/3] efi: Introduce *_continue efi_memory_desc iterators Mark Rutland
2016-06-01 10:43 ` Catalin Marinas
2016-06-02 14:36 ` Matt Fleming
2016-06-02 16:29 ` Catalin Marinas
2016-06-02 16:31 ` Jeremy Linton
2016-06-02 17:11 ` Catalin Marinas
2016-06-02 17:15 ` Jeremy Linton
2016-06-03 20:43 ` Matt Fleming
2016-05-31 15:14 ` [PATCH 2/3] arm64: efi: Ensure efi_create_mapping() does not map overlapping regions Catalin Marinas
2016-06-02 14:52 ` Matt Fleming
2016-06-02 16:56 ` Catalin Marinas
2016-06-03 20:56 ` Matt Fleming
2016-06-06 9:43 ` Ard Biesheuvel
2016-06-06 17:09 ` Catalin Marinas
2016-06-06 17:26 ` Ard Biesheuvel
2016-06-06 17:42 ` Catalin Marinas
2016-06-06 21:18 ` Ard Biesheuvel
2016-06-28 16:05 ` Catalin Marinas
2016-06-28 16:12 ` Ard Biesheuvel
2016-06-29 9:39 ` Catalin Marinas
2016-06-29 10:03 ` Ard Biesheuvel
2016-06-29 10:50 ` Catalin Marinas
2016-06-29 11:03 ` Ard Biesheuvel
2016-06-29 12:03 ` Catalin Marinas
2016-05-31 15:14 ` [PATCH 3/3] arm64: mm: Remove split_p*d() functions Catalin Marinas
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=1464707672-21882-2-git-send-email-catalin.marinas@arm.com \
--to=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).