This repository has been archived by the owner on Nov 21, 2022. It is now read-only.
forked from microsoft/WSL2-Linux-Kernel
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
riscv: compat: vdso: Add COMPAT_VDSO base code implementation
There is no vgettimeofday supported in rv32 that makes simple to generate rv32 vdso code which only needs riscv64 compiler. Other architectures need change compiler or -m (machine parameter) to support vdso32 compiling. If rv32 support vgettimeofday (which cause C compile) in future, we would add CROSS_COMPILE to support that makes more requirement on compiler enviornment. linux-rv64/arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg: file format elf64-littleriscv Disassembly of section .text: 0000000000000800 <__vdso_rt_sigreturn>: 800: 08b00893 li a7,139 804: 00000073 ecall 808: 0000 unimp ... 000000000000080c <__vdso_getcpu>: 80c: 0a800893 li a7,168 810: 00000073 ecall 814: 8082 ret ... 0000000000000818 <__vdso_flush_icache>: 818: 10300893 li a7,259 81c: 00000073 ecall 820: 8082 ret linux-rv32/arch/riscv/kernel/vdso/vdso.so.dbg: file format elf32-littleriscv Disassembly of section .text: 00000800 <__vdso_rt_sigreturn>: 800: 08b00893 li a7,139 804: 00000073 ecall 808: 0000 unimp ... 0000080c <__vdso_getcpu>: 80c: 0a800893 li a7,168 810: 00000073 ecall 814: 8082 ret ... 00000818 <__vdso_flush_icache>: 818: 10300893 li a7,259 81c: 00000073 ecall 820: 8082 ret Finally, reuse all *.S from vdso in compat_vdso that makes implementation clear and readable. Signed-off-by: Guo Ren <[email protected]> Signed-off-by: Guo Ren <[email protected]> Tested-by: Heiko Stuebner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
- Loading branch information
1 parent
f4b395e
commit 0715372
Showing
13 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
compat_vdso.lds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
# | ||
# Makefile for compat_vdso | ||
# | ||
|
||
# Symbols present in the compat_vdso | ||
compat_vdso-syms = rt_sigreturn | ||
compat_vdso-syms += getcpu | ||
compat_vdso-syms += flush_icache | ||
|
||
COMPAT_CC := $(CC) | ||
COMPAT_LD := $(LD) | ||
|
||
COMPAT_CC_FLAGS := -march=rv32g -mabi=ilp32 | ||
COMPAT_LD_FLAGS := -melf32lriscv | ||
|
||
# Files to link into the compat_vdso | ||
obj-compat_vdso = $(patsubst %, %.o, $(compat_vdso-syms)) note.o | ||
|
||
# Build rules | ||
targets := $(obj-compat_vdso) compat_vdso.so compat_vdso.so.dbg compat_vdso.lds | ||
obj-compat_vdso := $(addprefix $(obj)/, $(obj-compat_vdso)) | ||
|
||
obj-y += compat_vdso.o | ||
CPPFLAGS_compat_vdso.lds += -P -C -U$(ARCH) | ||
|
||
# Disable profiling and instrumentation for VDSO code | ||
GCOV_PROFILE := n | ||
KCOV_INSTRUMENT := n | ||
KASAN_SANITIZE := n | ||
UBSAN_SANITIZE := n | ||
|
||
# Force dependency | ||
$(obj)/compat_vdso.o: $(obj)/compat_vdso.so | ||
|
||
# link rule for the .so file, .lds has to be first | ||
$(obj)/compat_vdso.so.dbg: $(obj)/compat_vdso.lds $(obj-compat_vdso) FORCE | ||
$(call if_changed,compat_vdsold) | ||
LDFLAGS_compat_vdso.so.dbg = -shared -S -soname=linux-compat_vdso.so.1 \ | ||
--build-id=sha1 --hash-style=both --eh-frame-hdr | ||
|
||
$(obj-compat_vdso): %.o: %.S FORCE | ||
$(call if_changed_dep,compat_vdsoas) | ||
|
||
# strip rule for the .so file | ||
$(obj)/%.so: OBJCOPYFLAGS := -S | ||
$(obj)/%.so: $(obj)/%.so.dbg FORCE | ||
$(call if_changed,objcopy) | ||
|
||
# Generate VDSO offsets using helper script | ||
gen-compat_vdsosym := $(srctree)/$(src)/gen_compat_vdso_offsets.sh | ||
quiet_cmd_compat_vdsosym = VDSOSYM $@ | ||
cmd_compat_vdsosym = $(NM) $< | $(gen-compat_vdsosym) | LC_ALL=C sort > $@ | ||
|
||
include/generated/compat_vdso-offsets.h: $(obj)/compat_vdso.so.dbg FORCE | ||
$(call if_changed,compat_vdsosym) | ||
|
||
# actual build commands | ||
# The DSO images are built using a special linker script | ||
# Make sure only to export the intended __compat_vdso_xxx symbol offsets. | ||
quiet_cmd_compat_vdsold = VDSOLD $@ | ||
cmd_compat_vdsold = $(COMPAT_LD) $(ld_flags) $(COMPAT_LD_FLAGS) -T $(filter-out FORCE,$^) -o $@.tmp && \ | ||
$(OBJCOPY) $(patsubst %, -G __compat_vdso_%, $(compat_vdso-syms)) $@.tmp $@ && \ | ||
rm $@.tmp | ||
|
||
# actual build commands | ||
quiet_cmd_compat_vdsoas = VDSOAS $@ | ||
cmd_compat_vdsoas = $(COMPAT_CC) $(a_flags) $(COMPAT_CC_FLAGS) -c -o $@ $< | ||
|
||
# install commands for the unstripped file | ||
quiet_cmd_compat_vdso_install = INSTALL $@ | ||
cmd_compat_vdso_install = cp $(obj)/$@.dbg $(MODLIB)/compat_vdso/$@ | ||
|
||
compat_vdso.so: $(obj)/compat_vdso.so.dbg | ||
@mkdir -p $(MODLIB)/compat_vdso | ||
$(call cmd,compat_vdso_install) | ||
|
||
compat_vdso_install: compat_vdso.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
||
#define vdso_start compat_vdso_start | ||
#define vdso_end compat_vdso_end | ||
|
||
#define __VDSO_PATH "arch/riscv/kernel/compat_vdso/compat_vdso.so" | ||
|
||
#include "../vdso/vdso.S" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
||
#include "../vdso/vdso.lds.S" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
||
#include "../vdso/flush_icache.S" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
LC_ALL=C | ||
sed -n -e 's/^[0]\+\(0[0-9a-fA-F]*\) . \(__vdso_[a-zA-Z0-9_]*\)$/\#define compat\2_offset\t0x\1/p' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
||
#include "../vdso/getcpu.S" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
||
#include "../vdso/note.S" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
||
#include "../vdso/rt_sigreturn.S" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters