Skip to content

Commit 04cbbde

Browse files
committed
Merge branch 'tcg-sparc' of git://repo.or.cz/qemu/rth
* 'tcg-sparc' of git://repo.or.cz/qemu/rth: tcg-sparc: Preserve branch destinations during retranslation tcg-sparc: Fix and enable direct TB chaining. tcg-sparc: Add %g/%o registers to alloc_order tcg-sparc: Use defines for temporaries. tcg-sparc: Mask shift immediates to avoid illegal insns. tcg-sparc: Clean up cruft stemming from attempts to use global registers. tcg-sparc: Change AREG0 in generated code to %i0. tcg-sparc: Support GUEST_BASE. tcg-sparc: Fix qemu_ld/st to handle 32-bit host. tcg-sparc: Assume v9 cpu always, i.e. force v8plus in 32-bit mode. tcg-sparc: Don't MAP_FIXED on top of the program tcg-sparc: Fix ADDX opcode. tcg-sparc: Hack in qemu_ld/st64 for 32-bit. linux-user: Use memcpy in get_user/put_user.
2 parents ef04a84 + f4bf0b9 commit 04cbbde

File tree

9 files changed

+514
-622
lines changed

9 files changed

+514
-622
lines changed

Diff for: configure

+5-47
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ source_path=`dirname "$0"`
111111
cpu=""
112112
interp_prefix="/usr/gnemul/qemu-%M"
113113
static="no"
114-
sparc_cpu=""
115114
cross_prefix=""
116115
audio_drv_list=""
117116
audio_card_list="ac97 es1370 sb16 hda"
@@ -241,21 +240,6 @@ for opt do
241240
;;
242241
--disable-debug-info) debug_info="no"
243242
;;
244-
--sparc_cpu=*)
245-
sparc_cpu="$optarg"
246-
case $sparc_cpu in
247-
v7|v8|v8plus|v8plusa)
248-
cpu="sparc"
249-
;;
250-
v9)
251-
cpu="sparc64"
252-
;;
253-
*)
254-
echo "undefined SPARC architecture. Exiting";
255-
exit 1
256-
;;
257-
esac
258-
;;
259243
esac
260244
done
261245
# OS specific
@@ -343,8 +327,6 @@ elif check_define __i386__ ; then
343327
elif check_define __x86_64__ ; then
344328
cpu="x86_64"
345329
elif check_define __sparc__ ; then
346-
# We can't check for 64 bit (when gcc is biarch) or V8PLUSA
347-
# They must be specified using --sparc_cpu
348330
if check_define __arch64__ ; then
349331
cpu="sparc64"
350332
else
@@ -792,8 +774,6 @@ for opt do
792774
;;
793775
--enable-uname-release=*) uname_release="$optarg"
794776
;;
795-
--sparc_cpu=*)
796-
;;
797777
--enable-werror) werror="yes"
798778
;;
799779
--disable-werror) werror="no"
@@ -881,35 +861,17 @@ for opt do
881861
esac
882862
done
883863

884-
#
885-
# If cpu ~= sparc and sparc_cpu hasn't been defined, plug in the right
886-
# QEMU_CFLAGS/LDFLAGS (assume sparc_v8plus for 32-bit and sparc_v9 for 64-bit)
887-
#
888864
host_guest_base="no"
889865
case "$cpu" in
890-
sparc) case $sparc_cpu in
891-
v7|v8)
892-
QEMU_CFLAGS="-mcpu=${sparc_cpu} -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
893-
;;
894-
v8plus|v8plusa)
895-
QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_${sparc_cpu}__ $QEMU_CFLAGS"
896-
;;
897-
*) # sparc_cpu not defined in the command line
898-
QEMU_CFLAGS="-mcpu=ultrasparc -D__sparc_v8plus__ $QEMU_CFLAGS"
899-
esac
866+
sparc)
900867
LDFLAGS="-m32 $LDFLAGS"
901-
QEMU_CFLAGS="-m32 -ffixed-g2 -ffixed-g3 $QEMU_CFLAGS"
902-
if test "$solaris" = "no" ; then
903-
QEMU_CFLAGS="-ffixed-g1 -ffixed-g6 $QEMU_CFLAGS"
904-
fi
868+
QEMU_CFLAGS="-m32 -mcpu=ultrasparc $QEMU_CFLAGS"
869+
host_guest_base="yes"
905870
;;
906871
sparc64)
907-
QEMU_CFLAGS="-m64 -mcpu=ultrasparc -D__sparc_v9__ $QEMU_CFLAGS"
908872
LDFLAGS="-m64 $LDFLAGS"
909-
QEMU_CFLAGS="-ffixed-g5 -ffixed-g6 -ffixed-g7 $QEMU_CFLAGS"
910-
if test "$solaris" != "no" ; then
911-
QEMU_CFLAGS="-ffixed-g1 $QEMU_CFLAGS"
912-
fi
873+
QEMU_CFLAGS="-m64 -mcpu=ultrasparc $QEMU_CFLAGS"
874+
host_guest_base="yes"
913875
;;
914876
s390)
915877
QEMU_CFLAGS="-m31 -march=z990 $QEMU_CFLAGS"
@@ -4131,10 +4093,6 @@ fi
41314093

