* [GIT PULL 0/2] Final EFI fixes for v4.20
@ 2018-12-17 18:02 Ard Biesheuvel
2018-12-17 18:02 ` [PATCH 1/2] efi: let kmemleak ignore false positives Ard Biesheuvel
2018-12-17 18:02 ` [PATCH 2/2] efi: efi_guid_t must be 64-bit aligned Ard Biesheuvel
0 siblings, 2 replies; 10+ messages in thread
From: Ard Biesheuvel @ 2018-12-17 18:02 UTC (permalink / raw)
To: linux-efi, Ingo Molnar, Thomas Gleixner
Cc: Ard Biesheuvel, linux-kernel, Heinrich Schuchardt, Qian Cai
The following changes since commit 7566ec393f4161572ba6f11ad5171fd5d59b0fbd:
Linux 4.20-rc7 (2018-12-16 15:46:55 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git tags/efi-urgent
for you to fetch changes up to 7b671e6a4917594a4e9ffd64111b8ac2e0323837:
efi: efi_guid_t must be 64-bit aligned (2018-12-17 10:42:26 +0100)
Note that applying Qian's patch will result in a conflict with the EFI
changes queued for the next window - the solution is to simply drop the
kmemleak_ignore() call since it is not required for page based
allocations.
----------------------------------------------------------------
Final EFI fixes for v4.20:
- prevent false positives from kmemleak for persistent memory reservations
- use the correct alignment for EFI GUIDs, preventing potential crashes in
firmware calls on 32-bit ARM
----------------------------------------------------------------
Heinrich Schuchardt (1):
efi: efi_guid_t must be 64-bit aligned
Qian Cai (1):
efi: let kmemleak ignore false positives
drivers/firmware/efi/efi.c | 3 +++
include/linux/efi.h | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 1/2] efi: let kmemleak ignore false positives 2018-12-17 18:02 [GIT PULL 0/2] Final EFI fixes for v4.20 Ard Biesheuvel @ 2018-12-17 18:02 ` Ard Biesheuvel 2018-12-17 18:15 ` [tip:efi/urgent] efi: Let " tip-bot for Qian Cai 2018-12-17 18:02 ` [PATCH 2/2] efi: efi_guid_t must be 64-bit aligned Ard Biesheuvel 1 sibling, 1 reply; 10+ messages in thread From: Ard Biesheuvel @ 2018-12-17 18:02 UTC (permalink / raw) To: linux-efi, Ingo Molnar, Thomas Gleixner Cc: Ard Biesheuvel, linux-kernel, Heinrich Schuchardt, Qian Cai From: Qian Cai <cai@gmx.us> unreferenced object 0xffff8096c1acf580 (size 128): comm "swapper/63", pid 0, jiffies 4294937418 (age 1201.230s) hex dump (first 32 bytes): 80 87 b5 c1 96 00 00 00 00 00 cc c2 16 00 00 00 ................ 00 00 01 00 00 00 00 00 6b 6b 6b 6b 6b 6b 6b 6b ........kkkkkkkk backtrace: [<000000001d2549ba>] kmem_cache_alloc_trace+0x430/0x500 [<0000000093a6dfab>] efi_mem_reserve_persistent+0x50/0xf8 [<000000000a730828>] its_cpu_init_lpis+0x394/0x4b8 [<00000000edf04e07>] its_cpu_init+0x104/0x150 [<000000004d0342c5>] gic_starting_cpu+0x34/0x40 [<000000005d9da772>] cpuhp_invoke_callback+0x228/0x1d68 [<0000000061eace9b>] notify_cpu_starting+0xc0/0x118 [<0000000048bc2dc5>] secondary_start_kernel+0x23c/0x3b0 [<0000000015137d6a>] 0xffffffffffffffff efi_mem_reserve_persistent+0x50/0xf8: kmalloc at include/linux/slab.h:546 (inlined by) efi_mem_reserve_persistent at drivers/firmware/efi/efi.c:979 This line, rsv = kmalloc(sizeof(*rsv), GFP_ATOMIC); Kmemleak has a known limitation that can only track pointers in the kernel virtual space. Hence, it will report false positives due to "rsv" will only reference to other physical addresses, rsv->next = efi_memreserve_root->next; efi_memreserve_root->next = __pa(rsv); Signed-off-by: Qian Cai <cai@gmx.us> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- drivers/firmware/efi/efi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 415849bab233..7fcfe8a7ae98 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -31,6 +31,7 @@ #include <linux/acpi.h> #include <linux/ucs2_string.h> #include <linux/memblock.h> +#include <linux/kmemleak.h> #include <asm/early_ioremap.h> @@ -1000,6 +1001,8 @@ int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size) if (!rsv) return -ENOMEM; + kmemleak_ignore(rsv); + rsv->base = addr; rsv->size = size; -- 2.17.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [tip:efi/urgent] efi: Let kmemleak ignore false positives 2018-12-17 18:02 ` [PATCH 1/2] efi: let kmemleak ignore false positives Ard Biesheuvel @ 2018-12-17 18:15 ` tip-bot for Qian Cai 0 siblings, 0 replies; 10+ messages in thread From: tip-bot for Qian Cai @ 2018-12-17 18:15 UTC (permalink / raw) To: linux-tip-commits Cc: ard.biesheuvel, luto, cai, riel, dave.hansen, torvalds, mingo, hpa, peterz, linux-kernel, bp, tglx, xypron.glpk Commit-ID: a0fc5578f1d63ba6e80d9509991b4c14f6eaf488 Gitweb: https://git.kernel.org/tip/a0fc5578f1d63ba6e80d9509991b4c14f6eaf488 Author: Qian Cai <cai@gmx.us> AuthorDate: Mon, 17 Dec 2018 19:02:13 +0100 Committer: Ingo Molnar <mingo@kernel.org> CommitDate: Mon, 17 Dec 2018 19:12:47 +0100 efi: Let kmemleak ignore false positives Address this kmemleak false positive : unreferenced object 0xffff8096c1acf580 (size 128): comm "swapper/63", pid 0, jiffies 4294937418 (age 1201.230s) hex dump (first 32 bytes): 80 87 b5 c1 96 00 00 00 00 00 cc c2 16 00 00 00 ................ 00 00 01 00 00 00 00 00 6b 6b 6b 6b 6b 6b 6b 6b ........kkkkkkkk backtrace: [<000000001d2549ba>] kmem_cache_alloc_trace+0x430/0x500 [<0000000093a6dfab>] efi_mem_reserve_persistent+0x50/0xf8 [<000000000a730828>] its_cpu_init_lpis+0x394/0x4b8 [<00000000edf04e07>] its_cpu_init+0x104/0x150 [<000000004d0342c5>] gic_starting_cpu+0x34/0x40 [<000000005d9da772>] cpuhp_invoke_callback+0x228/0x1d68 [<0000000061eace9b>] notify_cpu_starting+0xc0/0x118 [<0000000048bc2dc5>] secondary_start_kernel+0x23c/0x3b0 [<0000000015137d6a>] 0xffffffffffffffff efi_mem_reserve_persistent+0x50/0xf8: kmalloc at include/linux/slab.h:546 (inlined by) efi_mem_reserve_persistent at drivers/firmware/efi/efi.c:979 It's allocated by this line: rsv = kmalloc(sizeof(*rsv), GFP_ATOMIC); Kmemleak has a known limitation that can only track pointers in the kernel virtual space. Hence, it will report false positives due to "rsv" will only reference to other physical addresses: rsv->next = efi_memreserve_root->next; efi_memreserve_root->next = __pa(rsv); So tell kmemleak to ignore the 'rsv' object. [ mingo: Improved the changelog. ] Signed-off-by: Qian Cai <cai@gmx.us> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@surriel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20181217180214.9436-2-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar <mingo@kernel.org> --- drivers/firmware/efi/efi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 415849bab233..7fcfe8a7ae98 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -31,6 +31,7 @@ #include <linux/acpi.h> #include <linux/ucs2_string.h> #include <linux/memblock.h> +#include <linux/kmemleak.h> #include <asm/early_ioremap.h> @@ -1000,6 +1001,8 @@ int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size) if (!rsv) return -ENOMEM; + kmemleak_ignore(rsv); + rsv->base = addr; rsv->size = size; ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/2] efi: efi_guid_t must be 64-bit aligned 2018-12-17 18:02 [GIT PULL 0/2] Final EFI fixes for v4.20 Ard Biesheuvel 2018-12-17 18:02 ` [PATCH 1/2] efi: let kmemleak ignore false positives Ard Biesheuvel @ 2018-12-17 18:02 ` Ard Biesheuvel 2018-12-17 18:16 ` [tip:efi/urgent] efi: Align 'efi_guid_t' to 64 bits tip-bot for Heinrich Schuchardt 1 sibling, 1 reply; 10+ messages in thread From: Ard Biesheuvel @ 2018-12-17 18:02 UTC (permalink / raw) To: linux-efi, Ingo Molnar, Thomas Gleixner Cc: Ard Biesheuvel, linux-kernel, Heinrich Schuchardt, Qian Cai From: Heinrich Schuchardt <xypron.glpk@gmx.de> The UEFI Specification Version 2.7 Errata A defines: "EFI_GUID 128-bit buffer containing a unique identifier value. Unless otherwise specified, aligned on a 64-bit boundary." Before this patch efi_guid_t was 8-bit aligned. Note that this could potentially trigger alignment faults during EFI runtime services calls on 32-bit ARM, given that it does not permit load/store double or load/store multiple instructions to operate on memory addresses that are not 32-bit aligned. Cc: <stable@vger.kernel.org> # v4.9+, or earlier if possible Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- include/linux/efi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/efi.h b/include/linux/efi.h index 100ce4a4aff6..e6480c805932 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -48,7 +48,7 @@ typedef u16 efi_char16_t; /* UNICODE character */ typedef u64 efi_physical_addr_t; typedef void *efi_handle_t; -typedef guid_t efi_guid_t; +typedef guid_t efi_guid_t __aligned(8); #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) -- 2.17.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [tip:efi/urgent] efi: Align 'efi_guid_t' to 64 bits 2018-12-17 18:02 ` [PATCH 2/2] efi: efi_guid_t must be 64-bit aligned Ard Biesheuvel @ 2018-12-17 18:16 ` tip-bot for Heinrich Schuchardt 2018-12-17 22:33 ` Heinrich Schuchardt 0 siblings, 1 reply; 10+ messages in thread From: tip-bot for Heinrich Schuchardt @ 2018-12-17 18:16 UTC (permalink / raw) To: linux-tip-commits Cc: tglx, hpa, riel, peterz, cai, torvalds, mingo, bp, dave.hansen, ard.biesheuvel, xypron.glpk, linux-kernel, luto Commit-ID: 793423cf07e51e3185b8680167115813589c057d Gitweb: https://git.kernel.org/tip/793423cf07e51e3185b8680167115813589c057d Author: Heinrich Schuchardt <xypron.glpk@gmx.de> AuthorDate: Mon, 17 Dec 2018 19:02:14 +0100 Committer: Ingo Molnar <mingo@kernel.org> CommitDate: Mon, 17 Dec 2018 19:12:48 +0100 efi: Align 'efi_guid_t' to 64 bits The UEFI Specification Version 2.7 Errata A defines: "EFI_GUID 128-bit buffer containing a unique identifier value. Unless otherwise specified, aligned on a 64-bit boundary." Before this patch efi_guid_t was only 8-bit aligned. Note that this could potentially trigger alignment faults during EFI runtime services calls on 32-bit ARM, given that it does not permit load/store double or load/store multiple instructions to operate on memory addresses that are not 32-bit aligned. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: <stable@vger.kernel.org> # v4.9+, or earlier if possible Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Qian Cai <cai@gmx.us> Cc: Rik van Riel <riel@surriel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20181217180214.9436-3-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar <mingo@kernel.org> --- include/linux/efi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/efi.h b/include/linux/efi.h index 100ce4a4aff6..e6480c805932 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -48,7 +48,7 @@ typedef u16 efi_char16_t; /* UNICODE character */ typedef u64 efi_physical_addr_t; typedef void *efi_handle_t; -typedef guid_t efi_guid_t; +typedef guid_t efi_guid_t __aligned(8); #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [tip:efi/urgent] efi: Align 'efi_guid_t' to 64 bits 2018-12-17 18:16 ` [tip:efi/urgent] efi: Align 'efi_guid_t' to 64 bits tip-bot for Heinrich Schuchardt @ 2018-12-17 22:33 ` Heinrich Schuchardt 2018-12-17 22:42 ` Ard Biesheuvel 0 siblings, 1 reply; 10+ messages in thread From: Heinrich Schuchardt @ 2018-12-17 22:33 UTC (permalink / raw) To: cai, torvalds, mingo, bp, dave.hansen, ard.biesheuvel, linux-kernel, luto, tglx, riel, hpa, peterz, linux-tip-commits On 12/17/18 7:16 PM, tip-bot for Heinrich Schuchardt wrote: > Commit-ID: 793423cf07e51e3185b8680167115813589c057d > Gitweb: https://git.kernel.org/tip/793423cf07e51e3185b8680167115813589c057d > Author: Heinrich Schuchardt <xypron.glpk@gmx.de> > AuthorDate: Mon, 17 Dec 2018 19:02:14 +0100 > Committer: Ingo Molnar <mingo@kernel.org> > CommitDate: Mon, 17 Dec 2018 19:12:48 +0100 > > efi: Align 'efi_guid_t' to 64 bits > > The UEFI Specification Version 2.7 Errata A defines: > > "EFI_GUID > 128-bit buffer containing a unique identifier value. > Unless otherwise specified, aligned on a 64-bit boundary." > > Before this patch efi_guid_t was only 8-bit aligned. > > Note that this could potentially trigger alignment faults during > EFI runtime services calls on 32-bit ARM, given that it does not > permit load/store double or load/store multiple instructions to > operate on memory addresses that are not 32-bit aligned. > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> > Cc: <stable@vger.kernel.org> # v4.9+, or earlier if possible > Cc: Andy Lutomirski <luto@kernel.org> > Cc: Borislav Petkov <bp@alien8.de> > Cc: Dave Hansen <dave.hansen@linux.intel.com> > Cc: H. Peter Anvin <hpa@zytor.com> > Cc: Linus Torvalds <torvalds@linux-foundation.org> > Cc: Peter Zijlstra <peterz@infradead.org> > Cc: Qian Cai <cai@gmx.us> > Cc: Rik van Riel <riel@surriel.com> > Cc: Thomas Gleixner <tglx@linutronix.de> > Cc: linux-efi@vger.kernel.org > Link: http://lkml.kernel.org/r/20181217180214.9436-3-ard.biesheuvel@linaro.org > Signed-off-by: Ingo Molnar <mingo@kernel.org> > --- > include/linux/efi.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/efi.h b/include/linux/efi.h > index 100ce4a4aff6..e6480c805932 100644 > --- a/include/linux/efi.h > +++ b/include/linux/efi.h > @@ -48,7 +48,7 @@ typedef u16 efi_char16_t; /* UNICODE character */ > typedef u64 efi_physical_addr_t; > typedef void *efi_handle_t; > > -typedef guid_t efi_guid_t; > + > > #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ > GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) > Before rushing this patch in, we should carefully review its side effects, e.g. on 32bit system this changes the size of efi_config_table_32_t from 20 to 24, which is part of the interface to the UEFI firmware. Best regards Heinrich ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [tip:efi/urgent] efi: Align 'efi_guid_t' to 64 bits 2018-12-17 22:33 ` Heinrich Schuchardt @ 2018-12-17 22:42 ` Ard Biesheuvel 2018-12-17 23:20 ` Heinrich Schuchardt 0 siblings, 1 reply; 10+ messages in thread From: Ard Biesheuvel @ 2018-12-17 22:42 UTC (permalink / raw) To: Heinrich Schuchardt Cc: Qian Cai, Linus Torvalds, Ingo Molnar, Borislav Petkov, Dave Hansen, Linux Kernel Mailing List, Andy Lutomirski, Thomas Gleixner, Rik van Riel, H. Peter Anvin, Peter Zijlstra, linux-tip-commits On Mon, 17 Dec 2018 at 23:33, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote: > > On 12/17/18 7:16 PM, tip-bot for Heinrich Schuchardt wrote: > > Commit-ID: 793423cf07e51e3185b8680167115813589c057d > > Gitweb: https://git.kernel.org/tip/793423cf07e51e3185b8680167115813589c057d > > Author: Heinrich Schuchardt <xypron.glpk@gmx.de> > > AuthorDate: Mon, 17 Dec 2018 19:02:14 +0100 > > Committer: Ingo Molnar <mingo@kernel.org> > > CommitDate: Mon, 17 Dec 2018 19:12:48 +0100 > > > > efi: Align 'efi_guid_t' to 64 bits > > > > The UEFI Specification Version 2.7 Errata A defines: > > > > "EFI_GUID > > 128-bit buffer containing a unique identifier value. > > Unless otherwise specified, aligned on a 64-bit boundary." > > > > Before this patch efi_guid_t was only 8-bit aligned. > > > > Note that this could potentially trigger alignment faults during > > EFI runtime services calls on 32-bit ARM, given that it does not > > permit load/store double or load/store multiple instructions to > > operate on memory addresses that are not 32-bit aligned. > > > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> > > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> > > Cc: <stable@vger.kernel.org> # v4.9+, or earlier if possible > > Cc: Andy Lutomirski <luto@kernel.org> > > Cc: Borislav Petkov <bp@alien8.de> > > Cc: Dave Hansen <dave.hansen@linux.intel.com> > > Cc: H. Peter Anvin <hpa@zytor.com> > > Cc: Linus Torvalds <torvalds@linux-foundation.org> > > Cc: Peter Zijlstra <peterz@infradead.org> > > Cc: Qian Cai <cai@gmx.us> > > Cc: Rik van Riel <riel@surriel.com> > > Cc: Thomas Gleixner <tglx@linutronix.de> > > Cc: linux-efi@vger.kernel.org > > Link: http://lkml.kernel.org/r/20181217180214.9436-3-ard.biesheuvel@linaro.org > > Signed-off-by: Ingo Molnar <mingo@kernel.org> > > --- > > include/linux/efi.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/include/linux/efi.h b/include/linux/efi.h > > index 100ce4a4aff6..e6480c805932 100644 > > --- a/include/linux/efi.h > > +++ b/include/linux/efi.h > > @@ -48,7 +48,7 @@ typedef u16 efi_char16_t; /* UNICODE character */ > > typedef u64 efi_physical_addr_t; > > typedef void *efi_handle_t; > > > > -typedef guid_t efi_guid_t; > > + > > > > #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ > > GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) > > > > Before rushing this patch in, we should carefully review its side > effects, e.g. on 32bit system this changes the size of > efi_config_table_32_t from 20 to 24, which is part of the interface to > the UEFI firmware. > grmbl. Thanks for spotting that. The UEFI spec defines a GUID struct as { UINT32; UINT16; UINT16; UINT8[8]; } so its natural alignment is 32 bits not 64 bits. The alignment issue on ARM would be solved by using __aligned(4) rather than __aligned(8), while not affecting the size of the config table struct (and potentially others) on 32-bit architectures. Ingo, apologies for the breakage. Do you prefer a replacement patch or a followup patch? ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [tip:efi/urgent] efi: Align 'efi_guid_t' to 64 bits 2018-12-17 22:42 ` Ard Biesheuvel @ 2018-12-17 23:20 ` Heinrich Schuchardt 2018-12-19 22:50 ` Ard Biesheuvel 0 siblings, 1 reply; 10+ messages in thread From: Heinrich Schuchardt @ 2018-12-17 23:20 UTC (permalink / raw) To: Ard Biesheuvel Cc: Qian Cai, Linus Torvalds, Ingo Molnar, Borislav Petkov, Dave Hansen, Linux Kernel Mailing List, Andy Lutomirski, Thomas Gleixner, Rik van Riel, H. Peter Anvin, Peter Zijlstra, linux-tip-commits On 12/17/18 11:42 PM, Ard Biesheuvel wrote: > On Mon, 17 Dec 2018 at 23:33, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote: >> >> On 12/17/18 7:16 PM, tip-bot for Heinrich Schuchardt wrote: >>> Commit-ID: 793423cf07e51e3185b8680167115813589c057d >>> Gitweb: https://git.kernel.org/tip/793423cf07e51e3185b8680167115813589c057d >>> Author: Heinrich Schuchardt <xypron.glpk@gmx.de> >>> AuthorDate: Mon, 17 Dec 2018 19:02:14 +0100 >>> Committer: Ingo Molnar <mingo@kernel.org> >>> CommitDate: Mon, 17 Dec 2018 19:12:48 +0100 >>> >>> efi: Align 'efi_guid_t' to 64 bits >>> >>> The UEFI Specification Version 2.7 Errata A defines: >>> >>> "EFI_GUID >>> 128-bit buffer containing a unique identifier value. >>> Unless otherwise specified, aligned on a 64-bit boundary." >>> >>> Before this patch efi_guid_t was only 8-bit aligned. >>> >>> Note that this could potentially trigger alignment faults during >>> EFI runtime services calls on 32-bit ARM, given that it does not >>> permit load/store double or load/store multiple instructions to >>> operate on memory addresses that are not 32-bit aligned. >>> >>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> >>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> >>> Cc: <stable@vger.kernel.org> # v4.9+, or earlier if possible >>> Cc: Andy Lutomirski <luto@kernel.org> >>> Cc: Borislav Petkov <bp@alien8.de> >>> Cc: Dave Hansen <dave.hansen@linux.intel.com> >>> Cc: H. Peter Anvin <hpa@zytor.com> >>> Cc: Linus Torvalds <torvalds@linux-foundation.org> >>> Cc: Peter Zijlstra <peterz@infradead.org> >>> Cc: Qian Cai <cai@gmx.us> >>> Cc: Rik van Riel <riel@surriel.com> >>> Cc: Thomas Gleixner <tglx@linutronix.de> >>> Cc: linux-efi@vger.kernel.org >>> Link: http://lkml.kernel.org/r/20181217180214.9436-3-ard.biesheuvel@linaro.org >>> Signed-off-by: Ingo Molnar <mingo@kernel.org> >>> --- >>> include/linux/efi.h | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/include/linux/efi.h b/include/linux/efi.h >>> index 100ce4a4aff6..e6480c805932 100644 >>> --- a/include/linux/efi.h >>> +++ b/include/linux/efi.h >>> @@ -48,7 +48,7 @@ typedef u16 efi_char16_t; /* UNICODE character */ >>> typedef u64 efi_physical_addr_t; >>> typedef void *efi_handle_t; >>> >>> -typedef guid_t efi_guid_t; >>> + >>> >>> #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ >>> GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) >>> >> >> Before rushing this patch in, we should carefully review its side >> effects, e.g. on 32bit system this changes the size of >> efi_config_table_32_t from 20 to 24, which is part of the interface to >> the UEFI firmware. >> > > grmbl. > > Thanks for spotting that. > > The UEFI spec defines a GUID struct as { UINT32; UINT16; UINT16; > UINT8[8]; } so its natural alignment is 32 bits not 64 bits. The > alignment issue on ARM would be solved by using __aligned(4) rather > than __aligned(8), while not affecting the size of the config table > struct (and potentially others) on 32-bit architectures. > > Ingo, apologies for the breakage. Do you prefer a replacement patch or > a followup patch? > The UEFI spec explicitly requires EFI_GUID to be 64-bit aligned. On the other hand neither EDK2 nor GRUB not U-Boot cared about this requirement up to now. So the array of efi_config_table_32_t had 20 byte long members at least on Linux, EDK2, GRUB, U-Boot, and possibly on other UEFI implementations though the UEFI spec does not mention packing here. As the 4.20 kernel release is imminent, please, keep this patch out before causing breakage. Best regards Heinrich ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [tip:efi/urgent] efi: Align 'efi_guid_t' to 64 bits 2018-12-17 23:20 ` Heinrich Schuchardt @ 2018-12-19 22:50 ` Ard Biesheuvel 2018-12-21 0:08 ` Ard Biesheuvel 0 siblings, 1 reply; 10+ messages in thread From: Ard Biesheuvel @ 2018-12-19 22:50 UTC (permalink / raw) To: Heinrich Schuchardt Cc: Qian Cai, Linus Torvalds, Ingo Molnar, Borislav Petkov, Dave Hansen, Linux Kernel Mailing List, Andy Lutomirski, Thomas Gleixner, Rik van Riel, H. Peter Anvin, Peter Zijlstra, linux-tip-commits On Tue, 18 Dec 2018 at 00:20, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote: > > On 12/17/18 11:42 PM, Ard Biesheuvel wrote: > > On Mon, 17 Dec 2018 at 23:33, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote: > >> > >> On 12/17/18 7:16 PM, tip-bot for Heinrich Schuchardt wrote: > >>> Commit-ID: 793423cf07e51e3185b8680167115813589c057d > >>> Gitweb: https://git.kernel.org/tip/793423cf07e51e3185b8680167115813589c057d > >>> Author: Heinrich Schuchardt <xypron.glpk@gmx.de> > >>> AuthorDate: Mon, 17 Dec 2018 19:02:14 +0100 > >>> Committer: Ingo Molnar <mingo@kernel.org> > >>> CommitDate: Mon, 17 Dec 2018 19:12:48 +0100 > >>> > >>> efi: Align 'efi_guid_t' to 64 bits > >>> > >>> The UEFI Specification Version 2.7 Errata A defines: > >>> > >>> "EFI_GUID > >>> 128-bit buffer containing a unique identifier value. > >>> Unless otherwise specified, aligned on a 64-bit boundary." > >>> > >>> Before this patch efi_guid_t was only 8-bit aligned. > >>> > >>> Note that this could potentially trigger alignment faults during > >>> EFI runtime services calls on 32-bit ARM, given that it does not > >>> permit load/store double or load/store multiple instructions to > >>> operate on memory addresses that are not 32-bit aligned. > >>> > >>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> > >>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> > >>> Cc: <stable@vger.kernel.org> # v4.9+, or earlier if possible > >>> Cc: Andy Lutomirski <luto@kernel.org> > >>> Cc: Borislav Petkov <bp@alien8.de> > >>> Cc: Dave Hansen <dave.hansen@linux.intel.com> > >>> Cc: H. Peter Anvin <hpa@zytor.com> > >>> Cc: Linus Torvalds <torvalds@linux-foundation.org> > >>> Cc: Peter Zijlstra <peterz@infradead.org> > >>> Cc: Qian Cai <cai@gmx.us> > >>> Cc: Rik van Riel <riel@surriel.com> > >>> Cc: Thomas Gleixner <tglx@linutronix.de> > >>> Cc: linux-efi@vger.kernel.org > >>> Link: http://lkml.kernel.org/r/20181217180214.9436-3-ard.biesheuvel@linaro.org > >>> Signed-off-by: Ingo Molnar <mingo@kernel.org> > >>> --- > >>> include/linux/efi.h | 2 +- > >>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>> > >>> diff --git a/include/linux/efi.h b/include/linux/efi.h > >>> index 100ce4a4aff6..e6480c805932 100644 > >>> --- a/include/linux/efi.h > >>> +++ b/include/linux/efi.h > >>> @@ -48,7 +48,7 @@ typedef u16 efi_char16_t; /* UNICODE character */ > >>> typedef u64 efi_physical_addr_t; > >>> typedef void *efi_handle_t; > >>> > >>> -typedef guid_t efi_guid_t; > >>> + > >>> > >>> #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ > >>> GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) > >>> > >> > >> Before rushing this patch in, we should carefully review its side > >> effects, e.g. on 32bit system this changes the size of > >> efi_config_table_32_t from 20 to 24, which is part of the interface to > >> the UEFI firmware. > >> > > > > grmbl. > > > > Thanks for spotting that. > > > > The UEFI spec defines a GUID struct as { UINT32; UINT16; UINT16; > > UINT8[8]; } so its natural alignment is 32 bits not 64 bits. The > > alignment issue on ARM would be solved by using __aligned(4) rather > > than __aligned(8), while not affecting the size of the config table > > struct (and potentially others) on 32-bit architectures. > > > > Ingo, apologies for the breakage. Do you prefer a replacement patch or > > a followup patch? > > > > The UEFI spec explicitly requires EFI_GUID to be 64-bit aligned. On the > other hand neither EDK2 nor GRUB not U-Boot cared about this requirement > up to now. So the array of efi_config_table_32_t had 20 byte long > members at least on Linux, EDK2, GRUB, U-Boot, and possibly on other > UEFI implementations though the UEFI spec does not mention packing here. > > As the 4.20 kernel release is imminent, please, keep this patch out > before causing breakage. > Ingo, Let's just drop Heinrich's patch for now, and I will come back to it for the next release. There is very little EFI on 32-bit ARM in the field, and this patch in its current form will break IA-32 as well, so a quick followup fix is probably not the best approach here. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [tip:efi/urgent] efi: Align 'efi_guid_t' to 64 bits 2018-12-19 22:50 ` Ard Biesheuvel @ 2018-12-21 0:08 ` Ard Biesheuvel 0 siblings, 0 replies; 10+ messages in thread From: Ard Biesheuvel @ 2018-12-21 0:08 UTC (permalink / raw) To: Heinrich Schuchardt, Ingo Molnar, Thomas Gleixner Cc: Qian Cai, Linus Torvalds, Borislav Petkov, Dave Hansen, Linux Kernel Mailing List, Andy Lutomirski, Rik van Riel, H. Peter Anvin, Peter Zijlstra, linux-tip-commits On Wed, 19 Dec 2018 at 23:50, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote: > > On Tue, 18 Dec 2018 at 00:20, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote: > > > > On 12/17/18 11:42 PM, Ard Biesheuvel wrote: > > > On Mon, 17 Dec 2018 at 23:33, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote: > > >> > > >> On 12/17/18 7:16 PM, tip-bot for Heinrich Schuchardt wrote: > > >>> Commit-ID: 793423cf07e51e3185b8680167115813589c057d > > >>> Gitweb: https://git.kernel.org/tip/793423cf07e51e3185b8680167115813589c057d > > >>> Author: Heinrich Schuchardt <xypron.glpk@gmx.de> > > >>> AuthorDate: Mon, 17 Dec 2018 19:02:14 +0100 > > >>> Committer: Ingo Molnar <mingo@kernel.org> > > >>> CommitDate: Mon, 17 Dec 2018 19:12:48 +0100 > > >>> > > >>> efi: Align 'efi_guid_t' to 64 bits > > >>> > > >>> The UEFI Specification Version 2.7 Errata A defines: > > >>> > > >>> "EFI_GUID > > >>> 128-bit buffer containing a unique identifier value. > > >>> Unless otherwise specified, aligned on a 64-bit boundary." > > >>> > > >>> Before this patch efi_guid_t was only 8-bit aligned. > > >>> > > >>> Note that this could potentially trigger alignment faults during > > >>> EFI runtime services calls on 32-bit ARM, given that it does not > > >>> permit load/store double or load/store multiple instructions to > > >>> operate on memory addresses that are not 32-bit aligned. > > >>> > > >>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> > > >>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> > > >>> Cc: <stable@vger.kernel.org> # v4.9+, or earlier if possible > > >>> Cc: Andy Lutomirski <luto@kernel.org> > > >>> Cc: Borislav Petkov <bp@alien8.de> > > >>> Cc: Dave Hansen <dave.hansen@linux.intel.com> > > >>> Cc: H. Peter Anvin <hpa@zytor.com> > > >>> Cc: Linus Torvalds <torvalds@linux-foundation.org> > > >>> Cc: Peter Zijlstra <peterz@infradead.org> > > >>> Cc: Qian Cai <cai@gmx.us> > > >>> Cc: Rik van Riel <riel@surriel.com> > > >>> Cc: Thomas Gleixner <tglx@linutronix.de> > > >>> Cc: linux-efi@vger.kernel.org > > >>> Link: http://lkml.kernel.org/r/20181217180214.9436-3-ard.biesheuvel@linaro.org > > >>> Signed-off-by: Ingo Molnar <mingo@kernel.org> > > >>> --- > > >>> include/linux/efi.h | 2 +- > > >>> 1 file changed, 1 insertion(+), 1 deletion(-) > > >>> > > >>> diff --git a/include/linux/efi.h b/include/linux/efi.h > > >>> index 100ce4a4aff6..e6480c805932 100644 > > >>> --- a/include/linux/efi.h > > >>> +++ b/include/linux/efi.h > > >>> @@ -48,7 +48,7 @@ typedef u16 efi_char16_t; /* UNICODE character */ > > >>> typedef u64 efi_physical_addr_t; > > >>> typedef void *efi_handle_t; > > >>> > > >>> -typedef guid_t efi_guid_t; > > >>> + > > >>> > > >>> #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ > > >>> GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) > > >>> > > >> > > >> Before rushing this patch in, we should carefully review its side > > >> effects, e.g. on 32bit system this changes the size of > > >> efi_config_table_32_t from 20 to 24, which is part of the interface to > > >> the UEFI firmware. > > >> > > > > > > grmbl. > > > > > > Thanks for spotting that. > > > > > > The UEFI spec defines a GUID struct as { UINT32; UINT16; UINT16; > > > UINT8[8]; } so its natural alignment is 32 bits not 64 bits. The > > > alignment issue on ARM would be solved by using __aligned(4) rather > > > than __aligned(8), while not affecting the size of the config table > > > struct (and potentially others) on 32-bit architectures. > > > > > > Ingo, apologies for the breakage. Do you prefer a replacement patch or > > > a followup patch? > > > > > > > The UEFI spec explicitly requires EFI_GUID to be 64-bit aligned. On the > > other hand neither EDK2 nor GRUB not U-Boot cared about this requirement > > up to now. So the array of efi_config_table_32_t had 20 byte long > > members at least on Linux, EDK2, GRUB, U-Boot, and possibly on other > > UEFI implementations though the UEFI spec does not mention packing here. > > > > As the 4.20 kernel release is imminent, please, keep this patch out > > before causing breakage. > > > > Ingo, > > Let's just drop Heinrich's patch for now, and I will come back to it > for the next release. There is very little EFI on 32-bit ARM in the > field, and this patch in its current form will break IA-32 as well, so > a quick followup fix is probably not the best approach here. Ingo, Could you please let me know what your plans are with this patch? It has been pulled into -next now. Please either drop it or revert it. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-12-21 0:08 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-12-17 18:02 [GIT PULL 0/2] Final EFI fixes for v4.20 Ard Biesheuvel 2018-12-17 18:02 ` [PATCH 1/2] efi: let kmemleak ignore false positives Ard Biesheuvel 2018-12-17 18:15 ` [tip:efi/urgent] efi: Let " tip-bot for Qian Cai 2018-12-17 18:02 ` [PATCH 2/2] efi: efi_guid_t must be 64-bit aligned Ard Biesheuvel 2018-12-17 18:16 ` [tip:efi/urgent] efi: Align 'efi_guid_t' to 64 bits tip-bot for Heinrich Schuchardt 2018-12-17 22:33 ` Heinrich Schuchardt 2018-12-17 22:42 ` Ard Biesheuvel 2018-12-17 23:20 ` Heinrich Schuchardt 2018-12-19 22:50 ` Ard Biesheuvel 2018-12-21 0:08 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
Powered by JetHome