Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 09 Sep 2020 16:08:22 -0700 (PDT)
From: Palmer Dabbelt <>
To:, Arnd Bergmann <>
Subject:     Re: riscv32 v2

On Wed, 09 Sep 2020 14:36:44 PDT (-0700), wrote:
> On Wed, Sep 09, 2020 at 02:28:55PM -0700, Palmer Dabbelt wrote:
>> On Wed, 09 Sep 2020 13:28:27 PDT (-0700), wrote:
>> >On Fri, Sep 04, 2020 at 01:48:19AM -0400, Stefan O'Rear wrote:
>> >>+#define VDSO_USEFUL
>> >>+/* We don't have a clock_gettime function.
>> >>+#define VDSO_CGT_SYM "__vdso_clock_gettime"
>> >>+#define VDSO_CGT_VER "LINUX_2.6" */
>> >>--
>> >>2.25.4
>> >>
>> >
>> >Is this correct? I see the comment is just copied from riscv64, but it
>> >seems wrong there, and here too. Also, is the vdso function named
>> >"clock_gettime" or "clock_gettime64" for riscv32? Or is there none at
>> >all and this macro just wrong?
>> Looks like we don't have __vdso_clock_gettime on rv32 but we do have one on
>> rv64.  glibc doesn't have the clock VDSO calls on rv32.
>> I'm not opposed to adding some sort of clock-related VDSO calls on rv32, but it
>> looks like doing so will require some thought.  Maybe it's best to wait on that
>> so we don't hold up the initial port?
> Possible addition of vdso clock_gettime isn't a blocker for moving
> forward with the musl port, but syscall_arch.h should accurately
> describe what's available and should not attempt to use vdso before
> it's a public kernel interface (e.g. resolving the question of what
> the function name will be). So I think it should be removed for now.

Sorry if that was confusing, but I definitely agree.

I guess my point was that the lack of VDSO clock functions on rv32 was probably
an oversight, but one that shouldn't block the port.  We definitely can't just
make up a kernel interface, particularly as the reason we don't have these on
rv32 is because the generic versions of the functions we're using don't appear
to run on 32-bit targets.

That probably means there's some more subtle issue, though TBH I don't know
enough about the 64-bit-ification of time_t for it to just jump out at me.  I
don't want to derail the thread too much, but I tried the obvious thing

    diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
    index 33dde87218dd..1cf24a8f76c4 100644
    --- a/arch/riscv/Kconfig
    +++ b/arch/riscv/Kconfig
    @@ -65,7 +65,7 @@ config RISCV
     	select HAVE_EBPF_JIT if MMU
     	select HAVE_GCC_PLUGINS
    -	select HAVE_GENERIC_VDSO if MMU && 64BIT
    +	select HAVE_GENERIC_VDSO if MMU
     	select HAVE_PCI
     	select HAVE_PERF_EVENTS
     	select HAVE_PERF_REGS
    diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
    index 478e7338ddc1..10f7a07ce85a 100644
    --- a/arch/riscv/kernel/vdso/Makefile
    +++ b/arch/riscv/kernel/vdso/Makefile
    @@ -7,9 +7,7 @@ ARCH_REL_TYPE_ABS := R_RISCV_32|R_RISCV_64|R_RISCV_JUMP_SLOT
     include $(srctree)/lib/vdso/Makefile
     # Symbols present in the vdso
     vdso-syms  = rt_sigreturn
    -ifdef CONFIG_64BIT
     vdso-syms += vgettimeofday
     vdso-syms += getcpu
     vdso-syms += flush_icache

and it doesn't build.  I've added Arnd, who might have a better idea of what's
going on.  Whatever happens, I think the best bet is to just drop the clock
functions (specifically __vdso_{clock_gettime,gettimeofday,clock_getres}) from
the rv32 port right now.

> But VDSO_USEFUL must be kept if we want to support the vdso icache
> flush function (is that actually supported on rv32 either? if not it
> should be made conditional on rv64 in src/linux/cache.c.

Yes, we have __vdso_flush_icache on rv32 and as far as I know it should work
fine (I guess QEMU isn't really going to find fence.i issues, but this
interface in particular is quite simple).  There's no way to build a working
system without some kernel-based fence.i mechanism, and IIRC we added the VDSO
entry at the same time as the syscall so it should always work itself out
(though we do have the syscall-based fallback in glibc)).  One of my working
directories reports

    $ riscv64-linux-gnu-objdump -d arch/riscv/kernel/vdso/
    arch/riscv/kernel/vdso/     file format elf32-littleriscv
    Disassembly of section .text:
    00000800 <__vdso_rt_sigreturn@@LINUX_4.15>:
     800:	08b00893          	li	a7,139
     804:	00000073          	ecall
     808:	0000                	unimp
    0000080c <__vdso_getcpu@@LINUX_4.15>:
     80c:	0a800893          	li	a7,168
     810:	00000073          	ecall
     814:	8082                	ret
    00000818 <__vdso_flush_icache@@LINUX_4.15>:
     818:	10300893          	li	a7,259
     81c:	00000073          	ecall
     820:	8082                	ret

when built for rv32 (despite the rv64 objdump command).

> Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.