41324094
if test "$target_linux_user" = "yes" -o "$target_bsd_user" = "yes" ; then
41334095
case "$ARCH" in
4134-
sparc)
4135-
# -static is used to avoid g1/g3 usage by the dynamic linker
4136-
ldflags="$linker_script -static $ldflags"
4137-
;;
41384096
alpha | s390x)
41394097
# The default placement of the application is fine.
41404098
;;

Diff for: disas.c

-2
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,7 @@ void disas(FILE *out, void *code, unsigned long size)
316316
print_insn = print_insn_alpha;
317317
#elif defined(__sparc__)
318318
print_insn = print_insn_sparc;
319-
#if defined(__sparc_v8plus__) || defined(__sparc_v8plusa__) || defined(__sparc_v9__)
320319
disasm_info.mach = bfd_mach_sparc_v9b;
321-
#endif
322320
#elif defined(__arm__)
323321
print_insn = print_insn_arm;
324322
#elif defined(__MIPSEB__)

Diff for: exec-all.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,10 @@ static inline void tlb_flush(CPUArchState *env, int flush_global)
132132
#define CODE_GEN_AVG_BLOCK_SIZE 64
133133
#endif
134134

135-
#if defined(_ARCH_PPC) || defined(__x86_64__) || defined(__arm__) || defined(__i386__)
136-
#define USE_DIRECT_JUMP
137-
#elif defined(CONFIG_TCG_INTERPRETER)
135+
#if defined(__arm__) || defined(_ARCH_PPC) \
136+
|| defined(__x86_64__) || defined(__i386__) \
137+
|| defined(__sparc__) \
138+
|| defined(CONFIG_TCG_INTERPRETER)
138139
#define USE_DIRECT_JUMP
139140
#endif
140141

@@ -244,6 +245,8 @@ static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr)
244245
__asm __volatile__ ("swi 0x9f0002" : : "r" (_beg), "r" (_end), "r" (_flg));
245246
#endif
246247
}
248+
#elif defined(__sparc__)
249+
void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr);
247250
#else
248251
#error tb_set_jmp_target1 is missing
249252
#endif

Diff for: exec.c

+5-7
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static int nb_tbs;
8686
/* any access to the tbs or the page table must use this lock */
8787
spinlock_t tb_lock = SPIN_LOCK_UNLOCKED;
8888

89-
#if defined(__arm__) || defined(__sparc_v9__)
89+
#if defined(__arm__) || defined(__sparc__)
9090
/* The prologue must be reachable with a direct jump. ARM and Sparc64
9191
have limited branch ranges (possibly also PPC) so place it in a
9292
section close to code segment. */
@@ -541,10 +541,9 @@ static void code_gen_alloc(unsigned long tb_size)
541541
/* Cannot map more than that */
542542
if (code_gen_buffer_size > (800 * 1024 * 1024))
543543
code_gen_buffer_size = (800 * 1024 * 1024);
544-
#elif defined(__sparc_v9__)
544+
#elif defined(__sparc__) && HOST_LONG_BITS == 64
545545
// Map the buffer below 2G, so we can use direct calls and branches
546-
flags |= MAP_FIXED;
547-
start = (void *) 0x60000000UL;
546+
start = (void *) 0x40000000UL;
548547
if (code_gen_buffer_size > (512 * 1024 * 1024))
549548
code_gen_buffer_size = (512 * 1024 * 1024);
550549
#elif defined(__arm__)
@@ -582,10 +581,9 @@ static void code_gen_alloc(unsigned long tb_size)
582581
/* Cannot map more than that */
583582
if (code_gen_buffer_size > (800 * 1024 * 1024))
584583
code_gen_buffer_size = (800 * 1024 * 1024);
585-
#elif defined(__sparc_v9__)
584+
#elif defined(__sparc__) && HOST_LONG_BITS == 64
586585
// Map the buffer below 2G, so we can use direct calls and branches
587-
flags |= MAP_FIXED;
588-
addr = (void *) 0x60000000UL;
586+
addr = (void *) 0x40000000UL;
589587
if (code_gen_buffer_size > (512 * 1024 * 1024)) {
590588
code_gen_buffer_size = (512 * 1024 * 1024);
591589
}

