From: Deepak Gupta <debug@rivosinc.com>
To: qemu-riscv@nongnu.org, qemu-devel@nongnu.org, jim.shu@sifive.com,
andy.chiu@sifive.com, jesse.huang@sifive.com,
kito.cheng@sifive.com
Cc: palmer@dabbelt.com, Alistair.Francis@wdc.com, laurent@vivier.eu,
bmeng.cn@gmail.com, liwei1518@gmail.com,
dbarboza@ventanamicro.com, zhiwei_liu@linux.alibaba.com,
Deepak Gupta <debug@rivosinc.com>
Subject: [PATCH 23/24] linux-user: Add RISC-V zicfilp support in VDSO
Date: Thu, 25 Jul 2024 16:46:12 -0700 [thread overview]
Message-ID: <20240725234614.3850142-24-debug@rivosinc.com> (raw)
In-Reply-To: <20240725234614.3850142-1-debug@rivosinc.com>
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.shu@sifive.com>
Signed-off-by: Deepak Gupta <debug@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`TfVcovANRA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m|=HV73ypSJ_~
z<O2|fJRcb5i6e}!D;#fWJy$=lXD}<ltX0Kge2VdkkAIHwS3Z8Z)X;Lmd_cFEA<8=5
z3>{6VtH|v2)99wz{?bNB7jqeM)ifG;D@Xo~6$*{frvJ5_f9#bOCr+W3+&Ha4qi9He
z`aFGZFXXa!K@5`_!U4;{c`Jrnfi7ItJ4G3v>4^@ll@B7dM5F9h@S~p4LQq9vBn42^
z6PgYw(n%q6kkCx1d)fjA=g8j=lUShHyjQ?)jZ>c0vk;|y1vK_lb*f|98Q<a9Dg1<I
z(5|Y4cw(IS{)}HEJVyHiUb5rMGWY&0-6zKXYT_~D{_L$X?yrs_<E<JZU&?zLa(}9t
z4i8YNglu-<^o7ju<$*=$zE^r^y%V@%J9s_Z7E|F+dJrFlk6Efc>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
next prev parent reply other threads:[~2024-07-25 23:48 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 23:45 [PATCH 00/24] riscv support for control flow integrity extensions Deepak Gupta
2024-07-25 23:45 ` [PATCH 01/24] target/riscv: Add zicfilp extension Deepak Gupta
2024-07-25 23:45 ` [PATCH 02/24] target/riscv: Introduce elp state and enabling controls for zicfilp Deepak Gupta
2024-07-25 23:45 ` [PATCH 03/24] target/riscv: save and restore elp state on priv transitions Deepak Gupta
2024-07-25 23:45 ` [PATCH 04/24] target/riscv: additional code information for sw check Deepak Gupta
2024-07-25 23:45 ` [PATCH 05/24] target/riscv: tracking indirect branches (fcfi) for zicfilp Deepak Gupta
2024-07-25 23:45 ` [PATCH 06/24] target/riscv: zicfilp `lpad` impl and branch tracking Deepak Gupta
2024-07-25 23:45 ` [PATCH 07/24] disas/riscv: enabled `lpad` disassembly Deepak Gupta
2024-07-25 23:45 ` [PATCH 08/24] linux-user/syscall: introduce prctl for indirect branch tracking Deepak Gupta
2024-07-25 23:45 ` [PATCH 09/24] linux-user/riscv: implement indirect branch tracking prctls Deepak Gupta
2024-07-25 23:45 ` [PATCH 10/24] target/riscv: Add zicfiss extension Deepak Gupta
2024-07-25 23:46 ` [PATCH 11/24] target/riscv: introduce ssp and enabling controls for zicfiss Deepak Gupta
2024-07-25 23:46 ` [PATCH 12/24] target/riscv: tb flag for shadow stack instructions Deepak Gupta
2024-07-25 23:46 ` [PATCH 13/24] target/riscv: implement zicfiss instructions Deepak Gupta
2024-07-25 23:46 ` [PATCH 14/24] target/riscv: compressed encodings for sspush and sspopchk Deepak Gupta
2024-07-25 23:46 ` [PATCH 15/24] target/riscv: mmu changes for zicfiss shadow stack protection Deepak Gupta
2024-07-25 23:46 ` [PATCH 16/24] target/riscv: shadow stack mmu index for shadow stack instructions Deepak Gupta
2024-07-25 23:46 ` [PATCH 17/24] linux-user/syscall: introduce prctl for shadow stack enable/disable Deepak Gupta
2024-07-25 23:46 ` [PATCH 18/24] linux-user/riscv: setup/teardown zicfiss shadow stack for qemu-user Deepak Gupta
2024-07-25 23:46 ` [PATCH 19/24] disas/riscv: enable disassembly for zicfiss instructions Deepak Gupta
2024-07-25 23:46 ` [PATCH 20/24] disas/riscv: enable disassembly for compressed sspush/sspopchk Deepak Gupta
2024-07-25 23:46 ` [PATCH 21/24] target/riscv: add trace-hooks for each case of sw-check exception Deepak Gupta
2024-07-25 23:46 ` [PATCH 22/24] linux-user: permit RISC-V CFI dynamic entry in VDSO Deepak Gupta
2024-07-25 23:46 ` Deepak Gupta [this message]
2024-07-25 23:46 ` [PATCH 24/24] linux-user/riscv: Adding zicfiss/lp extension in hwprobe syscall Deepak Gupta
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240725234614.3850142-24-debug@rivosinc.com \
--to=debug@rivosinc.com \
--cc=Alistair.Francis@wdc.com \
--cc=andy.chiu@sifive.com \
--cc=bmeng.cn@gmail.com \
--cc=dbarboza@ventanamicro.com \
--cc=jesse.huang@sifive.com \
--cc=jim.shu@sifive.com \
--cc=kito.cheng@sifive.com \
--cc=laurent@vivier.eu \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).