On 23/11/2023 15:35, Aditya Deshpande wrote:
Hello,
This patch series implements a pure-capability vDSO which purecap userspace applications can directly use. It also fixes the vDSO selftests so that they can be built as purecap binaries, therefore allowing the new purecap vDSO to be tested. The existing aarch64 vDSO implementation is unchanged - it has simply been redefined as the compat vDSO. Therefore, processes using both the standard and purecap ABIs will have a vDSO to use.
Main changes in v3:
- Series has now grown to 5 patches. The first patch duplicates an unmerged upstream change (I forgot to include this in v2). Once it is merged upstream and the fork is rebased this patch may disappear from the log.
- Patch 3 adds some purecap-only code to linux/types.h to enable the vDSO, which uses kernel headers, to be built for purecap.
- v2 removed the vdso-purecap/ directory, as it needlessly replicated the code in vdso/. vdso/Makefile was instead changed so it could build both vDSOs (regular and purecap) from the same source. This is achieved by calling the Makefile twice with BUILD_PURECAP_VDSO=[y/n]. v3 further changes this Makefile; now all purecap generated files are placed in a separate subdirectory (vdso/purecap.)
Aditya Deshpande (5): selftests: vDSO: fix Makefile so that it uses lib.mk correctly selftests/vDSO: Add support for purecap vDSO testing linux/types.h: Redefine uintptr_t to __uintcap_t under purecap arm64: vdso: Build a pure-capability vDSO arm64: vDSO: Provide a purecap vDSO to userspace purecap programs
Now that the CI is back on track, I have merged these patches in next, thanks!
I made a few amendments along the way:
- Part of patch 4 is replaced by "linux/compiler.h: Replace unsigned long with uintptr_t" (posted by Aditya in reply to this series, as I suggested to split this change out of patch 4). - Patch 4, vDSO Makefile: * Fixed the paths of files in the targets variable in purecap, so that files only get rebuilt when needed. * Renamed the installed purecap vDSO to vdso-purecap.so (this is installed under $INSTALL_MOD_PATH when running make vdso_install). * Moved the purecap/vgettimeofday.o CFLAGS / CFLAGS_REMOVE definition after the final assignment to CFLAGS_vgettimeofday.o for clarity. - Patch 5: fixed the signal trampoline offset in purecap by including the appropriate generated header in signal.c (the only place a generated offset is used). The alternative, renaming the generated macro in purecap, turned out to be too complicated to be worth it. - Patch 5: amended the bootstrap Morello kselftest so that it expects AT_SYSINFO_EHDR to be set to a valid capability. - Minor whitespace and comments tweaks, and update to patch 5's commit message.
With that, the Morello kselftests are happy and so is LTP. Worth noting that the clock_gettime04 LTP test still doesn't see the vDSO, because libltpvdso uses getauxval(AT_SYSINFO_EHDR), which returns an error as AT_SYSINFO_EHDR is a pointer (i.e. getauxptr(AT_SYSINFO_EHDR) must be used in purecap). This means that clock_gettime04 still passes, even though libltpvdso needs to be modified for purecap (pointer manipulation, etc.).
Kevin
arch/arm64/Makefile | 6 ++ arch/arm64/include/asm/elf.h | 24 +++++--- arch/arm64/include/asm/vdso.h | 1 + arch/arm64/include/asm/vdso/gettimeofday.h | 58 +++++++++++++++--- arch/arm64/kernel/Makefile | 2 + arch/arm64/kernel/vdso-purecap-wrap.S | 22 +++++++ arch/arm64/kernel/vdso.c | 55 ++++++++++++++++- arch/arm64/kernel/vdso/Makefile | 60 ++++++++++++++++--- fs/compat_binfmt_elf.c | 24 ++++---- include/linux/compiler.h | 3 +- include/linux/types.h | 4 ++ tools/testing/selftests/vDSO/Makefile | 16 ++--- tools/testing/selftests/vDSO/parse_vdso.h | 16 +++++ tools/testing/selftests/vDSO/vdso_test_abi.c | 5 +- .../selftests/vDSO/vdso_test_gettimeofday.c | 6 +- 15 files changed, 252 insertions(+), 50 deletions(-) create mode 100644 arch/arm64/kernel/vdso-purecap-wrap.S