Diff for: linux-user/qemu.h

+15-32
Original file line numberDiff line numberDiff line change
@@ -289,46 +289,29 @@ static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
289289
* struct has been locked - usually with lock_user_struct().
290290
*/
291291
#define __put_user(x, hptr)\
292-
({\
292+
({ __typeof(*hptr) pu_ = (x);\
293293
switch(sizeof(*hptr)) {\
294-
case 1:\
295-
*(uint8_t *)(hptr) = (uint8_t)(typeof(*hptr))(x);\
296-
break;\
297-
case 2:\
298-
*(uint16_t *)(hptr) = tswap16((uint16_t)(typeof(*hptr))(x));\
299-
break;\
300-
case 4:\
301-
*(uint32_t *)(hptr) = tswap32((uint32_t)(typeof(*hptr))(x));\
302-
break;\
303-
case 8:\
304-
*(uint64_t *)(hptr) = tswap64((typeof(*hptr))(x));\
305-
break;\
306-
default:\
307-
abort();\
294+
case 1: break;\
295+
case 2: pu_ = tswap16(pu_); break; \
296+
case 4: pu_ = tswap32(pu_); break; \
297+
case 8: pu_ = tswap64(pu_); break; \
298+
default: abort();\
308299
}\
300+
memcpy(hptr, &pu_, sizeof(pu_)); \
309301
0;\
310302
})
311303

312304
#define __get_user(x, hptr) \
313-
({\
305+
({ __typeof(*hptr) gu_; \
306+
memcpy(&gu_, hptr, sizeof(gu_)); \
314307
switch(sizeof(*hptr)) {\
315-
case 1:\
316-
x = (typeof(*hptr))*(uint8_t *)(hptr);\
317-
break;\
318-
case 2:\
319-
x = (typeof(*hptr))tswap16(*(uint16_t *)(hptr));\
320-
break;\
321-
case 4:\
322-
x = (typeof(*hptr))tswap32(*(uint32_t *)(hptr));\
323-
break;\
324-
case 8:\
325-
x = (typeof(*hptr))tswap64(*(uint64_t *)(hptr));\
326-
break;\
327-
default:\
328-
/* avoid warning */\
329-
x = 0;\
330-
abort();\
308+
case 1: break; \
309+
case 2: gu_ = tswap16(gu_); break; \
310+
case 4: gu_ = tswap32(gu_); break; \
311+
case 8: gu_ = tswap64(gu_); break; \
312+
default: abort();\
331313
}\
314+
(x) = gu_; \
332315
0;\
333316
})
334317

Diff for: qemu-timer.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static inline int64_t cpu_get_real_ticks(void)
218218
return val;
219219
}
220220

221-
#elif defined(__sparc_v8plus__) || defined(__sparc_v8plusa__) || defined(__sparc_v9__)
221+
#elif defined(__sparc__)
222222

223223
static inline int64_t cpu_get_real_ticks (void)
224224
{
@@ -227,15 +227,17 @@ static inline int64_t cpu_get_real_ticks (void)
227227
asm volatile("rd %%tick,%0" : "=r"(rval));
228228
return rval;
229229
#else
230+
/* We need an %o or %g register for this. For recent enough gcc
231+
there is an "h" constraint for that. Don't bother with that. */
230232
union {
231233
uint64_t i64;
232234
struct {
233235
uint32_t high;
234236
uint32_t low;
235237
} i32;
236238
} rval;
237-
asm volatile("rd %%tick,%1; srlx %1,32,%0"
238-
: "=r"(rval.i32.high), "=r"(rval.i32.low));
239+
asm volatile("rd %%tick,%%g1; srlx %%g1,32,%0; mov %%g1,%1"
240+
: "=r"(rval.i32.high), "=r"(rval.i32.low) : : "g1");
239241
return rval.i64;
240242
#endif
241243
}

0 commit comments

Comments
 (0)