1 | The linux-user patches are on the tcg-ish side of user-only | 1 | v2: Fix FreeBSD build error in patch 18. |
---|---|---|---|
2 | emulation, rather than the syscall-ish side, so queuing here. | ||
3 | Solving the deadlock issue is quite important vs timeouts. | ||
4 | |||
5 | 2 | ||
6 | r~ | 3 | r~ |
7 | 4 | ||
8 | 5 | ||
9 | The following changes since commit 6dffbe36af79e26a4d23f94a9a1c1201de99c261: | 6 | The following changes since commit 0d239e513e0117e66fa739fb71a43b9383a108ff: |
10 | 7 | ||
11 | Merge tag 'migration-20230215-pull-request' of https://gitlab.com/juan.quintela/qemu into staging (2023-02-16 13:09:51 +0000) | 8 | Merge tag 'pull-lu-20231018' of https://gitlab.com/rth7680/qemu into staging (2023-10-19 10:20:57 -0700) |
12 | 9 | ||
13 | are available in the Git repository at: | 10 | are available in the Git repository at: |
14 | 11 | ||
15 | https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20230219 | 12 | https://gitlab.com/rth7680/qemu.git tags/pull-tcg-20231018-2 |
16 | 13 | ||
17 | for you to fetch changes up to 2f5b4792c0220920831ac84f94c3435b14791857: | 14 | for you to fetch changes up to a75f704d972b9408f5e2843784b3add48c724c52: |
18 | 15 | ||
19 | target/microblaze: Add gdbstub xml (2023-02-19 16:12:26 -1000) | 16 | target/i386: Use i128 for 128 and 256-bit loads and stores (2023-10-19 21:11:44 -0700) |
20 | 17 | ||
21 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
22 | tcg: Allow first half of insn in ram, and second half in mmio | 19 | tcg: Drop unused tcg_temp_free define |
23 | linux-user/sparc: SIGILL for unknown trap vectors | 20 | tcg: Introduce tcg_use_softmmu |
24 | linux-user/microblaze: SIGILL for privileged insns | 21 | tcg: Optimize past conditional branches |
25 | linux-user: Fix deadlock while exiting due to signal | 22 | tcg: Use constant zero when expanding with divu2 |
26 | target/microblaze: Add gdbstub xml | 23 | tcg/ppc: Enable direct branching tcg_out_goto_tb with TCG_REG_TB |
24 | tcg/ppc: Use ADDPCIS for power9 | ||
25 | tcg/ppc: Use prefixed instructions for power10 | ||
26 | tcg/ppc: Disable TCG_REG_TB for Power9/Power10 | ||
27 | 27 | ||
28 | ---------------------------------------------------------------- | 28 | ---------------------------------------------------------------- |
29 | Ilya Leoshkevich (4): | 29 | Jordan Niethe (1): |
30 | linux-user: Always exit from exclusive state in fork_end() | 30 | tcg/ppc: Enable direct branching tcg_out_goto_tb with TCG_REG_TB |
31 | cpus: Make {start,end}_exclusive() recursive | ||
32 | linux-user/microblaze: Handle privileged exception | ||
33 | tests/tcg/linux-test: Add linux-fork-trap test | ||
34 | 31 | ||
35 | Richard Henderson (3): | 32 | Mike Frysinger (1): |
36 | accel/tcg: Allow the second page of an instruction to be MMIO | 33 | tcg: drop unused tcg_temp_free define |
37 | linux-user/sparc: Raise SIGILL for all unhandled software traps | ||
38 | target/microblaze: Add gdbstub xml | ||
39 | 34 | ||
40 | configs/targets/microblaze-linux-user.mak | 1 + | 35 | Richard Henderson (27): |
41 | configs/targets/microblaze-softmmu.mak | 1 + | 36 | tcg/ppc: Untabify tcg-target.c.inc |
42 | configs/targets/microblazeel-linux-user.mak | 1 + | 37 | tcg/ppc: Reinterpret tb-relative to TB+4 |
43 | configs/targets/microblazeel-softmmu.mak | 1 + | 38 | tcg/ppc: Use ADDPCIS in tcg_out_tb_start |
44 | include/hw/core/cpu.h | 4 +- | 39 | tcg/ppc: Use ADDPCIS in tcg_out_movi_int |
45 | target/microblaze/cpu.h | 2 + | 40 | tcg/ppc: Use ADDPCIS for the constant pool |
46 | accel/tcg/translator.c | 12 +++++- | 41 | tcg/ppc: Use ADDPCIS in tcg_out_goto_tb |
47 | cpus-common.c | 12 +++++- | 42 | tcg/ppc: Use PADDI in tcg_out_movi |
48 | linux-user/main.c | 10 +++-- | 43 | tcg/ppc: Use prefixed instructions in tcg_out_mem_long |
49 | linux-user/microblaze/cpu_loop.c | 10 ++++- | 44 | tcg/ppc: Use PLD in tcg_out_movi for constant pool |
50 | linux-user/sparc/cpu_loop.c | 8 ++++ | 45 | tcg/ppc: Use prefixed instructions in tcg_out_dupi_vec |
51 | linux-user/syscall.c | 1 + | 46 | tcg/ppc: Use PLD in tcg_out_goto_tb |
52 | target/microblaze/cpu.c | 7 ++- | 47 | tcg/ppc: Disable TCG_REG_TB for Power9/Power10 |
53 | target/microblaze/gdbstub.c | 51 ++++++++++++++++------ | 48 | tcg: Introduce tcg_use_softmmu |
54 | tests/tcg/multiarch/linux/linux-fork-trap.c | 51 ++++++++++++++++++++++ | 49 | tcg: Provide guest_base fallback for system mode |
55 | gdb-xml/microblaze-core.xml | 67 +++++++++++++++++++++++++++++ | 50 | tcg/arm: Use tcg_use_softmmu |
56 | gdb-xml/microblaze-stack-protect.xml | 12 ++++++ | 51 | tcg/aarch64: Use tcg_use_softmmu |
57 | 17 files changed, 224 insertions(+), 27 deletions(-) | 52 | tcg/i386: Use tcg_use_softmmu |
58 | create mode 100644 tests/tcg/multiarch/linux/linux-fork-trap.c | 53 | tcg/loongarch64: Use tcg_use_softmmu |
59 | create mode 100644 gdb-xml/microblaze-core.xml | 54 | tcg/mips: Use tcg_use_softmmu |
60 | create mode 100644 gdb-xml/microblaze-stack-protect.xml | 55 | tcg/ppc: Use tcg_use_softmmu |
56 | tcg/riscv: Do not reserve TCG_GUEST_BASE_REG for guest_base zero | ||
57 | tcg/riscv: Use tcg_use_softmmu | ||
58 | tcg/s390x: Use tcg_use_softmmu | ||
59 | tcg: Use constant zero when expanding with divu2 | ||
60 | tcg: Optimize past conditional branches | ||
61 | tcg: Add tcg_gen_{ld,st}_i128 | ||
62 | target/i386: Use i128 for 128 and 256-bit loads and stores | ||
63 | |||
64 | include/tcg/tcg-op-common.h | 3 + | ||
65 | include/tcg/tcg-op.h | 2 - | ||
66 | include/tcg/tcg.h | 8 +- | ||
67 | target/i386/tcg/translate.c | 63 ++--- | ||
68 | tcg/optimize.c | 8 +- | ||
69 | tcg/tcg-op-ldst.c | 14 +- | ||
70 | tcg/tcg-op.c | 38 ++- | ||
71 | tcg/tcg.c | 13 +- | ||
72 | tcg/aarch64/tcg-target.c.inc | 177 ++++++------ | ||
73 | tcg/arm/tcg-target.c.inc | 203 +++++++------- | ||
74 | tcg/i386/tcg-target.c.inc | 198 +++++++------- | ||
75 | tcg/loongarch64/tcg-target.c.inc | 126 +++++---- | ||
76 | tcg/mips/tcg-target.c.inc | 231 ++++++++-------- | ||
77 | tcg/ppc/tcg-target.c.inc | 561 ++++++++++++++++++++++++++------------- | ||
78 | tcg/riscv/tcg-target.c.inc | 189 ++++++------- | ||
79 | tcg/s390x/tcg-target.c.inc | 161 ++++++----- | ||
80 | 16 files changed, 1102 insertions(+), 893 deletions(-) | diff view generated by jsdifflib |
1 | If an instruction straddles a page boundary, and the first page | ||
---|---|---|---|
2 | was ram, but the second page was MMIO, we would abort. Handle | ||
3 | this as if both pages are MMIO, by setting the ram_addr_t for | ||
4 | the first page to -1. | ||
5 | |||
6 | Reported-by: Sid Manning <sidneym@quicinc.com> | ||
7 | Reported-by: Jørgen Hansen <Jorgen.Hansen@wdc.com> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 1 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 2 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | --- | 3 | --- |
11 | accel/tcg/translator.c | 12 ++++++++++-- | 4 | tcg/i386/tcg-target.c.inc | 198 +++++++++++++++++++------------------- |
12 | 1 file changed, 10 insertions(+), 2 deletions(-) | 5 | 1 file changed, 98 insertions(+), 100 deletions(-) |
13 | 6 | ||
14 | diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c | 7 | diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc |
15 | index XXXXXXX..XXXXXXX 100644 | 8 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/accel/tcg/translator.c | 9 | --- a/tcg/i386/tcg-target.c.inc |
17 | +++ b/accel/tcg/translator.c | 10 | +++ b/tcg/i386/tcg-target.c.inc |
18 | @@ -XXX,XX +XXX,XX @@ static void *translator_access(CPUArchState *env, DisasContextBase *db, | 11 | @@ -XXX,XX +XXX,XX @@ static TCGReg tcg_target_call_oarg_reg(TCGCallReturnKind kind, int slot) |
19 | if (host == NULL) { | 12 | # define ALL_VECTOR_REGS 0x00ff0000u |
20 | tb_page_addr_t phys_page = | 13 | # define ALL_BYTEL_REGS 0x0000000fu |
21 | get_page_addr_code_hostp(env, base, &db->host_addr[1]); | 14 | #endif |
22 | - /* We cannot handle MMIO as second page. */ | 15 | -#ifdef CONFIG_SOFTMMU |
23 | - assert(phys_page != -1); | 16 | -# define SOFTMMU_RESERVE_REGS ((1 << TCG_REG_L0) | (1 << TCG_REG_L1)) |
17 | -#else | ||
18 | -# define SOFTMMU_RESERVE_REGS 0 | ||
19 | -#endif | ||
20 | +#define SOFTMMU_RESERVE_REGS \ | ||
21 | + (tcg_use_softmmu ? (1 << TCG_REG_L0) | (1 << TCG_REG_L1) : 0) | ||
22 | |||
23 | /* For 64-bit, we always know that CMOV is available. */ | ||
24 | #if TCG_TARGET_REG_BITS == 64 | ||
25 | @@ -XXX,XX +XXX,XX @@ static bool tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) | ||
26 | return true; | ||
27 | } | ||
28 | |||
29 | -#ifndef CONFIG_SOFTMMU | ||
30 | +#ifdef CONFIG_USER_ONLY | ||
31 | static HostAddress x86_guest_base = { | ||
32 | .index = -1 | ||
33 | }; | ||
34 | @@ -XXX,XX +XXX,XX @@ static inline int setup_guest_base_seg(void) | ||
35 | } | ||
36 | return 0; | ||
37 | } | ||
38 | +#define setup_guest_base_seg setup_guest_base_seg | ||
39 | #elif defined(__x86_64__) && \ | ||
40 | (defined (__FreeBSD__) || defined (__FreeBSD_kernel__)) | ||
41 | # include <machine/sysarch.h> | ||
42 | @@ -XXX,XX +XXX,XX @@ static inline int setup_guest_base_seg(void) | ||
43 | } | ||
44 | return 0; | ||
45 | } | ||
46 | +#define setup_guest_base_seg setup_guest_base_seg | ||
47 | +#endif | ||
48 | #else | ||
49 | -static inline int setup_guest_base_seg(void) | ||
50 | -{ | ||
51 | - return 0; | ||
52 | -} | ||
53 | -#endif /* setup_guest_base_seg */ | ||
54 | -#endif /* !SOFTMMU */ | ||
55 | +# define x86_guest_base (*(HostAddress *)({ qemu_build_not_reached(); NULL; })) | ||
56 | +#endif /* CONFIG_USER_ONLY */ | ||
57 | +#ifndef setup_guest_base_seg | ||
58 | +# define setup_guest_base_seg() 0 | ||
59 | +#endif | ||
60 | |||
61 | #define MIN_TLB_MASK_TABLE_OFS INT_MIN | ||
62 | |||
63 | @@ -XXX,XX +XXX,XX @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, | ||
64 | MemOp s_bits = opc & MO_SIZE; | ||
65 | unsigned a_mask; | ||
66 | |||
67 | -#ifdef CONFIG_SOFTMMU | ||
68 | - h->index = TCG_REG_L0; | ||
69 | - h->ofs = 0; | ||
70 | - h->seg = 0; | ||
71 | -#else | ||
72 | - *h = x86_guest_base; | ||
73 | -#endif | ||
74 | + if (tcg_use_softmmu) { | ||
75 | + h->index = TCG_REG_L0; | ||
76 | + h->ofs = 0; | ||
77 | + h->seg = 0; | ||
78 | + } else { | ||
79 | + *h = x86_guest_base; | ||
80 | + } | ||
81 | h->base = addrlo; | ||
82 | h->aa = atom_and_align_for_opc(s, opc, MO_ATOM_IFALIGN, s_bits == MO_128); | ||
83 | a_mask = (1 << h->aa.align) - 1; | ||
84 | |||
85 | -#ifdef CONFIG_SOFTMMU | ||
86 | - int cmp_ofs = is_ld ? offsetof(CPUTLBEntry, addr_read) | ||
87 | - : offsetof(CPUTLBEntry, addr_write); | ||
88 | - TCGType ttype = TCG_TYPE_I32; | ||
89 | - TCGType tlbtype = TCG_TYPE_I32; | ||
90 | - int trexw = 0, hrexw = 0, tlbrexw = 0; | ||
91 | - unsigned mem_index = get_mmuidx(oi); | ||
92 | - unsigned s_mask = (1 << s_bits) - 1; | ||
93 | - int fast_ofs = tlb_mask_table_ofs(s, mem_index); | ||
94 | - int tlb_mask; | ||
95 | + if (tcg_use_softmmu) { | ||
96 | + int cmp_ofs = is_ld ? offsetof(CPUTLBEntry, addr_read) | ||
97 | + : offsetof(CPUTLBEntry, addr_write); | ||
98 | + TCGType ttype = TCG_TYPE_I32; | ||
99 | + TCGType tlbtype = TCG_TYPE_I32; | ||
100 | + int trexw = 0, hrexw = 0, tlbrexw = 0; | ||
101 | + unsigned mem_index = get_mmuidx(oi); | ||
102 | + unsigned s_mask = (1 << s_bits) - 1; | ||
103 | + int fast_ofs = tlb_mask_table_ofs(s, mem_index); | ||
104 | + int tlb_mask; | ||
105 | |||
106 | - ldst = new_ldst_label(s); | ||
107 | - ldst->is_ld = is_ld; | ||
108 | - ldst->oi = oi; | ||
109 | - ldst->addrlo_reg = addrlo; | ||
110 | - ldst->addrhi_reg = addrhi; | ||
111 | + ldst = new_ldst_label(s); | ||
112 | + ldst->is_ld = is_ld; | ||
113 | + ldst->oi = oi; | ||
114 | + ldst->addrlo_reg = addrlo; | ||
115 | + ldst->addrhi_reg = addrhi; | ||
116 | |||
117 | - if (TCG_TARGET_REG_BITS == 64) { | ||
118 | - ttype = s->addr_type; | ||
119 | - trexw = (ttype == TCG_TYPE_I32 ? 0 : P_REXW); | ||
120 | - if (TCG_TYPE_PTR == TCG_TYPE_I64) { | ||
121 | - hrexw = P_REXW; | ||
122 | - if (s->page_bits + s->tlb_dyn_max_bits > 32) { | ||
123 | - tlbtype = TCG_TYPE_I64; | ||
124 | - tlbrexw = P_REXW; | ||
125 | + if (TCG_TARGET_REG_BITS == 64) { | ||
126 | + ttype = s->addr_type; | ||
127 | + trexw = (ttype == TCG_TYPE_I32 ? 0 : P_REXW); | ||
128 | + if (TCG_TYPE_PTR == TCG_TYPE_I64) { | ||
129 | + hrexw = P_REXW; | ||
130 | + if (s->page_bits + s->tlb_dyn_max_bits > 32) { | ||
131 | + tlbtype = TCG_TYPE_I64; | ||
132 | + tlbrexw = P_REXW; | ||
133 | + } | ||
134 | } | ||
135 | } | ||
136 | - } | ||
137 | |||
138 | - tcg_out_mov(s, tlbtype, TCG_REG_L0, addrlo); | ||
139 | - tcg_out_shifti(s, SHIFT_SHR + tlbrexw, TCG_REG_L0, | ||
140 | - s->page_bits - CPU_TLB_ENTRY_BITS); | ||
141 | + tcg_out_mov(s, tlbtype, TCG_REG_L0, addrlo); | ||
142 | + tcg_out_shifti(s, SHIFT_SHR + tlbrexw, TCG_REG_L0, | ||
143 | + s->page_bits - CPU_TLB_ENTRY_BITS); | ||
144 | |||
145 | - tcg_out_modrm_offset(s, OPC_AND_GvEv + trexw, TCG_REG_L0, TCG_AREG0, | ||
146 | - fast_ofs + offsetof(CPUTLBDescFast, mask)); | ||
147 | + tcg_out_modrm_offset(s, OPC_AND_GvEv + trexw, TCG_REG_L0, TCG_AREG0, | ||
148 | + fast_ofs + offsetof(CPUTLBDescFast, mask)); | ||
149 | |||
150 | - tcg_out_modrm_offset(s, OPC_ADD_GvEv + hrexw, TCG_REG_L0, TCG_AREG0, | ||
151 | - fast_ofs + offsetof(CPUTLBDescFast, table)); | ||
152 | + tcg_out_modrm_offset(s, OPC_ADD_GvEv + hrexw, TCG_REG_L0, TCG_AREG0, | ||
153 | + fast_ofs + offsetof(CPUTLBDescFast, table)); | ||
154 | |||
155 | - /* | ||
156 | - * If the required alignment is at least as large as the access, simply | ||
157 | - * copy the address and mask. For lesser alignments, check that we don't | ||
158 | - * cross pages for the complete access. | ||
159 | - */ | ||
160 | - if (a_mask >= s_mask) { | ||
161 | - tcg_out_mov(s, ttype, TCG_REG_L1, addrlo); | ||
162 | - } else { | ||
163 | - tcg_out_modrm_offset(s, OPC_LEA + trexw, TCG_REG_L1, | ||
164 | - addrlo, s_mask - a_mask); | ||
165 | - } | ||
166 | - tlb_mask = s->page_mask | a_mask; | ||
167 | - tgen_arithi(s, ARITH_AND + trexw, TCG_REG_L1, tlb_mask, 0); | ||
168 | + /* | ||
169 | + * If the required alignment is at least as large as the access, | ||
170 | + * simply copy the address and mask. For lesser alignments, | ||
171 | + * check that we don't cross pages for the complete access. | ||
172 | + */ | ||
173 | + if (a_mask >= s_mask) { | ||
174 | + tcg_out_mov(s, ttype, TCG_REG_L1, addrlo); | ||
175 | + } else { | ||
176 | + tcg_out_modrm_offset(s, OPC_LEA + trexw, TCG_REG_L1, | ||
177 | + addrlo, s_mask - a_mask); | ||
178 | + } | ||
179 | + tlb_mask = s->page_mask | a_mask; | ||
180 | + tgen_arithi(s, ARITH_AND + trexw, TCG_REG_L1, tlb_mask, 0); | ||
181 | |||
182 | - /* cmp 0(TCG_REG_L0), TCG_REG_L1 */ | ||
183 | - tcg_out_modrm_offset(s, OPC_CMP_GvEv + trexw, | ||
184 | - TCG_REG_L1, TCG_REG_L0, cmp_ofs); | ||
185 | - | ||
186 | - /* jne slow_path */ | ||
187 | - tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0); | ||
188 | - ldst->label_ptr[0] = s->code_ptr; | ||
189 | - s->code_ptr += 4; | ||
190 | - | ||
191 | - if (TCG_TARGET_REG_BITS == 32 && s->addr_type == TCG_TYPE_I64) { | ||
192 | - /* cmp 4(TCG_REG_L0), addrhi */ | ||
193 | - tcg_out_modrm_offset(s, OPC_CMP_GvEv, addrhi, TCG_REG_L0, cmp_ofs + 4); | ||
194 | + /* cmp 0(TCG_REG_L0), TCG_REG_L1 */ | ||
195 | + tcg_out_modrm_offset(s, OPC_CMP_GvEv + trexw, | ||
196 | + TCG_REG_L1, TCG_REG_L0, cmp_ofs); | ||
197 | |||
198 | /* jne slow_path */ | ||
199 | tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0); | ||
200 | - ldst->label_ptr[1] = s->code_ptr; | ||
201 | + ldst->label_ptr[0] = s->code_ptr; | ||
202 | s->code_ptr += 4; | ||
203 | - } | ||
204 | |||
205 | - /* TLB Hit. */ | ||
206 | - tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_L0, TCG_REG_L0, | ||
207 | - offsetof(CPUTLBEntry, addend)); | ||
208 | -#else | ||
209 | - if (a_mask) { | ||
210 | + if (TCG_TARGET_REG_BITS == 32 && s->addr_type == TCG_TYPE_I64) { | ||
211 | + /* cmp 4(TCG_REG_L0), addrhi */ | ||
212 | + tcg_out_modrm_offset(s, OPC_CMP_GvEv, addrhi, | ||
213 | + TCG_REG_L0, cmp_ofs + 4); | ||
24 | + | 214 | + |
25 | + /* | 215 | + /* jne slow_path */ |
26 | + * If the second page is MMIO, treat as if the first page | 216 | + tcg_out_opc(s, OPC_JCC_long + JCC_JNE, 0, 0, 0); |
27 | + * was MMIO as well, so that we do not cache the TB. | 217 | + ldst->label_ptr[1] = s->code_ptr; |
28 | + */ | 218 | + s->code_ptr += 4; |
29 | + if (unlikely(phys_page == -1)) { | 219 | + } |
30 | + tb_set_page_addr0(tb, -1); | ||
31 | + return NULL; | ||
32 | + } | ||
33 | + | 220 | + |
34 | tb_set_page_addr1(tb, phys_page); | 221 | + /* TLB Hit. */ |
35 | #ifdef CONFIG_USER_ONLY | 222 | + tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_L0, TCG_REG_L0, |
36 | page_protect(end); | 223 | + offsetof(CPUTLBEntry, addend)); |
224 | + } else if (a_mask) { | ||
225 | ldst = new_ldst_label(s); | ||
226 | |||
227 | ldst->is_ld = is_ld; | ||
228 | @@ -XXX,XX +XXX,XX @@ static TCGLabelQemuLdst *prepare_host_addr(TCGContext *s, HostAddress *h, | ||
229 | ldst->label_ptr[0] = s->code_ptr; | ||
230 | s->code_ptr += 4; | ||
231 | } | ||
232 | -#endif | ||
233 | |||
234 | return ldst; | ||
235 | } | ||
236 | @@ -XXX,XX +XXX,XX @@ static void tcg_target_qemu_prologue(TCGContext *s) | ||
237 | tcg_out_push(s, tcg_target_callee_save_regs[i]); | ||
238 | } | ||
239 | |||
240 | -#if TCG_TARGET_REG_BITS == 32 | ||
241 | - tcg_out_ld(s, TCG_TYPE_PTR, TCG_AREG0, TCG_REG_ESP, | ||
242 | - (ARRAY_SIZE(tcg_target_callee_save_regs) + 1) * 4); | ||
243 | - tcg_out_addi(s, TCG_REG_ESP, -stack_addend); | ||
244 | - /* jmp *tb. */ | ||
245 | - tcg_out_modrm_offset(s, OPC_GRP5, EXT5_JMPN_Ev, TCG_REG_ESP, | ||
246 | - (ARRAY_SIZE(tcg_target_callee_save_regs) + 2) * 4 | ||
247 | - + stack_addend); | ||
248 | -#else | ||
249 | -# if !defined(CONFIG_SOFTMMU) | ||
250 | - if (guest_base) { | ||
251 | + if (!tcg_use_softmmu && guest_base) { | ||
252 | int seg = setup_guest_base_seg(); | ||
253 | if (seg != 0) { | ||
254 | x86_guest_base.seg = seg; | ||
255 | } else if (guest_base == (int32_t)guest_base) { | ||
256 | x86_guest_base.ofs = guest_base; | ||
257 | } else { | ||
258 | + assert(TCG_TARGET_REG_BITS == 64); | ||
259 | /* Choose R12 because, as a base, it requires a SIB byte. */ | ||
260 | x86_guest_base.index = TCG_REG_R12; | ||
261 | tcg_out_movi(s, TCG_TYPE_PTR, x86_guest_base.index, guest_base); | ||
262 | tcg_regset_set_reg(s->reserved_regs, x86_guest_base.index); | ||
263 | } | ||
264 | } | ||
265 | -# endif | ||
266 | - tcg_out_mov(s, TCG_TYPE_PTR, TCG_AREG0, tcg_target_call_iarg_regs[0]); | ||
267 | - tcg_out_addi(s, TCG_REG_ESP, -stack_addend); | ||
268 | - /* jmp *tb. */ | ||
269 | - tcg_out_modrm(s, OPC_GRP5, EXT5_JMPN_Ev, tcg_target_call_iarg_regs[1]); | ||
270 | -#endif | ||
271 | + | ||
272 | + if (TCG_TARGET_REG_BITS == 32) { | ||
273 | + tcg_out_ld(s, TCG_TYPE_PTR, TCG_AREG0, TCG_REG_ESP, | ||
274 | + (ARRAY_SIZE(tcg_target_callee_save_regs) + 1) * 4); | ||
275 | + tcg_out_addi(s, TCG_REG_ESP, -stack_addend); | ||
276 | + /* jmp *tb. */ | ||
277 | + tcg_out_modrm_offset(s, OPC_GRP5, EXT5_JMPN_Ev, TCG_REG_ESP, | ||
278 | + (ARRAY_SIZE(tcg_target_callee_save_regs) + 2) * 4 | ||
279 | + + stack_addend); | ||
280 | + } else { | ||
281 | + tcg_out_mov(s, TCG_TYPE_PTR, TCG_AREG0, tcg_target_call_iarg_regs[0]); | ||
282 | + tcg_out_addi(s, TCG_REG_ESP, -stack_addend); | ||
283 | + /* jmp *tb. */ | ||
284 | + tcg_out_modrm(s, OPC_GRP5, EXT5_JMPN_Ev, tcg_target_call_iarg_regs[1]); | ||
285 | + } | ||
286 | |||
287 | /* | ||
288 | * Return path for goto_ptr. Set return value to 0, a-la exit_tb, | ||
37 | -- | 289 | -- |
38 | 2.34.1 | 290 | 2.34.1 |
39 | 291 | ||
40 | 292 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The linux kernel's trap tables vector all unassigned trap | ||
2 | numbers to BAD_TRAP, which then raises SIGILL. | ||
3 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Ilya Leoshkevich <iii@linux.ibm.com> | ||
2 | 1 | ||
3 | fork()ed processes currently start with | ||
4 | current_cpu->in_exclusive_context set, which is, strictly speaking, not | ||
5 | correct, but does not cause problems (even assertion failures). | ||
6 | |||
7 | With one of the next patches, the code begins to rely on this value, so | ||
8 | fix it by always calling end_exclusive() in fork_end(). | ||
9 | |||
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> | ||
14 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | --- | ||
16 | linux-user/main.c | 10 ++++++---- | ||
17 | linux-user/syscall.c | 1 + | ||
18 | 2 files changed, 7 insertions(+), 4 deletions(-) | ||
19 | |||
20 | diff --git a/linux-user/main.c b/linux-user/main.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/linux-user/main.c | ||
23 | +++ b/linux-user/main.c | ||
24 | @@ -XXX,XX +XXX,XX @@ void fork_end(int child) | ||
25 | } | ||
26 | qemu_init_cpu_list(); | ||
27 | gdbserver_fork(thread_cpu); | ||
28 | - /* qemu_init_cpu_list() takes care of reinitializing the | ||
29 | - * exclusive state, so we don't need to end_exclusive() here. | ||
30 | - */ | ||
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 | } | ||
56 | -- | ||
57 | 2.34.1 | ||
58 | |||
59 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Ilya Leoshkevich <iii@linux.ibm.com> | ||
2 | 1 | ||
3 | Currently dying to one of the core_dump_signal()s deadlocks, because | ||
4 | dump_core_and_abort() calls start_exclusive() two times: first via | ||
5 | stop_all_tasks(), and then via preexit_cleanup() -> | ||
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> | ||
18 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | --- | ||
20 | include/hw/core/cpu.h | 4 ++-- | ||
21 | cpus-common.c | 12 ++++++++++-- | ||
22 | 2 files changed, 12 insertions(+), 4 deletions(-) | ||
23 | |||
24 | diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/include/hw/core/cpu.h | ||
27 | +++ b/include/hw/core/cpu.h | ||
28 | @@ -XXX,XX +XXX,XX @@ struct CPUState { | ||
29 | bool unplug; | ||
30 | bool crash_occurred; | ||
31 | bool exit_request; | ||
32 | - bool in_exclusive_context; | ||
33 | + int exclusive_context_count; | ||
34 | uint32_t cflags_next_tb; | ||
35 | /* updates protected by BQL */ | ||
36 | uint32_t interrupt_request; | ||
37 | @@ -XXX,XX +XXX,XX @@ void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func func, run_on_cpu_data | ||
38 | */ | ||
39 | static inline bool cpu_in_exclusive_context(const CPUState *cpu) | ||
40 | { | ||
41 | - return cpu->in_exclusive_context; | ||
42 | + return cpu->exclusive_context_count; | ||
43 | } | ||
44 | |||
45 | /** | ||
46 | diff --git a/cpus-common.c b/cpus-common.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/cpus-common.c | ||
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 | + } | ||
58 | + | ||
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) | ||
72 | { | ||
73 | - current_cpu->in_exclusive_context = false; | ||
74 | + current_cpu->exclusive_context_count--; | ||
75 | + if (current_cpu->exclusive_context_count) { | ||
76 | + return; | ||
77 | + } | ||
78 | |||
79 | qemu_mutex_lock(&qemu_cpu_list_lock); | ||
80 | qatomic_set(&pending_cpus, 0); | ||
81 | -- | ||
82 | 2.34.1 | ||
83 | |||
84 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Ilya Leoshkevich <iii@linux.ibm.com> | ||
2 | 1 | ||
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 |
Deleted patch | |||
---|---|---|---|
1 | From: Ilya Leoshkevich <iii@linux.ibm.com> | ||
2 | 1 | ||
3 | Check that dying due to a signal does not deadlock. | ||
4 | |||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
8 | Message-Id: <20230214140829.45392-5-iii@linux.ibm.com> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | --- | ||
11 | tests/tcg/multiarch/linux/linux-fork-trap.c | 51 +++++++++++++++++++++ | ||
12 | 1 file changed, 51 insertions(+) | ||
13 | create mode 100644 tests/tcg/multiarch/linux/linux-fork-trap.c | ||
14 | |||
15 | diff --git a/tests/tcg/multiarch/linux/linux-fork-trap.c b/tests/tcg/multiarch/linux/linux-fork-trap.c | ||
16 | new file mode 100644 | ||
17 | index XXXXXXX..XXXXXXX | ||
18 | --- /dev/null | ||
19 | +++ b/tests/tcg/multiarch/linux/linux-fork-trap.c | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | +/* | ||
22 | + * Test that a fork()ed process terminates after __builtin_trap(). | ||
23 | + * | ||
24 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
25 | + */ | ||
26 | +#include <assert.h> | ||
27 | +#include <stdio.h> | ||
28 | +#include <stdlib.h> | ||
29 | +#include <sys/resource.h> | ||
30 | +#include <sys/wait.h> | ||
31 | +#include <unistd.h> | ||
32 | + | ||
33 | +int main(void) | ||
34 | +{ | ||
35 | + struct rlimit nodump; | ||
36 | + pid_t err, pid; | ||
37 | + int wstatus; | ||
38 | + | ||
39 | + pid = fork(); | ||
40 | + assert(pid != -1); | ||
41 | + if (pid == 0) { | ||
42 | + /* We are about to crash on purpose; disable core dumps. */ | ||
43 | + if (getrlimit(RLIMIT_CORE, &nodump)) { | ||
44 | + return EXIT_FAILURE; | ||
45 | + } | ||
46 | + nodump.rlim_cur = 0; | ||
47 | + if (setrlimit(RLIMIT_CORE, &nodump)) { | ||
48 | + return EXIT_FAILURE; | ||
49 | + } | ||
50 | + /* | ||
51 | + * An alternative would be to dereference a NULL pointer, but that | ||
52 | + * would be an UB in C. | ||
53 | + */ | ||
54 | + printf("about to trigger fault...\n"); | ||
55 | +#if defined(__MICROBLAZE__) | ||
56 | + /* | ||
57 | + * gcc emits "bri 0", which is an endless loop. | ||
58 | + * Take glibc's ABORT_INSTRUCTION. | ||
59 | + */ | ||
60 | + asm volatile("brki r0,-1"); | ||
61 | +#else | ||
62 | + __builtin_trap(); | ||
63 | +#endif | ||
64 | + } | ||
65 | + err = waitpid(pid, &wstatus, 0); | ||
66 | + assert(err == pid); | ||
67 | + assert(WIFSIGNALED(wstatus)); | ||
68 | + printf("faulting thread exited cleanly\n"); | ||
69 | + | ||
70 | + return EXIT_SUCCESS; | ||
71 | +} | ||
72 | -- | ||
73 | 2.34.1 | ||
74 | |||
75 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Mirroring the upstream gdb xml files, the two stack boundary | ||
2 | registers are separated out. | ||
3 | 1 | ||
4 | Reviewed-by: Edgar E. Iglesias <edgar@zeroasic.com> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | configs/targets/microblaze-linux-user.mak | 1 + | ||
8 | configs/targets/microblaze-softmmu.mak | 1 + | ||
9 | configs/targets/microblazeel-linux-user.mak | 1 + | ||
10 | configs/targets/microblazeel-softmmu.mak | 1 + | ||
11 | target/microblaze/cpu.h | 2 + | ||
12 | target/microblaze/cpu.c | 7 ++- | ||
13 | target/microblaze/gdbstub.c | 51 +++++++++++----- | ||
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/configs/targets/microblaze-linux-user.mak b/configs/targets/microblaze-linux-user.mak | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/configs/targets/microblaze-linux-user.mak | ||
23 | +++ b/configs/targets/microblaze-linux-user.mak | ||
24 | @@ -XXX,XX +XXX,XX @@ TARGET_SYSTBL_ABI=common | ||
25 | TARGET_SYSTBL=syscall.tbl | ||
26 | TARGET_BIG_ENDIAN=y | ||
27 | TARGET_HAS_BFLT=y | ||
28 | +TARGET_XML_FILES=gdb-xml/microblaze-core.xml gdb-xml/microblaze-stack-protect.xml | ||
29 | diff --git a/configs/targets/microblaze-softmmu.mak b/configs/targets/microblaze-softmmu.mak | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/configs/targets/microblaze-softmmu.mak | ||
32 | +++ b/configs/targets/microblaze-softmmu.mak | ||
33 | @@ -XXX,XX +XXX,XX @@ TARGET_ARCH=microblaze | ||
34 | TARGET_BIG_ENDIAN=y | ||
35 | TARGET_SUPPORTS_MTTCG=y | ||
36 | TARGET_NEED_FDT=y | ||
37 | +TARGET_XML_FILES=gdb-xml/microblaze-core.xml gdb-xml/microblaze-stack-protect.xml | ||
38 | diff --git a/configs/targets/microblazeel-linux-user.mak b/configs/targets/microblazeel-linux-user.mak | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/configs/targets/microblazeel-linux-user.mak | ||
41 | +++ b/configs/targets/microblazeel-linux-user.mak | ||
42 | @@ -XXX,XX +XXX,XX @@ TARGET_ARCH=microblaze | ||
43 | TARGET_SYSTBL_ABI=common | ||
44 | TARGET_SYSTBL=syscall.tbl | ||
45 | TARGET_HAS_BFLT=y | ||
46 | +TARGET_XML_FILES=gdb-xml/microblaze-core.xml gdb-xml/microblaze-stack-protect.xml | ||
47 | diff --git a/configs/targets/microblazeel-softmmu.mak b/configs/targets/microblazeel-softmmu.mak | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/configs/targets/microblazeel-softmmu.mak | ||
50 | +++ b/configs/targets/microblazeel-softmmu.mak | ||
51 | @@ -XXX,XX +XXX,XX @@ | ||
52 | TARGET_ARCH=microblaze | ||
53 | TARGET_SUPPORTS_MTTCG=y | ||
54 | TARGET_NEED_FDT=y | ||
55 | +TARGET_XML_FILES=gdb-xml/microblaze-core.xml gdb-xml/microblaze-stack-protect.xml | ||
56 | diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/microblaze/cpu.h | ||
59 | +++ b/target/microblaze/cpu.h | ||
60 | @@ -XXX,XX +XXX,XX @@ hwaddr mb_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, | ||
61 | MemTxAttrs *attrs); | ||
62 | int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); | ||
63 | int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); | ||
64 | +int mb_cpu_gdb_read_stack_protect(CPUArchState *cpu, GByteArray *buf, int reg); | ||
65 | +int mb_cpu_gdb_write_stack_protect(CPUArchState *cpu, uint8_t *buf, int reg); | ||
66 | |||
67 | static inline uint32_t mb_cpu_read_msr(const CPUMBState *env) | ||
68 | { | ||
69 | diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/microblaze/cpu.c | ||
72 | +++ b/target/microblaze/cpu.c | ||
73 | @@ -XXX,XX +XXX,XX @@ | ||
74 | #include "qemu/module.h" | ||
75 | #include "hw/qdev-properties.h" | ||
76 | #include "exec/exec-all.h" | ||
77 | +#include "exec/gdbstub.h" | ||
78 | #include "fpu/softfloat-helpers.h" | ||
79 | |||
80 | static const struct { | ||
81 | @@ -XXX,XX +XXX,XX @@ static void mb_cpu_initfn(Object *obj) | ||
82 | CPUMBState *env = &cpu->env; | ||
83 | |||
84 | cpu_set_cpustate_pointers(cpu); | ||
85 | + gdb_register_coprocessor(CPU(cpu), mb_cpu_gdb_read_stack_protect, | ||
86 | + mb_cpu_gdb_write_stack_protect, 2, | ||
87 | + "microblaze-stack-protect.xml", 0); | ||
88 | |||
89 | set_float_rounding_mode(float_round_nearest_even, &env->fp_status); | ||
90 | |||
91 | @@ -XXX,XX +XXX,XX @@ static void mb_cpu_class_init(ObjectClass *oc, void *data) | ||
92 | cc->sysemu_ops = &mb_sysemu_ops; | ||
93 | #endif | ||
94 | device_class_set_props(dc, mb_properties); | ||
95 | - cc->gdb_num_core_regs = 32 + 27; | ||
96 | + cc->gdb_num_core_regs = 32 + 25; | ||
97 | + cc->gdb_core_xml_file = "microblaze-core.xml"; | ||
98 | |||
99 | cc->disas_set_info = mb_disas_set_info; | ||
100 | cc->tcg_ops = &mb_tcg_ops; | ||
101 | diff --git a/target/microblaze/gdbstub.c b/target/microblaze/gdbstub.c | ||
102 | index XXXXXXX..XXXXXXX 100644 | ||
103 | --- a/target/microblaze/gdbstub.c | ||
104 | +++ b/target/microblaze/gdbstub.c | ||
105 | @@ -XXX,XX +XXX,XX @@ enum { | ||
106 | GDB_PVR0 = 32 + 6, | ||
107 | GDB_PVR11 = 32 + 17, | ||
108 | GDB_EDR = 32 + 18, | ||
109 | - GDB_SLR = 32 + 25, | ||
110 | - GDB_SHR = 32 + 26, | ||
111 | +}; | ||
112 | + | ||
113 | +enum { | ||
114 | + GDB_SP_SHL, | ||
115 | + GDB_SP_SHR, | ||
116 | }; | ||
117 | |||
118 | int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) | ||
119 | @@ -XXX,XX +XXX,XX @@ int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) | ||
120 | case GDB_EDR: | ||
121 | val = env->edr; | ||
122 | break; | ||
123 | - case GDB_SLR: | ||
124 | - val = env->slr; | ||
125 | - break; | ||
126 | - case GDB_SHR: | ||
127 | - val = env->shr; | ||
128 | - break; | ||
129 | default: | ||
130 | /* Other SRegs aren't modeled, so report a value of 0 */ | ||
131 | val = 0; | ||
132 | @@ -XXX,XX +XXX,XX @@ int mb_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n) | ||
133 | return gdb_get_reg32(mem_buf, val); | ||
134 | } | ||
135 | |||
136 | +int mb_cpu_gdb_read_stack_protect(CPUMBState *env, GByteArray *mem_buf, int n) | ||
137 | +{ | ||
138 | + uint32_t val; | ||
139 | + | ||
140 | + switch (n) { | ||
141 | + case GDB_SP_SHL: | ||
142 | + val = env->slr; | ||
143 | + break; | ||
144 | + case GDB_SP_SHR: | ||
145 | + val = env->shr; | ||
146 | + break; | ||
147 | + default: | ||
148 | + return 0; | ||
149 | + } | ||
150 | + return gdb_get_reg32(mem_buf, val); | ||
151 | +} | ||
152 | + | ||
153 | int mb_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) | ||
154 | { | ||
155 | MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs); | ||
156 | @@ -XXX,XX +XXX,XX @@ int mb_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) | ||
157 | case GDB_EDR: | ||
158 | env->edr = tmp; | ||
159 | break; | ||
160 | - case GDB_SLR: | ||
161 | - env->slr = tmp; | ||
162 | - break; | ||
163 | - case GDB_SHR: | ||
164 | - env->shr = tmp; | ||
165 | - break; | ||
166 | + } | ||
167 | + return 4; | ||
168 | +} | ||
169 | + | ||
170 | +int mb_cpu_gdb_write_stack_protect(CPUMBState *env, uint8_t *mem_buf, int n) | ||
171 | +{ | ||
172 | + switch (n) { | ||
173 | + case GDB_SP_SHL: | ||
174 | + env->slr = ldl_p(mem_buf); | ||
175 | + break; | ||
176 | + case GDB_SP_SHR: | ||
177 | + env->shr = ldl_p(mem_buf); | ||
178 | + break; | ||
179 | + default: | ||
180 | + return 0; | ||
181 | } | ||
182 | return 4; | ||
183 | } | ||
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 |