Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1656225 > unrolled thread

[GIT PULL 00/13] First batch of EFI updates for v4.13

Started byArd Biesheuvel <ard.biesheuvel@linaro.org>
First post2017-06-02 16:00 +0200
Last post2017-06-05 18:00 +0200
Articles 10 on this page of 30 — 7 participants

Back to article view | Back to linux.kernel


Contents

  [GIT PULL 00/13] First batch of EFI updates for v4.13 Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-02 16:00 +0200
    [PATCH 07/13] efi/capsule: Remove NULL test on kmap() Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-02 16:00 +0200
      [tip:efi/core] efi/capsule: Remove NULL test on kmap() tip-bot for Fabian Frederick <tipbot@zytor.com> - 2017-06-05 19:20 +0200
    [PATCH 13/13] efi: arm: enable DMI/SMBIOS Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-02 16:00 +0200
      [tip:efi/core] efi/arm: Enable DMI/SMBIOS tip-bot for Ard Biesheuvel <tipbot@zytor.com> - 2017-06-05 19:30 +0200
    [PATCH 03/13] efi/capsule: Remove pr_debug on ENOMEM or EFAULT Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-02 16:00 +0200
      [tip:efi/core] efi/capsule: Remove pr_debug() on ENOMEM or EFAULT tip-bot for Jan Kiszka <tipbot@zytor.com> - 2017-06-05 19:20 +0200
    [PATCH 02/13] efi/capsule: Fix return code on failing kmap/vmap Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-02 16:00 +0200
      [tip:efi/core] efi/capsule: Fix return code on failing kmap/vmap tip-bot for Jan Kiszka <tipbot@zytor.com> - 2017-06-05 19:20 +0200
    [PATCH 10/13] efi/capsule: Add support for Quark security header Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-02 16:00 +0200
      Re: [PATCH 10/13] efi/capsule: Add support for Quark security header Ingo Molnar <mingo@kernel.org> - 2017-06-05 18:00 +0200
        Re: [PATCH 10/13] efi/capsule: Add support for Quark security header Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-05 18:10 +0200
          Re: [PATCH 10/13] efi/capsule: Add support for Quark security header Ingo Molnar <mingo@kernel.org> - 2017-06-05 18:20 +0200
      [tip:efi/core] efi/capsule: Add support for Quark security header tip-bot for Jan Kiszka <tipbot@zytor.com> - 2017-06-05 19:30 +0200
    [PATCH 01/13] x86/efi: Clean up efi CR3 save/restore Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-02 16:00 +0200
      Re: [PATCH 01/13] x86/efi: Clean up efi CR3 save/restore Ingo Molnar <mingo@kernel.org> - 2017-06-05 17:50 +0200
        Re: [PATCH 01/13] x86/efi: Clean up efi CR3 save/restore Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-05 18:10 +0200
          Re: [PATCH 01/13] x86/efi: Clean up efi CR3 save/restore Andy Lutomirski <luto@kernel.org> - 2017-06-05 18:20 +0200
    [PATCH 04/13] efi/capsule: Clean up pr_err/info messages Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-02 16:00 +0200
      [tip:efi/core] efi/capsule: Clean up pr_err/_info() messages tip-bot for Jan Kiszka <tipbot@zytor.com> - 2017-06-05 19:20 +0200
    [PATCH 12/13] x86/efi: Add EFI_PGT_DUMP support for x86_32 and kexec Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-02 16:00 +0200
      [tip:efi/core] x86/efi: Extend CONFIG_EFI_PGT_DUMP support to  x86_32 and kexec as well tip-bot for Sai Praneeth <tipbot@zytor.com> - 2017-06-05 19:30 +0200
    [PATCH 05/13] efi/capsule: Adjust return type of efi_capsule_setup_info Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-02 16:00 +0200
      [tip:efi/core] efi/capsule: Adjust return type of  efi_capsule_setup_info() tip-bot for Jan Kiszka <tipbot@zytor.com> - 2017-06-05 19:20 +0200
    [PATCH 09/13] efi/capsule-loader: Use page addresses rather than struct page pointers Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-02 16:00 +0200
      [tip:efi/core] efi/capsule-loader: Use page addresses rather than  struct page pointers tip-bot for Ard Biesheuvel <tipbot@zytor.com> - 2017-06-05 19:30 +0200
    Re: [GIT PULL 00/13] First batch of EFI updates for v4.13 Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-05 10:20 +0200
      Re: [GIT PULL 00/13] First batch of EFI updates for v4.13 Ingo Molnar <mingo@kernel.org> - 2017-06-05 11:10 +0200
        Re: [GIT PULL 00/13] First batch of EFI updates for v4.13 Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-06-05 11:40 +0200
          Re: [GIT PULL 00/13] First batch of EFI updates for v4.13 Ingo Molnar <mingo@kernel.org> - 2017-06-05 18:00 +0200

