no longer use get_errno for do_modify_ldt()

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3590 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
bellard 2007-11-11 14:57:14 +00:00
parent cd04168106
commit 03acab6618
1 changed files with 17 additions and 16 deletions

View File

@ -2229,7 +2229,7 @@ static bitmask_transtbl fcntl_flags_tbl[] = {
/* NOTE: there is really one LDT for all the threads */ /* NOTE: there is really one LDT for all the threads */
uint8_t *ldt_table; uint8_t *ldt_table;
static int read_ldt(abi_ulong ptr, unsigned long bytecount) static abi_long read_ldt(abi_ulong ptr, unsigned long bytecount)
{ {
int size; int size;
void *p; void *p;
@ -2241,7 +2241,7 @@ static int read_ldt(abi_ulong ptr, unsigned long bytecount)
size = bytecount; size = bytecount;
p = lock_user(VERIFY_WRITE, ptr, size, 0); p = lock_user(VERIFY_WRITE, ptr, size, 0);
if (!p) if (!p)
return -EFAULT; return -TARGET_EFAULT;
/* ??? Should this by byteswapped? */ /* ??? Should this by byteswapped? */
memcpy(p, ldt_table, size); memcpy(p, ldt_table, size);
unlock_user(p, ptr, size); unlock_user(p, ptr, size);
@ -2249,9 +2249,8 @@ static int read_ldt(abi_ulong ptr, unsigned long bytecount)
} }
/* XXX: add locking support */ /* XXX: add locking support */
/* write_ldt() returns host errnos */ static abi_long write_ldt(CPUX86State *env,
static int write_ldt(CPUX86State *env, abi_ulong ptr, unsigned long bytecount, int oldmode)
abi_ulong ptr, unsigned long bytecount, int oldmode)
{ {
struct target_modify_ldt_ldt_s ldt_info; struct target_modify_ldt_ldt_s ldt_info;
struct target_modify_ldt_ldt_s *target_ldt_info; struct target_modify_ldt_ldt_s *target_ldt_info;
@ -2260,9 +2259,9 @@ static int write_ldt(CPUX86State *env,
uint32_t *lp, entry_1, entry_2; uint32_t *lp, entry_1, entry_2;
if (bytecount != sizeof(ldt_info)) if (bytecount != sizeof(ldt_info))
return -EINVAL; return -TARGET_EINVAL;
if (!lock_user_struct(VERIFY_READ, target_ldt_info, ptr, 1)) if (!lock_user_struct(VERIFY_READ, target_ldt_info, ptr, 1))
return -EFAULT; return -TARGET_EFAULT;
ldt_info.entry_number = tswap32(target_ldt_info->entry_number); ldt_info.entry_number = tswap32(target_ldt_info->entry_number);
ldt_info.base_addr = tswapl(target_ldt_info->base_addr); ldt_info.base_addr = tswapl(target_ldt_info->base_addr);
ldt_info.limit = tswap32(target_ldt_info->limit); ldt_info.limit = tswap32(target_ldt_info->limit);
@ -2270,7 +2269,7 @@ static int write_ldt(CPUX86State *env,
unlock_user_struct(target_ldt_info, ptr, 0); unlock_user_struct(target_ldt_info, ptr, 0);
if (ldt_info.entry_number >= TARGET_LDT_ENTRIES) if (ldt_info.entry_number >= TARGET_LDT_ENTRIES)
return -EINVAL; return -TARGET_EINVAL;
seg_32bit = ldt_info.flags & 1; seg_32bit = ldt_info.flags & 1;
contents = (ldt_info.flags >> 1) & 3; contents = (ldt_info.flags >> 1) & 3;
read_exec_only = (ldt_info.flags >> 3) & 1; read_exec_only = (ldt_info.flags >> 3) & 1;
@ -2280,15 +2279,15 @@ static int write_ldt(CPUX86State *env,
if (contents == 3) { if (contents == 3) {
if (oldmode) if (oldmode)
return -EINVAL; return -TARGET_EINVAL;
if (seg_not_present == 0) if (seg_not_present == 0)
return -EINVAL; return -TARGET_EINVAL;
} }
/* allocate the LDT */ /* allocate the LDT */
if (!ldt_table) { if (!ldt_table) {
ldt_table = malloc(TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE); ldt_table = malloc(TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE);
if (!ldt_table) if (!ldt_table)
return -ENOMEM; return -TARGET_ENOMEM;
memset(ldt_table, 0, TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE); memset(ldt_table, 0, TARGET_LDT_ENTRIES * TARGET_LDT_ENTRY_SIZE);
env->ldt.base = h2g(ldt_table); env->ldt.base = h2g(ldt_table);
env->ldt.limit = 0xffff; env->ldt.limit = 0xffff;
@ -2333,11 +2332,10 @@ install:
} }
/* specific and weird i386 syscalls */ /* specific and weird i386 syscalls */
/* do_modify_ldt() returns host errnos (it is inconsistent with the abi_long do_modify_ldt(CPUX86State *env, int func, abi_ulong ptr,
other do_*() functions which return target errnos). */ unsigned long bytecount)
int do_modify_ldt(CPUX86State *env, int func, abi_ulong ptr, unsigned long bytecount)
{ {
int ret = -ENOSYS; abi_long ret;
switch (func) { switch (func) {
case 0: case 0:
@ -2349,6 +2347,9 @@ int do_modify_ldt(CPUX86State *env, int func, abi_ulong ptr, unsigned long bytec
case 0x11: case 0x11:
ret = write_ldt(env, ptr, bytecount, 0); ret = write_ldt(env, ptr, bytecount, 0);
break; break;
default:
ret = -TARGET_ENOSYS;
break;
} }
return ret; return ret;
} }
@ -4174,7 +4175,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
break; break;
#ifdef TARGET_I386 #ifdef TARGET_I386
case TARGET_NR_modify_ldt: case TARGET_NR_modify_ldt:
ret = get_errno(do_modify_ldt(cpu_env, arg1, arg2, arg3)); ret = do_modify_ldt(cpu_env, arg1, arg2, arg3);
break; break;
#if !defined(TARGET_X86_64) #if !defined(TARGET_X86_64)
case TARGET_NR_vm86old: case TARGET_NR_vm86old: