Ilias Apalodimas
53e54bf50d
efi_loader: Avoid emitting efi_var_buf to .GOT
Atish reports that on RISC-V, accessing the EFI variables causes
a kernel panic. An objdump of the file verifies that, since the
global pointer for efi_var_buf ends up in .GOT section which is
not mapped in virtual address space for Linux.
<snip of efi_var_mem_find>
0000000000000084 <efi_var_mem_find>:
84: 715d addi sp,sp,-80
* objdump -dr
0000000000000086 <.LCFI2>:
86: e0a2 sd s0,64(sp)
88: fc26 sd s1,56(sp)
8a: e486 sd ra,72(sp)
8c: f84a sd s2,48(sp)
8e: f44e sd s3,40(sp)
90: f052 sd s4,32(sp)
92: ec56 sd s5,24(sp)
94: 00000497 auipc s1,0x0
94: R_RISCV_GOT_HI20 efi_var_buf
98: 0004b483 ld s1,0(s1) # 94 <.LCFI2+0xe>
98: R_RISCV_PCREL_LO12_I .L0
98: R_RISCV_RELAX *ABS*
* objdump -t
0000000000000084 g F .text.efi_runtime 00000000000000b8 efi_var_mem_find
With the patch applied:
* objdump -dr
0000000000000086 <.LCFI2>:
86: e0a2 sd s0,64(sp)
88: fc26 sd s1,56(sp)
8a: e486 sd ra,72(sp)
8c: f84a sd s2,48(sp)
8e: f44e sd s3,40(sp)
90: f052 sd s4,32(sp)
92: ec56 sd s5,24(sp)
94: 00000497 auipc s1,0x0
94: R_RISCV_PCREL_HI20 .LANCHOR0
94: R_RISCV_RELAX *ABS*
98: 00048493 mv s1,s1
98: R_RISCV_PCREL_LO12_I .L0
98: R_RISCV_RELAX *ABS*
* objdump -t
0000000000000008 l O .data.efi_runtime 0000000000000008 efi_var_buf
On arm64 this works, because there's no .GOT entries for this
and everything is converted to relative references.
* objdump -dr (identical pre-post patch, only the new function shows up)
00000000000000b4 <efi_var_mem_find>:
b4: aa0003ee mov x14, x0
b8: 9000000a adrp x10, 0 <efi_var_mem_compare>
b8: R_AARCH64_ADR_PREL_PG_HI21 .data.efi_runtime
bc: 91000140 add x0, x10, #0x0
bc: R_AARCH64_ADD_ABS_LO12_NC .data.efi_runtime
c0: aa0103ed mov x13, x1
c4: 79400021 ldrh w1, [x1]
c8: aa0203eb mov x11, x2
cc: f9400400 ldr x0, [x0, #8]
d0: b940100c ldr w12, [x0, #16]
d4: 8b0c000c add x12, x0, x12
So let's switch efi_var_buf to static and create a helper function for
anyone that needs to update it.
Fixes: e01aed47d6 ("efi_loader: Enable run-time variable support for tee based variables")
Reported-by: Atish Patra <atishp@atishpatra.org>
Tested-by: Atish Patra <atish.patra@wdc.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-20 08:17:17 +01:00
..
2020-11-06 09:51:28 +08:00
2021-01-15 14:36:12 -05:00
2020-09-09 16:57:35 -04:00
2021-01-18 15:23:06 -05:00
2021-01-16 14:49:09 -05:00
2021-01-18 15:23:06 -05:00
2020-10-12 07:26:57 -04:00
2020-08-25 09:33:35 +08:00
2021-01-15 17:48:36 +08:00
2020-09-30 16:55:03 -04:00
2021-01-18 15:23:06 -05:00
2021-01-16 14:49:09 -05:00
2020-10-27 08:13:33 +01:00
2020-11-22 13:18:20 +01:00
2020-10-23 09:16:01 -04:00
2020-10-22 09:54:53 -04:00
2020-12-13 16:51:08 -07:00
2020-10-09 17:53:12 +08:00
2021-01-15 14:36:12 -05:00
2020-12-04 16:09:06 -05:00
2020-12-13 16:51:09 -07:00
2020-08-24 14:11:13 -04:00
2020-11-05 09:11:31 -07:00
2020-10-29 14:42:17 -06:00
2020-12-13 16:51:08 -07:00
2020-11-06 09:51:28 +08:00
2020-12-04 19:48:29 -05:00
2020-07-28 19:30:39 -06:00
2020-10-30 14:20:27 +01:00
2020-12-04 16:10:01 -05:00
2021-01-12 10:58:04 +05:30
2021-01-12 10:58:04 +05:30
2020-12-01 10:33:38 -05:00
2020-12-26 12:37:28 +01:00
2021-01-20 08:09:34 +01:00
2020-10-29 14:42:17 -06:00
2021-01-15 14:38:00 -05:00
2020-12-13 16:51:09 -07:00
2020-11-05 09:11:31 -07:00
2020-10-30 14:20:27 +01:00
2020-10-22 09:54:54 -04:00
2020-08-03 22:19:54 -04:00
2020-08-03 22:19:54 -04:00
2020-10-29 14:42:18 -06:00
2020-12-09 10:57:50 +01:00
2021-01-15 17:48:36 +08:00
2021-01-20 08:17:17 +01:00
2020-08-03 22:19:54 -04:00
2021-01-13 02:38:01 +01:00
2021-01-20 08:17:17 +01:00
2020-12-03 21:22:40 +01:00
2021-01-20 08:17:17 +01:00
2021-01-13 02:38:01 +01:00
2020-07-31 10:13:00 -04:00
2020-07-31 10:13:00 -04:00
2020-10-30 10:54:38 -04:00
2020-08-03 22:19:54 -04:00
2021-01-15 14:36:12 -05:00
2020-09-01 14:47:43 +02:00
2020-12-31 14:32:27 +01:00
2020-10-14 11:16:34 -04:00
2020-09-22 12:54:13 -06:00
2020-12-13 16:51:09 -07:00
2020-08-07 22:31:32 -04:00
2020-11-28 10:39:44 +08:00
2020-12-10 13:56:39 +05:30
2020-09-24 08:27:44 -04:00
2020-09-17 06:09:53 +02:00
2020-07-27 14:16:29 +05:30
2020-10-30 10:56:11 -04:00
2020-08-26 09:19:16 +02:00
2020-12-13 16:51:09 -07:00
2021-01-11 23:19:33 +00:00
2021-01-15 14:36:12 -05:00
2021-01-15 14:37:03 -05:00
2020-12-18 20:32:21 -07:00
2020-08-04 23:30:02 -04:00
2021-01-16 19:17:11 -05:00
2021-01-15 14:36:12 -05:00
2020-10-18 10:36:05 +02:00
2020-11-29 05:18:37 +01:00
2020-10-27 08:13:33 +01:00
2020-10-28 11:48:32 -04:00
2020-10-28 11:48:55 -04:00
2020-12-13 16:51:08 -07:00
2021-01-05 12:24:40 -07:00
2020-09-15 18:51:53 +05:30
2020-12-13 07:58:17 -07:00
2020-12-13 16:51:09 -07:00
2021-01-16 14:49:09 -05:00
2021-01-16 14:48:23 -05:00
2020-12-18 20:32:21 -07:00
2020-08-03 22:19:54 -04:00
2020-09-16 16:54:00 -04:00
2021-01-15 14:36:11 -05:00
2020-08-14 15:18:30 -04:00
2020-12-13 16:51:09 -07:00
2020-12-13 16:51:08 -07:00
2020-09-30 11:55:22 -04:00
2020-08-24 11:03:26 +02:00
2020-09-30 11:55:23 -04:00
2020-09-30 11:55:23 -04:00
2020-09-30 11:55:23 -04:00
2020-12-13 16:51:09 -07:00
2020-12-13 16:51:09 -07:00
2020-12-04 16:09:06 -05:00
2020-08-06 14:27:27 -04:00
2020-12-31 14:41:31 +01:00
2020-11-06 10:18:20 +08:00
2020-08-03 22:19:54 -04:00
2020-08-03 22:19:54 -04:00
2021-01-05 16:20:26 -05:00
2021-01-05 12:24:40 -07:00
2020-11-19 09:45:49 -05:00
2020-08-23 13:43:10 -04:00
2020-10-22 09:54:53 -04:00
2020-12-09 10:57:50 +01:00
2021-01-11 23:19:33 +00:00
2020-12-13 16:51:09 -07:00
2020-11-06 10:18:20 +08:00
2020-08-03 22:19:54 -04:00
2020-10-22 09:54:53 -04:00
2020-12-03 21:22:40 +01:00
2020-09-24 08:27:44 -04:00
2020-11-15 15:25:55 +05:30
2020-09-01 14:47:43 +02:00
2020-12-13 16:51:09 -07:00
2021-01-16 14:49:09 -05:00
2020-12-13 16:51:09 -07:00
2021-01-06 07:57:33 -05:00
2021-01-05 12:24:41 -07:00
2020-08-14 15:18:30 -04:00
2020-08-03 22:19:54 -04:00
2020-08-03 22:19:54 -04:00
2021-01-15 14:36:12 -05:00
2020-08-20 10:57:46 +02:00
2020-10-29 08:55:43 +01:00
2020-09-23 10:31:41 +02:00