mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 19:34:43 +01:00
riscv: implement kernel ifunc resolution
This completes the set of architectures implementing this feature. Move the calls to sched_instance_select() and link_elf_ireloc() later in initriscv(), after identify_cpu(0). There will be more information available to any resolver functions at this time. Reviewed by: imp, kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55082
This commit is contained in:
1 parent
157d6664ae
commit
cf41d11133
5 files changed
+14
-12
No files matched your search
@@ -119,10 +119,9 @@ CFLAGS+= ${CONF_CFLAGS}
|
||||
LDFLAGS+= --build-id=sha1
|
||||
.endif
|
||||
|
||||
.if ${MACHINE_CPUARCH} != "riscv" && \
|
||||
defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mifunc} == "" && \
|
||||
.if defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mifunc} == "" && \
|
||||
!make(install)
|
||||
.error amd64/arm/arm64/i386/ppc* kernel requires linker ifunc support
|
||||
.error kernel requires linker ifunc support
|
||||
.endif
|
||||
.if ${MACHINE_CPUARCH} == "amd64"
|
||||
LDFLAGS+= -z max-page-size=2097152
|
||||
|
||||
@@ -2041,7 +2041,6 @@ link_elf_propagate_vnets(linker_file_t lf)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(__riscv)
|
||||
/*
|
||||
* Use this lookup routine when performing relocations early during boot.
|
||||
* The generic lookup routine depends on kobj, which is not initialized
|
||||
@@ -2104,4 +2103,3 @@ link_elf_late_ireloc(void)
|
||||
relocate_file1(ef, elf_lookup_ifunc, elf_reloc_late, true);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -30,8 +30,6 @@
|
||||
#ifndef __RISCV_IFUNC_H
|
||||
#define __RISCV_IFUNC_H
|
||||
|
||||
#define __DO_NOT_HAVE_SYS_IFUNCS 1
|
||||
|
||||
#define DEFINE_IFUNC(qual, ret_type, name, args) \
|
||||
static ret_type (*name##_resolver(void))args __used; \
|
||||
qual ret_type name args __attribute__((ifunc(#name "_resolver"))); \
|
||||
|
||||
@@ -271,10 +271,10 @@ reloctype_to_str(int type)
|
||||
}
|
||||
|
||||
bool
|
||||
elf_is_ifunc_reloc(Elf_Size r_info __unused)
|
||||
elf_is_ifunc_reloc(Elf_Size r_info)
|
||||
{
|
||||
|
||||
return (false);
|
||||
return (ELF_R_TYPE(r_info) == R_RISCV_IRELATIVE);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -501,7 +501,12 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
(local ? 'l' : 'g'), reloctype_to_str(rtype),
|
||||
before32, *insn32p);
|
||||
break;
|
||||
|
||||
case R_RISCV_IRELATIVE:
|
||||
addr = relocbase + addend;
|
||||
val = ((Elf64_Addr (*)(void))addr)();
|
||||
if (*where != val)
|
||||
*where = val;
|
||||
break;
|
||||
default:
|
||||
printf("kldload: unexpected relocation type %ld, "
|
||||
"symbol index %ld\n", rtype, symidx);
|
||||
|
||||
@@ -479,8 +479,6 @@ parse_metadata(void)
|
||||
|
||||
/* Initialize preload_kmdp */
|
||||
preload_initkmdp(true);
|
||||
sched_instance_select();
|
||||
/* link_elf_ireloc(); */
|
||||
|
||||
/* Read the boot metadata */
|
||||
boothowto = MD_FETCH(preload_kmdp, MODINFOMD_HOWTO, int);
|
||||
@@ -626,6 +624,10 @@ initriscv(struct riscv_bootparams *rvbp)
|
||||
*/
|
||||
identify_cpu(0);
|
||||
|
||||
sched_instance_select();
|
||||
|
||||
link_elf_ireloc();
|
||||
|
||||
/* Do basic tuning, hz etc */
|
||||
init_param1();
|
||||
|
||||
|
||||
Reference in new issue
Block a user