Skip to content

Commit 171549f

Browse files
vlsunilpalmer-dabbelt
authored andcommitted
riscv/efi_stub: Add 64bit boot-hartid support on RV64
The boot-hartid can be a 64bit value on RV64 platforms but the "boot-hartid" in DT is assumed to be 32bit only. Detect the size of the "boot-hartid" in DT and use 32bit or 64bit read appropriately. Signed-off-by: Sunil V L <sunilvl@ventanamicro.com> Link: https://lore.kernel.org/r/20220527051743.2829940-6-sunilvl@ventanamicro.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent ad635e7 commit 171549f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/firmware/efi/libstub/riscv-stub.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <asm/efi.h>
1010
#include <asm/sections.h>
11+
#include <asm/unaligned.h>
1112

1213
#include "efistub.h"
1314

@@ -29,7 +30,7 @@ static int get_boot_hartid_from_fdt(void)
2930
{
3031
const void *fdt;
3132
int chosen_node, len;
32-
const fdt32_t *prop;
33+
const void *prop;
3334

3435
fdt = get_efi_config_table(DEVICE_TREE_GUID);
3536
if (!fdt)
@@ -40,10 +41,16 @@ static int get_boot_hartid_from_fdt(void)
4041
return -EINVAL;
4142

4243
prop = fdt_getprop((void *)fdt, chosen_node, "boot-hartid", &len);
43-
if (!prop || len != sizeof(u32))
44+
if (!prop)
45+
return -EINVAL;
46+
47+
if (len == sizeof(u32))
48+
hartid = (unsigned long) fdt32_to_cpu(*(fdt32_t *)prop);
49+
else if (len == sizeof(u64))
50+
hartid = (unsigned long) fdt64_to_cpu(__get_unaligned_t(fdt64_t, prop));
51+
else
4452
return -EINVAL;
4553

46-
hartid = fdt32_to_cpu(*prop);
4754
return 0;
4855
}
4956

0 commit comments

Comments
 (0)