Add zicfilp support in VDSO. VDSO functions need lpad instruction so that userspace could call this function when landing pad extension is enabled. This solution only works when toolchain always use landing pad label 1.
Otherwise, If extension is not enabled, lpad instructions will be lui instructions with rd=x0 (which is nop). Prebuilt VDSO is still compatible with RISC-V core w/o zicfilp extension. Signed-off-by: Jim Shu <jim....@sifive.com> Signed-off-by: Deepak Gupta <de...@rivosinc.com> --- linux-user/riscv/vdso-64.so | Bin 3944 -> 4128 bytes linux-user/riscv/vdso.S | 50 ++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/linux-user/riscv/vdso-64.so b/linux-user/riscv/vdso-64.so index ae49f5b043b5941b9d304a056c2b50c185f413b0..cd7f2fa7bdb811af6be2dcc3fb9601b66e3d1c81 100755 GIT binary patch delta 1345 zcmah}O=uHA6rRa8*`3W#v-vSWgUvy(QL#}%mV&j76iPuQBHAj2(ng|zmM)E!P>`g> ziy+eQP!K%yD2kv2Jb7q5_;(V#<f8T>2zrPIp$E0T*_|nLFFu%g^L_K)%k2BfxBcts zwSKzU%uIMvDl|QN=xp<WSxBkG7O6?t!5&mSxH{CqZapIS5in@ND0&^M9SwtYn2kCl z8HHvbTIYee+1S|&oZsNl6@EhD=NK-I`TfVcovANRA6MVpdHd;BIWn<tz;C}Zg!f#o zJIeOs$1M@)*Wc|0j<Y-<ig*^WdPuKL`0SmKqyiq##X<Z^OE9+jz3uoXh2tNAc{aFo z1twr<QCRm}!4()%@Eu+GDUKoG>4}g4*$}@d(n<~qepB*LP!3)Siz)<!cU)L~kXC{} zEqLOxKPmXG%f8cUD^<!G_?jY`yo4d|;kbMX*GF*m<L!yoO|MGplL+N?0uP|A=~d*e zHVAQWSlx}&F5K8<AH_U!-zdg#{GVyuzc7Q_Vx?MIB6I?e-o>SSu5ui{`}Ri4l{qVG z<))V_rE;ZO#UoHP&Zd{==Wom%v$EK`eUMXAv;*hV1Wm$<8dtCYs1tO{Mm~~-=ZGxa z<BEpgVQ6uMk)*A4Qbe7gH5*}xpr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6Efc>H&Nc9x~NiEBHO^ znyS~TI1+KqRtw@1d8*G+xEXP+8h24Gh(97jmTIbc5YN~{ri!eCOSWrHa-1h|({^L3 qZ<NlUh`Ofw^Ne9S>WX$;ijJCP(|ap?q2JVD+=;fE1#ar668QsJ{<Wt7 diff --git a/linux-user/riscv/vdso.S b/linux-user/riscv/vdso.S index c37275233a..d0817c58ce 100644 --- a/linux-user/riscv/vdso.S +++ b/linux-user/riscv/vdso.S @@ -14,6 +14,52 @@ #endif #include "vdso-asmoffset.h" +/* GNU_PROPERTY_RISCV64_* macros from elf.h for use in asm code. */ +#define FEATURE_1_AND 0xc0000000 + +#define GNU_PROPERTY(type, value) \ + .section .note.gnu.property, "a"; \ + .p2align 3; \ + .word 4; \ + .word 16; \ + .word 5; \ + .asciz "GNU"; \ + .word type; \ + .word 4; \ + .word value; \ + .word 0; \ + .text + +/* Add GNU property note with the supported features to all asm code + where sysdep.h is included. */ +#undef __VALUE_FOR_FEATURE_1_AND +#if defined (__riscv_zicfilp) || defined (__riscv_zicfiss) +# if defined (__riscv_zicfilp) +# if defined (__riscv_zicfiss) +# define __VALUE_FOR_FEATURE_1_AND 0x3 +# else +# define __VALUE_FOR_FEATURE_1_AND 0x1 +# endif +# else +# if defined (__riscv_zicfiss) +# define __VALUE_FOR_FEATURE_1_AND 0x2 +# else +# error "What?" +# endif +# endif +#endif + +#if defined (__VALUE_FOR_FEATURE_1_AND) +GNU_PROPERTY (FEATURE_1_AND, __VALUE_FOR_FEATURE_1_AND) +#endif +#undef __VALUE_FOR_FEATURE_1_AND + +#ifdef __riscv_zicfilp +# define LPAD lpad 1 +#else +# define LPAD +#endif + .text .macro endf name @@ -29,6 +75,7 @@ .macro vdso_syscall name, nr \name: + LPAD raw_syscall \nr ret endf \name @@ -36,6 +83,7 @@ endf \name __vdso_gettimeofday: .cfi_startproc + LPAD #ifdef __NR_gettimeofday raw_syscall __NR_gettimeofday ret @@ -86,6 +134,7 @@ vdso_syscall __vdso_getcpu, __NR_getcpu __vdso_flush_icache: /* qemu does not need to flush the icache */ + LPAD li a0, 0 ret endf __vdso_flush_icache @@ -181,6 +230,7 @@ endf __vdso_flush_icache nop __vdso_rt_sigreturn: + LPAD raw_syscall __NR_rt_sigreturn endf __vdso_rt_sigreturn -- 2.44.0