Page 2 of 2 — ← Prev page 1 [2]


#1656236 — [PATCH 12/13] x86/efi: Add EFI_PGT_DUMP support for x86_32 and kexec

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2017-06-02 16:00 +0200
Subject[PATCH 12/13] x86/efi: Add EFI_PGT_DUMP support for x86_32 and kexec
Message-ID<tNVhq-1Vg-59@gated-at.bofh.it>
In reply to#1656225
From: Sai Praneeth <sai.praneeth.prakhya@intel.com>

EFI_PGT_DUMP, as the name suggests dumps efi page tables to dmesg during
kernel boot. This feature is very useful while debugging page
faults/null pointer dereferences to efi related addresses. Presently,
this feature is limited only to x86_64, so let's extend it to other efi
configurations like kexec kernel, efi=old_map and to x86_32 as well.
This doesn't effect normal boot path because this config option should
be used only for debug purposes.

Signed-off-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Ricardo Neri <ricardo.neri@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Ravi Shankar <ravi.v.shankar@intel.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
---
 arch/x86/platform/efi/efi.c    | 3 ++-
 arch/x86/platform/efi/efi_32.c | 9 ++++++++-
 arch/x86/platform/efi/efi_64.c | 5 ++++-
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index dc2da5e2c7e4..3cf8536e803b 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -1012,7 +1012,6 @@ static void __init __efi_enter_virtual_mode(void)
 	 * necessary relocation fixups for the new virtual addresses.
 	 */
 	efi_runtime_update_mappings();
-	efi_dump_pagetable();
 
 	/* clean DUMMY object */
 	efi_delete_dummy_variable();
@@ -1027,6 +1026,8 @@ void __init efi_enter_virtual_mode(void)
 		kexec_enter_virtual_mode();
 	else
 		__efi_enter_virtual_mode();
+
+	efi_dump_pagetable();
 }
 
 /*
diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
index 403a987d06c7..fe18c5d32bf0 100644
--- a/arch/x86/platform/efi/efi_32.c
+++ b/arch/x86/platform/efi/efi_32.c
@@ -44,7 +44,14 @@ int __init efi_alloc_page_tables(void)
 }
 
 void efi_sync_low_kernel_mappings(void) {}
-void __init efi_dump_pagetable(void) {}
+
+void __init efi_dump_pagetable(void)
+{
+#ifdef CONFIG_EFI_PGT_DUMP
+	ptdump_walk_pgd_level(NULL, swapper_pg_dir);
+#endif
+}
+
 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
 {
 	return 0;
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index 6fbf6c47e603..0d8180811445 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -528,7 +528,10 @@ void __init efi_runtime_update_mappings(void)
 void __init efi_dump_pagetable(void)
 {
 #ifdef CONFIG_EFI_PGT_DUMP
-	ptdump_walk_pgd_level(NULL, efi_pgd);
+	if (efi_enabled(EFI_OLD_MEMMAP))
+		ptdump_walk_pgd_level(NULL, swapper_pg_dir);
+	else
+		ptdump_walk_pgd_level(NULL, efi_pgd);
 #endif
 }
 
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1657997 — [tip:efi/core] x86/efi: Extend CONFIG_EFI_PGT_DUMP support to x86_32 and kexec as well

Fromtip-bot for Sai Praneeth <tipbot@zytor.com>
Date2017-06-05 19:30 +0200
Subject[tip:efi/core] x86/efi: Extend CONFIG_EFI_PGT_DUMP support to x86_32 and kexec as well
Message-ID<tP3Zg-5PM-9@gated-at.bofh.it>
In reply to#1656236
Commit-ID:  ac81d3de03f7d8593a94240d057c8e2e8e869897
Gitweb:     http://git.kernel.org/tip/ac81d3de03f7d8593a94240d057c8e2e8e869897
Author:     Sai Praneeth <sai.praneeth.prakhya@intel.com>
AuthorDate: Fri, 2 Jun 2017 13:52:06 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 5 Jun 2017 17:50:43 +0200

x86/efi: Extend CONFIG_EFI_PGT_DUMP support to x86_32 and kexec as well

CONFIG_EFI_PGT_DUMP=y, as the name suggests, dumps EFI page tables to the
kernel log during kernel boot.

This feature is very useful while debugging page faults/null pointer
dereferences to EFI related addresses.

Presently, this feature is limited only to x86_64, so let's extend it to
other EFI configurations like kexec kernel, efi=old_map and to x86_32 as well.

This doesn't effect normal boot path because this config option should
be used only for debug purposes.

Signed-off-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Shankar <ravi.v.shankar@intel.com>
Cc: Ricardo Neri <ricardo.neri@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170602135207.21708-13-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/platform/efi/efi.c    | 3 ++-
 arch/x86/platform/efi/efi_32.c | 9 ++++++++-
 arch/x86/platform/efi/efi_64.c | 5 ++++-
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 43b96f5..f084d87 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -1014,7 +1014,6 @@ static void __init __efi_enter_virtual_mode(void)
 	 * necessary relocation fixups for the new virtual addresses.
 	 */
 	efi_runtime_update_mappings();
