提交 2f619698 编写于 作者: B bellard

suppressed tgetx and tputx (initial patch by Thayne Harbaugh)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3653 c046a42c-6fe2-441c-8c8c-71466251a162
上级 67276f53
......@@ -165,8 +165,14 @@ static void arm_semi_flen_cb(CPUState *env, target_ulong ret, target_ulong err)
#endif
}
#define ARG(n) tget32(args + (n) * 4)
#define SET_ARG(n, val) tput32(args + (n) * 4,val)
#define ARG(n) \
({ \
target_ulong __arg; \
/* FIXME - handle get_user() failure */ \
get_user_ual(__arg, args + (n) * 4); \
__arg; \
})
#define SET_ARG(n, val) put_user_ual(val, args + (n) * 4)
uint32_t do_arm_semihosting(CPUState *env)
{
target_ulong args;
......@@ -213,7 +219,11 @@ uint32_t do_arm_semihosting(CPUState *env)
}
case SYS_WRITEC:
{
char c = tget8(args);
char c;
if (get_user_u8(c, args))
/* FIXME - should this error code be -TARGET_EFAULT ? */
return (uint32_t)-1;
/* Write to debug console. stderr is near enough. */
if (use_gdb_syscalls()) {
gdb_do_syscall(arm_semi_cb, "write,2,%x,1", args);
......
......@@ -179,8 +179,9 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i
regs->ARM_cpsr |= CPSR_T;
regs->ARM_pc = infop->entry & 0xfffffffe;
regs->ARM_sp = infop->start_stack;
regs->ARM_r2 = tgetl(stack + 8); /* envp */
regs->ARM_r1 = tgetl(stack + 4); /* envp */
/* FIXME - what to for failure of get_user()? */
get_user_ual(regs->ARM_r2, stack + 8); /* envp */
get_user_ual(regs->ARM_r1, stack + 4); /* envp */
/* XXX: it seems that r0 is zeroed after ! */
regs->ARM_r0 = 0;
/* For uClinux PIC binaries. */
......@@ -341,7 +342,8 @@ static inline void init_thread(struct target_pt_regs *_regs, struct image_info *
* but this is what the ABI wants and is needed to allow
* execution of PPC BSD programs.
*/
_regs->gpr[3] = tgetl(pos);
/* FIXME - what to for failure of get_user()? */
get_user_ual(_regs->gpr[3], pos);
pos += sizeof(abi_ulong);
_regs->gpr[4] = pos;
for (tmp = 1; tmp != 0; pos += sizeof(abi_ulong))
......@@ -733,7 +735,8 @@ static void padzero(abi_ulong elf_bss, abi_ulong last_bss)
if (nbyte) {
nbyte = qemu_host_page_size - nbyte;
do {
tput8(elf_bss, 0);
/* FIXME - what to do if put_user() fails? */
put_user_u8(0, elf_bss);
elf_bss++;
} while (--nbyte);
}
......@@ -782,17 +785,11 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
/* This is correct because Linux defines
* elf_addr_t as Elf32_Off / Elf64_Off
*/
#if ELF_CLASS == ELFCLASS32
#define NEW_AUX_ENT(id, val) do { \
sp -= n; tput32(sp, val); \
sp -= n; tput32(sp, id); \
#define NEW_AUX_ENT(id, val) do { \
sp -= n; put_user_ual(val, sp); \
sp -= n; put_user_ual(id, sp); \
} while(0)
#else
#define NEW_AUX_ENT(id, val) do { \
sp -= n; tput64(sp, val); \
sp -= n; tput64(sp, id); \
} while(0)
#endif
NEW_AUX_ENT (AT_NULL, 0);
/* There must be exactly DLINFO_ITEMS entries here. */
......
......@@ -598,14 +598,16 @@ static int load_flat_file(struct linux_binprm * bprm,
rp = datapos;
while (1) {
abi_ulong addr;
addr = tgetl(rp);
if (get_user_ual(addr, rp))
return -EFAULT;
if (addr == -1)
break;
if (addr) {
addr = calc_reloc(addr, libinfo, id, 0);
if (addr == RELOC_FAILED)
return -ENOEXEC;
tputl(rp, addr);
if (put_user_ual(addr, rp))
return -EFAULT;
}
rp += sizeof(abi_ulong);
}
......@@ -629,14 +631,16 @@ static int load_flat_file(struct linux_binprm * bprm,
/* Get the address of the pointer to be
relocated (of course, the address has to be
relocated first). */
relval = tgetl(reloc + i * sizeof (abi_ulong));
if (get_user_ual(relval, reloc + i * sizeof(abi_ulong)))
return -EFAULT;
addr = flat_get_relocate_addr(relval);
rp = calc_reloc(addr, libinfo, id, 1);
if (rp == RELOC_FAILED)
return -ENOEXEC;
/* Get the pointer's value. */
addr = tgetl(rp);
if (get_user_ual(addr, rp))
return -EFAULT;
if (addr != 0) {
/*
* Do the relocation. PIC relocs in the data section are
......@@ -652,13 +656,15 @@ static int load_flat_file(struct linux_binprm * bprm,
return -ENOEXEC;
/* Write back the relocated pointer. */
tputl(rp, addr);
if (put_user_ual(addr, rp))
return -EFAULT;
}
}
} else {
for (i = 0; i < relocs; i++) {
abi_ulong relval;
relval = tgetl(reloc + i * sizeof (abi_ulong));
if (get_user_ual(relval, reloc + i * sizeof(abi_ulong)))
return -EFAULT;
old_reloc(&libinfo[0], relval);
}
}
......@@ -744,9 +750,12 @@ int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
p = libinfo[i].start_data;
for (j=0; j<MAX_SHARED_LIBS; j++) {
p -= 4;
tput32(p, libinfo[j].loaded
? libinfo[j].start_data
: UNLOADED_LIB);
/* FIXME - handle put_user() failures */
if (put_user_ual(libinfo[j].loaded
? libinfo[j].start_data
: UNLOADED_LIB,
p))
return -EFAULT;
}
}
}
......@@ -779,7 +788,9 @@ int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
for (i = MAX_SHARED_LIBS-1; i>0; i--) {
if (libinfo[i].loaded) {
/* Push previos first to call address */
--sp; put_user(start_addr, sp);
--sp;
if (put_user_ual(start_addr, sp))
return -EFAULT;
start_addr = libinfo[i].entry;
}
}
......
......@@ -124,21 +124,32 @@ abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
sp -= (argc + 1) * n;
argv = sp;
if (push_ptr) {
sp -= n; tputl(sp, envp);
sp -= n; tputl(sp, argv);
/* FIXME - handle put_user() failures */
sp -= n;
put_user_ual(envp, sp);
sp -= n;
put_user_ual(argv, sp);
}
sp -= n; tputl(sp, argc);
sp -= n;
/* FIXME - handle put_user() failures */
put_user_ual(argc, sp);
while (argc-- > 0) {
tputl(argv, stringp); argv += n;
/* FIXME - handle put_user() failures */
put_user_ual(stringp, argv);
argv += n;
stringp += target_strlen(stringp) + 1;
}
tputl(argv, 0);
/* FIXME - handle put_user() failures */
put_user_ual(0, argv);
while (envc-- > 0) {
tputl(envp, stringp); envp += n;
/* FIXME - handle put_user() failures */
put_user_ual(stringp, envp);
envp += n;
stringp += target_strlen(stringp) + 1;
}
tputl(envp, 0);
/* FIXME - handle put_user() failures */
put_user_ual(0, envp);
return sp;
}
......
......@@ -380,7 +380,8 @@ void cpu_loop(CPUARMState *env)
/* we handle the FPU emulation here, as Linux */
/* we get the opcode */
opcode = tget32(env->regs[15]);
/* FIXME - what to do if get_user() fails? */
get_user_u32(opcode, env->regs[15]);
if (EmulateAll(opcode, &ts->fpa, env) == 0) {
info.si_signo = SIGILL;
......@@ -401,20 +402,24 @@ void cpu_loop(CPUARMState *env)
/* system call */
if (trapnr == EXCP_BKPT) {
if (env->thumb) {
insn = tget16(env->regs[15]);
/* FIXME - what to do if get_user() fails? */
get_user_u16(insn, env->regs[15]);
n = insn & 0xff;
env->regs[15] += 2;
} else {
insn = tget32(env->regs[15]);
/* FIXME - what to do if get_user() fails? */
get_user_u32(insn, env->regs[15]);
n = (insn & 0xf) | ((insn >> 4) & 0xff0);
env->regs[15] += 4;
}
} else {
if (env->thumb) {
insn = tget16(env->regs[15] - 2);
/* FIXME - what to do if get_user() fails? */
get_user_u16(insn, env->regs[15] - 2);
n = insn & 0xff;
} else {
insn = tget32(env->regs[15] - 4);
/* FIXME - what to do if get_user() fails? */
get_user_u32(insn, env->regs[15] - 4);
n = insn & 0xffffff;
}
}
......@@ -520,7 +525,8 @@ static inline void save_window_offset(CPUSPARCState *env, int cwp1)
(int)sp_ptr, cwp1);
#endif
for(i = 0; i < 16; i++) {
tputl(sp_ptr, env->regbase[get_reg_index(env, cwp1, 8 + i)]);
/* FIXME - what to do if put_user() fails? */
put_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr);
sp_ptr += sizeof(abi_ulong);
}
}
......@@ -556,7 +562,8 @@ static void restore_window(CPUSPARCState *env)
(int)sp_ptr, cwp1);
#endif
for(i = 0; i < 16; i++) {
env->regbase[get_reg_index(env, cwp1, 8 + i)] = tgetl(sp_ptr);
/* FIXME - what to do if get_user() fails? */
get_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr);
sp_ptr += sizeof(abi_ulong);
}
env->wim = new_wim;
......@@ -1533,10 +1540,11 @@ void cpu_loop(CPUMIPSState *env)
sp_reg = env->gpr[29][env->current_tc];
switch (nb_args) {
/* these arguments are taken from the stack */
case 8: arg8 = tgetl(sp_reg + 28);
case 7: arg7 = tgetl(sp_reg + 24);
case 6: arg6 = tgetl(sp_reg + 20);
case 5: arg5 = tgetl(sp_reg + 16);
/* FIXME - what to do if get_user() fails? */
case 8: get_user_ual(arg8, sp_reg + 28);
case 7: get_user_ual(arg7, sp_reg + 24);
case 6: get_user_ual(arg6, sp_reg + 20);
case 5: get_user_ual(arg5, sp_reg + 16);
default:
break;
}
......
......@@ -226,7 +226,7 @@ static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
int size = sizeof(*hptr);\
switch(size) {\
case 1:\
*(uint8_t *)(hptr) = (typeof(*hptr))(x);\
*(uint8_t *)(hptr) = (uint8_t)(typeof(*hptr))(x);\
break;\
case 2:\
*(uint16_t *)(hptr) = tswap16((typeof(*hptr))(x));\
......@@ -260,6 +260,8 @@ static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
x = (typeof(*hptr))tswap64(*(uint64_t *)(hptr));\
break;\
default:\
/* avoid warning */\
x = 0;\
abort();\
}\
0;\
......@@ -291,11 +293,36 @@ static inline int access_ok(int type, abi_ulong addr, abi_ulong size)
if ((__hptr = lock_user(VERIFY_READ, __gaddr, sizeof(target_type), 1))) { \
__ret = __get_user((x), __hptr); \
unlock_user(__hptr, __gaddr, 0); \
} else \
} else { \
/* avoid warning */ \
(x) = 0; \
__ret = -TARGET_EFAULT; \
} \
__ret; \
})
#define put_user_ual(x, gaddr) put_user((x), (gaddr), abi_ulong)
#define put_user_sal(x, gaddr) put_user((x), (gaddr), abi_long)
#define put_user_u64(x, gaddr) put_user((x), (gaddr), uint64_t)
#define put_user_s64(x, gaddr) put_user((x), (gaddr), int64_t)
#define put_user_u32(x, gaddr) put_user((x), (gaddr), uint32_t)
#define put_user_s32(x, gaddr) put_user((x), (gaddr), int32_t)
#define put_user_u16(x, gaddr) put_user((x), (gaddr), uint16_t)
#define put_user_s16(x, gaddr) put_user((x), (gaddr), int16_t)
#define put_user_u8(x, gaddr) put_user((x), (gaddr), uint8_t)
#define put_user_s8(x, gaddr) put_user((x), (gaddr), int8_t)
#define get_user_ual(x, gaddr) get_user((x), (gaddr), abi_ulong)
#define get_user_sal(x, gaddr) get_user((x), (gaddr), abi_long)
#define get_user_u64(x, gaddr) get_user((x), (gaddr), uint64_t)
#define get_user_s64(x, gaddr) get_user((x), (gaddr), int64_t)
#define get_user_u32(x, gaddr) get_user((x), (gaddr), uint32_t)
#define get_user_s32(x, gaddr) get_user((x), (gaddr), int32_t)
#define get_user_u16(x, gaddr) get_user((x), (gaddr), uint16_t)
#define get_user_s16(x, gaddr) get_user((x), (gaddr), int16_t)
#define get_user_u8(x, gaddr) get_user((x), (gaddr), uint8_t)
#define get_user_s8(x, gaddr) get_user((x), (gaddr), int8_t)
/* copy_from_user() and copy_to_user() are usually used to copy data
* buffers between the target and host. These internally perform
* locking/unlocking of the memory.
......@@ -368,20 +395,4 @@ static inline void *lock_user_string(abi_ulong guest_addr)
#define unlock_user_struct(host_ptr, guest_addr, copy) \
unlock_user(host_ptr, guest_addr, (copy) ? sizeof(*host_ptr) : 0)
#define tget8(addr) ldub(addr)
#define tput8(addr, val) stb(addr, val)
#define tget16(addr) lduw(addr)
#define tput16(addr, val) stw(addr, val)
#define tget32(addr) ldl(addr)
#define tput32(addr, val) stl(addr, val)
#define tget64(addr) ldq(addr)
#define tput64(addr, val) stq(addr, val)
#if TARGET_ABI_BITS == 64
#define tgetl(addr) ldq(addr)
#define tputl(addr, val) stq(addr, val)
#else
#define tgetl(addr) ldl(addr)
#define tputl(addr, val) stl(addr, val)
#endif
#endif /* QEMU_H */
此差异已折叠。
......@@ -142,15 +142,23 @@ static void m68k_semi_cb(CPUState *env, target_ulong ret, target_ulong err)
if (m68k_semi_is_fseek) {
/* FIXME: We've already lost the high bits of the fseek
return value. */
tput32(args, 0);
/* FIXME - handle put_user() failure */
put_user_u32(0, args);
args += 4;
m68k_semi_is_fseek = 0;
}
tput32(args, ret);
tput32(args + 4, errno);
/* FIXME - handle put_user() failure */
put_user_u32(ret, args);
put_user_u32(errno, args + 4);
}
#define ARG(x) tget32(args + (x) * 4)
#define ARG(n) \
({ \
target_ulong __arg; \
/* FIXME - handle get_user() failure */ \
get_user_ual(__arg, args + (n) * 4); \
__arg; \
})
#define PARG(x) ((unsigned long)ARG(x))
void do_m68k_semihosting(CPUM68KState *env, int nr)
{
......@@ -237,9 +245,10 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
ARG(0), off, ARG(3));
} else {
off = lseek(ARG(0), off, ARG(3));
tput32(args, off >> 32);
tput32(args + 4, off);
tput32(args + 8, errno);
/* FIXME - handle put_user() failure */
put_user_u32(off >> 32, args);
put_user_u32(off, args + 4);
put_user_u32(errno, args + 8);
}
return;
}
......@@ -390,6 +399,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
cpu_abort(env, "Unsupported semihosting syscall %d\n", nr);
result = 0;
}
tput32(args, result);
tput32(args + 4, errno);
/* FIXME - handle put_user() failure */
put_user_u32(result, args);
put_user_u32(errno, args + 4);
}
......@@ -21,15 +21,18 @@ static inline uint32_t softmmu_tget8(CPUState *env, uint32_t addr)
cpu_memory_rw_debug(env, addr, &val, 1, 0);
return val;
}
#define tget32(p) softmmu_tget32(env, p)
#define tget8(p) softmmu_tget8(env, p)
#define get_user_u32(arg, p) ({ arg = softmmu_tget32(env, p) ; 0; })
#define get_user_u8(arg, p) ({ arg = softmmu_tget8(env, p) ; 0; })
#define get_user_ual(arg, p) get_user_u32(arg, p)
static inline void softmmu_tput32(CPUState *env, uint32_t addr, uint32_t val)
{
val = tswap32(val);
cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 1);
}
#define tput32(p, val) softmmu_tput32(env, p, val)
#define put_user_u32(arg, p) ({ softmmu_tput32(env, p, arg) ; 0; })
#define put_user_ual(arg, p) put_user_u32(arg, p)
static void *softmmu_lock_user(CPUState *env, uint32_t addr, uint32_t len,
int copy)
......
......@@ -34,7 +34,8 @@ void loadSingle(const unsigned int Fn,const unsigned int *pMem)
target_ulong addr = (target_ulong)(long)pMem;
FPA11 *fpa11 = GET_FPA11();
fpa11->fType[Fn] = typeSingle;
fpa11->fpreg[Fn].fSingle = tget32(addr);
/* FIXME - handle failure of get_user() */
get_user_u32(fpa11->fpreg[Fn].fSingle, addr);
}
static inline
......@@ -46,11 +47,13 @@ void loadDouble(const unsigned int Fn,const unsigned int *pMem)
p = (unsigned int*)&fpa11->fpreg[Fn].fDouble;
fpa11->fType[Fn] = typeDouble;
#ifdef WORDS_BIGENDIAN
p[0] = tget32(addr); /* sign & exponent */
p[1] = tget32(addr + 4);
/* FIXME - handle failure of get_user() */
get_user_u32(p[0], addr); /* sign & exponent */
get_user_u32(p[1], addr + 4);
#else
p[0] = tget32(addr + 4);
p[1] = tget32(addr); /* sign & exponent */
/* FIXME - handle failure of get_user() */
get_user_u32(p[0], addr + 4);
get_user_u32(p[1], addr); /* sign & exponent */
#endif
}
......@@ -62,9 +65,10 @@ void loadExtended(const unsigned int Fn,const unsigned int *pMem)
unsigned int *p;
p = (unsigned int*)&fpa11->fpreg[Fn].fExtended;
fpa11->fType[Fn] = typeExtended;
p[0] = tget32(addr); /* sign & exponent */
p[1] = tget32(addr + 8); /* ls bits */
p[2] = tget32(addr + 4); /* ms bits */
/* FIXME - handle failure of get_user() */
get_user_u32(p[0], addr); /* sign & exponent */
get_user_u32(p[1], addr + 8); /* ls bits */
get_user_u32(p[2], addr + 4); /* ms bits */
}
static inline
......@@ -76,7 +80,8 @@ void loadMultiple(const unsigned int Fn,const unsigned int *pMem)
unsigned long x;
p = (unsigned int*)&(fpa11->fpreg[Fn]);
x = tget32(addr);
/* FIXME - handle failure of get_user() */
get_user_u32(x, addr);
fpa11->fType[Fn] = (x >> 14) & 0x00000003;
switch (fpa11->fType[Fn])
......@@ -84,16 +89,18 @@ void loadMultiple(const unsigned int Fn,const unsigned int *pMem)
case typeSingle:
case typeDouble:
{
p[0] = tget32(addr + 8); /* Single */
p[1] = tget32(addr + 4); /* double msw */
/* FIXME - handle failure of get_user() */
get_user_u32(p[0], addr + 8); /* Single */
get_user_u32(p[1], addr + 4); /* double msw */
p[2] = 0; /* empty */
}
break;
case typeExtended:
{
p[1] = tget32(addr + 8);
p[2] = tget32(addr + 4); /* msw */
/* FIXME - handle failure of get_user() */
get_user_u32(p[1], addr + 8);
get_user_u32(p[2], addr + 4); /* msw */
p[0] = (x & 0x80003fff);
}
break;
......@@ -121,7 +128,8 @@ void storeSingle(const unsigned int Fn,unsigned int *pMem)
default: val = fpa11->fpreg[Fn].fSingle;
}
tput32(addr, p[0]);
/* FIXME - handle put_user() failures */
put_user_u32(p[0], addr);
}
static inline
......@@ -144,12 +152,13 @@ void storeDouble(const unsigned int Fn,unsigned int *pMem)
default: val = fpa11->fpreg[Fn].fDouble;
}
/* FIXME - handle put_user() failures */
#ifdef WORDS_BIGENDIAN
tput32(addr, p[0]); /* msw */
tput32(addr + 4, p[1]); /* lsw */
put_user_u32(p[0], addr); /* msw */
put_user_u32(p[1], addr + 4); /* lsw */
#else
tput32(addr, p[1]); /* msw */
tput32(addr + 4, p[0]); /* lsw */
put_user_u32(p[1], addr); /* msw */
put_user_u32(p[0], addr + 4); /* lsw */
#endif
}
......@@ -174,9 +183,10 @@ void storeExtended(const unsigned int Fn,unsigned int *pMem)
default: val = fpa11->fpreg[Fn].fExtended;
}
tput32(addr, p[0]); /* sign & exp */
tput32(addr + 8, p[1]);
tput32(addr + 4, p[2]); /* msw */
/* FIXME - handle put_user() failures */
put_user_u32(p[0], addr); /* sign & exp */
put_user_u32(p[1], addr + 8);
put_user_u32(p[2], addr + 4); /* msw */
}
static inline
......@@ -194,17 +204,17 @@ void storeMultiple(const unsigned int Fn,unsigned int *pMem)
case typeSingle:
case typeDouble:
{
tput32(addr + 8, p[0]); /* single */
tput32(addr + 4, p[1]); /* double msw */
tput32(addr, nType << 14);
put_user_u32(p[0], addr + 8); /* single */
put_user_u32(p[1], addr + 4); /* double msw */
put_user_u32(nType << 14, addr);
}
break;
case typeExtended:
{
tput32(addr + 4, p[2]); /* msw */
tput32(addr + 8, p[1]);
tput32(addr, (p[0] & 0x80003fff) | (nType << 14));
put_user_u32(p[2], addr + 4); /* msw */
put_user_u32(p[1], addr + 8);
put_user_u32((p[0] & 0x80003fff) | (nType << 14), addr);
}
break;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册