1 | The following changes since commit 67e41fe0cfb62e6cdfa659f0155417d17e5274ea: | 1 | The following changes since commit 79b677d658d3d35e1e776826ac4abb28cdce69b8: |
---|---|---|---|
2 | 2 | ||
3 | Merge tag 'pull-ppc-20220104' of https://github.com/legoater/qemu into staging (2022-01-04 07:23:27 -0800) | 3 | Merge tag 'net-pull-request' of https://github.com/jasowang/qemu into staging (2023-02-21 11:28:31 +0000) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20220104 | 7 | https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20230221 |
8 | 8 | ||
9 | for you to fetch changes up to d7478d4229f0a2b2817a55487e6b17081099fae4: | 9 | for you to fetch changes up to dbd672c87f19949bb62bfb1fb3a97b9729fd7560: |
10 | 10 | ||
11 | common-user: Fix tail calls to safe_syscall_set_errno_tail (2022-01-04 15:41:03 -0800) | 11 | sysemu/os-win32: fix setjmp/longjmp on windows-arm64 (2023-02-21 13:45:48 -1000) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Fix for safe_syscall_base. | 14 | tcg: Allow first half of insn in ram, and second half in mmio |
15 | Fix for folding of vector add/sub. | 15 | linux-user/sparc: SIGILL for unknown trap vectors |
16 | Fix build on loongarch64 with gcc 8. | 16 | linux-user/microblaze: SIGILL for privileged insns |
17 | Remove decl for qemu_run_machine_init_done_notifiers. | 17 | linux-user: Fix deadlock while exiting due to signal |
18 | target/microblaze: Add gdbstub xml | ||
19 | util: Adjust cacheflush for windows-arm64 | ||
20 | include/sysemu/os-win32: Adjust setjmp/longjmp for windows-arm64 | ||
18 | 21 | ||
19 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
20 | Philippe Mathieu-Daudé (1): | 23 | Ilya Leoshkevich (3): |
21 | linux-user: Fix trivial build error on loongarch64 hosts | 24 | linux-user: Always exit from exclusive state in fork_end() |
25 | cpus: Make {start,end}_exclusive() recursive | ||
26 | linux-user/microblaze: Handle privileged exception | ||
22 | 27 | ||
23 | Richard Henderson (2): | 28 | Pierrick Bouvier (2): |
24 | tcg/optimize: Fix folding of vector ops | 29 | util/cacheflush: fix cache on windows-arm64 |
25 | common-user: Fix tail calls to safe_syscall_set_errno_tail | 30 | sysemu/os-win32: fix setjmp/longjmp on windows-arm64 |
26 | 31 | ||
27 | Xiaoyao Li (1): | 32 | Richard Henderson (3): |
28 | sysemu: Cleanup qemu_run_machine_init_done_notifiers() | 33 | accel/tcg: Allow the second page of an instruction to be MMIO |
34 | linux-user/sparc: Raise SIGILL for all unhandled software traps | ||
35 | target/microblaze: Add gdbstub xml | ||
29 | 36 | ||
30 | include/sysemu/sysemu.h | 1 - | 37 | include/hw/core/cpu.h | 4 +- |
31 | linux-user/host/loongarch64/host-signal.h | 4 +-- | 38 | include/sysemu/os-win32.h | 28 ++++++++++-- |
32 | tcg/optimize.c | 49 +++++++++++++++++++++++------- | 39 | target/microblaze/cpu.h | 2 + |
33 | common-user/host/i386/safe-syscall.inc.S | 1 + | 40 | accel/tcg/translator.c | 12 +++++- |
34 | common-user/host/mips/safe-syscall.inc.S | 1 + | 41 | cpus-common.c | 12 +++++- |
35 | common-user/host/x86_64/safe-syscall.inc.S | 1 + | 42 | linux-user/main.c | 10 +++-- |
36 | 6 files changed, 42 insertions(+), 15 deletions(-) | 43 | linux-user/microblaze/cpu_loop.c | 10 ++++- |
37 | 44 | linux-user/sparc/cpu_loop.c | 8 ++++ | |
45 | linux-user/syscall.c | 1 + | ||
46 | target/microblaze/cpu.c | 7 ++- | ||
47 | target/microblaze/gdbstub.c | 51 ++++++++++++++++------ | ||
48 | util/cacheflush.c | 14 ++++-- | ||
49 | configs/targets/microblaze-linux-user.mak | 1 + | ||
50 | configs/targets/microblaze-softmmu.mak | 1 + | ||
51 | configs/targets/microblazeel-linux-user.mak | 1 + | ||
52 | configs/targets/microblazeel-softmmu.mak | 1 + | ||
53 | gdb-xml/microblaze-core.xml | 67 +++++++++++++++++++++++++++++ | ||
54 | gdb-xml/microblaze-stack-protect.xml | 12 ++++++ | ||
55 | meson.build | 21 +++++++++ | ||
56 | 19 files changed, 229 insertions(+), 34 deletions(-) | ||
57 | create mode 100644 gdb-xml/microblaze-core.xml | ||
58 | create mode 100644 gdb-xml/microblaze-stack-protect.xml | diff view generated by jsdifflib |
1 | For the ABIs in which the syscall return register is not | 1 | If an instruction straddles a page boundary, and the first page |
---|---|---|---|
2 | also the first function argument register, move the errno | 2 | was ram, but the second page was MMIO, we would abort. Handle |
3 | value into the correct place. | 3 | this as if both pages are MMIO, by setting the ram_addr_t for |
4 | the first page to -1. | ||
4 | 5 | ||
5 | Fixes: a3310c0397e2 ("linux-user: Move syscall error detection into safe_syscall_base") | 6 | Reported-by: Sid Manning <sidneym@quicinc.com> |
6 | Reported-by: Laurent Vivier <laurent@vivier.eu> | 7 | Reported-by: Jørgen Hansen <Jorgen.Hansen@wdc.com> |
7 | Tested-by: Laurent Vivier <laurent@vivier.eu> | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-Id: <20220104190454.542225-1-richard.henderson@linaro.org> | ||
11 | --- | 10 | --- |
12 | common-user/host/i386/safe-syscall.inc.S | 1 + | 11 | accel/tcg/translator.c | 12 ++++++++++-- |
13 | common-user/host/mips/safe-syscall.inc.S | 1 + | 12 | 1 file changed, 10 insertions(+), 2 deletions(-) |
14 | common-user/host/x86_64/safe-syscall.inc.S | 1 + | ||
15 | 3 files changed, 3 insertions(+) | ||
16 | 13 | ||
17 | diff --git a/common-user/host/i386/safe-syscall.inc.S b/common-user/host/i386/safe-syscall.inc.S | 14 | diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/common-user/host/i386/safe-syscall.inc.S | 16 | --- a/accel/tcg/translator.c |
20 | +++ b/common-user/host/i386/safe-syscall.inc.S | 17 | +++ b/accel/tcg/translator.c |
21 | @@ -XXX,XX +XXX,XX @@ safe_syscall_end: | 18 | @@ -XXX,XX +XXX,XX @@ static void *translator_access(CPUArchState *env, DisasContextBase *db, |
22 | pop %ebp | 19 | if (host == NULL) { |
23 | .cfi_adjust_cfa_offset -4 | 20 | tb_page_addr_t phys_page = |
24 | .cfi_restore ebp | 21 | get_page_addr_code_hostp(env, base, &db->host_addr[1]); |
25 | + mov %eax, (%esp) | 22 | - /* We cannot handle MMIO as second page. */ |
26 | jmp safe_syscall_set_errno_tail | 23 | - assert(phys_page != -1); |
27 | 24 | + | |
28 | .cfi_endproc | 25 | + /* |
29 | diff --git a/common-user/host/mips/safe-syscall.inc.S b/common-user/host/mips/safe-syscall.inc.S | 26 | + * If the second page is MMIO, treat as if the first page |
30 | index XXXXXXX..XXXXXXX 100644 | 27 | + * was MMIO as well, so that we do not cache the TB. |
31 | --- a/common-user/host/mips/safe-syscall.inc.S | 28 | + */ |
32 | +++ b/common-user/host/mips/safe-syscall.inc.S | 29 | + if (unlikely(phys_page == -1)) { |
33 | @@ -XXX,XX +XXX,XX @@ safe_syscall_end: | 30 | + tb_set_page_addr0(tb, -1); |
34 | 1: USE_ALT_CP(t0) | 31 | + return NULL; |
35 | SETUP_GPX(t1) | 32 | + } |
36 | SETUP_GPX64(t0, t1) | 33 | + |
37 | + move a0, v0 | 34 | tb_set_page_addr1(tb, phys_page); |
38 | PTR_LA t9, safe_syscall_set_errno_tail | 35 | #ifdef CONFIG_USER_ONLY |
39 | jr t9 | 36 | page_protect(end); |
40 | |||
41 | diff --git a/common-user/host/x86_64/safe-syscall.inc.S b/common-user/host/x86_64/safe-syscall.inc.S | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/common-user/host/x86_64/safe-syscall.inc.S | ||
44 | +++ b/common-user/host/x86_64/safe-syscall.inc.S | ||
45 | @@ -XXX,XX +XXX,XX @@ safe_syscall_end: | ||
46 | 1: pop %rbp | ||
47 | .cfi_def_cfa_offset 8 | ||
48 | .cfi_restore rbp | ||
49 | + mov %eax, %edi | ||
50 | jmp safe_syscall_set_errno_tail | ||
51 | .cfi_endproc | ||
52 | |||
53 | -- | 37 | -- |
54 | 2.25.1 | 38 | 2.34.1 |
55 | 39 | ||
56 | 40 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The linux kernel's trap tables vector all unassigned trap | ||
2 | numbers to BAD_TRAP, which then raises SIGILL. | ||
1 | 3 | ||
4 | Tested-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
5 | Reported-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | linux-user/sparc/cpu_loop.c | 8 ++++++++ | ||
9 | 1 file changed, 8 insertions(+) | ||
10 | |||
11 | diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/linux-user/sparc/cpu_loop.c | ||
14 | +++ b/linux-user/sparc/cpu_loop.c | ||
15 | @@ -XXX,XX +XXX,XX @@ void cpu_loop (CPUSPARCState *env) | ||
16 | cpu_exec_step_atomic(cs); | ||
17 | break; | ||
18 | default: | ||
19 | + /* | ||
20 | + * Most software trap numbers vector to BAD_TRAP. | ||
21 | + * Handle anything not explicitly matched above. | ||
22 | + */ | ||
23 | + if (trapnr >= TT_TRAP && trapnr <= TT_TRAP + 0x7f) { | ||
24 | + force_sig_fault(TARGET_SIGILL, ILL_ILLTRP, env->pc); | ||
25 | + break; | ||
26 | + } | ||
27 | fprintf(stderr, "Unhandled trap: 0x%x\n", trapnr); | ||
28 | cpu_dump_state(cs, stderr, 0); | ||
29 | exit(EXIT_FAILURE); | ||
30 | -- | ||
31 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Xiaoyao Li <xiaoyao.li@intel.com> | 1 | From: Ilya Leoshkevich <iii@linux.ibm.com> |
---|---|---|---|
2 | 2 | ||
3 | Remove qemu_run_machine_init_done_notifiers() since no implementation | 3 | fork()ed processes currently start with |
4 | and user. | 4 | current_cpu->in_exclusive_context set, which is, strictly speaking, not |
5 | correct, but does not cause problems (even assertion failures). | ||
5 | 6 | ||
6 | Fixes: f66dc8737c9 ("vl: move all generic initialization out of vl.c") | 7 | With one of the next patches, the code begins to rely on this value, so |
7 | Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com> | 8 | fix it by always calling end_exclusive() in fork_end(). |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 9 | |
9 | Message-Id: <20220104024136.1433545-1-xiaoyao.li@intel.com> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
12 | Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
13 | Message-Id: <20230214140829.45392-2-iii@linux.ibm.com> | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | --- | 15 | --- |
12 | include/sysemu/sysemu.h | 1 - | 16 | linux-user/main.c | 10 ++++++---- |
13 | 1 file changed, 1 deletion(-) | 17 | linux-user/syscall.c | 1 + |
18 | 2 files changed, 7 insertions(+), 4 deletions(-) | ||
14 | 19 | ||
15 | diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h | 20 | diff --git a/linux-user/main.c b/linux-user/main.c |
16 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/sysemu/sysemu.h | 22 | --- a/linux-user/main.c |
18 | +++ b/include/sysemu/sysemu.h | 23 | +++ b/linux-user/main.c |
19 | @@ -XXX,XX +XXX,XX @@ extern bool qemu_uuid_set; | 24 | @@ -XXX,XX +XXX,XX @@ void fork_end(int child) |
20 | void qemu_add_exit_notifier(Notifier *notify); | 25 | } |
21 | void qemu_remove_exit_notifier(Notifier *notify); | 26 | qemu_init_cpu_list(); |
22 | 27 | gdbserver_fork(thread_cpu); | |
23 | -void qemu_run_machine_init_done_notifiers(void); | 28 | - /* qemu_init_cpu_list() takes care of reinitializing the |
24 | void qemu_add_machine_init_done_notifier(Notifier *notify); | 29 | - * exclusive state, so we don't need to end_exclusive() here. |
25 | void qemu_remove_machine_init_done_notifier(Notifier *notify); | 30 | - */ |
26 | 31 | } else { | |
32 | cpu_list_unlock(); | ||
33 | - end_exclusive(); | ||
34 | } | ||
35 | + /* | ||
36 | + * qemu_init_cpu_list() reinitialized the child exclusive state, but we | ||
37 | + * also need to keep current_cpu consistent, so call end_exclusive() for | ||
38 | + * both child and parent. | ||
39 | + */ | ||
40 | + end_exclusive(); | ||
41 | } | ||
42 | |||
43 | __thread CPUState *thread_cpu; | ||
44 | diff --git a/linux-user/syscall.c b/linux-user/syscall.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/linux-user/syscall.c | ||
47 | +++ b/linux-user/syscall.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, | ||
49 | cpu_clone_regs_parent(env, flags); | ||
50 | fork_end(0); | ||
51 | } | ||
52 | + g_assert(!cpu_in_exclusive_context(cpu)); | ||
53 | } | ||
54 | return ret; | ||
55 | } | ||
27 | -- | 56 | -- |
28 | 2.25.1 | 57 | 2.34.1 |
29 | 58 | ||
30 | 59 | diff view generated by jsdifflib |
1 | Bitwise operations are easy to fold, because the operation is | 1 | From: Ilya Leoshkevich <iii@linux.ibm.com> |
---|---|---|---|
2 | identical regardless of element size. But add and sub need | ||
3 | extra element size info that is not currently propagated. | ||
4 | 2 | ||
5 | Fixes: 2f9f08ba43d | 3 | Currently dying to one of the core_dump_signal()s deadlocks, because |
6 | Cc: qemu-stable@nongnu.org | 4 | dump_core_and_abort() calls start_exclusive() two times: first via |
7 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/799 | 5 | stop_all_tasks(), and then via preexit_cleanup() -> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | qemu_plugin_user_exit(). |
7 | |||
8 | There are a number of ways to solve this: resume after dumping core; | ||
9 | check cpu_in_exclusive_context() in qemu_plugin_user_exit(); or make | ||
10 | {start,end}_exclusive() recursive. Pick the last option, since it's | ||
11 | the most straightforward one. | ||
12 | |||
13 | Fixes: da91c1920242 ("linux-user: Clean up when exiting due to a signal") | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
16 | Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
17 | Message-Id: <20230214140829.45392-3-iii@linux.ibm.com> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 18 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | --- | 19 | --- |
11 | tcg/optimize.c | 49 ++++++++++++++++++++++++++++++++++++++----------- | 20 | include/hw/core/cpu.h | 4 ++-- |
12 | 1 file changed, 38 insertions(+), 11 deletions(-) | 21 | cpus-common.c | 12 ++++++++++-- |
22 | 2 files changed, 12 insertions(+), 4 deletions(-) | ||
13 | 23 | ||
14 | diff --git a/tcg/optimize.c b/tcg/optimize.c | 24 | diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h |
15 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/tcg/optimize.c | 26 | --- a/include/hw/core/cpu.h |
17 | +++ b/tcg/optimize.c | 27 | +++ b/include/hw/core/cpu.h |
18 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_constant_folding_2(TCGOpcode op, uint64_t x, uint64_t y) | 28 | @@ -XXX,XX +XXX,XX @@ struct CPUState { |
19 | CASE_OP_32_64(mul): | 29 | bool unplug; |
20 | return x * y; | 30 | bool crash_occurred; |
21 | 31 | bool exit_request; | |
22 | - CASE_OP_32_64(and): | 32 | - bool in_exclusive_context; |
23 | + CASE_OP_32_64_VEC(and): | 33 | + int exclusive_context_count; |
24 | return x & y; | 34 | uint32_t cflags_next_tb; |
25 | 35 | /* updates protected by BQL */ | |
26 | - CASE_OP_32_64(or): | 36 | uint32_t interrupt_request; |
27 | + CASE_OP_32_64_VEC(or): | 37 | @@ -XXX,XX +XXX,XX @@ void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data |
28 | return x | y; | 38 | */ |
29 | 39 | static inline bool cpu_in_exclusive_context(const CPUState *cpu) | |
30 | - CASE_OP_32_64(xor): | 40 | { |
31 | + CASE_OP_32_64_VEC(xor): | 41 | - return cpu->in_exclusive_context; |
32 | return x ^ y; | 42 | + return cpu->exclusive_context_count; |
33 | |||
34 | case INDEX_op_shl_i32: | ||
35 | @@ -XXX,XX +XXX,XX @@ static uint64_t do_constant_folding_2(TCGOpcode op, uint64_t x, uint64_t y) | ||
36 | case INDEX_op_rotl_i64: | ||
37 | return rol64(x, y & 63); | ||
38 | |||
39 | - CASE_OP_32_64(not): | ||
40 | + CASE_OP_32_64_VEC(not): | ||
41 | return ~x; | ||
42 | |||
43 | CASE_OP_32_64(neg): | ||
44 | return -x; | ||
45 | |||
46 | - CASE_OP_32_64(andc): | ||
47 | + CASE_OP_32_64_VEC(andc): | ||
48 | return x & ~y; | ||
49 | |||
50 | - CASE_OP_32_64(orc): | ||
51 | + CASE_OP_32_64_VEC(orc): | ||
52 | return x | ~y; | ||
53 | |||
54 | CASE_OP_32_64(eqv): | ||
55 | @@ -XXX,XX +XXX,XX @@ static bool fold_const2(OptContext *ctx, TCGOp *op) | ||
56 | return false; | ||
57 | } | 43 | } |
58 | 44 | ||
59 | +static bool fold_commutative(OptContext *ctx, TCGOp *op) | 45 | /** |
60 | +{ | 46 | diff --git a/cpus-common.c b/cpus-common.c |
61 | + swap_commutative(op->args[0], &op->args[1], &op->args[2]); | 47 | index XXXXXXX..XXXXXXX 100644 |
62 | + return false; | 48 | --- a/cpus-common.c |
63 | +} | 49 | +++ b/cpus-common.c |
50 | @@ -XXX,XX +XXX,XX @@ void start_exclusive(void) | ||
51 | CPUState *other_cpu; | ||
52 | int running_cpus; | ||
53 | |||
54 | + if (current_cpu->exclusive_context_count) { | ||
55 | + current_cpu->exclusive_context_count++; | ||
56 | + return; | ||
57 | + } | ||
64 | + | 58 | + |
65 | static bool fold_const2_commutative(OptContext *ctx, TCGOp *op) | 59 | qemu_mutex_lock(&qemu_cpu_list_lock); |
60 | exclusive_idle(); | ||
61 | |||
62 | @@ -XXX,XX +XXX,XX @@ void start_exclusive(void) | ||
63 | */ | ||
64 | qemu_mutex_unlock(&qemu_cpu_list_lock); | ||
65 | |||
66 | - current_cpu->in_exclusive_context = true; | ||
67 | + current_cpu->exclusive_context_count = 1; | ||
68 | } | ||
69 | |||
70 | /* Finish an exclusive operation. */ | ||
71 | void end_exclusive(void) | ||
66 | { | 72 | { |
67 | swap_commutative(op->args[0], &op->args[1], &op->args[2]); | 73 | - current_cpu->in_exclusive_context = false; |
68 | @@ -XXX,XX +XXX,XX @@ static bool fold_add(OptContext *ctx, TCGOp *op) | 74 | + current_cpu->exclusive_context_count--; |
69 | return false; | 75 | + if (current_cpu->exclusive_context_count) { |
70 | } | 76 | + return; |
71 | |||
72 | +/* We cannot as yet do_constant_folding with vectors. */ | ||
73 | +static bool fold_add_vec(OptContext *ctx, TCGOp *op) | ||
74 | +{ | ||
75 | + if (fold_commutative(ctx, op) || | ||
76 | + fold_xi_to_x(ctx, op, 0)) { | ||
77 | + return true; | ||
78 | + } | 77 | + } |
79 | + return false; | 78 | |
80 | +} | 79 | qemu_mutex_lock(&qemu_cpu_list_lock); |
81 | + | 80 | qatomic_set(&pending_cpus, 0); |
82 | static bool fold_addsub2(OptContext *ctx, TCGOp *op, bool add) | ||
83 | { | ||
84 | if (arg_is_const(op->args[2]) && arg_is_const(op->args[3]) && | ||
85 | @@ -XXX,XX +XXX,XX @@ static bool fold_sub_to_neg(OptContext *ctx, TCGOp *op) | ||
86 | return false; | ||
87 | } | ||
88 | |||
89 | -static bool fold_sub(OptContext *ctx, TCGOp *op) | ||
90 | +/* We cannot as yet do_constant_folding with vectors. */ | ||
91 | +static bool fold_sub_vec(OptContext *ctx, TCGOp *op) | ||
92 | { | ||
93 | - if (fold_const2(ctx, op) || | ||
94 | - fold_xx_to_i(ctx, op, 0) || | ||
95 | + if (fold_xx_to_i(ctx, op, 0) || | ||
96 | fold_xi_to_x(ctx, op, 0) || | ||
97 | fold_sub_to_neg(ctx, op)) { | ||
98 | return true; | ||
99 | @@ -XXX,XX +XXX,XX @@ static bool fold_sub(OptContext *ctx, TCGOp *op) | ||
100 | return false; | ||
101 | } | ||
102 | |||
103 | +static bool fold_sub(OptContext *ctx, TCGOp *op) | ||
104 | +{ | ||
105 | + return fold_const2(ctx, op) || fold_sub_vec(ctx, op); | ||
106 | +} | ||
107 | + | ||
108 | static bool fold_sub2(OptContext *ctx, TCGOp *op) | ||
109 | { | ||
110 | return fold_addsub2(ctx, op, false); | ||
111 | @@ -XXX,XX +XXX,XX @@ void tcg_optimize(TCGContext *s) | ||
112 | * Sorted alphabetically by opcode as much as possible. | ||
113 | */ | ||
114 | switch (opc) { | ||
115 | - CASE_OP_32_64_VEC(add): | ||
116 | + CASE_OP_32_64(add): | ||
117 | done = fold_add(&ctx, op); | ||
118 | break; | ||
119 | + case INDEX_op_add_vec: | ||
120 | + done = fold_add_vec(&ctx, op); | ||
121 | + break; | ||
122 | CASE_OP_32_64(add2): | ||
123 | done = fold_add2(&ctx, op); | ||
124 | break; | ||
125 | @@ -XXX,XX +XXX,XX @@ void tcg_optimize(TCGContext *s) | ||
126 | CASE_OP_32_64(sextract): | ||
127 | done = fold_sextract(&ctx, op); | ||
128 | break; | ||
129 | - CASE_OP_32_64_VEC(sub): | ||
130 | + CASE_OP_32_64(sub): | ||
131 | done = fold_sub(&ctx, op); | ||
132 | break; | ||
133 | + case INDEX_op_sub_vec: | ||
134 | + done = fold_sub_vec(&ctx, op); | ||
135 | + break; | ||
136 | CASE_OP_32_64(sub2): | ||
137 | done = fold_sub2(&ctx, op); | ||
138 | break; | ||
139 | -- | 81 | -- |
140 | 2.25.1 | 82 | 2.34.1 |
141 | 83 | ||
142 | 84 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Ilya Leoshkevich <iii@linux.ibm.com> | ||
1 | 2 | ||
3 | Follow what kernel's full_exception() is doing. | ||
4 | |||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
7 | Message-Id: <20230214140829.45392-4-iii@linux.ibm.com> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | --- | ||
10 | linux-user/microblaze/cpu_loop.c | 10 ++++++++-- | ||
11 | 1 file changed, 8 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/linux-user/microblaze/cpu_loop.c b/linux-user/microblaze/cpu_loop.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/linux-user/microblaze/cpu_loop.c | ||
16 | +++ b/linux-user/microblaze/cpu_loop.c | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | |||
19 | void cpu_loop(CPUMBState *env) | ||
20 | { | ||
21 | + int trapnr, ret, si_code, sig; | ||
22 | CPUState *cs = env_cpu(env); | ||
23 | - int trapnr, ret, si_code; | ||
24 | |||
25 | while (1) { | ||
26 | cpu_exec_start(cs); | ||
27 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUMBState *env) | ||
28 | env->iflags &= ~(IMM_FLAG | D_FLAG); | ||
29 | switch (env->esr & 31) { | ||
30 | case ESR_EC_DIVZERO: | ||
31 | + sig = TARGET_SIGFPE; | ||
32 | si_code = TARGET_FPE_INTDIV; | ||
33 | break; | ||
34 | case ESR_EC_FPU: | ||
35 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUMBState *env) | ||
36 | * if there's no recognized bit set. Possibly this | ||
37 | * implies that si_code is 0, but follow the structure. | ||
38 | */ | ||
39 | + sig = TARGET_SIGFPE; | ||
40 | si_code = env->fsr; | ||
41 | if (si_code & FSR_IO) { | ||
42 | si_code = TARGET_FPE_FLTINV; | ||
43 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUMBState *env) | ||
44 | si_code = TARGET_FPE_FLTRES; | ||
45 | } | ||
46 | break; | ||
47 | + case ESR_EC_PRIVINSN: | ||
48 | + sig = SIGILL; | ||
49 | + si_code = ILL_PRVOPC; | ||
50 | + break; | ||
51 | default: | ||
52 | fprintf(stderr, "Unhandled hw-exception: 0x%x\n", | ||
53 | env->esr & ESR_EC_MASK); | ||
54 | cpu_dump_state(cs, stderr, 0); | ||
55 | exit(EXIT_FAILURE); | ||
56 | } | ||
57 | - force_sig_fault(TARGET_SIGFPE, si_code, env->pc); | ||
58 | + force_sig_fault(sig, si_code, env->pc); | ||
59 | break; | ||
60 | |||
61 | case EXCP_DEBUG: | ||
62 | -- | ||
63 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Mirroring the upstream gdb xml files, the two stack boundary | ||
2 | registers are separated out. | ||
1 | 3 | ||
4 | Reviewed-by: Edgar E. Iglesias <edgar@zeroasic.com> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/microblaze/cpu.h | 2 + | ||
8 | target/microblaze/cpu.c | 7 ++- | ||
9 | target/microblaze/gdbstub.c | 51 +++++++++++----- | ||
10 | configs/targets/microblaze-linux-user.mak | 1 + | ||
11 | configs/targets/microblaze-softmmu.mak | 1 + | ||
12 | configs/targets/microblazeel-linux-user.mak | 1 + | ||
13 | configs/targets/microblazeel-softmmu.mak | 1 + | ||
14 | gdb-xml/microblaze-core.xml | 67 +++++++++++++++++++++ | ||
15 | gdb-xml/microblaze-stack-protect.xml | 12 ++++ | ||
16 | 9 files changed, 128 insertions(+), 15 deletions(-) | ||
17 | create mode 100644 gdb-xml/microblaze-core.xml | ||
18 | create mode 100644 gdb-xml/microblaze-stack-protect.xml | ||
19 | |||
20 | diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/microblaze/cpu.h | ||
23 | +++ b/target/microblaze/cpu.h | ||
24 | @@ -XXX,XX +XXX,XX @@ hwaddr mb_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, | ||
25 | MemTxAttrs *attrs); | ||
26 | int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); | ||
27 | int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); | ||
28 | +int mb_cpu_gdb_read_stack_protect(CPUArchState *cpu, GByteArray *buf, int reg); | ||
29 | +int mb_cpu_gdb_write_stack_protect(CPUArchState *cpu, uint8_t *buf, int reg); | ||
30 | |||
31 | static inline uint32_t mb_cpu_read_msr(const CPUMBState *env) | ||
32 | { | ||
33 | diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/microblaze/cpu.c | ||
36 | +++ b/target/microblaze/cpu.c | ||
37 | @@ -XXX,XX +XXX,XX @@ | ||
38 | #include "qemu/module.h" | ||
39 | #include "hw/qdev-properties.h" | ||
40 | #include "exec/exec-all.h" | ||
41 | +#include "exec/gdbstub.h" | ||
42 | #include "fpu/softfloat-helpers.h" | ||
43 | |||
44 | static const struct { | ||
45 | @@ -XXX,XX +XXX,XX @@ static void mb_cpu_initfn(Object *obj) | ||
46 | CPUMBState *env = &cpu->env; | ||
47 | |||
48 | cpu_set_cpustate_pointers(cpu); | ||
49 | + gdb_register_coprocessor(CPU(cpu), mb_cpu_gdb_read_stack_protect, | ||
50 | + mb_cpu_gdb_write_stack_protect, 2, | ||
51 | + "microblaze-stack-protect.xml", 0); | ||
52 | |||
53 | set_float_rounding_mode(float_round_nearest_even, &env->fp_status); | ||
54 | |||
55 | @@ -XXX,XX +XXX,XX @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) | ||
56 | cc->sysemu_ops = &mb_sysemu_ops; | ||
57 | #endif | ||
58 | device_class_set_props(dc, mb_properties); | ||
59 | - cc->gdb_num_core_regs = 32 + 27; | ||
60 | + cc->gdb_num_core_regs = 32 + 25; | ||
61 | + cc->gdb_core_xml_file = "microblaze-core.xml"; | ||
62 | |||
63 | cc->disas_set_info = mb_disas_set_info; | ||
64 | cc->tcg_ops = &mb_tcg_ops; | ||
65 | diff --git a/target/microblaze/gdbstub.c b/target/microblaze/gdbstub.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/microblaze/gdbstub.c | ||
68 | +++ b/target/microblaze/gdbstub.c | ||
69 | @@ -XXX,XX +XXX,XX @@ enum { | ||
70 | GDB_PVR0 = 32 + 6, | ||
71 | GDB_PVR11 = 32 + 17, | ||
72 | GDB_EDR = 32 + 18, | ||
73 | - GDB_SLR = 32 + 25, | ||
74 | - GDB_SHR = 32 + 26, | ||
75 | +}; | ||
76 | + | ||
77 | +enum { | ||
78 | + GDB_SP_SHL, | ||
79 | + GDB_SP_SHR, | ||
80 | }; | ||
81 | |||
82 | int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) | ||
83 | @@ -XXX,XX +XXX,XX @@ int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) | ||
84 | case GDB_EDR: | ||
85 | val = env->edr; | ||
86 | break; | ||
87 | - case GDB_SLR: | ||
88 | - val = env->slr; | ||
89 | - break; | ||
90 | - case GDB_SHR: | ||
91 | - val = env->shr; | ||
92 | - break; | ||
93 | default: | ||
94 | /* Other SRegs aren't modeled, so report a value of 0 */ | ||
95 | val = 0; | ||
96 | @@ -XXX,XX +XXX,XX @@ int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) | ||
97 | return gdb_get_reg32(mem_buf, val); | ||
98 | } | ||
99 | |||
100 | +int mb_cpu_gdb_read_stack_protect(CPUMBState *env, GByteArray *mem_buf, int n) | ||
101 | +{ | ||
102 | + uint32_t val; | ||
103 | + | ||
104 | + switch (n) { | ||
105 | + case GDB_SP_SHL: | ||
106 | + val = env->slr; | ||
107 | + break; | ||
108 | + case GDB_SP_SHR: | ||
109 | + val = env->shr; | ||
110 | + break; | ||
111 | + default: | ||
112 | + return 0; | ||
113 | + } | ||
114 | + return gdb_get_reg32(mem_buf, val); | ||
115 | +} | ||
116 | + | ||
117 | int mb_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) | ||
118 | { | ||
119 | MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); | ||
120 | @@ -XXX,XX +XXX,XX @@ int mb_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) | ||
121 | case GDB_EDR: | ||
122 | env->edr = tmp; | ||
123 | break; | ||
124 | - case GDB_SLR: | ||
125 | - env->slr = tmp; | ||
126 | - break; | ||
127 | - case GDB_SHR: | ||
128 | - env->shr = tmp; | ||
129 | - break; | ||
130 | + } | ||
131 | + return 4; | ||
132 | +} | ||
133 | + | ||
134 | +int mb_cpu_gdb_write_stack_protect(CPUMBState *env, uint8_t *mem_buf, int n) | ||
135 | +{ | ||
136 | + switch (n) { | ||
137 | + case GDB_SP_SHL: | ||
138 | + env->slr = ldl_p(mem_buf); | ||
139 | + break; | ||
140 | + case GDB_SP_SHR: | ||
141 | + env->shr = ldl_p(mem_buf); | ||
142 | + break; | ||
143 | + default: | ||
144 | + return 0; | ||
145 | } | ||
146 | return 4; | ||
147 | } | ||
148 | diff --git a/configs/targets/microblaze-linux-user.mak b/configs/targets/microblaze-linux-user.mak | ||
149 | index XXXXXXX..XXXXXXX 100644 | ||
150 | --- a/configs/targets/microblaze-linux-user.mak | ||
151 | +++ b/configs/targets/microblaze-linux-user.mak | ||
152 | @@ -XXX,XX +XXX,XX @@ TARGET_SYSTBL_ABI=common | ||
153 | TARGET_SYSTBL=syscall.tbl | ||
154 | TARGET_BIG_ENDIAN=y | ||
155 | TARGET_HAS_BFLT=y | ||
156 | +TARGET_XML_FILES=gdb-xml/microblaze-core.xml gdb-xml/microblaze-stack-protect.xml | ||
157 | diff --git a/configs/targets/microblaze-softmmu.mak b/configs/targets/microblaze-softmmu.mak | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/configs/targets/microblaze-softmmu.mak | ||
160 | +++ b/configs/targets/microblaze-softmmu.mak | ||
161 | @@ -XXX,XX +XXX,XX @@ TARGET_ARCH=microblaze | ||
162 | TARGET_BIG_ENDIAN=y | ||
163 | TARGET_SUPPORTS_MTTCG=y | ||
164 | TARGET_NEED_FDT=y | ||
165 | +TARGET_XML_FILES=gdb-xml/microblaze-core.xml gdb-xml/microblaze-stack-protect.xml | ||
166 | diff --git a/configs/targets/microblazeel-linux-user.mak b/configs/targets/microblazeel-linux-user.mak | ||
167 | index XXXXXXX..XXXXXXX 100644 | ||
168 | --- a/configs/targets/microblazeel-linux-user.mak | ||
169 | +++ b/configs/targets/microblazeel-linux-user.mak | ||
170 | @@ -XXX,XX +XXX,XX @@ TARGET_ARCH=microblaze | ||
171 | TARGET_SYSTBL_ABI=common | ||
172 | TARGET_SYSTBL=syscall.tbl | ||
173 | TARGET_HAS_BFLT=y | ||
174 | +TARGET_XML_FILES=gdb-xml/microblaze-core.xml gdb-xml/microblaze-stack-protect.xml | ||
175 | diff --git a/configs/targets/microblazeel-softmmu.mak b/configs/targets/microblazeel-softmmu.mak | ||
176 | index XXXXXXX..XXXXXXX 100644 | ||
177 | --- a/configs/targets/microblazeel-softmmu.mak | ||
178 | +++ b/configs/targets/microblazeel-softmmu.mak | ||
179 | @@ -XXX,XX +XXX,XX @@ | ||
180 | TARGET_ARCH=microblaze | ||
181 | TARGET_SUPPORTS_MTTCG=y | ||
182 | TARGET_NEED_FDT=y | ||
183 | +TARGET_XML_FILES=gdb-xml/microblaze-core.xml gdb-xml/microblaze-stack-protect.xml | ||
184 | diff --git a/gdb-xml/microblaze-core.xml b/gdb-xml/microblaze-core.xml | ||
185 | new file mode 100644 | ||
186 | index XXXXXXX..XXXXXXX | ||
187 | --- /dev/null | ||
188 | +++ b/gdb-xml/microblaze-core.xml | ||
189 | @@ -XXX,XX +XXX,XX @@ | ||
190 | +<?xml version="1.0"?> | ||
191 | +<!-- Copyright (C) 2008 Free Software Foundation, Inc. | ||
192 | + | ||
193 | + Copying and distribution of this file, with or without modification, | ||
194 | + are permitted in any medium without royalty provided the copyright | ||
195 | + notice and this notice are preserved. --> | ||
196 | + | ||
197 | +<!DOCTYPE feature SYSTEM "gdb-target.dtd"> | ||
198 | +<feature name="org.gnu.gdb.microblaze.core"> | ||
199 | + <reg name="r0" bitsize="32" regnum="0"/> | ||
200 | + <reg name="r1" bitsize="32" type="data_ptr"/> | ||
201 | + <reg name="r2" bitsize="32"/> | ||
202 | + <reg name="r3" bitsize="32"/> | ||
203 | + <reg name="r4" bitsize="32"/> | ||
204 | + <reg name="r5" bitsize="32"/> | ||
205 | + <reg name="r6" bitsize="32"/> | ||
206 | + <reg name="r7" bitsize="32"/> | ||
207 | + <reg name="r8" bitsize="32"/> | ||
208 | + <reg name="r9" bitsize="32"/> | ||
209 | + <reg name="r10" bitsize="32"/> | ||
210 | + <reg name="r11" bitsize="32"/> | ||
211 | + <reg name="r12" bitsize="32"/> | ||
212 | + <reg name="r13" bitsize="32"/> | ||
213 | + <reg name="r14" bitsize="32"/> | ||
214 | + <reg name="r15" bitsize="32"/> | ||
215 | + <reg name="r16" bitsize="32"/> | ||
216 | + <reg name="r17" bitsize="32"/> | ||
217 | + <reg name="r18" bitsize="32"/> | ||
218 | + <reg name="r19" bitsize="32"/> | ||
219 | + <reg name="r20" bitsize="32"/> | ||
220 | + <reg name="r21" bitsize="32"/> | ||
221 | + <reg name="r22" bitsize="32"/> | ||
222 | + <reg name="r23" bitsize="32"/> | ||
223 | + <reg name="r24" bitsize="32"/> | ||
224 | + <reg name="r25" bitsize="32"/> | ||
225 | + <reg name="r26" bitsize="32"/> | ||
226 | + <reg name="r27" bitsize="32"/> | ||
227 | + <reg name="r28" bitsize="32"/> | ||
228 | + <reg name="r29" bitsize="32"/> | ||
229 | + <reg name="r30" bitsize="32"/> | ||
230 | + <reg name="r31" bitsize="32"/> | ||
231 | + <reg name="rpc" bitsize="32" type="code_ptr"/> | ||
232 | + <reg name="rmsr" bitsize="32"/> | ||
233 | + <reg name="rear" bitsize="32"/> | ||
234 | + <reg name="resr" bitsize="32"/> | ||
235 | + <reg name="rfsr" bitsize="32"/> | ||
236 | + <reg name="rbtr" bitsize="32"/> | ||
237 | + <reg name="rpvr0" bitsize="32"/> | ||
238 | + <reg name="rpvr1" bitsize="32"/> | ||
239 | + <reg name="rpvr2" bitsize="32"/> | ||
240 | + <reg name="rpvr3" bitsize="32"/> | ||
241 | + <reg name="rpvr4" bitsize="32"/> | ||
242 | + <reg name="rpvr5" bitsize="32"/> | ||
243 | + <reg name="rpvr6" bitsize="32"/> | ||
244 | + <reg name="rpvr7" bitsize="32"/> | ||
245 | + <reg name="rpvr8" bitsize="32"/> | ||
246 | + <reg name="rpvr9" bitsize="32"/> | ||
247 | + <reg name="rpvr10" bitsize="32"/> | ||
248 | + <reg name="rpvr11" bitsize="32"/> | ||
249 | + <reg name="redr" bitsize="32"/> | ||
250 | + <reg name="rpid" bitsize="32"/> | ||
251 | + <reg name="rzpr" bitsize="32"/> | ||
252 | + <reg name="rtlbx" bitsize="32"/> | ||
253 | + <reg name="rtlbsx" bitsize="32"/> | ||
254 | + <reg name="rtlblo" bitsize="32"/> | ||
255 | + <reg name="rtlbhi" bitsize="32"/> | ||
256 | +</feature> | ||
257 | diff --git a/gdb-xml/microblaze-stack-protect.xml b/gdb-xml/microblaze-stack-protect.xml | ||
258 | new file mode 100644 | ||
259 | index XXXXXXX..XXXXXXX | ||
260 | --- /dev/null | ||
261 | +++ b/gdb-xml/microblaze-stack-protect.xml | ||
262 | @@ -XXX,XX +XXX,XX @@ | ||
263 | +<?xml version="1.0"?> | ||
264 | +<!-- Copyright (C) 2008 Free Software Foundation, Inc. | ||
265 | + | ||
266 | + Copying and distribution of this file, with or without modification, | ||
267 | + are permitted in any medium without royalty provided the copyright | ||
268 | + notice and this notice are preserved. --> | ||
269 | + | ||
270 | +<!DOCTYPE feature SYSTEM "gdb-target.dtd"> | ||
271 | +<feature name="org.gnu.gdb.microblaze.stack-protect"> | ||
272 | + <reg name="rslr" bitsize="32"/> | ||
273 | + <reg name="rshr" bitsize="32"/> | ||
274 | +</feature> | ||
275 | -- | ||
276 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Pierrick Bouvier <pierrick.bouvier@linaro.org> | ||
1 | 2 | ||
3 | ctr_el0 access is privileged on this platform and fails as an illegal | ||
4 | instruction. | ||
5 | |||
6 | Windows does not offer a way to flush data cache from userspace, and | ||
7 | only FlushInstructionCache is available in Windows API. | ||
8 | |||
9 | The generic implementation of flush_idcache_range uses, | ||
10 | __builtin___clear_cache, which already use the FlushInstructionCache | ||
11 | function. So we rely on that. | ||
12 | |||
13 | Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-Id: <20230221153006.20300-2-pierrick.bouvier@linaro.org> | ||
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | --- | ||
18 | util/cacheflush.c | 14 +++++++++++--- | ||
19 | 1 file changed, 11 insertions(+), 3 deletions(-) | ||
20 | |||
21 | diff --git a/util/cacheflush.c b/util/cacheflush.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/util/cacheflush.c | ||
24 | +++ b/util/cacheflush.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static void sys_cache_info(int *isize, int *dsize) | ||
26 | static bool have_coherent_icache; | ||
27 | #endif | ||
28 | |||
29 | -#if defined(__aarch64__) && !defined(CONFIG_DARWIN) | ||
30 | -/* Apple does not expose CTR_EL0, so we must use system interfaces. */ | ||
31 | +#if defined(__aarch64__) && !defined(CONFIG_DARWIN) && !defined(CONFIG_WIN32) | ||
32 | +/* | ||
33 | + * Apple does not expose CTR_EL0, so we must use system interfaces. | ||
34 | + * Windows neither, but we use a generic implementation of flush_idcache_range | ||
35 | + * in this case. | ||
36 | + */ | ||
37 | static uint64_t save_ctr_el0; | ||
38 | static void arch_cache_info(int *isize, int *dsize) | ||
39 | { | ||
40 | @@ -XXX,XX +XXX,XX @@ static void __attribute__((constructor)) init_cache_info(void) | ||
41 | |||
42 | /* Caches are coherent and do not require flushing; symbol inline. */ | ||
43 | |||
44 | -#elif defined(__aarch64__) | ||
45 | +#elif defined(__aarch64__) && !defined(CONFIG_WIN32) | ||
46 | +/* | ||
47 | + * For Windows, we use generic implementation of flush_idcache_range, that | ||
48 | + * performs a call to FlushInstructionCache, through __builtin___clear_cache. | ||
49 | + */ | ||
50 | |||
51 | #ifdef CONFIG_DARWIN | ||
52 | /* Apple does not expose CTR_EL0, so we must use system interfaces. */ | ||
53 | -- | ||
54 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Pierrick Bouvier <pierrick.bouvier@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When building using GCC 8.3.0 on loongarch64 (Loongnix) we get: | 3 | Windows implementation of setjmp/longjmp is done in |
4 | C:/WINDOWS/system32/ucrtbase.dll. Alas, on arm64, it seems to *always* | ||
5 | perform stack unwinding, which crashes from generated code. | ||
4 | 6 | ||
5 | In file included from ../linux-user/signal.c:33: | 7 | By using alternative implementation built in mingw, we avoid doing stack |
6 | ../linux-user/host/loongarch64/host-signal.h: In function ‘host_signal_write’: | 8 | unwinding and this fixes crash when calling longjmp. |
7 | ../linux-user/host/loongarch64/host-signal.h:57:9: error: a label can only be part of a statement and a declaration is not a statement | ||
8 | uint32_t sel = (insn >> 15) & 0b11111111111; | ||
9 | ^~~~~~~~ | ||
10 | 9 | ||
11 | We don't use the 'sel' variable more than once, so drop it. | 10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
12 | 11 | Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> | |
13 | Meson output for the record: | 12 | Acked-by: Richard Henderson <richard.henderson@linaro.org> |
14 | 13 | Message-Id: <20230221153006.20300-3-pierrick.bouvier@linaro.org> | |
15 | Host machine cpu family: loongarch64 | ||
16 | Host machine cpu: loongarch64 | ||
17 | C compiler for the host machine: cc (gcc 8.3.0 "cc (Loongnix 8.3.0-6.lnd.vec.27) 8.3.0") | ||
18 | C linker for the host machine: cc ld.bfd 2.31.1-system | ||
19 | |||
20 | Fixes: ad812c3bd65 ("linux-user: Implement CPU-specific signal handler for loongarch64 hosts") | ||
21 | Reported-by: Song Gao <gaosong@loongson.cn> | ||
22 | Suggested-by: Song Gao <gaosong@loongson.cn> | ||
23 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
24 | Reviewed-by: WANG Xuerui <git@xen0n.name> | ||
25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
26 | Message-Id: <20220104215027.2180972-1-f4bug@amsat.org> | ||
27 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
28 | --- | 15 | --- |
29 | linux-user/host/loongarch64/host-signal.h | 4 +--- | 16 | include/sysemu/os-win32.h | 28 ++++++++++++++++++++++++---- |
30 | 1 file changed, 1 insertion(+), 3 deletions(-) | 17 | meson.build | 21 +++++++++++++++++++++ |
18 | 2 files changed, 45 insertions(+), 4 deletions(-) | ||
31 | 19 | ||
32 | diff --git a/linux-user/host/loongarch64/host-signal.h b/linux-user/host/loongarch64/host-signal.h | 20 | diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h |
33 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/linux-user/host/loongarch64/host-signal.h | 22 | --- a/include/sysemu/os-win32.h |
35 | +++ b/linux-user/host/loongarch64/host-signal.h | 23 | +++ b/include/sysemu/os-win32.h |
36 | @@ -XXX,XX +XXX,XX @@ static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) | 24 | @@ -XXX,XX +XXX,XX @@ typedef struct sockaddr_un { |
37 | } | 25 | extern "C" { |
38 | break; | 26 | #endif |
39 | case 0b001110: /* indexed, atomic, bounds-checking memory operations */ | 27 | |
40 | - uint32_t sel = (insn >> 15) & 0b11111111111; | 28 | -#if defined(_WIN64) |
41 | - | 29 | -/* On w64, setjmp is implemented by _setjmp which needs a second parameter. |
42 | - switch (sel) { | 30 | +#if defined(__aarch64__) |
43 | + switch ((insn >> 15) & 0b11111111111) { | 31 | +/* |
44 | case 0b00000100000: /* stx.b */ | 32 | + * On windows-arm64, setjmp is available in only one variant, and longjmp always |
45 | case 0b00000101000: /* stx.h */ | 33 | + * does stack unwinding. This crash with generated code. |
46 | case 0b00000110000: /* stx.w */ | 34 | + * Thus, we use another implementation of setjmp (not windows one), coming from |
35 | + * mingw, which never performs stack unwinding. | ||
36 | + */ | ||
37 | +#undef setjmp | ||
38 | +#undef longjmp | ||
39 | +/* | ||
40 | + * These functions are not declared in setjmp.h because __aarch64__ defines | ||
41 | + * setjmp to _setjmpex instead. However, they are still defined in libmingwex.a, | ||
42 | + * which gets linked automatically. | ||
43 | + */ | ||
44 | +extern int __mingw_setjmp(jmp_buf); | ||
45 | +extern void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int); | ||
46 | +#define setjmp(env) __mingw_setjmp(env) | ||
47 | +#define longjmp(env, val) __mingw_longjmp(env, val) | ||
48 | +#elif defined(_WIN64) | ||
49 | +/* | ||
50 | + * On windows-x64, setjmp is implemented by _setjmp which needs a second parameter. | ||
51 | * If this parameter is NULL, longjump does no stack unwinding. | ||
52 | * That is what we need for QEMU. Passing the value of register rsp (default) | ||
53 | - * lets longjmp try a stack unwinding which will crash with generated code. */ | ||
54 | + * lets longjmp try a stack unwinding which will crash with generated code. | ||
55 | + */ | ||
56 | # undef setjmp | ||
57 | # define setjmp(env) _setjmp(env, NULL) | ||
58 | -#endif | ||
59 | +#endif /* __aarch64__ */ | ||
60 | /* QEMU uses sigsetjmp()/siglongjmp() as the portable way to specify | ||
61 | * "longjmp and don't touch the signal masks". Since we know that the | ||
62 | * savemask parameter will always be zero we can safely define these | ||
63 | diff --git a/meson.build b/meson.build | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/meson.build | ||
66 | +++ b/meson.build | ||
67 | @@ -XXX,XX +XXX,XX @@ if targetos == 'windows' | ||
68 | }''', name: '_lock_file and _unlock_file')) | ||
69 | endif | ||
70 | |||
71 | +if targetos == 'windows' | ||
72 | + mingw_has_setjmp_longjmp = cc.links(''' | ||
73 | + #include <setjmp.h> | ||
74 | + int main(void) { | ||
75 | + /* | ||
76 | + * These functions are not available in setjmp header, but may be | ||
77 | + * available at link time, from libmingwex.a. | ||
78 | + */ | ||
79 | + extern int __mingw_setjmp(jmp_buf); | ||
80 | + extern void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int); | ||
81 | + jmp_buf env; | ||
82 | + __mingw_setjmp(env); | ||
83 | + __mingw_longjmp(env, 0); | ||
84 | + } | ||
85 | + ''', name: 'mingw setjmp and longjmp') | ||
86 | + | ||
87 | + if cpu == 'aarch64' and not mingw_has_setjmp_longjmp | ||
88 | + error('mingw must provide setjmp/longjmp for windows-arm64') | ||
89 | + endif | ||
90 | +endif | ||
91 | + | ||
92 | ######################## | ||
93 | # Target configuration # | ||
94 | ######################## | ||
47 | -- | 95 | -- |
48 | 2.25.1 | 96 | 2.34.1 |
49 | 97 | ||
50 | 98 | diff view generated by jsdifflib |