-	efi_dump_pagetable();
 
 	/* clean DUMMY object */
 	efi_delete_dummy_variable();
@@ -1029,6 +1028,8 @@ void __init efi_enter_virtual_mode(void)
 		kexec_enter_virtual_mode();
 	else
 		__efi_enter_virtual_mode();
+
+	efi_dump_pagetable();
 }
 
 /*
diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
index 3481268..52f7faa 100644
--- a/arch/x86/platform/efi/efi_32.c
+++ b/arch/x86/platform/efi/efi_32.c
@@ -44,7 +44,14 @@ int __init efi_alloc_page_tables(void)
 }
 
 void efi_sync_low_kernel_mappings(void) {}
-void __init efi_dump_pagetable(void) {}
+
+void __init efi_dump_pagetable(void)
+{
+#ifdef CONFIG_EFI_PGT_DUMP
+	ptdump_walk_pgd_level(NULL, swapper_pg_dir);
+#endif
+}
+
 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
 {
 	return 0;
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index eb8dff1..8ff1f95 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -589,7 +589,10 @@ void __init efi_runtime_update_mappings(void)
 void __init efi_dump_pagetable(void)
 {
 #ifdef CONFIG_EFI_PGT_DUMP
-	ptdump_walk_pgd_level(NULL, efi_pgd);
+	if (efi_enabled(EFI_OLD_MEMMAP))
+		ptdump_walk_pgd_level(NULL, swapper_pg_dir);
+	else
+		ptdump_walk_pgd_level(NULL, efi_pgd);
 #endif
 }
 

[toc] | [prev] | [next] | [standalone]


#1656237 — [PATCH 05/13] efi/capsule: Adjust return type of efi_capsule_setup_info

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2017-06-02 16:00 +0200
Subject[PATCH 05/13] efi/capsule: Adjust return type of efi_capsule_setup_info
Message-ID<tNVhq-1Vg-57@gated-at.bofh.it>
In reply to#1656225
From: Jan Kiszka <jan.kiszka@siemens.com>

We actually expect int at the caller and never return any size
information.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/firmware/efi/capsule-loader.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c
index 3fb91e1597a9..37d3f6ec2d28 100644
--- a/drivers/firmware/efi/capsule-loader.c
+++ b/drivers/firmware/efi/capsule-loader.c
@@ -53,8 +53,8 @@ static void efi_free_all_buff_pages(struct capsule_info *cap_info)
  * @kbuff: a mapped first page buffer pointer
  * @hdr_bytes: the total received number of bytes for efi header
  **/
