[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RISU PATCH v2 1/5] risu: Use alternate stack
From: |
Song Gao |
Subject: |
[RISU PATCH v2 1/5] risu: Use alternate stack |
Date: |
Thu, 13 Oct 2022 16:28:50 +0800 |
We can use alternate stack, so that we can use sp register as intput/ouput
register.
I had tested aarch64/LoongArch architecture.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Song Gao <gaosong@loongson.cn>
---
risu.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/risu.c b/risu.c
index 1c096a8..714074e 100644
--- a/risu.c
+++ b/risu.c
@@ -329,7 +329,7 @@ static void set_sigill_handler(void (*fn) (int, siginfo_t
*, void *))
memset(&sa, 0, sizeof(struct sigaction));
sa.sa_sigaction = fn;
- sa.sa_flags = SA_SIGINFO;
+ sa.sa_flags = SA_SIGINFO | SA_ONSTACK;
sigemptyset(&sa.sa_mask);
if (sigaction(SIGILL, &sa, 0) != 0) {
perror("sigaction");
@@ -550,6 +550,7 @@ int main(int argc, char **argv)
char *trace_fn = NULL;
struct option *longopts;
char *shortopts;
+ stack_t ss;
longopts = setup_options(&shortopts);
@@ -617,6 +618,19 @@ int main(int argc, char **argv)
load_image(imgfile);
+ /* create alternate stack */
+ ss.ss_sp = malloc(SIGSTKSZ);
+ if (ss.ss_sp == NULL) {
+ perror("malloc");
+ exit(EXIT_FAILURE);
+ }
+ ss.ss_size = SIGSTKSZ;
+ ss.ss_flags = 0;
+ if (sigaltstack(&ss, NULL) == -1) {
+ perror("sigaltstac");
+ exit(EXIT_FAILURE);
+ }
+
/* E.g. select requested SVE vector length. */
arch_init();
--
2.31.1
- [RISU PATCH v2 0/5] Add LoongArch architectures support, Song Gao, 2022/10/13
- [RISU PATCH v2 5/5] loongarch: Add block 'safefloat' and nanbox_s(), Song Gao, 2022/10/13
- [RISU PATCH v2 4/5] loongarch: Add risufile with loongarch instructions, Song Gao, 2022/10/13
- [RISU PATCH v2 1/5] risu: Use alternate stack,
Song Gao <=
- [RISU PATCH v2 2/5] loongarch: Add LoongArch basic test support, Song Gao, 2022/10/13
- [RISU PATCH v2 3/5] loongarch: Implement risugen module, Song Gao, 2022/10/13
- Re: [RISU PATCH v2 0/5] Add LoongArch architectures support, Peter Maydell, 2022/10/20