-static ssize_t efi_capsule_setup_info(struct capsule_info *cap_info,
-				      void *kbuff, size_t hdr_bytes)
+static int efi_capsule_setup_info(struct capsule_info *cap_info,
+				  void *kbuff, size_t hdr_bytes)
 {
 	efi_capsule_header_t *cap_hdr;
 	size_t pages_needed;
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1657988 — [tip:efi/core] efi/capsule: Adjust return type of efi_capsule_setup_info()

Fromtip-bot for Jan Kiszka <tipbot@zytor.com>
Date2017-06-05 19:20 +0200
Subject[tip:efi/core] efi/capsule: Adjust return type of efi_capsule_setup_info()
Message-ID<tP3PC-5Lk-71@gated-at.bofh.it>
In reply to#1656237
Commit-ID:  41b0c376951417d1b37448957b30f766b10d3090
Gitweb:     http://git.kernel.org/tip/41b0c376951417d1b37448957b30f766b10d3090
Author:     Jan Kiszka <jan.kiszka@siemens.com>
AuthorDate: Fri, 2 Jun 2017 13:51:59 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 5 Jun 2017 17:50:39 +0200

efi/capsule: Adjust return type of efi_capsule_setup_info()

We actually expect int at the caller and never return any size
information.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170602135207.21708-6-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 drivers/firmware/efi/capsule-loader.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c
index 3fb91e1..37d3f6e 100644
--- a/drivers/firmware/efi/capsule-loader.c
+++ b/drivers/firmware/efi/capsule-loader.c
@@ -53,8 +53,8 @@ static void efi_free_all_buff_pages(struct capsule_info *cap_info)
  * @kbuff: a mapped first page buffer pointer
  * @hdr_bytes: the total received number of bytes for efi header
  **/
-static ssize_t efi_capsule_setup_info(struct capsule_info *cap_info,
-				      void *kbuff, size_t hdr_bytes)
+static int efi_capsule_setup_info(struct capsule_info *cap_info,
+				  void *kbuff, size_t hdr_bytes)
 {
 	efi_capsule_header_t *cap_hdr;
 	size_t pages_needed;

[toc] | [prev] | [next] | [standalone]


#1656238 — [PATCH 09/13] efi/capsule-loader: Use page addresses rather than struct page pointers

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2017-06-02 16:00 +0200
Subject[PATCH 09/13] efi/capsule-loader: Use page addresses rather than struct page pointers
Message-ID<tNVhq-1Vg-55@gated-at.bofh.it>
In reply to#1656225
To give some leeway to code that handles non-standard capsule headers,
let's keep an array of page addresses rather than struct page pointers.

This gives special implementations of efi_capsule_setup_info() the
opportunity to mangle the payload a bit before it is presented to the
firmware, without putting any knowledge of the nature of such quirks
into the generic code.

Cc: Matt Fleming <matt@codeblueprint.co.uk>
Tested-by: "Bryan O'Donoghue" <pure.logic@nexus-software.ie>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/firmware/efi/capsule-loader.c | 12 ++++++++----
 drivers/firmware/efi/capsule.c        |  7 ++++---
 include/linux/efi.h                   |  4 ++--
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c
index cbc3526953d5..ec8ac5c4dd84 100644
--- a/drivers/firmware/efi/capsule-loader.c
+++ b/drivers/firmware/efi/capsule-loader.c
@@ -20,6 +20,10 @@
 
 #define NO_FURTHER_WRITE_ACTION -1
 
+#ifndef phys_to_page
+#define phys_to_page(x)		pfn_to_page((x) >> PAGE_SHIFT)
+#endif
+
 /**
  * efi_free_all_buff_pages - free all previous allocated buffer pages
  * @cap_info: pointer to current instance of capsule_info structure
@@ -31,7 +35,7 @@
 static void efi_free_all_buff_pages(struct capsule_info *cap_info)
 {
 	while (cap_info->index > 0)
-		__free_page(cap_info->pages[--cap_info->index]);
+		__free_page(phys_to_page(cap_info->pages[--cap_info->index]));
 
 	cap_info->index = NO_FURTHER_WRITE_ACTION;
 }
@@ -161,12 +165,12 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff,
 			goto failed;
 		}
 
-		cap_info->pages[cap_info->index++] = page;
+		cap_info->pages[cap_info->index++] = page_to_phys(page);
 		cap_info->page_bytes_remain = PAGE_SIZE;
+	} else {
+		page = phys_to_page(cap_info->pages[cap_info->index - 1]);
 	}
 
-	page = cap_info->pages[cap_info->index - 1];
-
 	kbuff = kmap(page);
 	kbuff += PAGE_SIZE - cap_info->page_bytes_remain;
 
diff --git a/drivers/firmware/efi/capsule.c b/drivers/firmware/efi/capsule.c
index e603ccf39d80..901b9306bf94 100644
--- a/drivers/firmware/efi/capsule.c
+++ b/drivers/firmware/efi/capsule.c
@@ -214,7 +214,7 @@ efi_capsule_update_locked(efi_capsule_header_t *capsule,
  *
  * Return 0 on success, a converted EFI status code on failure.
  */
-int efi_capsule_update(efi_capsule_header_t *capsule, struct page **pages)
+int efi_capsule_update(efi_capsule_header_t *capsule, phys_addr_t *pages)
 {
 	u32 imagesize = capsule->imagesize;
 	efi_guid_t guid = capsule->guid;
@@ -249,10 +249,11 @@ int efi_capsule_update(efi_capsule_header_t *capsule, struct page **pages)
 		sglist = kmap(sg_pages[i]);
 
 		for (j = 0; j < SGLIST_PER_PAGE && count > 0; j++) {
-			u64 sz = min_t(u64, imagesize, PAGE_SIZE);
+			u64 sz = min_t(u64, imagesize,
+				       PAGE_SIZE - (u64)*pages % PAGE_SIZE);
 
 			sglist[j].length = sz;
-			sglist[j].data = page_to_phys(*pages++);
+			sglist[j].data = *pages++;
 
 			imagesize -= sz;
 			count--;
diff --git a/include/linux/efi.h b/include/linux/efi.h
index a7379a2b5680..8269bcb8ccf7 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -143,7 +143,7 @@ struct capsule_info {
 	long			index;
 	size_t			count;
 	size_t			total_size;
-	struct page		**pages;
+	phys_addr_t		*pages;
 	size_t			page_bytes_remain;
 };
 
@@ -1415,7 +1415,7 @@ extern int efi_capsule_supported(efi_guid_t guid, u32 flags,
 				 size_t size, int *reset);
 
 extern int efi_capsule_update(efi_capsule_header_t *capsule,
-			      struct page **pages);
+			      phys_addr_t *pages);
 
 #ifdef CONFIG_EFI_RUNTIME_MAP
 int efi_runtime_map_init(struct kobject *);
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1658007 — [tip:efi/core] efi/capsule-loader: Use page addresses rather than struct page pointers

Fromtip-bot for Ard Biesheuvel <tipbot@zytor.com>
Date2017-06-05 19:30 +0200
Subject[tip:efi/core] efi/capsule-loader: Use page addresses rather than struct page pointers
Message-ID<tP3Zg-5PM-27@gated-at.bofh.it>
In reply to#1656238
Commit-ID:  2a457fb31df62c6b482f78e4f74aaed99271f44d
Gitweb:     http://git.kernel.org/tip/2a457fb31df62c6b482f78e4f74aaed99271f44d
Author:     Ard Biesheuvel <ard.biesheuvel@linaro.org>
AuthorDate: Fri, 2 Jun 2017 13:52:03 +0000
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 5 Jun 2017 17:50:41 +0200

efi/capsule-loader: Use page addresses rather than struct page pointers

To give some leeway to code that handles non-standard capsule headers,
let's keep an array of page addresses rather than struct page pointers.

This gives special implementations of efi_capsule_setup_info() the
opportunity to mangle the payload a bit before it is presented to the
firmware, without putting any knowledge of the nature of such quirks
into the generic code.

Tested-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170602135207.21708-10-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 drivers/firmware/efi/capsule-loader.c | 12 ++++++++----
 drivers/firmware/efi/capsule.c        |  7 ++++---
 include/linux/efi.h                   |  4 ++--
 3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c
index cbc35269..ec8ac5c 100644
--- a/drivers/firmware/efi/capsule-loader.c
+++ b/drivers/firmware/efi/capsule-loader.c
@@ -20,6 +20,10 @@
 
 #define NO_FURTHER_WRITE_ACTION -1
 
+#ifndef phys_to_page
+#define phys_to_page(x)		pfn_to_page((x) >> PAGE_SHIFT)
+#endif
+
 /**
  * efi_free_all_buff_pages - free all previous allocated buffer pages
  * @cap_info: pointer to current instance of capsule_info structure
@@ -31,7 +35,7 @@
 static void efi_free_all_buff_pages(struct capsule_info *cap_info)
 {
 	while (cap_info->index > 0)
-		__free_page(cap_info->pages[--cap_info->index]);
+		__free_page(phys_to_page(cap_info->pages[--cap_info->index]));
 
 	cap_info->index = NO_FURTHER_WRITE_ACTION;
 }
@@ -161,12 +165,12 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff,
 			goto failed;
 		}
 
-		cap_info->pages[cap_info->index++] = page;
+		cap_info->pages[cap_info->index++] = page_to_phys(page);
 		cap_info->page_bytes_remain = PAGE_SIZE;
+	} else {
+		page = phys_to_page(cap_info->pages[cap_info->index - 1]);
 	}
 
-	page = cap_info->pages[cap_info->index - 1];
-
 	kbuff = kmap(page);
 	kbuff += PAGE_SIZE - cap_info->page_bytes_remain;
 
diff --git a/drivers/firmware/efi/capsule.c b/drivers/firmware/efi/capsule.c
index e603ccf..901b930 100644
--- a/drivers/firmware/efi/capsule.c
+++ b/drivers/firmware/efi/capsule.c
@@ -214,7 +214,7 @@ efi_capsule_update_locked(efi_capsule_header_t *capsule,
  *
  * Return 0 on success, a converted EFI status code on failure.
  */
-int efi_capsule_update(efi_capsule_header_t *capsule, struct page **pages)
+int efi_capsule_update(efi_capsule_header_t *capsule, phys_addr_t *pages)
 {
 	u32 imagesize = capsule->imagesize;
 	efi_guid_t guid = capsule->guid;
@@ -249,10 +249,11 @@ int efi_capsule_update(efi_capsule_header_t *capsule, struct page **pages)
 		sglist = kmap(sg_pages[i]);
 
 		for (j = 0; j < SGLIST_PER_PAGE && count > 0; j++) {
-			u64 sz = min_t(u64, imagesize, PAGE_SIZE);
+			u64 sz = min_t(u64, imagesize,
+				       PAGE_SIZE - (u64)*pages % PAGE_SIZE);
 
 			sglist[j].length = sz;
-			sglist[j].data = page_to_phys(*pages++);
+			sglist[j].data = *pages++;
 
 			imagesize -= sz;
 			count--;
diff --git a/include/linux/efi.h b/include/linux/efi.h
index a7379a2..8269bcb 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -143,7 +143,7 @@ struct capsule_info {
 	long			index;
 	size_t			count;
 	size_t			total_size;
-	struct page		**pages;
+	phys_addr_t		*pages;
 	size_t			page_bytes_remain;
 };
 
@@ -1415,7 +1415,7 @@ extern int efi_capsule_supported(efi_guid_t guid, u32 flags,
 				 size_t size, int *reset);
 
 extern int efi_capsule_update(efi_capsule_header_t *capsule,
-			      struct page **pages);
+			      phys_addr_t *pages);
 
 #ifdef CONFIG_EFI_RUNTIME_MAP
 int efi_runtime_map_init(struct kobject *);

[toc] | [prev] | [next] | [standalone]


#1657355

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2017-06-05 10:20 +0200
Message-ID<tOVp1-nU-31@gated-at.bofh.it>
In reply to#1656225
(trim cc)

On 2 June 2017 at 13:51, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> The following changes since commit 5ed02dbb497422bf225783f46e6eadd237d23d6b:
>
>   Linux 4.12-rc3 (2017-05-28 17:20:53 -0700)
>
> are available in the git repository at:
>
>   git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git tags/efi-next
>
> for you to fetch changes up to 3acbd5a24ab9d9a82c56d9018f4d340fa574b91d:
>
>   efi: arm: enable DMI/SMBIOS (2017-06-02 13:38:56 +0000)
>
> ----------------------------------------------------------------
> First batch of EFI changes for v4.13:
> - rework the EFI capsule loader to allow for workarounds for non-compliant
>   firmware to be implemented more easily and in a more self contained
>   manner (Ard)
> - implement a capsule loader quirk for Quark X102x, which prepends a
>   security header in a non-compliant way (Jan Kiszka)
> - enable SMBIOS/DMI support for the ARM architecture (Ard)
> - add EFI_PGT_DUMP support for x86_32 and kexec (Sai Praneeth)
> - some other cleanups
>
> ----------------------------------------------------------------
> Andy Lutomirski (1):
>       x86/efi: Clean up efi CR3 save/restore
>
> Ard Biesheuvel (4):
>       efi/capsule-loader: Use a cached copy of the capsule header
>       efi/capsule-loader: Redirect calls to efi_capsule_setup_info via weak alias
>       efi/capsule-loader: Use page addresses rather than struct page pointers
>       efi: arm: enable DMI/SMBIOS
>
> Fabian Frederick (1):
>       efi/capsule: Remove NULL test on kmap()
>
> Geliang Tang (1):
>       efi/efi_test: Use memdup_user() helper
>
> Jan Kiszka (5):
>       efi/capsule: Fix return code on failing kmap/vmap
>       efi/capsule: Remove pr_debug on ENOMEM or EFAULT
>       efi/capsule: Clean up pr_err/info messages
>       efi/capsule: Adjust return type of efi_capsule_setup_info
>       efi/capsule: Add support for Quark security header
>
> Sai Praneeth (1):
>       x86/efi: Add EFI_PGT_DUMP support for x86_32 and kexec
>

All,

I just noticed that this patch lacks my signoff. This is due to the
fact that Matt queued this particular patch, and I didn't update the
branch to add my sob, so it is only signed off by Matt not me.

How should we handle this now, and in the future? Matt and I share
maintainership responsibilities, and so everything that gets queued
into the EFI tree may be treated as signed off by either and/or the
both of us. For multi-maintainer trees that get pulled directly, this
is usually not an issue AFAIK, but given that Ingo is the one that
deals with EFI usually, and prefers to apply the patches individually,
this may  get flagged as a missing signoff.

In any case, I am happy to respin the patches, re-sign the tag etc if
this is deemed necessary.

Thanks,
Ard.

[toc] | [prev] | [next] | [standalone]


#1657407

FromIngo Molnar <mingo@kernel.org>
Date2017-06-05 11:10 +0200
Message-ID<tOWbn-Zl-1@gated-at.bofh.it>
In reply to#1657355
* Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

> (trim cc)
> 
> On 2 June 2017 at 13:51, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> > The following changes since commit 5ed02dbb497422bf225783f46e6eadd237d23d6b:
> >
> >   Linux 4.12-rc3 (2017-05-28 17:20:53 -0700)
> >
> > are available in the git repository at:
> >
> >   git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git tags/efi-next
> >
> > for you to fetch changes up to 3acbd5a24ab9d9a82c56d9018f4d340fa574b91d:
> >
> >   efi: arm: enable DMI/SMBIOS (2017-06-02 13:38:56 +0000)
> >
> > ----------------------------------------------------------------
> > First batch of EFI changes for v4.13:
> > - rework the EFI capsule loader to allow for workarounds for non-compliant
> >   firmware to be implemented more easily and in a more self contained
> >   manner (Ard)
> > - implement a capsule loader quirk for Quark X102x, which prepends a
> >   security header in a non-compliant way (Jan Kiszka)
> > - enable SMBIOS/DMI support for the ARM architecture (Ard)
> > - add EFI_PGT_DUMP support for x86_32 and kexec (Sai Praneeth)
> > - some other cleanups
> >
> > ----------------------------------------------------------------
> > Andy Lutomirski (1):
> >       x86/efi: Clean up efi CR3 save/restore
> >
> > Ard Biesheuvel (4):
> >       efi/capsule-loader: Use a cached copy of the capsule header
> >       efi/capsule-loader: Redirect calls to efi_capsule_setup_info via weak alias
> >       efi/capsule-loader: Use page addresses rather than struct page pointers
> >       efi: arm: enable DMI/SMBIOS
> >
> > Fabian Frederick (1):
> >       efi/capsule: Remove NULL test on kmap()
> >
> > Geliang Tang (1):
> >       efi/efi_test: Use memdup_user() helper
> >
> > Jan Kiszka (5):
> >       efi/capsule: Fix return code on failing kmap/vmap
> >       efi/capsule: Remove pr_debug on ENOMEM or EFAULT
> >       efi/capsule: Clean up pr_err/info messages
> >       efi/capsule: Adjust return type of efi_capsule_setup_info
> >       efi/capsule: Add support for Quark security header
> >
> > Sai Praneeth (1):
> >       x86/efi: Add EFI_PGT_DUMP support for x86_32 and kexec
> >
> 
> All,
> 
> I just noticed that this patch lacks my signoff. This is due to the
> fact that Matt queued this particular patch, and I didn't update the
> branch to add my sob, so it is only signed off by Matt not me.
> 
> How should we handle this now, and in the future? Matt and I share
> maintainership responsibilities, and so everything that gets queued
> into the EFI tree may be treated as signed off by either and/or the
> both of us. For multi-maintainer trees that get pulled directly, this
> is usually not an issue AFAIK, but given that Ingo is the one that
> deals with EFI usually, and prefers to apply the patches individually,
> this may  get flagged as a missing signoff.

So the root problem is that that's not the proper usage of SOB: SOB tracks the 
true propagation of patches, it's not an Acked-by tag.

What should be added instead in such cases is an Acked-by or Reviewed-by from your 
co-maintainer when you apply the patch - and a SOB of yourself. That is how we are 
doing it in -tip: you'll see that 99% of the patches there get signed off by only 
one of the co-maintainers.

> In any case, I am happy to respin the patches, re-sign the tag etc if this is 
> deemed necessary.

It would be nice to fix your SOB flow: the maintainer who queues up a patch should 
add the SOB, and add an Acked-by of the co-maintainer if the co-maintainer agrees 
with the patch as well. The tree should typically not be rebased after that point 
(especially not by the other co-maintainer) - that's just indicative of a messy 
workflow.

( In rare circumstances we do double signoffs as well in -tip, when there's a
  _true_ patch flow between the maintainers, but it's the exception, not the
  rule. )

Thanks,

	Ingo

[toc] | [prev] | [next] | [standalone]


#1657464

FromArd Biesheuvel <ard.biesheuvel@linaro.org>
Date2017-06-05 11:40 +0200
Message-ID<tOWEq-193-23@gated-at.bofh.it>
In reply to#1657407
On 5 June 2017 at 09:07, Ingo Molnar <mingo@kernel.org> wrote:
>
> * Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
>> (trim cc)
>>
>> On 2 June 2017 at 13:51, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>> > The following changes since commit 5ed02dbb497422bf225783f46e6eadd237d23d6b:
>> >
>> >   Linux 4.12-rc3 (2017-05-28 17:20:53 -0700)
>> >
>> > are available in the git repository at:
>> >
>> >   git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git tags/efi-next
>> >
>> > for you to fetch changes up to 3acbd5a24ab9d9a82c56d9018f4d340fa574b91d:
>> >
>> >   efi: arm: enable DMI/SMBIOS (2017-06-02 13:38:56 +0000)
>> >
>> > ----------------------------------------------------------------
>> > First batch of EFI changes for v4.13:
>> > - rework the EFI capsule loader to allow for workarounds for non-compliant
>> >   firmware to be implemented more easily and in a more self contained
>> >   manner (Ard)
>> > - implement a capsule loader quirk for Quark X102x, which prepends a
>> >   security header in a non-compliant way (Jan Kiszka)
>> > - enable SMBIOS/DMI support for the ARM architecture (Ard)
>> > - add EFI_PGT_DUMP support for x86_32 and kexec (Sai Praneeth)
>> > - some other cleanups
>> >
>> > ----------------------------------------------------------------
>> > Andy Lutomirski (1):
>> >       x86/efi: Clean up efi CR3 save/restore
>> >
>> > Ard Biesheuvel (4):
>> >       efi/capsule-loader: Use a cached copy of the capsule header
>> >       efi/capsule-loader: Redirect calls to efi_capsule_setup_info via weak alias
>> >       efi/capsule-loader: Use page addresses rather than struct page pointers
>> >       efi: arm: enable DMI/SMBIOS
>> >
>> > Fabian Frederick (1):
>> >       efi/capsule: Remove NULL test on kmap()
>> >
>> > Geliang Tang (1):
>> >       efi/efi_test: Use memdup_user() helper
>> >
>> > Jan Kiszka (5):
>> >       efi/capsule: Fix return code on failing kmap/vmap
>> >       efi/capsule: Remove pr_debug on ENOMEM or EFAULT
>> >       efi/capsule: Clean up pr_err/info messages
>> >       efi/capsule: Adjust return type of efi_capsule_setup_info
>> >       efi/capsule: Add support for Quark security header
>> >
>> > Sai Praneeth (1):
>> >       x86/efi: Add EFI_PGT_DUMP support for x86_32 and kexec
>> >
>>
>> All,
>>
>> I just noticed that this patch lacks my signoff. This is due to the
>> fact that Matt queued this particular patch, and I didn't update the
>> branch to add my sob, so it is only signed off by Matt not me.
>>
>> How should we handle this now, and in the future? Matt and I share
>> maintainership responsibilities, and so everything that gets queued
>> into the EFI tree may be treated as signed off by either and/or the
>> both of us. For multi-maintainer trees that get pulled directly, this
>> is usually not an issue AFAIK, but given that Ingo is the one that
>> deals with EFI usually, and prefers to apply the patches individually,
>> this may  get flagged as a missing signoff.
>
> So the root problem is that that's not the proper usage of SOB: SOB tracks the
> true propagation of patches, it's not an Acked-by tag.
>
> What should be added instead in such cases is an Acked-by or Reviewed-by from your
> co-maintainer when you apply the patch - and a SOB of yourself. That is how we are
> doing it in -tip: you'll see that 99% of the patches there get signed off by only
> one of the co-maintainers.
>

OK, so by that reasoning, having a mix of patches sob'ed by Matt xor
sob'ed by me in the same pull request is fine. Are all patches in -tip
acked/rb'd by the co-maintainers that did not do the signoff? If not,
why should that requirement exist for the EFI tree?

>> In any case, I am happy to respin the patches, re-sign the tag etc if this is
>> deemed necessary.
>
> It would be nice to fix your SOB flow: the maintainer who queues up a patch should
> add the SOB, and add an Acked-by of the co-maintainer if the co-maintainer agrees
> with the patch as well. The tree should typically not be rebased after that point
> (especially not by the other co-maintainer) - that's just indicative of a messy
> workflow.
>

OK, so this is exactly what we have in the queue right now, and what I
sent the pull request for.

-- 
Ard.

[toc] | [prev] | [next] | [standalone]


#1657685

FromIngo Molnar <mingo@kernel.org>
Date2017-06-05 18:00 +0200
Message-ID<tP2A9-4My-9@gated-at.bofh.it>
In reply to#1657464
* Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:

> > It would be nice to fix your SOB flow: the maintainer who queues up a patch should
> > add the SOB, and add an Acked-by of the co-maintainer if the co-maintainer agrees
> > with the patch as well. The tree should typically not be rebased after that point
> > (especially not by the other co-maintainer) - that's just indicative of a messy
> > workflow.
> 
> OK, so this is exactly what we have in the queue right now, and what I
> sent the pull request for.

Ok, the SOB chains are perfect - and I've started applying the patches to 
tip:efi/core.

Most of them are looking good, except #1 which won't apply. There were a few small 
details in changelogs that I have fixed up in place.

Will push out the rest if they pass testing.

Thanks,

	Ingo

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | linux.kernel


csiph-web